问题
Converting xamarin plugin to SDK style plugin (i.e. ).
I'm receiving nil.
System.Exception: 'Could not initialize an instance of the type 'UIKit.UIImage': the native 'initWithContentsOfFile:' method returned nil.
var favoriteImage = new UIImage("color-picker-favorite@2x.png")
I've moved this file into Resources folder (didn't work), and I've used the following to link it to Resources folder in my project.
<BundleResource Include="..\PopColorPicker.iOS.Shared\Resources\color-picker-favorite%402x.png">
<Link>Resources\color-picker-favorite%402x.png</Link>
</BundleResource>
The IOS project always receives this error when trying to find the file. My detailed diagnostic build in VS2019. I've also tried to not pull in from shared project and had it directly in the plugin. Nothing tried works.
The output of the build shows this about 6 times.
1> C:\Users\....\PopColorPicker.iOS.Shared\Resources\color-picker-favorite@2x.png
1> CopyToOutputDirectory=Never
1> Link=Resources\color-picker-favorite@2x.png
1> OriginalItemSpec=C:\Users\Brent Safer\Documents\MyDataApp\PopColorPicker.iOS.Shared\Resources\color-picker-favorite@2x.png
1> TargetPath=Resources\color-picker-favorite@2x.png
and that looks correct with Resources being root folder, but it also shows this sometimes and I can't see why or what the difference is in the output and why it's showing this different in same build.
1> iOS\PopupColorPicker\Resources\color-picker-favorite@2x.png
1> CopyToOutputDirectory=Never
1> OriginalItemSpec=iOS\PopupColorPicker\Resources\color-picker-favorite@2x.png
1> TargetPath=iOS\PopupColorPicker\Resources\color-picker-favorite@2x.png
How do I know if the file is making it into the DLL and what folder it's in? There doesn't seem to be much docs on how to do this.
来源:https://stackoverflow.com/questions/63497104/xamarin-plugin-sdk-style-ios-project-uikit-uiimage-method-returns-a-nill-and-doe