本文翻译自:iOS app with framework crashed on device, dyld: Library not loaded, Xcode 6 Beta

This crash has been a blocking issue I used the following steps to reproduce the issue: 此崩溃一直是一个阻止问题,我使用以下步骤来重现该问题:

  • Create a Cocoa Touch Framework project 创建一个Cocoa Touch Framework项目
  • Add a swift file and a class Dog 添加一个快速文件和一个类Dog
  • Build a framework for device 建立设备框架
  • Create a Single View application in Swift 在Swift中创建一个单视图应用程序
  • Import framework into app project 将框架导入应用程序项目
  • Instantiate swift class from the framework in ViewController 从ViewController中的框架实例化swift类
  • Build and run an app on the device 在设备上构建并运行应用

The app immediate crashed upon launching, here is console log: 该应用立即在启动时崩溃,这是控制台日志:

dyld: Library not loaded: @rpath/FrameworkTest03.framework/FrameworkTest03Referenced from: /var/mobile/Applications/FA6BAAC8-1AAD-49B4-8326-F30F66458CB6/FrameworkTest03App.app/FrameworkTest03AppReason: image not found

I have tried to build on iOS 7.1 and 8.0 devices, they both have the same crash. 我尝试在iOS 7.1和8.0设备上构建,它们都崩溃了。 However, I can build an app and run on the simulator fine. 但是,我可以构建一个应用程序并在模拟器上正常运行。 Also, I am aware that I can change the framework to form Required to Optional in Link Binary With Libraries , but it did not completely resolve the problem, the app crashed when I create an instance of Dog . 另外,我知道我可以将框架更改为“ 使用库的链接二进制文件”中的“ 必需”到“ 可选”形式,但是并不能完全解决问题,当我创建Dog实例时,应用程序崩溃了。 The behavior is different on the device and simulator, I suspect that we can't distribute a framework for the device using a beta version of Xcode. 在设备和模拟器上的行为是不同的,我怀疑我们无法使用Beta版的Xcode来为设备分发框架。 Can anyone shed light on this? 谁能阐明这一点?


#1楼

参考:https://stackoom.com/question/1e6NZ/带有框架的iOS应用在设备上崩溃-dyld-库未加载-Xcode-Beta


#2楼

You need to add the framework to a new Copy Files Build Phase to ensure that the framework is copied into the application bundle at runtime.. 您需要将框架添加到新的“复制文件”构建阶段,以确保在运行时将框架复制到应用程序包中。

See How to add a 'Copy Files build phase' to my Target for more information. 有关更多信息,请参见如何向我的目标添加“复制文件构建阶段” 。

Official Apple Docs: https://developer.apple.com/library/mac/recipes/xcode_help-project_editor/Articles/CreatingaCopyFilesBuildPhase.html 官方Apple文件: https : //developer.apple.com/library/mac/recipes/xcode_help-project_editor/Articles/CreatingaCopyFilesBuildPhase.html


#3楼

In the target's General tab, there is an Embedded Binaries field. 在目标的“ 常规”选项卡中,有一个“ 嵌入式二进制文件”字段。 When you add the framework there the crash is resolved. 当您添加框架时,崩溃已解决。

Reference is here on Apple Developer Forums. 参考是这里的苹果开发者论坛。


#4楼

For iOS greater than or equal to 8 对于iOS大于或等于8

Under the target's General tab, in the Embedded Binaries section add the framework. 在目标的“常规”选项卡下的“嵌入式二进制文件”部分中,添加框架。 This will copy the framework into the compiled so that it can be linked to at runtime. 这会将框架复制到已编译的框架中,以便可以在运行时链接到该框架。

在此处输入图片说明

Why is this happening? 为什么会这样呢? : because the framework you are linking to is compiled as a dynamically linked framework and thus is linked to at runtime. 因为要链接的框架被编译为动态链接的框架,因此在运行时已链接到该框架。

** Note:** Embedding custom frameworks is only supported in iOS > 8 and thus an alternative solution that works on older versions of iOS follows. **注意:**仅在iOS> 8中支持嵌入自定义框架,因此,下面是适用于旧版本iOS的替代解决方案。

For iOS less than 8 对于小于8的iOS

If you influence this framework (have access to the source code/build process) you may change this framework to be statically linked rather than dynamically linked. 如果您影响此框架(可以访问源代码/构建过程),则可以将此框架更改为静态链接而不是动态链接。 This will cause the code to be included in your compiled app rather than linked to at runtime and thus the framework will not have to be embedded. 这将导致代码包含在编译的应用程序中,而不是在运行时链接到该代码,因此不必嵌入框架。

** How:** Under the framework's Build Setting tab, in the Linking section, change the Mach-O Type to Static Library. **方法:**在框架的“构建设置”选项卡下的“链接”部分中,将Mach-O类型更改为“静态库”。 You should now not need to include the framework under embedded binaries. 现在,您无需将框架包含在嵌入式二进制文件下。

静态框架

Including Assets: To include things such as images, audio, or xib/nib files I recommend creating a bundle (essentially a directory, more info here bit.ly/ios_bundle) and then load the assets from the bundle using NSBundle. 包括资产:为了包括诸如图像,音频或xib / nib文件之类的东西,我建议创建捆绑软件(基本上是目录,更多信息在此处bit.ly/ios_bundle),然后使用NSBundle从捆绑软件中加载资产。


#5楼

