跳转到内容

Unity iOS Podfile 问题

问题

有时,Unity External Dependency Manager 会进行 Podfile 变更,导致 iOS 端出现错误,继而产生多种不同的错误信息。 例如:

2021-03-11 11:08:47.571790+0100 demo[61453:2259760] Uncaught exception: NSInvalidArgumentException: Passed an object of type other than ALAd: ALAdServerAd.
(
0 CoreFoundation 0x0000000184755880 727F2644-EB4E-3D57-BC2E-E6803BA92366 + 1202304
1 libobjc.A.dylib 0x0000000199770c50 objc_exception_throw + 60
2 CoreFoundation 0x000000018464e4a4 727F2644-EB4E-3D57-BC2E-E6803BA92366 + 124068
3 demo 0x0000000104a92768 +[ALUtils assertValidAd:] + 408
4 demo 0x0000000104a09274 -[ALAdView render:] + 72
5 demo 0x0000000104a68268 __64-[ALAppLovinMediationAdapterAdViewDelegate adService:didLoadAd:]_block_invoke + 588
6 Foundation 0x0000000185aa4850 7698BF3E-0CF6-31C0-85E9-562714F01276 + 1259600
7 Foundation 0x0000000185991740 7698BF3E-0CF6-31C0-85E9-562714F01276 + 132928
8 Foundation 0x0000000185aa6ca4 7698BF3E-0CF6-31C0-85E9-562714F01276 + 1268900
9 Foundation 0x00000001859913c8 7698BF3E-0CF6-31C0-85E9-562714F01276 + 132040
10 Foundation 0x0000000185aa774c 7698BF3E-0CF6-31C0-85E9-562714F01276 + 1271628
11 Foundation 0x0000000185aa71d4 7698BF3E-0CF6-31C0-85E9-562714F01276 + 1270228
12 libdispatch.dylib 0x0000000184357fb8 B92757B1-0434-3E9B-A3AC-B6DA6B81945C + 73656
13 libdispatch.dylib 0x0000000184349db0 B92757B1-0434-3E9B-A3AC-B6DA6B81945C + 15792
14 libdispatch.dylib 0x00000001843577ac _dispatch_main_queue_callback_4CF + 836
15 CoreFoundation 0x00000001846d111c 727F2644-EB4E-3D57-BC2E-E6803BA92366 + 659740
16 CoreFoundation 0x00000001846cb120 727F2644-EB4E-3D57-BC2E-E6803BA92366 + 635168
17 CoreFoundation 0x00000001846ca21c CFRunLoopRunSpecific + 600
18 GraphicsServices 0x000000019c296784 GSEventRunModal + 164
19 UIKitCore 0x000000018710aee8 8518EAE3-832B-3FF0-9FA5-9DBE3041F26C + 12357352
20 UIKitCore 0x000000018711075c UIApplicationMain + 168
21 UnityFramework 0x000000010bed9704 -[UnityFramework runUIApplicationMainWithArgc:argv:] + 108
22 demo 0x0000000104898e5c main + 68
23 libdyld.dylib 0x000000018438a6b0 21B19919-1334-38BC-B233-896E929945E0 + 5808
)
2021-03-11 11:08:47.572392+0100 demo[61453:2259760] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Passed an object of type other than ALAd: ALAdServerAd.'
*** First throw call stack:
(0x18475586c 0x199770c50 0x18464e4a4 0x104a92768 0x104a09274 0x104a68268 0x185aa4850 0x185991740 0x185aa6ca4 0x1859913c8 0x185aa774c 0x185aa71d4 0x184357fb8 0x184349db0 0x1843577ac 0x1846d111c 0x1846cb120 0x1846ca21c 0x19c296784 0x18710aee8 0x18711075c 0x10bed9704 0x104898e5c 0x18438a6b0)
libc++abi.dylib: terminating with uncaught exception of type NSException
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Passed an object of type other than ALAd: ALAdServerAd.'
terminating with uncaught exception of type NSException

或:

18:57:54.955924+0300 demo [AppLovinSdk] ERROR [ALIncentivizedInterstitialAd] Attempted to display a non-incentivized ad using ALIncentivizedInterstitialAd: [ALAd #9224781 source=4, zoneIdentifier=(null), size=[ALAdSize: INTER], type=[ALAdType: VIDEOA]]

或:

2021-04-12 16:14:11.491511+0300 demo [956:240795] [AppLovinSdk] ERROR [ALSdk] Developer passed nil instead of ALAd instance - please check object types!
2021-04-12 16:14:11.497797+0300 demo [956:240795] [AppLovinSdk] ERROR [ALSdk] Called with an invalid object type from: (
0 carrace 0x00000001025d07fc +[ALUtils assertValidAd:] + 280
1 carrace 0x0000000102545278 -[ALAdView render:] + 72
2 carrace 0x00000001025a590c __64-[ALAppLovinMediationAdapterAdViewDelegate adService:didLoadAd:]_block_invoke + 588
3 Foundation 0x000000019c9063f0

解决方案

  1. Unity External Dependency Manager 更新至最低 1.2.164 版本。
  2. 找到 Unity External Dependency Manager OS Resolver Settings (导航方法:Assets > External Dependency Manager > iOS Resolver > Settings),然后取消选中 Add use_frameworks! to PodfileAlways add the main target to Podfile 两个复选框。

iOS Resolver Settings

替代解决方案

Podfile 中移除下列行:

target 'Unity-iPhone' do
end
use_frameworks!

然后运行下列指令,为项目应用 Podfile 变更。

Terminal window
pod install --repo-update