SDL 2.0.14 and ios / xcode

Unlike previous versions, SDL 2.0.14 source doesn’t have
a subfolder “SDL” in folder “Xcode-iOS”,
which should have the project, SDL.xcodeproj, for xcode.

Previus version:
SDL2-2.0.12/Xcode-iOS/SDL/SDL.xcodeproj - works fine

I tried to compile other SDL.xcodeproj, from Xcode/SDL folder,
but dispite compiling ok, fails when linking with my project.

Am I doing something wrong ? how to compile it ?


I’m also investigating how to do so.

There is a file in build-scripts called

But one problem is that Xcode 12.4 (apparently this started in 12.3?) no longer supports “fat binaries” which is what gets created with lipo, which is what that script uses.

Apple now requires the use of XCFrameworks to support multiple targets (such as two different targets with the same architecture, which isn’t possible with lipo), and I’m currently checking to see if there are already issues or patches for SDL2 in this regard.

EDIT: Well, perhaps I’ve posted too soon. XCFrameworks is a way to support binary libraries, if you can’t or don’t want to distribute the source. So perhaps there is still a way to do it with SDL2 and related libraries that doesn’t require using XCFrameworks.

It’s in the regular SDL Xcode project, in the Xcode/SDL/ folder. There are targets for Mac, iOS, and tvOS.

Ok, but then what is the purpose of the Xcode-ios directory, which is what the specifies? It also mentions the SDL directory under it that is no longer there.

After digging through the SDL2 code changes, it looks like there was some effort to unify everything into the main Xcode directory, but I couldn’t find any documentation on what changes to make if you were relying on the Xcode-ios/SDL directory before.

1 Like

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.


Here’s the device SDL2:

$ file SDL2.framework/SDL2 
SDL2.framework/SDL2: Mach-O universal binary with 2 architectures: [arm_v7:Mach-O dynamically linked shared library arm_v7] [arm64]
SDL2.framework/SDL2 (for architecture armv7):	Mach-O dynamically linked shared library arm_v7
SDL2.framework/SDL2 (for architecture arm64):	Mach-O 64-bit dynamically linked shared library arm64

And here’s the sim SDL2:

$ file SDL2.framework/SDL2 
SDL2.framework/SDL2: Mach-O 64-bit dynamically linked shared library x86_64

After I started this thread and got no answer,
I tried many thing for several days. I started over again and again.

When I realized the obvius, this link errors are not related to
folder of SDL project.

Just use the SDL2-2.0.14/Xcode/SDL folder, then go to your code to correct the errors.

some of then:
Undefined symbol: OBJC_CLASS$_CHHapticDynamicParameter
Undefined symbol: _CHHapticEventParameterIDHapticIntensity
Undefined symbol: OBJC_CLASS$_CHHapticPattern
Undefined symbol: OBJC_CLASS$_CHHapticEvent
Undefined symbol: _CHHapticEventTypeHapticContinuous
Undefined symbol: OBJC_CLASS$_CHHapticEventParameter
Undefined symbol: _CHHapticDynamicParameterIDHapticIntensityControl

Unfortunately I don’t remember in what I did anymore.
(ok with xcode 12.4 12D4e - SDL2-2.0.14)

1 Like

Ah, that’s good to hear that you got it working at some point.

I am not sure what you mean by “use the SDL2-2.0.14/Xcode/SDL folder.” I feel like this is the part that is glossed over in the suggestions I find in the forum.

I tried building it in Xcode using the schemes/targets I mentioned above as well as doing the same with xcodebuild on the command line. The README files in docs haven’t been updated in years, and so the iOS docs are definitely outdated since those instructions can’t work anymore both because the directory they mention is gone and because the instructions create the unsupported fat binaries. The Mac OS X instructions also predate unifying the iOS build into the Xcode directory with the OS X build.

I would love to help update the docs once I figure out what I need to do, but the obvious things and some of the non-obvious things I’ve tried do not seem to get me there.

1 Like

I just pulled down the latest from GitHub to see if perhaps anything relevant might have changed since 2.0.14 was released, but I’m getting the same errors.

