Visual Studio xamarin forms iOS entrypointnotfound with simulator but not iphone

社会主义新天地 提交于 2019-12-25 07:21:10

问题


In my Visual Studio Xamarin Forms iOS project, I am linking against a native (c++) library I built and deployed using Visual Studio Cross C++ Platform. I can link and run against an actual device (through the Mac Server), but I cannot get it to work through the simulator. If I build with the same link settings, the build fails, not being able to find the entrypoint. If I choose not to link, then the build succeeds but I get am Entrypointnotfoundexception when running at the point where I try to call into the native code.


回答1:


I just went through the example from your comment, using his sample code here. I had to do a couple things to get it to run correctly. My problem was on Xamarin.iOS, but the same steps can be applied for Xamarin.Forms, assuming you already have platform-specific integration working.

Since you have the code working on a physical device, you should already have a Native Static Reference to your .a library. But the iOS simulator runs on the x86_64 architecture (iOS 11 and later does not support i386), while your device likely runs on some version/variant of ARM. It sounds like your library is built to support only your device's architecture. You can check this by running lipo from your Mac:

% lipo -info /usr/lib/libCLib.iOS.a

To support the sim's architecture as well (see this article), build the C++ project to the architectures you need to support, then combine them, like so:

lipo -create -output libCLib.iOS.a libCLib.iOS-x8664.a libCLib.iOS-arm64.a

Use that output .a file as your new Native Static Reference file back in Visual Studio. Change Supported Architectures in your project settings to x86_64, and that should be everything. Hope this helps somebody.



来源:https://stackoverflow.com/questions/37774999/visual-studio-xamarin-forms-ios-entrypointnotfound-with-simulator-but-not-iphone

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