Yes, I think you’re right. I have been building and using a static Rust library for iOS but I want to switch to dynamic during development.
I can build and use a Rust dylib with a macOS application fine. I was hoping the iOS simulator at least would let me build a dynamic Rust library (seeing as it is the same platform as macOS), but even that has the same
unsupported crate type warning when trying to build for it.
Actually, I wonder if a C dynamic library (plain C source) would work with the iOS simulator - just as a proof of concept…
So, building a simple C dynamic library for the iOS simulator works:
clang -arch x86_64 -shared -mios-simulator-version-min=12.1 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.1.sdk -o test2.dylib test.c
(even without -isysroot it still works but with a warning…)
I can load the dylib with Swift on the iOS simulator:
let handle = dlopen("test2.dylib", RTLD_LAZY);
This bodes well for the cargo build process to be made to build a dynamic library for the iOS simulator. It looks like the trick is
-mios-simulator-version-min and there are issues on github relating to this.
Could a workaround, to let me build a dylib from Rust for the iOS simulator, be to build/target macOS but add that compiler flag somehow? Any thoughts?