Skip to content

google_mobile_ads 5.2.0 causes build errors in Flutter apps #1193

Closed as not planned

Description

@loic-sharma

[REQUIRED] Step 1: Describe your environment

Clean app built using the Flutter master channel and Xcode 15.0.

Xcode 16.0 will build the app fine, but the app will crash immediately at launch due to dynamic linking errors.

Plugin Version

google_mobile_ads version 5.2.0

[REQUIRED] Step 2: Describe the problem

Hello, I'm from the Flutter team. Updating google_mobile_ads from 5.1.0 to 5.2.0 in the Flutter SDK caused build errors. See: flutter/flutter#156606

These build errors can be reproduced on a brand new application.

Steps to Reproduce

Switch to Xcode 15.0:

sudo xcode-select -s /Applications/Xcode_15_0.app

Switch to the latest Flutter master channel:

  1. cd path/to/flutter
  2. git checkout master
  3. git pull

Create a new Flutter app, add google_mobile_ads, and build it:

  1. flutter create ads_link_error
  2. cd ads_link_error
  3. flutter pub add google_mobile_ads
  4. flutter build ios --verbose

I've created this repo that contains these modifications: https://github.com/loic-sharma/ads_link_error

Expected results:

App builds successfully.

Actual results:

App build fails with the following errors:

