uikit-sys
uikit-sys copied to clipboard
Error: Library not loaded: @rpath/libclang.dylib
I tried to follow this tutorial: https://simlay.net/posts/using-uikit-sys/
But the cargo build return:
cargo bundle --example uikit --target x86_64-apple-ios
Compiling malloc_buf v0.0.6
Compiling raw-window-handle v0.3.4
Compiling uikit-sys v0.0.1 (https://github.com/simlay/uikit-sys?rev=ce0ffa193b7d0c55c02f77bba2327ba43ee9204f#ce0ffa19)
error: failed to run custom build command for `uikit-sys v0.0.1 (https://github.com/simlay/uikit-sys?rev=ce0ffa193b7d0c55c02f77bba2327ba43ee9204f#ce0ffa19)`
Caused by:
process didn't exit successfully: `/Users/brunoaraujo/opt/use-uikit-sys/target/debug/build/uikit-sys-789b76a700bf0932/build-script-build` (signal: 6, SIGABRT: process abort signal)
--- stderr
dyld[4843]: Library not loaded: @rpath/libclang.dylib
Referenced from: /Users/brunoaraujo/opt/use-uikit-sys/target/debug/build/uikit-sys-789b76a700bf0932/build-script-build
Reason: tried: '/Users/brunoaraujo/opt/use-uikit-sys/target/debug/deps/libclang.dylib' (no such file), '/Users/brunoaraujo/opt/use-uikit-sys/target/debug/libclang.dylib' (no such file), '/Users/brunoaraujo/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libclang.dylib' (no such file), '/Users/brunoaraujo/.rustup/toolchains/stable-x86_64-apple-darwin/lib/libclang.dylib' (no such file), '/Users/brunoaraujo/.rustup/toolchains/stable-x86_64-apple-darwin/lib/libclang.dylib' (no such file), '/Users/brunoaraujo/lib/libclang.dylib' (no such file), '/usr/local/lib/libclang.dylib' (no such file), '/usr/lib/libclang.dylib' (no such file)
warning: build failed, waiting for other jobs to finish...
error: build failed
error: Result of `cargo build` operation was unsuccessful: exit status: 101
make: *** [build] Error 1
What I did, with no results:
- Install last xcode version (13.3)
- Also tried to use the probable tutorial revision: ce0ffa193b7d0c55c02f77bba2327ba43ee9204f
My libclang dylib path: /Library/Developer/CommandLineTools/usr/lib/libclang.dylib
There is something more to do?
Hi! Glad you're reading the tutorial!
Yeah. It seems that recent macos/LLVM stuff has broken the bindgen part of this.
I've noticed that adding the LLVM_CONFIG_PATH
environment variable to the Makefile
fixed it:
LLVM_CONFIG_PATH=$(shell brew --prefix llvm)/bin/llvm-config
Something like:
LLVM_CONFIG_PATH=$(brew --prefix llvm)/bin/llvm-configcargo bundle --example uikit --target x86_64-apple-ios
.
Let me know if there's anything else you're struggling with. There's a bunch of weird edge cases with iOS rust stuff.
Hi, I'm having the same issue. I don't understand this command line:
LLVM_CONFIG_PATH=$(shell brew --prefix llvm)/bin/llvm-configcargo bundle --example uikit --target x86_64-apple-ios.
Please explain how to include uikit-sys from an existing Cargo.toml like you're speaking to a 5-year old? :)
Hi, I'm having the same issue. I don't understand this command line:
LLVM_CONFIG_PATH=$(shell brew --prefix llvm)/bin/llvm-config cargo bundle --example uikit --target x86_64-apple-ios.
There's some bug I've not dug into quite yet with bindgen and llvm between apple's llvm version and what bindgen uses. I've not quite narrowed it down entirely. This line tells clang-sys
to use brew's llvm. You need to have homebrew and llvm to make this work.
Now that I look at it, I have/had a typo in the shell expansion between bash and make above. The Makefile environment variable requires $(shell brew --prefix ...)
, bash/sh requires $(brew --prefix ...)
Please explain how to include uikit-sys from an existing Cargo.toml like you're speaking to a 5-year old? :)
Right now uikit-sys
is pretty much in development mode. I'm not able to publish to crates.io because there's an unmerged pull request on rust-bindgen. To use it from an existing Cargo.toml
, you'll need to use the git dependency notation.
So, try something like:
[dependencies]
uikit-sys = { git = "https://github.com/simlay/uikit-sys"}
Thanks, makes sense.
- I assume you mean
cargo-bundle
and notmake
? - The error output lists the locations it looks for the .dylib, and the
lib
folder in the user's home directory is one of them. I was able to work around the problem by creating~/lib
and creating a symlink tolibclang.dylib
in that folder. - Now I'm running into another problem - the
build.rs
panics in line 20 when passed a Mac Catalyst targetx86_64-apple-ios-macabi
andaarch64-apple-ios-macabi
. Is this an easy fix at your end or would you like me to open a separate bug? EDIT: Just ran into another issue - When compiling for the iPad simulator, get an error related to the redefinition of
pub type id
which does in fact occur twice in the generateduikit.rs
, first:
pub type id = *mut objc::runtime::Object;
and second:
pub type id = NSUnit;
Is this a known issue?
3. Now I'm running into another problem - the
build.rs
panics in line 20 when passed a Mac Catalyst targetx86_64-apple-ios-macabi
andaarch64-apple-ios-macabi
. Is this an easy fix at your end or would you like me to open a separate bug?
I'm open to a PR if you wanna add that case. I actually don't know much about the macabi
targets. I Assume this would be the macOS version of a given app.
4. When compiling for the iPad simulator, get an error related to the redefinition of
pub type id
which does in fact occur twice in the generateduikit.rs
, first:pub type id = *mut objc::runtime::Object;
and second:
pub type id = NSUnit;
Is this a known issue?
This is a new one. There's probably some item that needs to be added to the blocklist. Tracking it down can be a bit of a pain.
Which compiler target, and iOS sdk was it? I've not ran any of this tested with Xcode 14 so the SDK's could have changed.
I'm open to a PR if you wanna add that case. I actually don't know much about the macabi targets. I Assume this would be the macOS version of a given app.
Sent a PR for the initial Catalyst support as well as a fix. Could you give it a try with a regular (iOS) target and a catalyst (-macabi
) target and let me know if you're seeing duplicate Id
definition?