How to set Xamarin.iOS SDK version?

JoeMankeJoeManke USMember ✭✭✭✭✭
edited October 9 in Xamarin.iOS

The Xamarin.iOS Troubleshooting documentation suggests it is possible to set which version of the Xamarin.iOS SDK to use, but when following the paths listed there is only an option for setting the Xcode path. https://docs.microsoft.com/en-us/xamarin/ios/troubleshooting/questions/ios-sdk

For context, I am attempting to set up a Mac to support targeting either iOS 12.4 or 13.1. While I have figured out how to enable selecting an SDK version in the iOS Build tab in Visual Studio, the build fails because it is using the Xamarin.iOS 13 SDK regardless of the native iOS SDK being used.

(_CompileToNative target) -> 
 /Library/Frameworks/Xamarin.iOS.framework/Versions/13.2.0.42/src/Xamarin.iOS/CLLocationManager.g.cs(1053): error MT4162: The type 'CoreLocation.CLBeaconIdentityConstraint' (used as a parameter in CoreLocation.CLLocationManager/_CLLocationManagerDelegate.DidFailRangingBeacons) is not available in iOS 12.4 (it was introduced in iOS 13.0). Please build with a newer iOS SDK (usually done by using the most recent version of Xcode). 
 /Library/Frameworks/Xamarin.iOS.framework/Versions/13.2.0.42/src/Xamarin.iOS/CLLocationManager.g.cs(1077): error MT4162: The type 'CoreLocation.CLBeaconIdentityConstraint' (used as a parameter in CoreLocation.CLLocationManager/_CLLocationManagerDelegate.DidRangeBeaconsSatisfyingConstraint) is not available in iOS 12.4 (it was introduced in iOS 13.0). Please build with a newer iOS SDK (usually done by using the most recent version of Xcode). 
Tagged:

Answers

  • LandLuLandLu Member, Xamarin Team Xamurai

    This error occurs because you are using the APIs which are only available on iOS 13+:
    https://developer.apple.com/documentation/corelocation/cllocationmanagerdelegate/3240610-locationmanager?changes=latest_minor&language=objc
    I think it's not easy for changing the Xamarin.iOS framework as one VS for Mac version is corresponding to one Xamarin.iOS version. But as the doc said you could find the framework at: /Library/Frameworks/Xamarin.iOS.framework/Versions/Current.
    Then try to download a prior version there:

    Replace all the current folder's content with the previous Xamarin.iOS framework will complete the changing.
    However, I think if you want to make it work you should also change the corresponding Mono.framework and download the compatible XCode. It's really a long way.
    Moreover, you can try the service of App Center. It offers multiple versions to be tested:
    https://docs.microsoft.com/en-us/appcenter/build/software#xamarin
    It utilizes the command line to build the project and has downloaded multiple frameworks on the cloud.

  • JoeMankeJoeManke USMember ✭✭✭✭✭

    I am not actually using the APIs listed in that error message. I do use CoreLocation, but not beacons, and only via a NuGet package which was compiled against iOS 12.

    I think it's not easy for changing the Xamarin.iOS framework as one VS for Mac version is corresponding to one Xamarin.iOS version. But as the doc said you could find the framework at: /Library/Frameworks/Xamarin.iOS.framework/Versions/Current.
    Then try to download a prior version there:

    Replace all the current folder's content with the previous Xamarin.iOS framework will complete the changing.
    However, I think if you want to make it work you should also change the corresponding Mono.framework and download the compatible XCode. It's really a long way.

    I do have the previous versions of Xamarin.iOS, Xcode, Mono, etc. all installed next to the current versions. Like I said, my goal is to be able to switch between the two versions on one Mac. What I want is a way to tell the system to use a directory besides Current, because changing what Current points to depending on which app (or potentially even which branch of which app) is being built simply is not going to work on an automated build machine.

    Moreover, you can try the service of App Center. It offers multiple versions to be tested:
    https://docs.microsoft.com/en-us/appcenter/build/software#xamarin
    It utilizes the command line to build the project and has downloaded multiple frameworks on the cloud.

    I will look into this. We already use AppCenter for analytics so perhaps we can add using it for builds instead of configuring another local Mac with build agents.

  • LandLuLandLu Member, Xamarin Team Xamurai

    I am not actually using the APIs listed in that error message. I do use CoreLocation, but not beacons, and only via a NuGet package which was compiled against iOS 12.

    You need to check whether this API has been called somewhere else maybe by this package. But what we got from your error messages are these two events not available on iOS 12.

    my goal is to be able to switch between the two versions on one Mac.

    I didn't find an appropriate approach to switch Xamarin.iOS versions in VS for Mac. We can only select the current Xamarin.iOS version in a certain VS version. VS doesn't offer such features for switching. We can only utilize this hacky manner.
    I think AppCenter is much more appropriate for you. It offers different versions of Xamarin.iOS which could fit your requirements.

Sign In or Register to comment.