静态库的应用程序在模拟器上运行,但在实际设备上运行 [英] Application with static library runs on simulator but not on actual device

查看:123
本文介绍了静态库的应用程序在模拟器上运行,但在实际设备上运行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个包含objective-c静态库的monotouch应用程序。应用程序在模拟器上正常运行,但是当我尝试在iPhone 3GS上运行应用程序时,它会在启动时崩溃。以下是我尝试使其工作的步骤:

I have an monotouch application that includes an objective-c static library. The application runs correctly on the simulator, but when I try run the app on my iPhone 3GS, it crashes on startup. These are the steps that I have taken to try get it working:


  • 使用 Device 指定和活动架构设置在armv6和armv7(我不确定哪个是正确的,但我尝试了两个并且都没有工作)。

  • 在项目下info我将代码签名身份设置为我的开发人员密钥。

  • 在MonoDevelop中,我通过设置 iPhone build 下的其他monotouch参数具有以下值(这与iPhoneSimulator设置的相同):

  • Compiled the static library in Xcode with Device specified and active architecture set at armv6 and at armv7 (I am not sure which is correct, but I tried both and neither worked).
  • Under the project info I set code signing identity to my developer key.
  • In MonoDevelop I have included the static library in the application project options by setting the additional monotouch arguments under iPhone build to have the following value (this is identical to what is set for iPhoneSimulator):

-v -v -v -gcc_flags-lstdc ++ -I $ {ProjectDir} / Ultralite / Include -L $ {ProjectDir} / Ultralite -lUltralite -force_load $ {ProjectDir} /Ultralite/libUltralite.a

-v -v -v -gcc_flags "-lstdc++ -I${ProjectDir}/Ultralite/Include -L${ProjectDir}/Ultralite -lUltralite -force_load ${ProjectDir}/Ultralite/libUltralite.a"

当我尝试运行应用程序时,它在启动时崩溃(因此应用程序屏幕甚至没有出现)。在MonoDevelop中,我看到的是以下异常消息:

When I try run the application, it crashes on startup (so the application screen does not even appear). In MonoDevelop all that I see is the following exception message:

Exception of type 'Mono.Debugger.Soft.VMDisconnectedException' was thrown.

我在Xcode的设备日志中看到的所有内容如下:

All that I see in the device log in Xcode is the following:

Exception Type:  EXC_BAD_ACCESS (SIGSEGV)
Exception Codes: KERN_PROTECTION_FAILURE at 0x2fd00f24

如果从项目选项中删除-gcc_flags选项,则应用程序启动,但在第一次尝试访问静态库时崩溃。所以它肯定与静态库有关,导致应用程序在启动时崩溃。

If I remove the -gcc_flags option from the project options, then the application starts up, but crashes at the first attempt at accessing the static library. So it is definitely something to do with the static library that is causing the application to crash on startup.

我不知道从哪里开始解决这个问题,所以真的需要一些帮助。任何人都对我所包含的静态库有什么问题有所了解,或者知道在哪里可以获得有关出错的更多信息?崩溃报告中的KERN_PROTECTION_FAILURE消息实际上并没有给我太多帮助。

I have no idea where to even begin with solving this, and so really need some help on this one. Anyone got any ideas as to what is wrong with the static library that I am including, or know where I can get more information about what is going wrong? The KERN_PROTECTION_FAILURE message in the crash report is really not giving me much to work with.

更新:
我创建了一个简单的Hello World应用程序,它有一个按钮,单击时调用静态库中的方法 sayHello 。即使有这个基本的例子,我遇到了同样的问题;即它在模拟器上运行但在实际设备上运行。我已将我的helloworld示例上传到github。如果有人能帮助我完成这项工作,我将非常感激。以下是Hello World示例:

Update: I have created a simple Hello World application which has one button, which when clicked calls a method sayHello in a static library. Even with this basic example I encountered the same problem; namely that it runs on the simulator but not on the actual device. I have uploaded my helloworld example to github. I would really appreciate it if someone could help me in getting this working. Here is the Hello World sample:

https:// github .com / BruceHill / HelloWorld

这包括基本应用程序的文件夹,带有objective-c静态库的文件夹,最后是一个用于btouch定义。我用参数-outdir =调用btouch。构建 Messaging.g.cs UltraliteManager.g.cs ,然后将其包含在MonoTouch应用程序中。

This includes a folder for the basic application, a folder with the objective-c static library and then finally a folder for the btouch definition. I call btouch with the parameter -outdir=. to build Messaging.g.cs and UltraliteManager.g.cs which I then include in the MonoTouch application.

推荐答案

我必须进行两项更改才能在iphone上正常工作:

I had to make two changes to get this working correctly on the iphone:


  1. 链接器行为必须设置链接所有程序集选项。

  2. 我必须添加 -framework Security 到gcc_flags。

  1. linker behavior in the build options had to have the option Link all assemblies set.
  2. I had to add -framework Security to the gcc_flags.

所以构建选项下的其他monotouch参数必须具有以下内容价值:

So additional monotouch arguments under the build options had to have the following value:

-v -v -v -gcc_flags-framework Security -lstdc ++ -I $ {ProjectDir} / Ultralite / Include -L $ {ProjectDir} / Ultralite - lUltralite -force_load $ {ProjectDir} /Ultralite/libUltralite.a

-v -v -v -gcc_flags "-framework Security -lstdc++ -I${ProjectDir}/Ultralite/Include -L${ProjectDir}/Ultralite -lUltralite -force_load ${ProjectDir}/Ultralite/libUltralite.a"

我必须添加安全框架的原因是,当时,MonoTouch似乎包含此框架不在构建选项中指定链接,但在其他两个选项时不包括它重启。我通过比较不同选项的构建日志来确定这一点。

The reason I had to add the Security framework is that it seems MonoTouch includes this framework when Don't link is specified in the build options, but does not include it when the other two options are set. I determined this by comparing the build logs for the different options.

这篇关于静态库的应用程序在模拟器上运行,但在实际设备上运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