Logs
           Ld /Users/loicsharma/Code/tmp/ads_link_error/build/ios/Release-iphoneos/Runner.app/Runner normal (in target 'Runner' from project 'Runner')
               cd /Users/loicsharma/Code/tmp/ads_link_error/ios
               /Applications/Xcode_15.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -Xlinker -reproducible -target arm64-apple-ios12.0 -isysroot /Applications/Xcode_15.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS17.0.sdk -Os -L/Users/loicsharma/Library/Developer/Xcode/DerivedData/Runner-ddpxcupiwivysphihgoqhhedcmkq/Build/Intermediates.noindex/EagerLinkingTBDs/Release-iphoneos -L/Users/loicsharma/Code/tmp/ads_link_error/build/ios/Release-iphoneos -L/Applications/Xcode_15.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphoneos -L/Applications/Xcode_15.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS17.0.sdk/usr/lib/swift -F/Users/loicsharma/Library/Developer/Xcode/DerivedData/Runner-ddpxcupiwivysphihgoqhhedcmkq/Build/Intermediates.noindex/EagerLinkingTBDs/Release-iphoneos -F/Users/loicsharma/Code/tmp/ads_link_error/build/ios/Release-iphoneos -F/Users/loicsharma/Code/tmp/ads_link_error/build/ios/Release-iphoneos/Google-Mobile-Ads-SDK -F/Users/loicsharma/Code/tmp/ads_link_error/build/ios/Release-iphoneos/google_mobile_ads -F/Users/loicsharma/Code/tmp/ads_link_error/build/ios/Release-iphoneos/webview_flutter_wkwebview -F/Users/loicsharma/Code/tmp/ads_link_error/ios/Pods/Google-Mobile-Ads-SDK/Frameworks/GoogleMobileAdsFramework -F/Users/loicsharma/Code/tmp/ads_link_error/ios/Pods/GoogleUserMessagingPlatform/Frameworks/Release -F/Users/loicsharma/Code/tmp/ads_link_error/build/ios/Release-iphoneos/XCFrameworkIntermediates/Google-Mobile-Ads-SDK -F/Users/loicsharma/Code/tmp/ads_link_error/build/ios/Release-iphoneos/XCFrameworkIntermediates/GoogleUserMessagingPlatform -filelist /Users/loicsharma/Library/Developer/Xcode/DerivedData/Runner-ddpxcupiwivysphihgoqhhedcmkq/Build/Intermediates.noindex/Runner.build/Release-iphoneos/Runner.build/Objects-normal/arm64/Runner.LinkFileList -Xlinker -rpath -Xlinker /usr/lib/swift -Xlinker -rpath -Xlinker @executable_path/Frameworks -Xlinker -rpath -Xlinker @loader_path/Frameworks -dead_strip -Xlinker -object_path_lto -Xlinker /Users/loicsharma/Library/Developer/Xcode/DerivedData/Runner-ddpxcupiwivysphihgoqhhedcmkq/Build/Intermediates.noindex/Runner.build/Release-iphoneos/Runner.build/Objects-normal/arm64/Runner_lto.o -fobjc-arc -fobjc-link-runtime -L/Applications/Xcode_15.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphoneos -L/usr/lib/swift -Xlinker -add_ast_path -Xlinker /Users/loicsharma/Library/Developer/Xcode/DerivedData/Runner-ddpxcupiwivysphihgoqhhedcmkq/Build/Intermediates.noindex/Runner.build/Release-iphoneos/Runner.build/Objects-normal/arm64/Runner.swiftmodule -ObjC -lsqlite3 -lz -framework AVFoundation -framework AudioToolbox -framework CFNetwork -framework CoreGraphics -framework CoreMedia -framework CoreTelephony -framework CoreVideo -framework GoogleMobileAds -framework Google_Mobile_Ads_SDK -framework JavaScriptCore -framework MediaPlayer -framework MessageUI -framework MobileCoreServices -framework Network -framework QuartzCore -framework Security -framework StoreKit -framework SystemConfiguration -framework UserMessagingPlatform -framework WebKit -framework google_mobile_ads -framework webview_flutter_wkwebview -weak_framework AdSupport -weak_framework JavaScriptCore -weak_framework SafariServices -weak_framework WebKit -framework Pods_Runner -Xlinker -no_adhoc_codesign -Xlinker -dependency_info -Xlinker /Users/loicsharma/Library/Developer/Xcode/DerivedData/Runner-ddpxcupiwivysphihgoqhhedcmkq/Build/Intermediates.noindex/Runner.build/Release-iphoneos/Runner.build/Objects-normal/arm64/Runner_dependency_info.dat -o /Users/loicsharma/Code/tmp/ads_link_error/build/ios/Release-iphoneos/Runner.app/Runner
           ld: warning: Could not find or use auto-linked library 'swiftXPC': library 'swiftXPC' not found
           ld: warning: Could not find or use auto-linked framework 'CoreAudioTypes': framework 'CoreAudioTypes' not found
           ld: warning: Could not find or use auto-linked framework 'MarketplaceKit': framework 'MarketplaceKit' not found
           ld: Undefined symbols:
             enum case for MarketplaceKit.AppDistributor.testFlight(MarketplaceKit.AppDistributor.Type) -> MarketplaceKit.AppDistributor, referenced from:
                 l007 in GoogleMobileAds[arm64][422](GADMarketplaceKitSignals.o)
                 l008 in GoogleMobileAds[arm64][422](GADMarketplaceKitSignals.o)
             enum case for MarketplaceKit.AppDistributor.marketplace(MarketplaceKit.AppDistributor.Type) -> (Swift.String) -> MarketplaceKit.AppDistributor, referenced from:
                 l007 in GoogleMobileAds[arm64][422](GADMarketplaceKitSignals.o)
                 l008 in GoogleMobileAds[arm64][422](GADMarketplaceKitSignals.o)
             enum case for MarketplaceKit.AppDistributor.other(MarketplaceKit.AppDistributor.Type) -> MarketplaceKit.AppDistributor, referenced from:
                 l007 in GoogleMobileAds[arm64][422](GADMarketplaceKitSignals.o)
                 l008 in GoogleMobileAds[arm64][422](GADMarketplaceKitSignals.o)
             static MarketplaceKit.AppDistributor.current.getter : MarketplaceKit.AppDistributor, referenced from:
                 function signature specialization <Arg[0] = Dead> of static GoogleMobileAds.GADMarketplaceKitSignals.appDistributor() async -> Swift.String in GoogleMobileAds[arm64][422](GADMarketplaceKitSignals.o)
             async function pointer to static MarketplaceKit.AppDistributor.current.getter : MarketplaceKit.AppDistributor, referenced from:
                 function signature specialization <Arg[0] = Dead> of static GoogleMobileAds.GADMarketplaceKitSignals.appDistributor() async -> Swift.String in GoogleMobileAds[arm64][422](GADMarketplaceKitSignals.o)
             enum case for MarketplaceKit.AppDistributor.appStore(MarketplaceKit.AppDistributor.Type) -> MarketplaceKit.AppDistributor, referenced from:
                 l007 in GoogleMobileAds[arm64][422](GADMarketplaceKitSignals.o)
                 l008 in GoogleMobileAds[arm64][422](GADMarketplaceKitSignals.o)
             type metadata accessor for MarketplaceKit.AppDistributor, referenced from:
                 l007 in GoogleMobileAds[arm64][422](GADMarketplaceKitSignals.o)
                 l008 in GoogleMobileAds[arm64][422](GADMarketplaceKitSignals.o)
             nominal type descriptor for MarketplaceKit.AppDistributor, referenced from:
                 _symbolic _____Sg 14MarketplaceKit14AppDistributorO in GoogleMobileAds[arm64][422](GADMarketplaceKitSignals.o)
             __swift_FORCE_LOAD_$_swiftXPC, referenced from:
                 __swift_FORCE_LOAD_$_swiftXPC_$_GoogleMobileAds in GoogleMobileAds[arm64][422](GADMarketplaceKitSignals.o)
           clang: error: linker command failed with exit code 1 (use -v to see invocation)

           note: Run script build phase 'Run Script' will be run during every build because the option to run the script phase "Based on dependency analysis" is unchecked. (in target 'Runner' from project 'Runner')
           note: Run script build phase 'Thin Binary' will be run during every build because the option to run the script phase "Based on dependency analysis" is unchecked. (in target 'Runner' from project 'Runner')

           Result bundle written to path:
           	/var/folders/nm/_kd4yq192953vs2wyp4c4sfm00ysym/T/flutter_tools.qTlJvs/flutter_ios_build_temp_dir2P2DVE/temporary_xcresult_bundle


           2024-10-15 12:56:40.515 xcodebuild[97588:733779] [MT] DVTAssertions: Warning in /System/Volumes/Data/SWE/Apps/DT/BuildRoots/BuildRoot11/ActiveBuildRoot/Library/Caches/com.apple.xbs/Sources/IDEFrameworks/IDEFrameworks-22267/IDEFoundation/Provisioning/Capabilities Infrastructure/IDECapabilityQuerySelection.swift:103
           Details:  createItemModels creation requirements should not create capability item model for a capability item model that already exists.
           Function: createItemModels(for:itemModelSource:)
           Thread:   <_NSMainThread: 0x600001280040>{number = 1, name = main}
           Please file a bug at https://feedbackassistant.apple.com with this warning message and any useful information you can provide.
           ...
           2024-10-15 12:56:40.519 xcodebuild[97588:733779] [MT] DVTAssertions: Warning in /System/Volumes/Data/SWE/Apps/DT/BuildRoots/BuildRoot11/ActiveBuildRoot/Library/Caches/com.apple.xbs/Sources/IDEFrameworks/IDEFrameworks-22267/IDEFoundation/Provisioning/Capabilities Infrastructure/IDECapabilityQuerySelection.swift:103
           Details:  createItemModels creation requirements should not create capability item model for a capability item model that already exists.
           Function: createItemModels(for:itemModelSource:)
           Thread:   <_NSMainThread: 0x600001280040>{number = 1, name = main}
           Please file a bug at https://feedbackassistant.apple.com with this warning message and any useful information you can provide.
           ** BUILD FAILED **


           The following build commands failed:
           	Ld /Users/loicsharma/Code/tmp/ads_link_error/build/ios/Release-iphoneos/Runner.app/Runner normal (in target 'Runner' from project 'Runner')
           (1 failure)
