tauri icon indicating copy to clipboard operation
tauri copied to clipboard

[bug] Google AdMob Tauri iOS plugin

Open setoelkahfi opened this issue 1 month ago • 6 comments

Describe the bug

Discussion.

I'm trying to add support for Tauri plugin AdMob on iOS. It works fine on XCode but fails on the example project saying ``- error: no such module 'GoogleMobileAds'`. Package.swift file:

// swift-tools-version:5.3
// The swift-tools-version declares the minimum version of Swift required to build this package.

import PackageDescription

let package = Package(
    name: "tauri-plugin-admob",
    platforms: [
        .macOS(.v10_13),
        .iOS(.v13),
    ],
    products: [
        // Products define the executables and libraries a package produces, and make them visible to other packages.
        .library(
            name: "tauri-plugin-admob",
            type: .static,
            targets: ["tauri-plugin-admob"])
    ],
    dependencies: [
        .package(name: "Tauri", path: "../.tauri/tauri-api"),
        .package(
            url: "https://github.com/googleads/swift-package-manager-google-mobile-ads.git",
            from: "12.14.0"
        ),
    ],
    targets: [
        // Targets are the basic building blocks of a package. A target can define a module or a test suite.
        // Targets can depend on other targets in this package, and on products in packages this package depends on.
        .target(
            name: "tauri-plugin-admob",
            dependencies: [
                .byName(name: "Tauri"),
                .product(
                    name: "GoogleMobileAds", package: "swift-package-manager-google-mobile-ads"),

            ],
            path: "Sources")
    ]
)

It seems like the iOS plugin build compile the Swift package before finishing installing the dependency. I might be wrong:


   Compiling tauri-plugin-admob v0.0.4 (/Users/setoelkahfi/Repositories/tauri-plugin-admob)
   Compiling tauri-macros v2.5.1
   Compiling tauri-app v0.0.0 (/Users/setoelkahfi/Repositories/tauri-plugin-admob/examples/tauri-app/src-tauri)
error: failed to run custom build command for `tauri-plugin-admob v0.0.4 (/Users/setoelkahfi/Repositories/tauri-plugin-admob)`

