You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Unity iOS项目归档时出现Undefined symbol: _OBJC_CLASS_$_UnityAds错误

问题

将Unity项目构建为iOS版本后,在Xcode中执行归档操作以上传至App Store。为集成Google AdMob,在终端执行了pod install --repo-update命令,打开Unity-iPhone.xcworkspace配置签名、调整Pods的iOS部署目标后归档,出现以下链接错误:

Undefined symbol: _OBJC_CLASS_$_UnityAds
Linker command failed with exit code 1(use -v to see invocation)

完整错误日志:

Ld /Users/macbookpro/Library/Developer/Xcode/DerivedData/Unity-iPhone-bwgxquphgntexaaskcghcrqzasat/Build/Intermediates.noindex/ArchiveIntermediates/Unity-iPhone/IntermediateBuildFilesPath/UninstalledProducts/iphoneos/UnityFramework.framework/UnityFramework normal (in target 'UnityFramework' from project 'Unity-iPhone')
    cd /Users/macbookpro/Desktop/Projekte/Gym/Gym_0_0_9
    /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++ -Xlinker -reproducible -target arm64-apple-ios12.0 -dynamiclib -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS17.4.sdk -Os -L/Users/macbookpro/Library/Developer/Xcode/DerivedData/Unity-iPhone-bwgxquphgntexaaskcghcrqzasat/Build/Intermediates.noindex/ArchiveIntermediates/Unity-iPhone/IntermediateBuildFilesPath/EagerLinkingTBDs/Release-iphoneos -L/Users/macbookpro/Library/Developer/Xcode/DerivedData/Unity-iPhone-bwgxquphgntexaaskcghcrqzasat/Build/Intermediates.noindex/ArchiveIntermediates/Unity-iPhone/BuildProductsPath/Release-iphoneos -L/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphoneos -L/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS17.4.sdk/usr/lib/swift -L/Users/macbookpro/Desktop/Projekte/Gym/Gym_0_0_9/Libraries -L/Users/macbookpro/Desktop/Projekte/Gym/Gym_0_0_9/Libraries/Plugins/iOS -F/Users/macbookpro/Library/Developer/Xcode/DerivedData/Unity-iPhone-bwgxquphgntexaaskcghcrqzasat/Build/Intermediates.noindex/ArchiveIntermediates/Unity-iPhone/IntermediateBuildFilesPath/EagerLinkingTBDs/Release-iphoneos -F/Users/macbookpro/Library/Developer/Xcode/DerivedData/Unity-iPhone-bwgxquphgntexaaskcghcrqzasat/Build/Intermediates.noindex/ArchiveIntermediates/Unity-iPhone/BuildProductsPath/Release-iphoneos -F/Users/macbookpro/Library/Developer/Xcode/DerivedData/Unity-iPhone-bwgxquphgntexaaskcghcrqzasat/Build/Intermediates.noindex/ArchiveIntermediates/Unity-iPhone/BuildProductsPath/Release-iphoneos/GoogleUtilities -F/Users/macbookpro/Library/Developer/Xcode/DerivedData/Unity-iPhone-bwgxquphgntexaaskcghcrqzasat/Build/Intermediates.noindex/ArchiveIntermediates/Unity-iPhone/BuildProductsPath/Release-iphoneos/PromisesObjC -F/Users/macbookpro/Library/Developer/Xcode/DerivedData/Unity-iPhone-bwgxquphgntexaaskcghcrqzasat/Build/Intermediates.noindex/ArchiveIntermediates/Unity-iPhone/BuildProductsPath/Release-iphoneos/Protobuf -F/Users/macbookpro/Library/Developer/Xcode/DerivedData/Unity-iPhone-bwgxquphgntexaaskcghcrqzasat/Build/Intermediates.noindex/ArchiveIntermediates/Unity-iPhone/BuildProductsPath/Release-iphoneos/nanopb -F/Users/macbookpro/Desktop/Projekte/Gym/Gym_0_0_9/Pods/Google-Mobile-Ads-SDK/Frameworks/GoogleMobileAdsFramework-Current -F/Users/macbookpro/Desktop/Projekte/Gym/Gym_0_0_9/Pods/GoogleAppMeasurement/Frameworks -F/Users/macbookpro/Desktop/Projekte/Gym/Gym_0_0_9/Pods/GoogleUserMessagingPlatform/Frameworks/Release -F/Users/macbookpro/Desktop/Projekte/Gym/Gym_0_0_9/Pods/UnityAds -F/Users/macbookpro/Desktop/Projekte/Gym/Gym_0_0_9/Pods/UnityMediationAdapter -F/Users/macbookpro/Desktop/Projekte/Gym/Gym_0_0_9/Pods/UnityMediationLogging -F/Users/macbookpro/Desktop/Projekte/Gym/Gym_0_0_9/Pods/UnityMediationSdk -F/Users/macbookpro/Desktop/Projekte/Gym/Gym_0_0_9/Pods/UnityMediationUnityAdapter -F/Users/macbookpro/Library/Developer/Xcode/DerivedData/Unity-iPhone-bwgxquphgntexaaskcghcrqzasat/Build/Intermediates.noindex/ArchiveIntermediates/Unity-iPhone/BuildProductsPath/Release-iphoneos/XCFrameworkIntermediates/Google-Mobile-Ads-SDK -F/Users/macbookpro/Library/Developer/Xcode/DerivedData/Unity-iPhone-bwgxquphgntexaaskcghcrqzasat/Build/Intermediates.noindex/ArchiveIntermediates/Unity-iPhone/BuildProductsPath/Release-iphoneos/XCFrameworkIntermediates/GoogleAppMeasurement/AdIdSupport -F/Users/macbookpro/Library/Developer/Xcode/DerivedData/Unity-iPhone-bwgxquphgntexaaskcghcrqzasat/Build/Intermediates.noindex/ArchiveIntermediates/Unity-iPhone/BuildProductsPath/Release-iphoneos/XCFrameworkIntermediates/GoogleAppMeasurement/WithoutAdIdSupport -F/Users/macbookpro/Library/Developer/Xcode/DerivedData/Unity-iPhone-bwgxquphgntexaaskcghcrqzasat/Build/Intermediates.noindex/ArchiveIntermediates/Unity-iPhone/BuildProductsPath/Release-iphoneos/XCFrameworkIntermediates/GoogleUserMessagingPlatform -F/Users/macbookpro/Library/Developer/Xcode/DerivedData/Unity-iPhone-bwgxquphgntexaaskcghcrqzasat/Build/Intermediates.noindex/ArchiveIntermediates/Unity-iPhone/BuildProductsPath/Release-iphoneos/XCFrameworkIntermediates/UnityAds -F/Users/macbookpro/Library/Developer/Xcode/DerivedData/Unity-iPhone-bwgxquphgntexaaskcghcrqzasat/Build/Intermediates.noindex/ArchiveIntermediates/Unity-iPhone/BuildProductsPath/Release-iphoneos/XCFrameworkIntermediates/UnityMediationAdapter -F/Users/macbookpro/Library/Developer/Xcode/DerivedData/Unity-iPhone-bwgxquphgntexaaskcghcrqzasat/Build/Intermediates.noindex/ArchiveIntermediates/Unity-iPhone/BuildProductsPath/Release-iphoneos/XCFrameworkIntermediates/UnityMediationLogging -F/Users/macbookpro/Library/Developer/Xcode/DerivedData/Unity-iPhone-bwgxquphgntexaaskcghcrqzasat/Build/Intermediates.noindex/ArchiveIntermediates/Unity-iPhone/BuildProductsPath/Release-iphoneos/XCFrameworkIntermediates/UnityMediationSdk -F/Users/macbookpro/Library/Developer/Xcode/DerivedData/Unity-iPhone-bwgxquphgntexaaskcghcrqzasat/Build/Intermediates.noindex/ArchiveIntermediates/Unity-iPhone/BuildProductsPath/Release-iphoneos/XCFrameworkIntermediates/UnityMediationUnityAdapter -filelist /Users/macbookpro/Library/Developer/Xcode/DerivedData/Unity-iPhone-bwgxquphgntexaaskcghcrqzasat/Build/Intermediates.noindex/ArchiveIntermediates/Unity-iPhone/IntermediateBuildFilesPath/Unity-iPhone.build/Release-iphoneos/UnityFramework.build/Objects-normal/arm64/UnityFramework.LinkFileList -install_name @rpath/UnityFramework.framework/UnityFramework -Xlinker -rpath -Xlinker /usr/lib/swift -Xlinker -rpath -Xlinker @executable_path/Frameworks -Xlinker -rpath -Xlinker @loader_path/Frameworks -Xlinker -rpath -Xlinker @executable_path/../../Frameworks -Xlinker -map -Xlinker /Users/macbookpro/Library/Developer/Xcode/DerivedData/Unity-iPhone-bwgxquphgntexaaskcghcrqzasat/Build/Intermediates.noindex/ArchiveIntermediates/Unity-iPhone/IntermediateBuildFilesPath/Unity-iPhone.build/Release-iphoneos/UnityFramework.build/UnityFramework-LinkMap-normal-arm64.txt -dead_strip -Xlinker -object_path_lto -Xlinker /Users/macbookpro/Library/Developer/Xcode/DerivedData/Unity-iPhone-bwgxquphgntexaaskcghcrqzasat/Build/Intermediates.noindex/ArchiveIntermediates/Unity-iPhone/IntermediateBuildFilesPath/Unity-iPhone.build/Release-iphoneos/UnityFramework.build/Objects-normal/arm64/UnityFramework_lto.o -stdlib=libc++ -fobjc-arc -fobjc-link-runtime -ObjC -lc++ -lsqlite3 -lz -framework AVFAudio -framework AVFoundation -framework AdSupport -framework AppTrackingTransparency -framework AudioToolbox -framework CFNetwork -framework CoreFoundation -framework CoreGraphics -framework CoreMedia -framework CoreTelephony -framework CoreVideo -framework FBLPromises -framework Foundation -framework GoogleAppMeasurement -framework GoogleAppMeasurementIdentitySupport -framework GoogleMobileAds -framework GoogleUtilities -framework MediaPlayer -framework MessageUI -framework MobileCoreServices -framework Network -framework Protobuf -framework QuartzCore -framework Security -framework StoreKit -framework SystemConfiguration -framework UIKit -framework UnityAds -framework UnityMediationAdapter -framework UnityMediationLogging -framework UnityMediationSdk -framework UnityMediationUnityAdapter -framework UserMessagingPlatform -framework WebKit -framework nanopb -weak_framework AdSupport -weak_framework JavaScriptCore -weak_framework SafariServices -weak_framework WebKit -weak_framework CoreMotion -weak-lSystem -liPhone-lib -framework Metal -framework Security -framework MediaToolbox -framework CoreText -framework AudioToolbox -weak_framework AVFoundation -framework AVKit -framework CFNetwork -framework CoreGraphics -framework CoreMedia -weak_framework CoreMotion -framework CoreVideo -framework Foundation -framework OpenAL -framework QuartzCore -framework SystemConfiguration -framework UIKit -liconv.2 -lil2cpp /Users/macbookpro/Desktop/Projekte/Gym/Gym_0_0_9/Libraries/baselib.a /Users/macbookpro/Desktop/Projekte/Gym/Gym_0_0_9/Libraries/Plugins/iOS/unity-plugin-library.a -weak_framework GameController -framework Pods_UnityFramework -Xlinker -dependency_info -Xlinker /Users/macbookpro/Library/Developer/Xcode/DerivedData/Unity-iPhone-bwgxquphgntexaaskcghcrqzasat/Build/Intermediates.noindex/ArchiveIntermediates/Unity-iPhone/IntermediateBuildFilesPath/Unity-iPhone.build/Release-iphoneos/UnityFramework.build/Objects-normal/arm64/UnityFramework_dependency_info.dat -o /Users/macbookpro/Library/Developer/Xcode/DerivedData/Unity-iPhone-bwgxquphgntexaaskcghcrqzasat/Build/Intermediates.noindex/ArchiveIntermediates/Unity-iPhone/IntermediateBuildFilesPath/UninstalledProducts/iphoneos/UnityFramework.framework/UnityFramework

