Admob not compiling on iOS (Undefined Symbols)

Hi. Ive been trying to compile a build with Google Mobile Ads (aka Admob) integration for iOS and Android. The build compiles fine on android but when I export to iOS and try to compile on xCode it throws several “undefined symbol” errors.

Im using unity 2021.3.4f1 with Google Mobile Ads plugin version 7.1. Ive been at it for days and can’t figure out what the issue is. Any help would be appreciated.

Xcode screenshot attached

Hello I have the same problem

Hello, have a similar issue using Shopify for unity SDK

any suggestion on how to find the actual origin and posible solutions to this kind of issue?

also attach my xCodeScreenShot

I have the same problem.
xcode 14
iOS 16
Unity 2020.2.6f1

1 Like

Hey folks! When a build errors with “Undefined symbol: …”, it means XCode cannot find some native functions that the code being compiled is calling. This happens when some native iOS library/framework (in your cases Admob and Shopify) is missing in the XCode project.

As far as I know, Admob uses External Dependency Manager for Unity (EDM4U) (reference docs saying that here), Shopify might use it too. In iOS, what EDM4U does is generate a Podfile for Cocoa Pods, which is a tool that manages native iOS dependencies. When Unity generates the XCode project, EDM4U runs the Cocoa Pods script, installing the dependencies locally in the XCode project and generating the file “Unity-iPhone.xcworkspace”. You should be opening XCode using this “xcworkspace” file and not the “xcodeproj” file. When you do, you’ll see a “Pods” project, that is automatically linked to the “Unity-iPhone” project and should build correctly.

Now, if you are opening XCode from the “xcworkspace” file generated by Cocoa Pods, then there might be something else preventing Unity from copying native library files from the project, but we would need more info to investigate further. For example check if the native libraries are actually in the Unity project under a “Plugins/iOS” folder, in case EDM4U is not used.

2 Likes

I keep getting this issue from time to time. sometimes the build is fine, sometimes the build is not fine. and now the build has been persisting with this error.

in the podfile, if i add this
target ‘Unity-iPhone’ do
end

the symbol errors from google ads will show

if i remove it
the build will compile but app will crash

i cant figure out how to fix this issue permenantly

@mrm83_1 If the code compiles, it’s a good signal! What is the crash message exactly?

Hi, from time to time Unity have some errors while executing the pod install command from the Unity build script.
All I have to do, is to open a terminal, navigate to the build folder and run:

pod repo update

then

pod install

this generates the xcworkspace and I can open it and build without errors.

1 Like

Found the problem. very subtle.

doing pod update/install will usually fail for me asking to use $inherit instead of the default for a bunch of settings (including other linker flags) otherwise pod installs/update will not work.

however, doing that for other linker flags will result in compilation issue.

so the fix for me was:
use $inherit as pod warns
once pod installs or updates
remove inherit for other linker flags and use “-ObjC”

1 Like

thanks. it’s helpful. for me, it’s because the pod install failed for some reason at the end of the unity build. so there is no xcworkspace. after I ran the pod install manually. there was xcworkspace file can be open with xcode, and then all admob relative frameworks involved.

1 Like