Skip to content
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 build fails #352

Open
thisbefruit opened this issue Jul 16, 2024 · 1 comment
Open

iOS build fails #352

thisbefruit opened this issue Jul 16, 2024 · 1 comment

Comments

@thisbefruit
Copy link

Describe the bug
cargo mobile init then building in XCode fails to build the Rust Code with error

library 'System' not found

The Rust dependencies do not finish building. Now when I add this line:

export LIBRARY_PATH="${DEVELOPER_SDK_DIR}/MacOSX.sdk/usr/lib:${LIBRARY_PATH:-}"

to the Build Rust Code build phase (from this tutorial; I assume compiling proc macros etc requires the MacOS SDK), all the dependencies build successfully, but the final linking fails with:

ld: building for 'iOS', but linking in dylib (/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/lib/libobjc.A.tbd) built for 'macOS macCatalyst zippered(macOS/Catalyst)'

Probably the XCode build environment is somehow messed up during the generation of the XCode project?

Steps To Reproduce

  1. cargo mobile init on MacOS Somona
  2. open and run the generated XCode project in XCode 15.3

Expected behavior
XCode builds the project successfully out of the box.

Platform and Versions (please complete the following information):
Host OS: MacOS Sonoma 14.5
Target OS: aarch64 iOS
Rustc: 1.79.0
Ouput of cargo mobile doctor:

[✔] cargo-mobile v0.12.2
    • Contains commits up to "Publish New Versions (#344)\n"
    • Installed at "~/.cargo/.cargo-mobile2"
    • macOS v14.5 (23F79)
    • rustc v1.79.0 (129f3b996 2024-6-10)

[!] Apple developer tools
    • Xcode v15.3
    • Active developer dir: "/Applications/Xcode.app/Contents/Developer"
    • ios-deploy v1.12.2
    • XcodeGen v2.41.0
    ✗ xcode-rust-plugin plugin absent
    ✗ xcode-rust-plugin lang spec absent
    ✗ xcode-rust-plugin lang metadata absent
    • xcode-rust-plugin is up-to-date
    ✗ Failed to check xcode-rust-plugin UUID status: Failed to lookup Xcode
      UUID: command ["defaults", "read"] exited with code 1
    • Development team: Gephyra OU (5M9G3KQ5FK)

[!] Android developer tools
    ✗ Have you installed the Android SDK? The ANDROID_HOME environment
      variable isn't set, and is required: environment variable not found
/usr/local/bin/ios-deploy

[!] Connected devices
    ✗ Failed to get iOS device list: Failed to request device list from
      ios-deploy: command ["ios-deploy", "--detect", "--timeout", "1",
      "--json", "--no-wifi"] exited with code 253

Additional context
Modifying the Build Rust Code build phase to this (essentially first building with LIBRARY_PATH=MacOS_SDK, which builds all dependencies but fails to link, then un-setting the LIBRARY_PATH to build with the iOS SDK, which succeeds in linking) somehow works, albeit with an error thrown and ignored in the middle:

export PATH=${PATH}:${HOME:?}/.cargo/bin
export MACOS_SDKROOT=$(xcrun --sdk macosx --show-sdk-path)
export OLD_LIBRARY_PATH=$LIBRARY_PATH
export LIBRARY_PATH="${MACOS_SDKROOT}/usr/lib:${SDKROOT}/usr/lib:${LIBRARY_PATH:-}"
cargo build --target aarch64-apple-ios || true
export LIBRARY_PATH=$OLD_LIBRARY_PATH
cargo build --target aarch64-apple-ios
cargo build --target x86_64-apple-ios
@PWhiddy
Copy link

PWhiddy commented Sep 23, 2024

I also am unable to get this to build for ios.

$ cargo mobile doctor

[✔] cargo-mobile v0.17.2
    • Contains commits up to "publish new versions (#389)\n"
    • Installed at "~/.cargo/.cargo-mobile2"
    • macOS v14.2.1 (23C71)
    • rustc v1.78.0 (9b00956e5 2024-4-29)

[!] Apple developer tools
    • Xcode v15.4
    • Active developer dir: "/Applications/Xcode.app/Contents/Developer"
    ✗ Failed to check ios-deploy version: No such file or directory (os error 2)
    • XcodeGen v2.42.0
    ✗ xcode-rust-plugin plugin absent
    ✗ xcode-rust-plugin lang spec absent
    ✗ xcode-rust-plugin lang metadata absent
    • xcode-rust-plugin is up-to-date
    ✗ Failed to check xcode-rust-plugin UUID status: Failed to lookup Xcode UUID: command ["defaults", "read"] exited with code 1
    • Development team: ************

[!] Android developer tools
    ✗ Have you installed the Android SDK? The `ANDROID_HOME` environment variable isn't set, and is required: environment variable not found

[✔] Connected devices
    • ****’s Device of Ultimate Destiny (iPhone13,2)

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

No branches or pull requests

2 participants