Updated 2017-11-19: Rewrote for clarity and removed references to the 32-bit simulator which has been removed from the default install as of Xcode 9


For iOS development it is handy to have a single SDL2 library that supports both the simulator and the physical device. This is how to create a libSDL2.a that can be used for both.

Step 1: Build libSDL2.a for each target

Download the SDL2 source from the official SDL website and verify the integrity of the source package using GPG.

Extract the source. There will be a folder named Xcode-iOS that is used to build the iOS version of the library.

Now build the project twice, once against the simulator and then against an actual device. This will build a version of the library for each architecture.

In the project navigator right-click the Product folder. There will be two output libraries named libSDL2.a. Select one of them and choose Show in Finder. Go up a directory and there should be two folders: Debug-iphoneos and Debug-iphonesimulator

Step 2: Combine into a single library

Use the macOS lipo command command to combine the two output libraries into a single library.

Open Terminal and cd to the Build/Projects directory containing the two folders listed above.

The following lipo command can be used to combine them and but the resulting library in the home directory:

lipo -create Debug-iphoneos/libSDL2.a Debug-iphonesimulator/libSDL2.a -output ~/libSDL2.a

Linking against this libSDL2.a will allow the project to run in either the simulator or the physical device.

For App Store submission you may wish to replace this with the SDL2 framework without debugging symbols so that the binary size is smaller.