Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Admob not compiling on iOS (Undefined Symbols)

Discussion in 'iOS and tvOS' started by thelearningapplications, Jul 15, 2022.

  1. thelearningapplications

    thelearningapplications

    Joined:
    Apr 23, 2019
    Posts:
    4
    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
     
  2. TobiasDro

    TobiasDro

    Joined:
    Oct 1, 2022
    Posts:
    1
    Hello I have the same problem
     
  3. AkamaruDesign

    AkamaruDesign

    Joined:
    Dec 17, 2016
    Posts:
    13
    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
    upload_2022-10-4_22-0-52.png
     
  4. junhee_kim

    junhee_kim

    Joined:
    Feb 23, 2018
    Posts:
    1
    I have the same problem.
    xcode 14
    iOS 16
    Unity 2020.2.6f1 Screen Shot 2022-10-13 at 21.32.36.png
     
    noptanakhon11 likes this.
  5. gilzoide

    gilzoide

    Joined:
    Oct 7, 2015
    Posts:
    27
    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.
     
    khaled24 and gpom like this.
  6. mrm83

    mrm83

    Joined:
    Nov 29, 2014
    Posts:
    345
    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
     
  7. gilzoide

    gilzoide

    Joined:
    Oct 7, 2015
    Posts:
    27
    @mrm83 If the code compiles, it's a good signal! What is the crash message exactly?
     
  8. BBO_Lagoon

    BBO_Lagoon

    Joined:
    Mar 2, 2017
    Posts:
    199
    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:
    Code (CSharp):
    1. pod repo update
    then
    Code (CSharp):
    1. pod install
    this generates the xcworkspace and I can open it and build without errors.
     
    juratedesigns likes this.
  9. mrm83

    mrm83

    Joined:
    Nov 29, 2014
    Posts:
    345
    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"
     
  10. gpom

    gpom

    Joined:
    Jul 25, 2018
    Posts:
    1
    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.
     
    gilzoide likes this.