ld: warning: ignoring duplicate libraries: '-lc++'
ld: warning: Could not find or use auto-linked framework 'CoreAudioTypes': framework 'CoreAudioTypes' not found
ld: warning: Could not find or use auto-linked framework 'UnityMediationInstantiationService': framework 'UnityMediationInstantiationService' not found
ld: warning: Could not find or use auto-linked framework 'UnityMediationS2SService': framework 'UnityMediationS2SService' not found
ld: warning: Could not find or use auto-linked framework 'UnityMediationTrackingService': framework 'UnityMediationTrackingService' not found
ld: warning: Could not find or use auto-linked framework 'UnitySwiftProtobuf': framework 'UnitySwiftProtobuf' not found
Undefined symbols for architecture arm64:
  "_OBJC_CLASS_$_UnityAds", referenced from:
       in UnityMediationUnityAdapter[arm64][6](UMSUnityAdsAdapterFactory.o)
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

注:已在Unity中禁用UnityAds功能,未主动引入相关依赖。

解决方案

  • 清理Podfile中的UnityAds相关依赖
    打开导出的Xcode项目目录中的Podfile,移除所有UnityAds、UnityMediation相关的pod条目,仅保留Google AdMob的依赖:

    pod 'Google-Mobile-Ads-SDK'
    

    执行命令更新Pods:

    pod deintegrate && pod install --repo-update
    
  • 移除Unity项目中的残留文件与包

    1. 打开Unity项目,进入Package Manager,确认Unity Ads和Unity Mediation包已被完全删除(而非仅禁用)。
    2. 检查Assets/Plugins/iOS目录,删除所有UnityAds相关的.framework或.a静态库文件。
    3. 搜索项目中所有脚本,确认没有残留引用UnityAds API的代码(比如初始化、广告加载逻辑)。
  • 调整Xcode链接器设置

    1. 在Xcode中选中UnityFramework目标,进入Build Settings。
    2. 找到Other Linker Flags,移除-framework UnityAds、-framework UnityMediation*等相关条目。
    3. 若仍有残留引用,可添加-weak_framework UnityAds,让链接器忽略未找到的符号;同时确保Dead Code Stripping在Release模式下设置为YES,自动剔除未使用的代码。
  • 重新构建Unity项目

    1. 在Unity中执行File -> Build Settings -> Clean,清理旧的构建缓存。
    2. 重新导出iOS项目,再执行pod install,避免基于旧项目的残留配置修改。

内容的提问来源于stack exchange,提问作者Berlin-Koeln

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.19 21:48:09