Xamarin Forms - Error MT2002: Failed to resolve UI

2019-08-05 08:32发布

问题:

I am working on a Xamarin.Forms project and I am getting the following error after I updated my Xamarin.Forms version to 2.4.0.74863.

/Users/UserName/Official/Projects/ProjectFolder/ProjectName/iOS/MTOUCH: Error MT2002: Failed to resolve "UIKit.UIEdgeInsets UIKit.UIView::get_SafeAreaInsets()" reference from "Xamarin.iOS, Version=0.0.0.0, Culture=neutral, PublicKeyToken=84e04ff9cfb79065" (MT2002) (ProjectName.iOS)

How can I resolve this? I have XCode 8.2.1, Xamarin Studio 6.1.2.44 installed in my machine.

I tried to change the link mode to 'Don't Link' (although its not preferable) but it gives different problems.

回答1:

Besides updating Xcode (to 9.x) you must set the Deployment Target to iOS 9.0 in the Info.plist file.

This is because SafeAreaInsets is only available in iOS 9 and up (as SushiHangover pointed out in the comments).

This will however mean that your app will only work on devices that run iOS 9.0 and up.