Again, I’m not sure how I’m supposed to build it, but since the Framework-iOS scheme and target was there, I assumed it was a valid option, so I used that, then tried to include it in my project.

After searching for the symbols online, I finally decided to read more closely what came up, and I see that they come from CoreHaptics.framework.

I had my project linking to the following frameworks (I cannot recall where I originally got this list, but it might have been cobbled together from various SDL2-and-CMake-based iOS projects):

  • AudioToolbox
  • AVFoundation
  • CoreAudio
  • CoreGraphics
  • CoreMotion
  • Foundation
  • GameController
  • ImageIO
  • MobileCoreServices
  • OpenGLES
  • QuartzCore
  • UIKit
  • Metal

And CoreHaptics wasn’t in the list.

So basically, CoreHaptics is a new dependency that I didn’t have in my project.

So now I can run my application in the simulator, but I still get a problem when trying to build for the hardware device:

ld: entry point (_main) undefined. for architecture arm64

You have a main() function, right?

Also, it seems that if SDL needs CoreHaptics but isn’t linked against it then that’s definitely a bug.

Yes, I have a main() function.

This is its signature:
int main(int argc, char** argv)

And I’ve used this signature in previous projects that have successfully built for iOS in the past, although I recognize that with how things change with Apple that it might not mean anything. However, I believe I’ve used the same signature in this form in multiple projects on multiple platforms, and it’s never failed me before.

I did get the app running on the simulator once I added CoreHaptics to my project, which indicates to me that the main() function is fine, but I don’t understand why building the libraries and my app for an actual device can’t seem to find it. The only changes I make is to point my build scheme from a simulator to an actual hardware device I have plugged in as well as pointing my project at the similarly targeted SDL2 library I’ve built.

Ok, I finally got it to build.

Ultimately I ended up creating the static library for SDL2, and then when I build for the simulator I need to put my simulator SDL2 libraries in the correct location, and when I build for the device I need to put the device-specific SDL2 libraries in the correct location.

I was trying to use frameworks and XCFrameworks, but I must build them wrong or use them incorrectly. In the end, just creating static .a files and pointing my build to the correct location works.

It’s annoying that I now have make a special effort to build separately for the sim and for the device when before all I had to do was change my build target. But I did get it working.

So, in summary, there was a CoreHaptics dependency this entire time, and unless someone knows how to get Xcode to actually link their project to an SDL2 framework consistently, I will just use static libraries.

The question I have now is: what changes can be made to the SDL2 docs? Obviously these lessons help me, and I have something that will carry me forward until Apple changes something else that I depend upon, but are they universal for everyone? Does anyone have success with the SDL2 framework, or is everyone expected to be using static libraries for iOS?


I share the same questions. Also would be interesting if there’s some way to get sdl2 and iOS to build consistently with CMake.

1 Like

You could always try adding the SDL project to your own project, then setting the iOS target as a dependency for your app’s build target.

He wrote:

The question I have now is: what changes can be made to the SDL2 docs? Obviously these lessons help me, and I have something that will carry me forward until Apple changes something else that I depend upon, but are they universal for everyone? Does anyone have success with the SDL2 framework, or is everyone expected to be using static libraries for iOS?

That would eliminate the need for changing static libraries depending on if he’s building for the device or simulator. When building for the device, so would SDL be, and ditto for the simulator.

The SDL2 docs re: building for macOS and iOS are old and out of date, yes. What changes can be made? Honestly, rewrite them.

As to iOS, I’ve never really cared about the simulator. It’s always been such a pain to deal with even when developing regular apps that I just test on the device if at all possible, and when it comes to games the simulator’s performance etc. is different enough that it’s kind of worthless for testing IMHO. :man_shrugging:


Sounds good you make it work!

What is the environment?

SDL 2.0.14? XCode 12.4?

Did you try updating to latest XCode 14.x?

Asking; as want to get a working combination (at least working for someone) and will get cracking on till getting it working locally.

Two years back the following link was good enough: Build SDL2 projects for iOS with Xcode 11 –