Unity集成Admob后Xcode编译出现Apple Mach-O Linker (id)错误求助
Hey there, let's work through this Apple Mach-O Linker error you're facing after integrating AdMob into your Unity project and exporting to Xcode. I've debugged plenty of these issues before, so here are the most actionable fixes to try out:
Verify all required frameworks are included
AdMob doesn't work with just the mainGoogleMobileAds.framework—you need to add its dependencies too. Make sure these are in your Xcode project's frameworks directory:AdSupport.frameworkAppTrackingTransparency.frameworkCoreTelephony.frameworkSystemConfiguration.framework
Plus, don't forget the two required libraries:libsqlite3.tbdandlibz.tbd. Unity exports sometimes miss these, so manually adding them can resolve missing symbol errors.
Check framework embedding settings
In Xcode, select your project target, go to theGeneraltab, and scroll toFrameworks, Libraries, and Embedded Content. Set all AdMob-related frameworks toEmbed & Signinstead ofDo Not Embed. If they're set to the latter, the linker won't be able to resolve the necessary symbols at build time.Audit Unity's iOS export settings
Misconfigured Unity settings can cause conflicts in the exported Xcode project. Head to Unity'sPlayer Settings > iOS > Other Settingsand check:- Ensure
Scripting Backendis set toIL2CPP(AdMob has better compatibility with IL2CPP than Mono for iOS) - Confirm
Architectureis set toARM64(Apple no longer supports 32-bit iOS apps) - If
Strip Engine Codeis enabled, try disabling it—this feature can accidentally strip code AdMob needs. Re-export the project after changing this.
- Ensure
Clean Xcode's build cache
Stale cache is a common culprit for linker errors. Do the following:- Go to
Product > Clean Build Folder(use the shortcut Cmd+Shift+K) - Delete Xcode's Derived Data: Open
Xcode > Preferences > Locations, click the arrow next to the Derived Data path, and delete the entire folder for your project - Rebuild the project from scratch
- Go to
Ensure version compatibility between Unity plugin and SDK
If you manually added the AdMob framework to Xcode, it might conflict with the version included in your Unity AdMob plugin. Instead of manual framework addition, use Unity's Package Manager to install the official AdMob plugin—it automatically handles framework dependencies during Xcode export, eliminating version mismatch issues.Remove duplicate framework references
Sometimes Unity's export process already adds the AdMob framework, and manual addition creates duplicates. Check your Xcode project'sFrameworksdirectory for multiple copies ofGoogleMobileAds.frameworkand delete the extra one.
内容的提问来源于stack exchange,提问作者dubstepteam

