Context
We have an application made in Xamarin Forms. Xamarin Forms will only support Xcode 14 SDKs and iOS 17 will probably be available on September. The problem is that we want to be ready for September with some new features that are available from iOS 17 (Xcode 15) on the AuthenticationServices
.
To do so, we could migrate the project to MAUI but we've encountered a lot of issues on the multi-project approach and it'd be good to have something as a backup in case we cannot migrate to MAUI for September.
Proposed solution
Create a Swift framework in Xcode 15 beta that uses the AuthenticationServices
framework and expose some public classes to be used on the main application. (compiled with Xcode 15.*)
Then we create a Xamarin iOS binding library based on the Swift framework of the previous step.
We add the Xamarin binding library as a reference and try to invoke the methods and use the protocols the swift library exposes. (compiled with Xamarin iOS which relies on Xcode 14.*)
This works great on iOS 17 beta, but when testing it on iOS 16.4 simulator the app doesn't even load stating that it has some symbols missing from the AuthenticationServices
which makes sense given that the library uses symbols of the new stuff of Xcode 15.* SDKs and we're trying to use them in a iOS 16.4 which doesn't have those symbols. So here it's the problem.
What we tried but keeps crashing
We've tried different approaches like adding @available(ios 17.0 *)
on all the stuff in the Swift custom framework that rely on iOS 17 features (directly and indirectly).
In the binding library project configuration, for the native binding tried specifying ForceLoad
as true
and false
. Also changed Frameworks
to WeakFrameworks
which include the AuthenticationServices
.
Just to see if it was a problem with direct references to iOS 17, we tried creating an empty class in the Swift custom framework and only reference that from the main app, and still crashes when trying to load it, saying that symbols are missing.
Questions
Is there a way to make this work backwards compatible?
Can we remove the reference to the symbols or the whole library in runtime depending on the OS version?
Or is this approach impossible to work given that we're using a newer version of the SDK for the library than the one used in the app?
Alternatives
Another way we thought was to somehow use P/Invoke but dunno if it's worth the shot, what do you think?