"dyld: Library not loaded" when running on physical iOS device.
rmehta33 opened this issue · 3 comments
Hello!
The Problem
When trying to run the wry template on a physical device, it can't find the .dylib file.
The full error code:
dyld[88994]: Library not loaded: /Users/me/Coding/Projects/RustXCodeTesting/target/aarch64-apple-ios/debug/deps/librust_x_code_testing.dylib Referenced from: <C7021B88-EDB8-3613-AFC6-31082A638B50> /private/var/containers/Bundle/Application/04200ED3-4C04-433B-ABB4-9617DF041E6A/rust-x-code-testing.app/rust-x-code-testing Reason: tried: '/usr/lib/system/introspection/librust_x_code_testing.dylib' (errno=2, not in dyld cache), '/Users/me/Coding/Projects/RustXCodeTesting/target/aarch64-apple-ios/debug/deps/librust_x_code_testing.dylib' (errno=2), '/private/preboot/Cryptexes/OS/Users/me/Coding/Projects/RustXCodeTesting/target/aarch64-apple-ios/debug/deps/librust_x_code_testing.dylib' (errno=2), '/Users/me/Coding/Projects/RustXCodeTesting/target/aarch64-apple-ios/debug/deps/librust_x_code_testing.dylib' (errno=2), '/usr/local/lib/librust_x_code_testing.dylib' (errno=2), '/usr/lib/librust_x_code_testing.dylib' (errno=2, not in dyld cache) Library not loaded: /Users/me/Coding/Projects/RustXCodeTesting/target/aarch64-apple-ios/debug/deps/librust_x_code_testing.dylib Referenced from: <C7021B88-EDB8-3613-AFC6-31082A638B50> /private/var/containers/Bundle/Application/04200ED3-4C04-433B-ABB4-9617DF041E6A/rust-x-code-testing.app/rust-x-code-testing Reason: tried: '/usr/lib/system/introspection/librust_x_code_testing.dylib' (errno=2, not in dyld cache), '/Users/me/Coding/Projects/RustXCodeTesting/target/aarch64-apple-ios/debug/deps/librust_x_code_testing.dylib' (errno=2), '/private/preboot/Cryptexes/OS/Users/me/Coding/Projects/RustXCodeTesting/target/aarch64-apple-ios/debug/deps/librust_x_code_testing.dylib' (errno=2), '/Users/me/Coding/Projects/RustXCodeTesting/target/aarch64-apple-ios/debug/deps/librust_x_code_testing.dylib' (errno=2), '/usr/local/lib/librust_x_code_testing.dylib' (errno=2), '/usr/lib/librust_x_code_testing.dylib' (errno=2, not in dyld cache) dyld config: DYLD_LIBRARY_PATH=/usr/lib/system/introspection DYLD_INSERT_LIBRARIES=/usr/lib/libBacktraceRecording.dylib:/usr/lib/libMainThreadChecker.dylib:/usr/lib/libRPAC.dylib:/System/Library/PrivateFrameworks/GPUToolsCapture.framework/GPUToolsCapture:/Developer/Library/PrivateFrameworks/DTDDISupport.framework/libViewDebuggerSupport.dylib
Reproducing the Issue
Setup:
Xcode 14.2
Running on M1 Max
Physical Device is iPhone 14 Pro on iOS 16.2
- Create project from wry template
- Fix linker issue by compiling rust targets manually as mentioned in #81
- Fix search path location from #79
From here, compiling, running, and GUI debugging rust on the iOS Simulator work. Compiling will work for a physical device, however it will crash with the error above.
What I've Tried
I noticed a closed 'Library not loaded' issue #50 , however the fix stated has already been merged - so I'm assuming this is something different?
As a side note, I've also tried doing the process on my own without 'tauri-mobile'. I was able to link the .a files in a XCFramework and access them via the c bridging header in the simulator and physical device, however I'm unsure how to get GUI debugging to work.
Any help is greatly appreciated! I've been stuck on this for a few days now.
I fix it by copying the shared library to the package and linked to it.
But I'm not sure if that's the best practice for it.
It seems Xcode 14 cannot link to files outside of device anymore.
Did you check original cargo-mobile also have this problem?
Okay cool, thank you for the fix! Yes I forgot to mention that the original cargo-mobile also had the issue (I posted here as it's more active). Regardless, late last night I did end up getting mostly everything to work for iOS by using this project instead. I'll close this for now as there is a fix and as I'm no longer using this repo, I won't be of much help.
I fix it by copying the shared library to the package and linked to it. But I'm not sure if that's the best practice for it. It seems Xcode 14 cannot link to files outside of device anymore. Did you check original cargo-mobile also have this problem?
I also face the same problem.
dyld[7345]: Library not loaded: /Users/bytedance/github/admin-web/apps/chat/src-tauri/target/aarch64-apple-ios/release/deps/libchatgptenhanced.dylib
Referenced from: /private/var/containers/Bundle/Application/D20681C5-5C52-4EA6-AE2A-05CC8463442E/chatgptenhanced.app/chatgptenhanced
Reason: tried: '/usr/lib/system/introspection/libchatgptenhanced.dylib' (no such file, not in dyld cache), '/Users/bytedance/github/admin-web/apps/chat/src-tauri/target/aarch64-apple-ios/release/deps/libchatgptenhanced.dylib' (no such file), '/private/preboot/Cryptexes/OS/Users/bytedance/github/admin-web/apps/chat/src-tauri/target/aarch64-apple-ios/release/deps/libchatgptenhanced.dylib' (no such file), '/Users/bytedance/github/admin-web/apps/chat/src-tauri/target/aarch64-apple-ios/release/deps/libchatgptenhanced.dylib' (no such file), '/usr/local/lib/libchatgptenhanced.dylib' (no such file), '/usr/lib/libchatgptenhanced.dylib' (no such file, not in dyld cache)
(lldb)
this file exist there, but it still error. can you tell me in detail how do you fix this? I have been stuck this a few days, thank you very much~