Has anyone tried and successfully built a JUCE iOS static library for x86_64 architecture?
The context here is that I built a JUCE iOS static library for my iOS application. It works great except that I can’t run my app on simulator, because my MacBook Pro is an Intel machine with x86_64 architecture which the simulators also follow, but the static library is only built for ARM architecture. My goal here is to build the library in x86_64 so that I can run my app on simulators.
I have tried changing Xcode build settings ARCHS to x86_64 and adding it to VALID_ARCHS. But I got build error such as the screenshot below, where a macro in iOS types.h says that non-arm architecture is not supported. I feel like I’m missing some build settings perhaps?
This is pretty confusing - the simulator itself is an emulator that runs ARM apps regardless of whatever arch your computer is in, not sure why it would be different with a static library.
I don’t think you need to build an Intel version of your library to run the simulator and it likely won’t be possible anyway for iOS (since no iOS devices exist with an Intel CPU).
The reason I think the iOS static library needs to be built for x86_64 is that…
If the JUCE iOS static library is kept the way it is (i.e. Architectures set to “Standard Architectures (arm64)”), when I try to build for say iPhone 15 simulator iOS 17.4, in the build log I would see lines like
Compile <file name> (x86_64) <...> seconds
… for all the files getting compiled. Going through the error message in detail I could see
Undefined symbols for architecture x86_64:
"juce::this_will_fail_to_link_if_some_of_your_compile_units_are_built_in_debug_mode::this_will_fail_to_link_if_some_of_your_compile_units_are_built_in_debug_mode()", referenced from:
That assert failure from juce_core.cpp might look like the cause but I don’t think it is, because in this situation it would build and run fine once I change the run destination to my iPhone device. The real cause seems to be “Undefined symbols for architecture x86_64”.
JUCE in general doesn’t love static libs. I would suggest to just build a regular JUCE app on iOS for simplicity (and that will work on the simulator as well on device).
I’m not sure why would that be the case - a JUCE build for iOS should be building ARM and ARM only, I would go over your setting up steps as ‘just the default’ should compile the library correctly. At least with an app and not a library, this should work.
When you said “just build a regular JUCE app”, I believe it meant building the UI using only the JUCE framework? That’s not sufficient for my use case unfortunately.
I found it! It’s actually really simple - when building the static library, I overlooked the option in Run Destination “Any iOS Simulator Device (arm64, x86_64)”. Once that is chosen, the resultant .a file would work in simulators.
I’m not sure why would that be the case - a JUCE build for iOS should be building ARM and ARM only, I would go over your setting up steps as ‘just the default’ should compile the library correctly. At least with an app and not a library, this should work.
Worth clarifying…
Apple DOES have 3 ABIs now (following arm and macOS is now always 64bit):
x86_64 Simulator
arm64 Simulator
arm64
I guess I could find more details but this document I read lately explained it quite nice: