简体   繁体   English

Visual Studio xamarin形式的iOS入口点未在模拟器中找到,但未在iPhone中找到

[英]Visual Studio xamarin forms iOS entrypointnotfound with simulator but not iphone

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. 在我的Visual Studio Xamarin Forms iOS项目中,我链接到使用Visual Studio Cross C ++ Platform构建和部署的本机(c ++)库。 I can link and run against an actual device (through the Mac Server), but I cannot get it to work through the simulator. 我可以链接并在实际设备上运行(通过Mac Server),但是无法通过模拟器运行它。 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. 如果我选择不链接,那么构建会成功,但是在尝试调用本机代码的位置运行时会收到Entrypointnotfoundexception。

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. 我的问题是在Xamarin.iOS上,但是假设您已经有特定于平台的集成工作,则可以将相同的步骤应用于Xamarin.Forms。

Since you have the code working on a physical device, you should already have a Native Static Reference to your .a library. 由于您具有在物理设备上运行的代码,因此您应该已经具有对.a库的本Native Static Reference 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 . 但是,iOS模拟器可在x86_64架构上运行(iOS 11及更高版本不支持i386 ),而您的设备可能会在某些版本/ 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: 您可以通过在Mac上运行lipo进行检查:

% 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: 为了也支持sim的体系结构(请参阅本文 ),将C ++项目构建为您需要支持的体系结构,然后将它们组合起来,如下所示:

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. 将该输出.a文件用作Visual Studio中的新本Native Static Reference文件。 Change Supported Architectures in your project settings to x86_64 , and that should be everything. 在项目设置中将Supported Architectures更改为x86_64 ,这应该就是一切。 Hope this helps somebody. 希望这对某人有帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM