Latest SDL2 2.0.26 - iOS dev - Anyone having any success? [SOLVED]

Steps I used just now to make a test iOS SDL app:

  1. Build iOS framework (make sure you select “Framework-iOS”, and next to it select “Build->Any iOS Device (arm64)”)
  2. Make a new Xcode project. For this one I chose the “Game” framework, since it doesn’t try to add as unneeded stuff (for macOS choose regular “App” template).
  3. Remove all added source code and other detritus. Leave main.storyboard, LaunchScreen.storyboard, and Assets.xcassets
  4. Copy the iOS SDL2.framework to wherever YouriOSApp.xcodeproject is
  5. In build settings, under General, under Frameworks, Libraries, and Embedded Content, add a new framework. Choose Add Other and then Add Files and then choose your iOS SDL2.framework
  6. This is the annoying part, and isn’t required for SDL3. On iOS, your app needs to run from a class that inherits from UIAppDelegate so it can handle all the various iOS things, like the app going to the background, low memory notifications, etc. Apparently, if you use the iOS static library it includes its own main() function that creates and runs SDL’s own UIAppDelegate for you, which then calls your main(). Since we aren’t using the static library, we have to create this ourself. So:
    6.1) Create a file called iosmain.m
    6.2) Fill it with the code below. It’s just doing the UIAppDelegate thing, which will then call your main()
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>

#import <SDL2/SDL_main.h>

#ifdef main
#undef main
#endif

int main(int argc, char *argv[])
{
	return SDL_UIKitRunApp(argc, argv, SDL_main);
}
  1. Add your own main.c and source code.
1 Like