The Issue
The issue appears to be that a framework/dependency is not added to the Xcode project, so it doesn't have the code necessary to compile the application. AdMob relies on that UserMessagingPlatform
thing to work, and without the Mobile Ads SDK being present in your codebase, UserMessagingPlatform
is missing and your application is essentially asking for code that isn't there. To resolve this, you have to tell cocoapods (a dependency manager, think npm but for Swift/Objective-C) to locate and add the missing code to your project.
First, install cocoapods if you haven't already. I used Homebrew to do this, as it seems to be the only method that worked without headache. Many people already have Homebrew, but if you don't, install that first, then run:
brew install cocoapods
Next, go into your project directory using the Terminal. Once you're in the directory, run:
pod install --repo-update
Reopen your project in Xcode, and it should compile successfully now.
Step by step resolution:
Skip any steps that aren't necessary for your environment.
- Install Homebrew:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
- Install cocoapods:
brew install cocoapods
- Open a terminal, navigate to your project directory:
cd /path/to/your/project
- Update dependencies:
pod install --repo-update
Disclaimer: I'm not a Swift or Objective-C developer, and my experience with Apple/Xcode is limited. I also am unfamiliar with "cocoapods" and AdMob. I just downloaded the sample code and worked through the issue until I got it to compile successfully.