Xamarin Plugin SDK style IOS project UIKit.UIImage method returns a nill and doesn't find file

只愿长相守 提交于 2021-01-29 05:56:44

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!