1

We make middleware using Cordova and AdMob to show ads. Cordova generates an Xcode project for us. However the resulting Xcode projects now fail to build with the error ld: framework not found UserMessagingPlatform.xcframework.

This appears to be caused by the Google UMP SDK updating to version 1.3.0, which notes "Updated the SDK from a .framework to a .xcframework." I've contacted AdMob support, and they claim the build works for them and haven't provided any useful help.

I have no idea why our builds now fail and I'm at a loss as to what to do about it. Here is a sample Xcode project: https://www.dropbox.com/s/y1ly2c3yi45rop6/TestBuild.ios.project.zip?dl=0

Can anyone identify what has gone wrong with this Xcode project causing it to fail to build, and identify a workaround?

niqueco
  • 2,261
  • 19
  • 39
AshleysBrain
  • 22,335
  • 15
  • 88
  • 124

3 Answers3

1

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.

  1. Install Homebrew: /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
  2. Install cocoapods: brew install cocoapods
  3. Open a terminal, navigate to your project directory: cd /path/to/your/project
  4. 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.

Ryan
  • 13
  • 5
  • Also note that you don't necessarily need cocoapods to install the missing code, it's just the easiest way. There's more information on how to manually install the framework in [Google's documentation](https://developers.google.com/ad-manager/mobile-ads-sdk/ios/quick-start). I've worked with Cordova (through ngx-rocket) in the past and once you install the missing SDK, I'd expect you wont have to do it again as long as you don't remove the cordova project and re-add it (which is sometimes necessary unfortunately) but if you do, simply repeat the steps. I like to note this stuff in the README – Ryan Nov 16 '20 at 21:53
  • Thank you a lot. You save me a lot of time – Alex Zhulin Dec 12 '20 at 10:29
  • @AlexZhulin happy to have helped :) – Ryan Dec 12 '20 at 22:34
0

Are you using Cocoapods for your XCode project?

This stackoverflow answer suggest updating cocoapods

Try updating cocoapods:

sudo gem install cocoapods

Cocoapods changelog contains fixes for XCFrameworks

Reaver
  • 101
  • 3
0

.xcframework files can only be used on CocoaPods 1.10.0 or newer, in your sample app you were using 1.8.4.

Update CocoaPods to latest and run pod install again.

jcesarmobile
  • 51,328
  • 11
  • 132
  • 176