Open PrismaPhonic opened 3 months ago
Whoops, accidentally closed - sorry about that
@deg4uss3r @vladimir-ea @leohowell
@deg4uss3r @vladimir-ea @leohowell
have a few questions
I can get it to work in an Apple Watch app if I manually link the static library file generated from my rust project, however it will only work for debug runs pushed to the watch wirelessly for testing. Any attempt to make an archive build results in similar errors inside xcode.
The build command actually comes from swift-rust-bridge
codegen, but can be reproduced with the following simplified version:
xcodebuild -create-xcframework -library target/aarch64-apple-watchos/release/librepetitiontracker.a -output test.xcframework
If I run that exact same xcodebuild
command pointing at the watchos-sim
static library file instead, it has no problem creating the xcframework
EDIT: Forgot to answer your second question. It is a hybrid project, however only the WatchOS project needs the generated library from the xcodebuild command. I currently have it linked manually and it "works" in the way I've described above. I can't currently generate the library at all when using the non sim watchos targets
I reproduced your problem and tried some fixes, I don't know if this will solve your problem, but there are no errors with your simplified xcodebuild command.
cargo build -Zbuild-std=std,panic_abort --target aarch64-apple-watchos --release
cargo build -Zbuild-std=std,panic_abort --target arm64_32-apple-watchos --release
cargo build -Zbuild-std=std,panic_abort --target armv7k-apple-watchos --release
lipo -create target/aarch64-apple-watchos/release/libtest_watchos.a\
target/arm64_32-apple-watchos/release/libtest_watchos.a\
target/armv7k-apple-watchos/release/libtest_watchos.a\
-o libtest_watchos_lipo.a
lipo -info libtest_watchos_lipo.a
# output: Architectures in the fat file: libtest_watchos_lipo.a are: arm64_32 armv7k arm64
xcodebuild -create-xcframework -library libtest_watchos_lipo.a -output test.xcframework
# xcframework successfully written out to: test.xcframework
Main reference documents https://developer.apple.com/documentation/xcode/creating-a-multi-platform-binary-framework-bundle#Generate-the-XCFramework-bundle
Ahh interesting - so it seems that lipo does need to be used to combine all possible watch architectures then? I'll give that a try and report back, thank you
I still get the same error:
$ lipo -info target/lipo/release/librepetitiontracker.a
Architectures in the fat file: target/lipo/release/librepetitiontracker.a are: arm64_32 armv7k arm64
$ xcodebuild -create-xcframework -library target/lipo/release/librepetitiontracker.a -output test.xcframework
error: unable to determine the platform for the given binary '/Users/pmfarr/git/workout-planner/target/lipo/release/librepetitiontracker.a'; check your deployment version settings
Xcode version 15.3 for reference, in case this is a requirement of an xcode version newer than the one you're testing with
When compiling for aarch64-apple-watchos target, building is successful, but when trying to pipe the generated binaries into xcodebuild I get:
This issue does not occur oddly with aarch64-apple-watchos-sim target, which works perfectly. It does however happen with every non simulator target for apple watch at the moment