[  +17 ms]  └─Compiling, linking and signing... (completed in 1,113ms)
[        ] Xcode build done.                                           19.9s
...
[   +6 ms] Failed to build iOS app
[   +6 ms] "flutter ios" took 23,502ms.
[        ] ensureAnalyticsSent: 0ms
[        ] Running 2 shutdown hooks
[  +13 ms] Shutdown hooks complete
[        ] exiting with code 1

Analyzing ads_link_error...
No issues found! (ran in 0.7s)

The warning is because I've checked out a specific Flutter SDK commit off the master channel.

[!] Flutter (Channel [user-branch], 3.27.0-1.0.pre.8, on macOS 14.7 23H124 darwin-arm64, locale en)
    ! Flutter version 3.27.0-1.0.pre.8 on channel [user-branch] at /Users/loicsharma/Code/flutter
      Currently on an unknown channel. Run `flutter channel` to switch to an official channel.
      If that doesn't fix the issue, reinstall Flutter by following instructions at https://flutter.dev/setup.
    ! Upstream repository unknown source is not a standard remote.
      Set environment variable "FLUTTER_GIT_URL" to unknown source to dismiss this error.
    • Framework revision 82ebb74c64 (5 days ago), 2024-10-10 15:45:39 -0400
    • Engine revision 3ce72a2893
    • Dart version 3.6.0 (build 3.6.0-334.2.beta)
    • DevTools version 2.40.1
    • If those were intentional, you can disregard the above warnings; however it is recommended to use "git" directly to perform update checks and upgrades.

