| Summary: | [patch] Add Xamarin.iOS support | ||
|---|---|---|---|
| Product: | SDL | Reporter: | Caleb Cornett <spydog> |
| Component: | video | Assignee: | Sam Lantinga <slouken> |
| Status: | RESOLVED FIXED | QA Contact: | Sam Lantinga <slouken> |
| Severity: | normal | ||
| Priority: | P2 | CC: | amaranth72 |
| Version: | 2.0.9 | ||
| Hardware: | iPhone/iPod touch | ||
| OS: | iOS (All) | ||
| Attachments: | Patch to add support for Xamarin.iOS | ||
Closing, as this was indirectly fixed by https://hg.libsdl.org/SDL/rev/e7f525b10380#l2.41 . |
Created attachment 3467 [details] Patch to add support for Xamarin.iOS As you may know, Xamarin is Microsoft's toolkit for enabling developers to write apps for mobile platforms using C#. However, because of Apple's strict rules on dynamic code generation, Xamarin.iOS apps are AOT compiled, and all native libraries used in the project must be statically-linked. When attempting to statically link libSDL2.a with a Xamarin.iOS project, it results in a build-time linker error about an "undefined symbol _SDL_main", indicating that the usual redefinition of main() doesn't work in this context. (Not surprising, since C# has a different signature for its Main function.) To overcome this limitation and to enable use of SDL in Xamarin apps, I propose the attached patch. This patch handles the redefinition of main() and adds an SDL_XamarinRunApp() function, similar to SDL_WinRTRunApp(). All the relevant code is sectioned off inside #ifdef XAMARIN blocks, so normal iOS development is not affected. I've tested this patch on iOS and tvOS, and it works like a charm. However, I'm sure it can be improved -- especially in regard to naming and organization. Additionally, this currently requires a compiler flag (-DXAMARIN) to build. Is that acceptable, or is there a better way to enable this feature?