I had to (on top of what mentioned here) add the following line to Runpath Search Paths under Build Settings tab: 我必须(在此处提到的内容之上) 将以下行添加到 构建设置”选项卡下的“运行 路径搜索路径 ”中
@executable_path/Frameworks

在此处输入图片说明


#6楼

I had the same issue. 我遇到过同样的问题。 I tried building my project with an iPhone that I never used before and I didn't add a new framework. 我尝试使用从未使用过的iPhone构建项目,也没有添加新框架。 For me, cleaning up worked fine ( Shift+Command+K ). 对我而言,清理工作正常( Shift + Command + K )。 Maybe it's because I use beta 5 of Xcode 7 and an iPhone 6 with iOS 9 Beta, but it worked. 也许是因为我使用Xcode 7的Beta 5和带有iOS 9 Beta的iPhone 6,但它确实有效。

带有框架的iOS应用在设备上崩溃,dyld:库未加载,Xcode 6 Beta相关推荐

  1. 利用JPCT-AE在安卓设备上进行*.obj文件的加载和显示

    最近做一个项目,需要加载带纹理的3d模型obj文件并显示出来,仅限于安卓平台,因此需要一个轻量级的3d内核. 找了很多内核,要不就是太久没更新不能用了,要不就是功能太复杂,后来找到了JPCT-AE,网 ...

  2. cmake中添加引用动态链接_macos - CMake:MacOS上动态链接资源的运行时错误(dyld:未加载库) - SO中文参考 - www.soinside.com...

    问题 在MacOS上,我在运行时为依赖于动态链接资源的CMake项目获取链接问题 - 但仅在安装项目之后!当我只构建二进制文件而不安装它时,不会发生这个问题. $ ./testapp Hello wo ...

  3. html2canvas在手机不行,html2canvas - 在iOS设备上崩溃

    我为客户端建立了一个系统,它允许您选择或上传汽车图像,在中键入数字,然后移动/调整大小/旋转/将板倾斜到正确的位置,然后下载图像:html2canvas - 在iOS设备上崩溃 这都是每次我在测试设备 ...

  4. 将iOS刷到Android设备上

    原文地址:http://qorbot.com/archives/178.html 一般情况下,同等流畅度的苹果手机和安卓手机相比,安卓的硬件配置比苹果几乎要高出一倍以上.之所以会有这么大的悬殊,主要是 ...

  5. iOS开发UI篇-在UItableview中实现加载更多功能

    iOS开发UI篇-在UItableview中实现加载更多功能 一.实现效果 点击加载更多按钮,出现一个加载图示,三秒钟后添加两条新的数据. 二.实现代码和说明 当在页面(视图部分)点击加载更多按钮的时 ...

  6. jQuery模拟原生态App上拉刷新下拉加载

    jQuery模拟原生态App上拉刷新下拉加载效果代码,鼠标上拉时会显示loading字样,并且会模拟加载一条静态数据,支持触屏设备使用. <!doctype html> <html ...

  7. jQuery模拟原生态App上拉刷新下拉加载效果代码

    以下任意均可: 1. jQuery模拟原生态App上拉刷新下拉加载效果代码,鼠标上拉时会显示loading字样,并且会模拟加载一条静态数据,支持触屏设备使用. 原文:http://www.sucaij ...

  8. Android——Xlistview上拉刷新下拉加载

    配置网络权限+xutils包+gson包 代码如下: values下修改strings添加 直接粘 <?xml version="1.0" encoding="ut ...

  9. iOS底层原理之dyld应用程序加载

    前言 众所周知,main作为程序的入口,但是在它之前发生了什么?有点好奇,让我们来瞅一瞅: 一.准备工作 1.代码 __attribute__((constructor)) void Func(){p ...

最新文章

  1. 对DeDecms之index.php页面的补充
  2. VB.NET 调用外部程序
  3. java基础之包装类
  4. java三角形剪角_大班数学:拼角剪角
  5. 自定义圆形控件 RoundImageView
  6. 前端学习(2216):react元素渲染
  7. 整理的3500个常用汉字的调用字典
  8. 报“parseSdkContent failed java.lang.NullPointerException”的错误。
  9. linux php mysql 中文_Linux下PHP+MySQL+CoreSeek中文检索引擎配置 | 系统运维
  10. 我们的内存中都放了什么
  11. java设计模式迭代器模式_Java中的迭代器设计模式
  12. 判断运行环境是手机还是 PC
  13. 给js对象定义属性的方法
  14. 算法工程师面试常见问题
  15. linux下的护眼软件
  16. Win7如何去除快捷方式小箭头
  17. python 预测分析_如何用Python来预测分析离职率呢
  18. 微信中屏蔽分享按钮一把梭快速干
  19. 《笼中鸟——精神病人的生存现状》观后的一点思考
  20. 【Onedrive】查看和使用组共享链接

热门文章

  1. 算法-----前 k 个出现次数最多的单词
  2. Android Service、 BroadcastReceiver、ContentProvider ANR 原理详解
  3. 数字签名、数字证书、对称加密算法、非对称加密算法、单向加密(散列算法)
  4. ScrollView嵌套ListView处理事件冲突
  5. android 判断横竖屏的方法
  6. matlab均值量化函数_在matlab中理解抽样量化的概念:均匀量化的实现
  7. Android之EventBus框架源码解析下(源码解析)
  8. (0020)iOS 开发之-设计模式-懒加载解惑
  9. android sqlitelog,android-Room-SQLiteLog:(1)SQL变量过多
  10. 【spring教程之中的一个】创建一个最简单的spring样例