Ok, after trying to investigate how to build the SDL2 and related libraries in multiple ways (static libraries, creating an XCFramework, creating just a plain SDL2 framework, etc), I keep running into the same linker errors when I try to use the SDL2 library in my project (building for an iOS simulator):
Undefined symbols for architecture x86_64:
"_OBJC_CLASS_$_CHHapticDynamicParameter", referenced from:
objc-class-ref in SDL2(SDL_mfijoystick.o)
"_OBJC_CLASS_$_CHHapticEventParameter", referenced from:
objc-class-ref in SDL2(SDL_mfijoystick.o)
"_CHHapticDynamicParameterIDHapticIntensityControl", referenced from:
l002 in SDL2(SDL_mfijoystick.o)
"_CHHapticEventParameterIDHapticIntensity", referenced from:
l002 in SDL2(SDL_mfijoystick.o)
"_OBJC_CLASS_$_CHHapticPattern", referenced from:
objc-class-ref in SDL2(SDL_mfijoystick.o)
"_OBJC_CLASS_$_CHHapticEvent", referenced from:
objc-class-ref in SDL2(SDL_mfijoystick.o)
"_CHHapticEventTypeHapticContinuous", referenced from:
l002 in SDL2(SDL_mfijoystick.o)
ld: symbol(s) not found for architecture x86_64
EDIT: I’ll add that if I try to create an SDL framework for an actual device that when I try to build my project for an actual device and linking/embedding that framework, I instead get:
ld: entry point (_main) undefined. for architecture arm64
I even built the hidapi framework and added it to my project, but it didn’t seem to provide the needed symbols. I am not sure if hidapi is needed since it looks like it gets built as part of building the SDL2 framework anyway.
I’ve spent a few weeks on trying to figure this out, but from comments on this forum I get the impression it should be more straightforward.
I’m using Xcode 12.4 (12D4e), and I know 12.3 started enforcing changes related to libraries and CPU architectures, so universal/fat binaries won’t work anymore, which is why I can no longer use a version of the script mentioned at Improving the iOS experience
But even trying to build SDL2, whether with xcodebuild on the command line or from the Xcode IDE, I run into the above problems, and I don’t know if the problem is on my end or on SDL2’s iOS build no longer working as expected due to Apple changing what is allowed/supported.
To be clear, I downloaded v2.0.14, and I tried to build the library in Xcode/SDL as Xcode-ios no longer has an SDL directory. I tried using Framework-iOS and Static Library-iOS as build targets, then tried to link/embed the resulting libraries. I even tried to create an XCFramework by combining the simulator and hardware frameworks.
If the libraries are missing, I get different errors along those lines, as expected.
If I use libraries built for the simulator and try to build my project for an actual device, I get errors telling me I am using the wrong libraries. I get similar errors if I build the libraries for a device and try to build my project for the simulator.
So I expect that I am linking to them correctly, and I am trying to rule out that the errors I pasted above aren’t me missing something important.
I am at the point where I would like to confirm that someone else using SDL 2.0.14 and the latest Xcode is able to successfully build the iOS library and link it to their project for the simulator and/or a device.