-
Notifications
You must be signed in to change notification settings - Fork 62
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
iOS app can't link to extern "Swift"
code in Release mode
#166
Comments
How are you building your iOS application? If you're using the Xcode + Cargo approach, if you look for If you're using the Swift package approach, did you include your release binary in the universal library? But yeah, please go into more detail about your build setup. |
I am using the Swift package approach. The binary is built like this: cargo build --release --target x86_64-apple-darwin
cargo build --release --target aarch64-apple-darwin
lipo \
./target/aarch64-apple-darwin/release/libmyproj_ios.a \
./target/x86_64-apple-darwin/release/libmyproj_ios.a -create -output \
./target/universal-macos/release/libmyproj_ios.a
cargo build --release --target aarch64-apple-ios
cargo build --release --target x86_64-apple-ios
cargo build --release --target aarch64-apple-ios-sim
lipo \
./target/aarch64-apple-ios-sim/release/libmyproj_ios.a \
./target/x86_64-apple-ios/release/libmyproj_ios.a -create -output \
./target/universal-ios/release/libmyproj_ios.a
swift-bridge-cli create-package \
--bridges-dir ./generated \
--out-dir ../../video-ios/lib-myproj-ios \
--ios target/aarch64-apple-ios/release/libmyproj_ios.a \
--simulator target/universal-ios/release/libmyproj_ios.a \
--macos target/universal-macos/release/libmyproj_ios.a \
--name myprojIos I didn't originally include the macos target, but added that as a way to see if I could move forward. I'm happy to share more about my setup, but I'm not sure what to look for. Any help would be appreciated. |
Gotcha. Those symbols should be in the Swift code that So, it sounds like your generated Swift code is being included in your Swift package in Debug, but not in Release. Can you compare the Swift and C code in that If you'd like to explore yourself you can do clone the If you can make a minimal reproduction of the issue such that we can run something like:
Then we can look into this. |
The thing is - I'm using the SAME I am also not using a spm-over-git setup, but rather I have embedded the package as a "local" spm package in XCode. But I compared the output from the xcode compiler, and the code in the generated .swift file: // ___swift_bridge__$OfflineReceiver$_free
@_cdecl("__swift_bridge__$OfflineReceiver$_free") I build my xcode project using Fastlane, which looks like this: lane :build_debug do
gym(
scheme: 'X-debug',
configuration: 'Debug',
include_symbols: true,
export_options: {
compileBitcode: false,
uploadBitcode: false,
uploadSymbols: true,
method: "development",
teamID: "xxx",
provisioningProfiles: {
// ...
},
},
)
end
lane :build_release do
gym(
scheme: "X-release",
configuration: "Release",
export_method: "app-store",
export_options: {
compileBitcode: false,
uploadBitcode: false,
uploadSymbols: true,
method: "app-store",
teamID: "xxx",
provisioningProfiles: {
// ...
},
},
)
end But the build failure also happens when I switch over to the release profile in xcode and build from there. I will try to make a proof-of-concept, but that will probably take some time to get working. Summary:
|
OK so I made some progress - @_cdecl("__swift_bridge__$OfflineReceiver$_free")
public func __swift_bridge__OfflineReceiver__free (ptr: UnsafeMutableRawPointer) { If I slap Seems like XCode is aggressively pruning those functions in the Release build, for some reason. |
For now I'm making do with sed -i '' 's/^func __swift_bridge__/public func __swift_bridge__/g' mylib.swift But I feel like either I should modify my XCode build somehow or this is a bug in |
Yeah we should solve this in We just need to make this a swift-bridge/crates/swift-bridge-ir/src/codegen/generate_swift.rs Lines 317 to 319 in 3c0d00d
We can add a swift-bridge/crates/swift-bridge-ir/src/codegen/codegen_tests.rs Lines 30 to 49 in 3c0d00d
And then in that module we can add a We can use Lines 32 to 34 in 4f2a9d7
Lines 95 to 97 in 4f2a9d7
|
@chinedufn I've put up a PR (#262) based on these instructions.
|
lol i ran into the same issue: rustunit/bevy_ios_iap@ba61693 |
hey, Im running into the same issue |
If someone writes a PR that solves this issue, I can merge it. A contributor wrote a pull-request that fixed it, but they are no longer planning to work on addressing the PR's feedback. Anyone can feel free to fork that branch, or create their own new brach, and then get the fix working. |
When I run my iOS application in Debug mode, everything is working correctly and the code is linking properly.
But when I build my iOS app in Release mode, for App Store release, I am greeted with the following errors:
Basically it can't link against anything that is declared
extern "Swift"
. I've tried a few things before reaching out, but I can't figure out what is going wrong.Please help 🙏
The text was updated successfully, but these errors were encountered: