Skip to content

[MacCatalyst]: Can't determine the platform when creating an xcframework from rust libraries #107630

@Milerius

Description

@Milerius

Hello I'm using aarch64-apple-ios-macabi and x86_64-apple-ios-macabi as follow in my project:

CARGO_TARGET_DIR=$BUILD_FOLDER cargo +nightly build -Z build-std --target aarch64-apple-ios-macabi --release CARGO_TARGET_DIR=$BUILD_FOLDER cargo +nightly build -Z build-std --target x86_64-apple-ios-macabi --release lipo $BUILD_FOLDER/aarch64-apple-ios-macabi/release/$TARGET_NAME $BUILD_FOLDER/x86_64-apple-ios-macabi/release/$TARGET_NAME -create -output $BUILD_FOLDER/catalyst/$TARGET_NAME xcodebuild -create-xcframework -library $BUILD_FOLDER/$TARGET_NAME -library $BUILD_FOLDER/darwin_universal/$TARGET_NAME -library $BUILD_FOLDER/aarch64-apple-ios/release/$TARGET_NAME -library $BUILD_FOLDER/catalyst/$TARGET_NAME -output $TARGET_XCFRAMEWORK_NAME 

Was working fine until XCode 14.2 release which now produce:

error: unable to determine the platform for the given binary 'project/build/local/catalyst/libproject_rs.a'; check your deployment version settings 

This is the json target spec for MacCatalyst (aarch64):

{ "abi": "macabi", "abi-return-struct-as-int": true, "arch": "aarch64", "archive-format": "darwin", "bitcode-llvm-cmdline": "-triple\u0000arm64-apple-ios-macabi\u0000-emit-obj\u0000-disable-llvm-passes\u0000-Os\u0000", "cpu": "apple-a12", "data-layout": "e-m:o-i64:64-i128:128-n32:64-S128", "debuginfo-kind": "dwarf-dsym", "default-dwarf-version": 2, "dll-suffix": ".dylib", "dynamic-linking": true, "eh-frame-header": false, "emit-debug-gdb-scripts": false, "features": "+neon,+fp-armv8,+apple-a12", "forces-embed-bitcode": true, "frame-pointer": "non-leaf", "function-sections": false, "has-rpath": true, "is-builtin": true, "is-like-osx": true, "link-env": [ "ZERO_AR_DATE=1" ], "link-env-remove": [ "IPHONEOS_DEPLOYMENT_TARGET" ], "linker-is-gnu": false, "lld-flavor": "darwin", "llvm-target": "arm64-apple-ios-macabi", "max-atomic-width": 128, "os": "ios", "pre-link-args": { "gcc": [ "-target", "arm64-apple-ios-macabi" ], "ld": [ "-arch", "arm64", "-platform_version", "mac-catalyst", "7.0", "7.0" ], "ld64.lld": [ "-arch", "arm64", "-platform_version", "mac-catalyst", "7.0", "7.0" ] }, "split-debuginfo": "packed", "supported-split-debuginfo": [ "packed", "unpacked", "off" ], "target-family": [ "unix" ], "target-pointer-width": "64", "vendor": "apple" } 

Every other targets outside of catalyst seems to work

Meta

rustc --version --verbose:

rustc 1.69.0-nightly (f3126500f 2023-02-02) binary: rustc commit-hash: f3126500f25114ba4e0ac3e76694dd45a22de56d commit-date: 2023-02-02 host: aarch64-apple-darwin release: 1.69.0-nightly LLVM version: 15.0.7 

Maybe XCode have new requirements that the targets doesn't respect correctly? and therefore xcodebuild can't create an xcframework from any catalyst library?

Simple repro:

rustup update rustup toolchain install nightly rustup default nightly rustup toolchain install nightly-x86_64-apple-darwin rustup toolchain install nightly-aarch64-apple-darwin rustup component add rust-src --toolchain nightly-aarch64-apple-darwin rustup component add rust-src --toolchain nightly-x86_64-apple-darwin rustup target add aarch64-apple-darwin x86_64-apple-darwin rustup target add x86_64-apple-ios aarch64-apple-ios-sim aarch64-apple-ios 
cargo build --target aarch64-apple-ios --release cargo build --target aarch64-apple-ios-sim --release cargo build --target x86_64-apple-ios --release cargo build --target aarch64-apple-darwin --release cargo build --target x86_64-apple-darwin --release cargo +nightly build -Z build-std --target aarch64-apple-ios-macabi --release cargo +nightly build -Z build-std --target x86_64-apple-ios-macabi --release lipo build_folder/x86_64-apple-ios/release/lib_name.a build_folder/aarch64-apple-ios-sim/release/libname.a -create -output build_folder/libname.a mkdir -p build_folder/darwin_universal lipo build_folder/x86_64-apple-darwin/release/libname.a build_folder/aarch64-apple-darwin/release/libname.a -create -output build_folder/darwin_universal/libname.a mkdir -p build_folder//catalyst lipo build_folder/aarch64-apple-ios-macabi/release/libname.a build_folder/x86_64-apple-ios-macabi/release/libname.a -create -output build_folder/catalyst/libname.a ## Will fail on catalyst with `error: unable to determine the platform for the given binary 'project/build/local/catalyst/libname.a'; check your deployment version settings` xcodebuild -create-xcframework -library $BUILD_FOLDER/$TARGET_NAME -library $BUILD_FOLDER/darwin_universal/$TARGET_NAME -library $BUILD_FOLDER/aarch64-apple-ios/release/$TARGET_NAME -library $BUILD_FOLDER/catalyst/$TARGET_NAME -output $TARGET_XCFRAMEWORK_NAME 

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.O-iosOperating system: iOS

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions