Write a Swift library binding to detect Xamarin

CodeMan 1 Reputation point
2021-10-05T16:16:57.877+00:00

I'm building a native SDK in Swift and I would like to be able to detect at runtime if the app is in Xamarin. My first thought was to use some reflection to determine if Xamarin classes are present by doing something like this:

if NSClassFromString("xamarin-support") != nil
But I don't think that'll actually return true in a Xamarin app since xamarin-support is a file not a class: https://github.com/xamarin/xamarin-macios/blob/main/runtime/xamarin-support.m

Are there any ways I could write some Swift that would detect if the current app is built using Xamarin? Any pre-processors?

Xamarin
Xamarin
A Microsoft open-source app platform for building Android and iOS apps with .NET and C#.
5,296 questions
{count} votes

1 answer

Sort by: Most helpful
  1. CodeMan 1 Reputation point
    2021-10-05T16:34:58.25+00:00

    Maybe NSClassFromString("XamarinAssociatedObject")?

    0 comments No comments