We are currently migrating Bugzilla to GitHub issues.
Any changes made to the bug tracker now will be lost, so please do not post new bugs or make changes to them.
When we're done, all bug URLs will redirect to their equivalent location on the new bug tracker.

Bug 4058

Summary: Make iOS build friendlier for consumption by Xamarin projects
Product: SDL Reporter: Cole Campbell <cole.campbell>
Component: *don't know*Assignee: Ryan C. Gordon <icculus>
Status: NEW --- QA Contact: Sam Lantinga <slouken>
Severity: normal    
Priority: P2    
Version: don't know   
Hardware: iPhone/iPod touch   
OS: iOS 11   
Attachments: A patch including the changes described in this ticket.

Description Cole Campbell 2018-01-20 20:04:46 UTC
Created attachment 3148 [details]
A patch including the changes described in this ticket.

The included patch makes the following changes, which are designed to make it easier to use SDL from a Xamarin iOS project:

1. When the XAMARIN flag is defined as part of the build arguments, the main() function defined in SDL_uikitappdelegate.m is removed. The Xamarin runtime already defines a main() function, so this being present causes linker errors.

2. When the SDL_DYNAMIC_MAIN flag is defined, the following new API functions are exposed:

 * SDL_SetDynamicMain()
 * SDL_GetDynamicMain()

A C# application can use P/Invoke to pass a pointer to managed code into the SDL_SetDynamicMain() function; a simple replacement for the SDL_main function is included which will invoke this function at the necessary time.

The SDL_DYNAMIC_MAIN flag is automatically set when the XAMARIN flag is set and the target platform is iOS.