Unable to build a dynamic library (.dylib) for iOS

I am receiving the warning: dropping unsupported crate type cdylib for target aarch64-apple-ios

Build command is: cargo build --target x86_64-apple-ios

The Cargo.toml file contains:

[lib]
name = "mylib"
crate-type = ["staticlib", "cdylib"]

The static lib file is generated fine, but not the dylib.

Also note I can build the static and the dynamic libraries for x86_64 fine, with: cargo build --target x86_64-apple-darwin

Any ideas why this is occurring and how to resolve it?

Does iOS allow non-Apple dynamic libraries yet?

I haven't checked for a while, but since appstore's inception dynamic libraries weren't allowed, and static libraries were the only possible kind for non-Apple libraries.

Not sure, but i'm only trying to use dylibs during the development stage on a local device.

You may need to use static libs for dev as well

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...

UPDATE:

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?