質問編集履歴
2
Xcodeのクラッシュレポート
title
CHANGED
|
File without changes
|
body
CHANGED
|
@@ -199,4 +199,131 @@
|
|
|
199
199
|
iPhoneXR iOS13.5.1
|
|
200
200
|
|
|
201
201
|
|
|
202
|
-
ご教示いただければ幸いです。
|
|
202
|
+
ご教示いただければ幸いです。
|
|
203
|
+
|
|
204
|
+
|
|
205
|
+
### Xcode クラッシュレポート
|
|
206
|
+
```ここに言語を入力
|
|
207
|
+
#import "PLCrashReporter.h"
|
|
208
|
+
#import "CrashReporter.h"
|
|
209
|
+
|
|
210
|
+
#include "UndefinePlatforms.h"
|
|
211
|
+
#include <mach-o/ldsyms.h>
|
|
212
|
+
#include "RedefinePlatforms.h"
|
|
213
|
+
|
|
214
|
+
extern "C" NSString* UnityGetCrashReportsPath();
|
|
215
|
+
|
|
216
|
+
static NSUncaughtExceptionHandler* gsCrashReporterUEHandler = NULL;
|
|
217
|
+
|
|
218
|
+
static decltype(_mh_execute_header) * sExecuteHeader = NULL;
|
|
219
|
+
extern "C" void UnitySetExecuteMachHeader(const decltype(_mh_execute_header)* header)
|
|
220
|
+
{
|
|
221
|
+
sExecuteHeader = header;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
extern "C" const decltype(_mh_execute_header) * UnityGetExecuteMachHeader() {
|
|
225
|
+
return sExecuteHeader;
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
static void SavePendingCrashReport()
|
|
229
|
+
{
|
|
230
|
+
if (![[UnityPLCrashReporter sharedReporter] hasPendingCrashReport])
|
|
231
|
+
return;
|
|
232
|
+
|
|
233
|
+
NSFileManager *fm = [NSFileManager defaultManager];
|
|
234
|
+
NSError *error;
|
|
235
|
+
|
|
236
|
+
if (![fm createDirectoryAtPath: UnityGetCrashReportsPath() withIntermediateDirectories: YES attributes: nil error: &error])
|
|
237
|
+
{
|
|
238
|
+
::printf("CrashReporter: could not create crash report directory: %s\n", [[error localizedDescription] UTF8String]);
|
|
239
|
+
return;
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
NSData *data = [[UnityPLCrashReporter sharedReporter] loadPendingCrashReportDataAndReturnError: &error];
|
|
243
|
+
if (data == nil)
|
|
244
|
+
{
|
|
245
|
+
::printf("CrashReporter: failed to load crash report data: %s\n", [[error localizedDescription] UTF8String]);
|
|
246
|
+
return;
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
NSString* file = [UnityGetCrashReportsPath() stringByAppendingPathComponent: @"crash-"];
|
|
250
|
+
unsigned long long seconds = (unsigned long long)[[NSDate date] timeIntervalSince1970];
|
|
251
|
+
file = [file stringByAppendingString: [NSString stringWithFormat: @"%llu", seconds]];
|
|
252
|
+
file = [file stringByAppendingString: @".plcrash"];
|
|
253
|
+
if ([data writeToFile: file atomically: YES])
|
|
254
|
+
{
|
|
255
|
+
::printf("CrashReporter: saved pending crash report.\n");
|
|
256
|
+
if (![[UnityPLCrashReporter sharedReporter] purgePendingCrashReportAndReturnError: &error])
|
|
257
|
+
{
|
|
258
|
+
::printf("CrashReporter: couldn't remove pending report: %s\n", [[error localizedDescription] UTF8String]);
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
else
|
|
262
|
+
{
|
|
263
|
+
::printf("CrashReporter: couldn't save crash report.\n");
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
// Now copy out a pending version that we can delete if/when we send it
|
|
267
|
+
file = [UnityGetCrashReportsPath() stringByAppendingPathComponent: @"crash-pending.plcrash"];
|
|
268
|
+
if ([data writeToFile: file atomically: YES])
|
|
269
|
+
{
|
|
270
|
+
::printf("CrashReporter: saved copy of pending crash report.\n");
|
|
271
|
+
}
|
|
272
|
+
else
|
|
273
|
+
{
|
|
274
|
+
::printf("CrashReporter: couldn't save copy of pending crash report.\n");
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
static void InitCrashReporter()
|
|
279
|
+
{
|
|
280
|
+
NSError *error;
|
|
281
|
+
|
|
282
|
+
UnityInstallPostCrashCallback();
|
|
283
|
+
if ([[UnityPLCrashReporter sharedReporter] enableCrashReporterAndReturnError: &error])
|
|
284
|
+
::printf("CrashReporter: initialized\n");
|
|
285
|
+
else
|
|
286
|
+
NSLog(@"CrashReporter: could not enable crash reporter: %@", error);
|
|
287
|
+
|
|
288
|
+
SavePendingCrashReport();
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
static void UncaughtExceptionHandler(NSException *exception)
|
|
292
|
+
{
|
|
293
|
+
NSLog(@"Uncaught exception: %@: %@\n%@", [exception name], [exception reason], [exception callStackSymbols]);
|
|
294
|
+
if (gsCrashReporterUEHandler)
|
|
295
|
+
gsCrashReporterUEHandler(exception);
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
static void InitObjCUEHandler()
|
|
299
|
+
{
|
|
300
|
+
// Crash reporter sets its own handler, so we have to save it and call it manually
|
|
301
|
+
gsCrashReporterUEHandler = NSGetUncaughtExceptionHandler();
|
|
302
|
+
NSSetUncaughtExceptionHandler(&UncaughtExceptionHandler);
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
void InitCrashHandling()
|
|
306
|
+
{
|
|
307
|
+
#if ENABLE_CUSTOM_CRASH_REPORTER
|
|
308
|
+
InitCrashReporter();
|
|
309
|
+
#endif
|
|
310
|
+
|
|
311
|
+
#if ENABLE_OBJC_UNCAUGHT_EXCEPTION_HANDLER
|
|
312
|
+
InitObjCUEHandler();
|
|
313
|
+
#endif
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
// This function will be called when AppDomain.CurrentDomain.UnhandledException event is triggered.
|
|
317
|
+
// When running on device the app will do a hard crash and it will generate a crash log.
|
|
318
|
+
extern "C" void CrashedCheckBelowForHintsWhy()
|
|
319
|
+
{
|
|
320
|
+
#if ENABLE_IOS_CRASH_REPORTING || ENABLE_CUSTOM_CRASH_REPORTER
|
|
321
|
+
// Make app crash hard here
|
|
322
|
+
__builtin_trap();
|
|
323
|
+
|
|
324
|
+
// Just in case above doesn't work
|
|
325
|
+
abort();
|
|
326
|
+
#endif
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
```
|
1
コードの追加
title
CHANGED
|
File without changes
|
body
CHANGED
|
@@ -112,8 +112,79 @@
|
|
|
112
112
|
Assets/GoogleMobileAds/Editor ディレクトリで PListProcessor.cs を開いても
|
|
113
113
|
「ADMOB_APPLICATION_ID」というのがなく試せません。
|
|
114
114
|
|
|
115
|
+
```ここに言語を入力
|
|
116
|
+
#if UNITY_IPHONE || UNITY_IOS
|
|
115
117
|
|
|
118
|
+
using System.IO;
|
|
116
119
|
|
|
120
|
+
using UnityEditor;
|
|
121
|
+
using UnityEditor.Callbacks;
|
|
122
|
+
using UnityEditor.iOS.Xcode;
|
|
123
|
+
|
|
124
|
+
using GoogleMobileAds.Editor;
|
|
125
|
+
|
|
126
|
+
public static class PListProcessor
|
|
127
|
+
{
|
|
128
|
+
[PostProcessBuild]
|
|
129
|
+
public static void OnPostProcessBuild(BuildTarget buildTarget, string path)
|
|
130
|
+
{
|
|
131
|
+
string plistPath = Path.Combine(path, "Info.plist");
|
|
132
|
+
PlistDocument plist = new PlistDocument();
|
|
133
|
+
plist.ReadFromFile(plistPath);
|
|
134
|
+
|
|
135
|
+
if (!GoogleMobileAdsSettings.Instance.IsAdManagerEnabled && !GoogleMobileAdsSettings.Instance.IsAdMobEnabled)
|
|
136
|
+
{
|
|
137
|
+
NotifyBuildFailure("Neither Ad Manager nor AdMob is enabled yet.");
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
if (GoogleMobileAdsSettings.Instance.IsAdManagerEnabled)
|
|
141
|
+
{
|
|
142
|
+
plist.root.SetBoolean("GADIsAdManagerApp", true);
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
if (GoogleMobileAdsSettings.Instance.IsAdMobEnabled)
|
|
146
|
+
{
|
|
147
|
+
string appId = GoogleMobileAdsSettings.Instance.AdMobIOSAppId;
|
|
148
|
+
if (appId.Length == 0)
|
|
149
|
+
{
|
|
150
|
+
NotifyBuildFailure(
|
|
151
|
+
"iOS AdMob app ID is empty. Please enter a valid app ID to run ads properly.");
|
|
152
|
+
}
|
|
153
|
+
else
|
|
154
|
+
{
|
|
155
|
+
plist.root.SetString("GADApplicationIdentifier", appId);
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
if (GoogleMobileAdsSettings.Instance.DelayAppMeasurementInit)
|
|
160
|
+
{
|
|
161
|
+
plist.root.SetBoolean("GADDelayAppMeasurementInit", true);
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
File.WriteAllText(plistPath, plist.WriteToString());
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
private static void NotifyBuildFailure(string message)
|
|
168
|
+
{
|
|
169
|
+
string prefix = "[GoogleMobileAds] ";
|
|
170
|
+
|
|
171
|
+
bool openSettings = EditorUtility.DisplayDialog(
|
|
172
|
+
"Google Mobile Ads", "Error: " + message, "Open Settings", "Close");
|
|
173
|
+
if (openSettings)
|
|
174
|
+
{
|
|
175
|
+
GoogleMobileAdsSettingsEditor.OpenInspector();
|
|
176
|
+
}
|
|
177
|
+
#if UNITY_2017_1_OR_NEWER
|
|
178
|
+
throw new BuildPlayerWindow.BuildMethodException(prefix + message);
|
|
179
|
+
#else
|
|
180
|
+
throw new OperationCanceledException(prefix + message);
|
|
181
|
+
#endif
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
#endif
|
|
186
|
+
```
|
|
187
|
+
|
|
117
188
|
### 補足情報(FW/ツールのバージョンなど)
|
|
118
189
|
アプリ作成はWindowsでしています。
|
|
119
190
|
Windows 10 Pro バージョン1903
|