Skip to content

fix(build): pass --triple for every cross build (#74) - #84

Open
IIK3D wants to merge 1 commit into
Brendonovich:mainfrom
IIK3D:fix/triple-for-every-cross-build
Open

IIK3D wants to merge 1 commit into
Brendonovich:mainfrom
IIK3D:fix/triple-for-every-cross-build

Conversation

@IIK3D

@IIK3D IIK3D commented Sep 26, 2026 •

Copy link
Copy Markdown

Fixes #74.

Problem

Cross-compiling for iOS under Xcode < 27, build.rs runs swift build --arch arm64 -Xswiftc -sdk … -Xswiftc -target arm64-apple-ios…. The compiler is retargeted, but SwiftPM itself still resolves the package graph for the host triple (arm64-apple-macosx). That triple is what selects the slice of a binary target: an iOS-only .xcframework (GoogleMobileAds, for instance) has no macOS slice, its module is never exposed, and the dependent target fails with:

error: no such module 'GoogleMobileAds'

--triple was already the answer, but only under Xcode 27.

Change

  • use_triple = cross_compiling instead of cross_compiling && xcode27.
  • When --triple is used below Xcode 27, look for lib<name>.a in the directory SwiftPM then creates: <arch>-apple-<os>[-simulator]/<configuration> (e.g. arm64-apple-ios/release), instead of <arch>-apple-macosx/<configuration>.
  • The Xcode 27 path is unchanged.

Tested

Xcode 26.6: a Swift package depending on swift-package-manager-google-mobile-ads and swift-package-manager-google-user-messaging-platform now builds for an iOS device, and the app that links it builds with xcodebuild (BUILD SUCCEEDED). Before the change, the same package failed with "no such module".

TEST_SWIFT_RS=true cargo test --features build: all 6 tests in test_bindings pass, both with this change and on main without it (my first run omitted TEST_SWIFT_RS, which crashes the binary before it links the test's own Swift code — unrelated to this change; corrected here).

🤖 Generated with Claude Code

With --arch plus -Xswiftc -target, the compiler is retargeted, but SwiftPM
still resolves the package graph for the host triple (arm64-apple-macosx).
That triple is what selects the slice of a binary target, so an iOS-only
.xcframework such as GoogleMobileAds exposes no module and the dependent
target fails with "no such module" (Brendonovich#74).

--triple was only used under Xcode 27. Use it for every cross build, and
look for the static library in the directory SwiftPM then creates
(<arch>-apple-<os>[-simulator]/<configuration>). The Xcode 27 path is
unchanged.

Tested on Xcode 26.6: a package depending on GoogleMobileAds and
GoogleUserMessagingPlatform builds for an iOS device, and the resulting
app links and builds with xcodebuild.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

GoogleMobileAds yields - error: no such module 'GoogleMobileAds' even though Xcode builds successfully

1 participant