Caused by:
  process didn't exit successfully: `/Users/setoelkahfi/Repositories/tauri-plugin-admob/examples/tauri-app/src-tauri/target/debug/build/tauri-plugin-admob-4a2939bc6545f557/build-script-build` (exit status: 101)
  --- stdout
  cargo:rerun-if-changed=permissions
  cargo:PERMISSION_FILES_PATH=/Users/setoelkahfi/Repositories/tauri-plugin-admob/examples/tauri-app/src-tauri/target/aarch64-apple-ios-sim/debug/build/tauri-plugin-admob-f27d046634e407b0/out/tauri-plugin-admob-permission-files
  cargo:rerun-if-env-changed=REMOVE_UNUSED_COMMANDS
  cargo:rustc-check-cfg=cfg(mobile)
  cargo:rustc-cfg=mobile
  cargo:rustc-check-cfg=cfg(desktop)
  cargo:rerun-if-changed=/Users/setoelkahfi/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tauri-2.9.3/mobile/ios-api/README.md
  cargo:rerun-if-changed=/Users/setoelkahfi/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tauri-2.9.3/mobile/ios-api/.gitignore
  cargo:rerun-if-changed=/Users/setoelkahfi/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tauri-2.9.3/mobile/ios-api/Package.swift
  cargo:rerun-if-changed=/Users/setoelkahfi/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tauri-2.9.3/mobile/ios-api/Sources/Tauri/UiUtils.swift
  cargo:rerun-if-changed=/Users/setoelkahfi/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tauri-2.9.3/mobile/ios-api/Sources/Tauri/JsonValue.swift
  cargo:rerun-if-changed=/Users/setoelkahfi/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tauri-2.9.3/mobile/ios-api/Sources/Tauri/Invoke.swift
  cargo:rerun-if-changed=/Users/setoelkahfi/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tauri-2.9.3/mobile/ios-api/Sources/Tauri/Logger.swift
  cargo:rerun-if-changed=/Users/setoelkahfi/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tauri-2.9.3/mobile/ios-api/Sources/Tauri/Plugin/Plugin.swift
  cargo:rerun-if-changed=/Users/setoelkahfi/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tauri-2.9.3/mobile/ios-api/Sources/Tauri/Channel.swift
  cargo:rerun-if-changed=/Users/setoelkahfi/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tauri-2.9.3/mobile/ios-api/Sources/Tauri/JSTypes.swift
  cargo:rerun-if-changed=/Users/setoelkahfi/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tauri-2.9.3/mobile/ios-api/Sources/Tauri/Tauri.swift
  cargo:rustc-link-search=native=/Applications/Xcode-26.0.0.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator
  cargo:rustc-link-search=native=/usr/lib/swift
  cargo:rustc-link-lib=clang_rt.iossim
  cargo:rustc-link-search=/Applications/Xcode-26.0.0.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/17/lib/darwin
  Building for debugging...
  [0/10] Write sources
  [4/10] Compiling UserMessagingPlatformTarget placeholder.m
  [5/10] Write swift-version-49B95AFC49DCD68C.txt
  [7/14] Compiling GoogleMobileAdsTarget placeholder.swift
  [8/14] Emitting module GoogleMobileAdsTarget
  [9/14] Compiling SwiftRs lib.swift
  [10/14] Emitting module SwiftRs
  [11/23] Compiling Tauri Invoke.swift
  [12/23] Compiling Tauri Plugin.swift
  [13/23] Compiling Tauri JsonValue.swift
  /Users/setoelkahfi/Repositories/tauri-plugin-admob/.tauri/tauri-api/Sources/Tauri/JsonValue.swift:42:11: warning: expression implicitly coerced from 'Any?' to 'Any'
  40 | 				return prepare(array: anArray)
  41 | 			}
  42 | 			return value
     |           |- warning: expression implicitly coerced from 'Any?' to 'Any'
     |           |- note: provide a default value to avoid this warning
     |           |- note: force-unwrap the value to avoid this warning
     |           `- note: explicitly cast to 'Any' with 'as Any' to silence this warning
  43 | 		}
  44 | 	}
  [14/23] Compiling Tauri UiUtils.swift
  [15/23] Compiling Tauri Logger.swift
  [16/23] Compiling Tauri JSTypes.swift
  [17/23] Compiling Tauri Channel.swift
  [18/23] Emitting module Tauri
  [19/23] Compiling Tauri Tauri.swift
  [19/23] Write Objects.LinkFileList
  [20/23] Archiving libTauri.a
  error: emit-module command failed with exit code 1 (use -v to see invocation)
  [22/27] Emitting module tauri_plugin_admob
  /Users/setoelkahfi/Repositories/tauri-plugin-admob/ios/Sources/AdmobPlugin.swift:5:8: error: no such module 'GoogleMobileAds'
   3 | import UIKit
   4 | import WebKit
   5 | import GoogleMobileAds
     |        `- error: no such module 'GoogleMobileAds'
   6 |
   7 | class PingArgs: Decodable {
  [23/27] Compiling tauri_plugin_admob Context.swift
  /Users/setoelkahfi/Repositories/tauri-plugin-admob/ios/Sources/AdmobPlugin.swift:5:8: error: no such module 'GoogleMobileAds'
   3 | import UIKit
   4 | import WebKit
   5 | import GoogleMobileAds
     |        `- error: no such module 'GoogleMobileAds'
   6 |
   7 | class PingArgs: Decodable {
  [24/27] Compiling tauri_plugin_admob ExecuteContext.swift
  /Users/setoelkahfi/Repositories/tauri-plugin-admob/ios/Sources/AdmobPlugin.swift:5:8: error: no such module 'GoogleMobileAds'
   3 | import UIKit
   4 | import WebKit
   5 | import GoogleMobileAds
     |        `- error: no such module 'GoogleMobileAds'
   6 |
   7 | class PingArgs: Decodable {
  [25/27] Compiling tauri_plugin_admob AdmobPlugin.swift
  /Users/setoelkahfi/Repositories/tauri-plugin-admob/ios/Sources/AdmobPlugin.swift:5:8: error: no such module 'GoogleMobileAds'
   3 | import UIKit
   4 | import WebKit
   5 | import GoogleMobileAds
     |        `- error: no such module 'GoogleMobileAds'
   6 |
   7 | class PingArgs: Decodable {

  --- stderr
  Fetching https://github.com/googleads/swift-package-manager-google-user-messaging-platform.git from cache
  Fetching https://github.com/googleads/swift-package-manager-google-mobile-ads.git from cache
  Fetching https://github.com/Brendonovich/swift-rs from cache
  Fetched https://github.com/googleads/swift-package-manager-google-user-messaging-platform.git from cache (0.42s)
  Fetched https://github.com/googleads/swift-package-manager-google-mobile-ads.git from cache (0.42s)
  Fetched https://github.com/Brendonovich/swift-rs from cache (0.59s)
  Computing version for https://github.com/Brendonovich/swift-rs
  Computed https://github.com/Brendonovich/swift-rs at 1.0.7 (1.08s)
  Computing version for https://github.com/googleads/swift-package-manager-google-mobile-ads.git
  Computed https://github.com/googleads/swift-package-manager-google-mobile-ads.git at 12.14.0 (0.36s)
  Computing version for https://github.com/googleads/swift-package-manager-google-user-messaging-platform.git
  Computed https://github.com/googleads/swift-package-manager-google-user-messaging-platform.git at 3.1.0 (0.40s)
  Creating working copy for https://github.com/googleads/swift-package-manager-google-user-messaging-platform.git
  Working copy of https://github.com/googleads/swift-package-manager-google-user-messaging-platform.git resolved at 3.1.0
  Creating working copy for https://github.com/googleads/swift-package-manager-google-mobile-ads.git
  Working copy of https://github.com/googleads/swift-package-manager-google-mobile-ads.git resolved at 12.14.0
  Creating working copy for https://github.com/Brendonovich/swift-rs
  Working copy of https://github.com/Brendonovich/swift-rs resolved at 1.0.7
  Fetching binary artifact https://dl.google.com/googleadmobadssdk/90fe6bf3b0f4ce0d/googleusermessagingplatformios-spm-3.1.0.zip from cache
  Fetching binary artifact https://dl.google.com/googleadmobadssdk/c8c5523373ed76aa/googlemobileadsios-spm-12.14.0.zip from cache
  Fetched https://dl.google.com/googleadmobadssdk/90fe6bf3b0f4ce0d/googleusermessagingplatformios-spm-3.1.0.zip from cache (0.23s)
  Fetched https://dl.google.com/googleadmobadssdk/c8c5523373ed76aa/googlemobileadsios-spm-12.14.0.zip from cache (0.56s)

  thread 'main' panicked at /Users/setoelkahfi/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/swift-rs-1.0.7/src-rs/build.rs:281:17:
  Failed to compile swift package tauri-plugin-admob
  stack backtrace:
     0: __rustc::rust_begin_unwind
               at /rustc/1159e78c4747b02ef996e55082b704c09b970588/library/std/src/panicking.rs:697:5
     1: core::panicking::panic_fmt
               at /rustc/1159e78c4747b02ef996e55082b704c09b970588/library/core/src/panicking.rs:75:14
     2: swift_rs::build::SwiftLinker::link
               at /Users/setoelkahfi/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/swift-rs-1.0.7/src-rs/build.rs:281:17
     3: tauri_utils::build::link_swift_library
               at /Users/setoelkahfi/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tauri-utils-2.8.0/src/build.rs:30:4
     4: tauri_utils::build::link_apple_library
               at /Users/setoelkahfi/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tauri-utils-2.8.0/src/build.rs:11:5
     5: tauri_plugin::build::mobile::setup
               at /Users/setoelkahfi/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tauri-plugin-2.5.1/src/build/mobile.rs:110:9
     6: tauri_plugin::build::Builder::try_build
               at /Users/setoelkahfi/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tauri-plugin-2.5.1/src/build/mod.rs:150:5
     7: tauri_plugin::build::Builder::build
               at /Users/setoelkahfi/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tauri-plugin-2.5.1/src/build/mod.rs:83:30
     8: build_script_build::main
               at ./build.rs:20:10
     9: core::ops::function::FnOnce::call_once
               at /Users/setoelkahfi/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/src/rust/library/core/src/ops/function.rs:253:5
  note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
       Error failed to compile iOS app: Failed to run `cargo build`: command ["cargo", "build", "--package", "tauri-app", "--manifest-path", "/Users/setoelkahfi/Repositories/tauri-plugin-admob/examples/tauri-app/src-tauri/Cargo.toml", "--target", "aarch64-apple-ios-sim", "--lib", "--no-default-features"] exited with code 101

note: Run script build phase 'Build Rust Code' will be run during every build because the option to run the script phase "Based on dependency analysis" is unchecked. (in target 'tauri-app_iOS' from project 'tauri-app')
** BUILD FAILED **


The following build commands failed:
	PhaseScriptExecution Build\ Rust\ Code /Users/setoelkahfi/Library/Developer/Xcode/DerivedData/tauri-app-glpbgfzyojduwyfgbsjitbunblxa/Build/Intermediates.noindex/tauri-app.build/debug-iphonesimulator/tauri-app_iOS.build/Script-4CFF21EFA1FFE4D2AB9D6998.sh (in target 'tauri-app_iOS' from project 'tauri-app')
	Building workspace tauri-app with scheme tauri-app_iOS and configuration debug
(2 failures)
       Error failed to run iOS app: failed to build with xcodebuild: command ["xcodebuild"] exited with code 65

Any pointers?

Reproduction

No response

Expected behavior

No response

Full tauri info output

➜  tauri-app git:(feature/ios-support) ✗ cargo tauri info

[✔] Environment
    - OS: Mac OS 26.0.1 arm64 (X64)
    ✔ Xcode Command Line Tools: installed
    ✔ Xcode: 26.0
    ✔ rustc: 1.90.0 (1159e78c4 2025-09-14)
    ✔ cargo: 1.90.0 (840b83a10 2025-07-30)
    ✔ rustup: 1.28.2 (e4f3ad6f8 2025-04-28)
    ✔ Rust toolchain: stable-aarch64-apple-darwin (overridden by environment variable RUSTUP_TOOLCHAIN)
    - node: 24.9.0
    - pnpm: 10.22.0
    - yarn: 1.22.22
    - npm: 11.6.0

[-] Packages
    - tauri 🦀: 2.9.3
    - tauri-build 🦀: 2.5.2
    - wry 🦀: 0.53.5
    - tao 🦀: 0.34.5
    - tauri-cli 🦀: 2.9.2 (outdated, latest: 2.9.4)
    - @tauri-apps/api  ⱼₛ: 2.9.0
    - @tauri-apps/cli  ⱼₛ: 2.9.2 (outdated, latest: 2.9.4)

[-] Plugins

[-] App
    - build-type: bundle
    - CSP: unset
    - frontendDist: ../dist
    - devUrl: http://localhost:1420/
    - framework: Svelte
    - bundler: Vite

Stack trace


Additional context

No response

setoelkahfi avatar Nov 19 '25 21:11 setoelkahfi

@FabianLars Looks like this is solved here without proper answer. You know anything about it?

setoelkahfi avatar Nov 27 '25 20:11 setoelkahfi

"without proper answer" ? it was fixed by https://github.com/tauri-apps/tauri/pull/13995 and making sure your project uses the latest tauri-utils version should pull the fix. i assume it worked for the PR author at least. Looking at the PR they also mentioned the PATH env var so maybe admob must be in the path? idk let's ignore that for now and make sure you're on latest tauri-utils (in the runtime deps, build-dependencies via tauri-build and tauri-plugin, and the cli - simply everywhere)

FabianLars avatar Nov 27 '25 21:11 FabianLars

No, I meant there's a dangling question in the last thread. It seems to be working now with the latest Tauri deps. I wasn't aware that I put exact versions in the Cargo file.

setoelkahfi avatar Nov 27 '25 21:11 setoelkahfi

No, I commented out the import statement in the Swift code. It backs to square one now. I updated the description with the Package.swift content.

setoelkahfi avatar Nov 27 '25 21:11 setoelkahfi

the PR only touches code that runs in xcode plugins, not swift pm plugins so if you haven't already try creating the plugin with tauri plugin ios init --ios-framework xcode - i'm not really familiar with this stuff either so that's the only suggestion i can think of

FabianLars avatar Nov 27 '25 21:11 FabianLars

Ok, I re-initiated the plugin with --ios-framework and got new errors:

 = note: some arguments are omitted. use `--verbose` to show all linker arguments
  = note: ld: warning: ignoring duplicate libraries: '-lSystem', '-lclang_rt.iossim', '-lobjc'
          ld: warning: Could not find or use auto-linked framework 'UIUtilities': framework 'UIUtilities' not found
          ld: warning: Could not parse or use implicit file '/Applications/Xcode-26.0.0.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk/System/Library/Frameworks/SwiftUICore.framework/SwiftUICore.tbd': cannot link directly with 'SwiftUICore' because product being built is not an allowed client of it
          Undefined symbols for architecture arm64:
            "_OBJC_CLASS_$_GADMobileAds", referenced from:
                 in libtauri_plugin_admob-5ab5a21ac9680b8c.rlib[9](AdmobPlugin.o)
          ld: symbol(s) not found for architecture arm64
          clang: error: linker command failed with exit code 1 (use -v to see invocation)


error: could not compile `tauri-app` (lib) due to 1 previous error
       Error failed to compile iOS app: Failed to run `cargo build`: command ["cargo", "build", "--package", "tauri-app", "--manifest-path", "/Users/setoelkahfi/Repositories/tauri-plugin-admob/examples/tauri-app/src-tauri/Cargo.toml", "--target", "aarch64-apple-ios-sim", "--lib", "--no-default-features"] exited with code 101

** BUILD FAILED **

I'll continue again tomorrow.

setoelkahfi avatar Nov 27 '25 22:11 setoelkahfi