[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
    • Android SDK at /Users/loicsharma/Library/Android/sdk
    • Platform android-34, build-tools 34.0.0
    • Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 17.0.9+0-17.0.9b1087.7-11185874)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 15.0)
    • Xcode at /Applications/Xcode_15.app/Contents/Developer
    • Build 15A240d
    • CocoaPods version 1.15.2

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2023.2)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 17.0.9+0-17.0.9b1087.7-11185874)

[✓] VS Code (version 1.94.2)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension can be installed from:
      🔨 https://marketplace.visualstudio.com/items?itemName=Dart-Code.flutter

[✓] Connected device (4 available)
    • Loïc’s iPhone 15 (mobile)       • 00008120-001665D90E51A01E • ios            • iOS 18.0 22A5297f
    • macOS (desktop)                 • macos                     • darwin-arm64   • macOS 14.7 23H124 darwin-arm64
    • Mac Designed for iPad (desktop) • mac-designed-for-ipad     • darwin         • macOS 14.7 23H124 darwin-arm64
    • Chrome (web)                    • chrome                    • web-javascript • Google Chrome 130.0.6723.44

[✓] Network resources
    • All expected network resources are available.

! Doctor found issues in 1 category.

Activity

  1. loic-sharma commented on Oct 15, 2024

    @loic-sharma
    Author

    This build error was introduced in Google-Mobile-Ads-SDK version 11.6.0. Steps to bisect:

    1. Follow the steps above to reproduce the build error.

    2. Backup ios/.symlinks/plugins/google_mobile_ads/ios/google_mobile_ads.podspec

    3. Check that downgrading Google-Mobile-Ads-SDK to version 11.6.0 does not fix the build error...

      1. Edit ios/.symlinks/plugins/google_mobile_ads/ios/google_mobile_ads.podspec and downgrade Google-Mobile-Ads-SDK to 11.6.0

      2. Delete ios/Podfile.lock to make CocoaPods re-download dependencies

      3. Build the app: flutter build ios

        This fails.

    4. Check that downgrading Google-Mobile-Ads-SDK to version 11.5.0 does fix the build error...

      1. Edit ios/.symlinks/plugins/google_mobile_ads/ios/google_mobile_ads.podspec and downgrade Google-Mobile-Ads-SDK to 11.5.0
      2. Delete ios/Podfile.lock to make CocoaPods re-download dependencies
      3. Build the app: flutter build ios
        This succeeds.
    5. Reset ios/.symlinks/plugins/google_mobile_ads/ios/google_mobile_ads.podspec to the backed up version

    Patch to downgrade Google-Mobile-Ads-SDK to 11.5.0...
      s.dependency 'Flutter'
    - s.dependency 'Google-Mobile-Ads-SDK','~> 11.10.0'
    + s.dependency 'Google-Mobile-Ads-SDK','~> 11.5.0'
      s.dependency 'webview_flutter_wkwebview'
      s.ios.deployment_target = '12.0'
      s.pod_target_xcconfig = { 'DEFINES_MODULE' => 'YES', 'VALID_ARCHS' => 'armv7 arm64 x86_64' }
  2. malandr2 commented on Oct 16, 2024

    @malandr2
    Collaborator

    Duplicate of #1185

    See #1185 (comment) for context. The minimum Xcode version was raised with the latest to Xcode >= 15.3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions