这个崩溃是一个阻塞问题,我使用以下步骤来重现这个问题:

创建一个Cocoa Touch框架项目 添加一个swift文件和一个类Dog 为设备构建一个框架 在Swift中创建一个单视图应用程序 导入框架到应用程序项目 从ViewController中的框架实例化swift类 在设备上构建并运行应用程序

应用程序在启动时立即崩溃,这是控制台日志:

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

I have tried to build on iOS 7.1 and 8.0 devices, they both have the same crash. 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. 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. Can anyone shed light on this?


当前回答

如果你使用的是Xcode 11或更新版本:

导航到目标的设置并选择General。

向下滚动到框架、库和嵌入式内容。 如有必要,请确保为“嵌入”选项选择了“嵌入&签名”或“嵌入不签名”值。

其他回答

我不得不(在这里提到的内容之上)将以下一行添加到构建设置选项卡下的Runpath Search Paths: @executable_path /框架

进入xcode ->工作空间设置文件 点击旁边的箭头,出现/Users/apple/Library/Developer/Xcode/DerivedData 选择Derived数据并将其移动到Trash。 然后重新打开xcode。 清理项目并再次运行。

以上步骤解决了我的问题。

如果你使用的是Xcode 11或更新版本:

导航到目标的设置并选择General。

向下滚动到框架、库和嵌入式内容。 如有必要,请确保为“嵌入”选项选择了“嵌入&签名”或“嵌入不签名”值。

对于SumUp用户,如果您正在加载最新的SumUpSDK。xcFramework,然后您需要确保从目标的应用程序的General选项卡中将其设置为“Embed & Sign”。

也就是说,把上面的语句颠倒过来(这样更容易理解):

转到“项目导航器”(即显示所有项目项的第一个图标等) 从树的顶部选择您的项目。 在页面中间的菜单上(稍向右),在“Targets”下选择您的应用程序 在顶部选项卡中,选择“General” 向下滚动到“框架,库和嵌入式内容” 从列表中选择您的Lib 从它旁边的下拉列表中选择“嵌入&签名”。 清洁 重新构建并运行。

我希望这能有所帮助。

H

After trying all the methods available on internet and my own trial and error tricks 100 times. Finally I was able to solve it. – Apeksha Sahu 6 mins ago Goto iTunes in Mac --> accounts-->Authorize this computer – Apeksha Sahu 5 mins ago second step.... Goto developer in settings in iPad and iPhone and reindex with identifiers and clear trust computers everything. It worked for me........ ....... After reinstalling Mac OSHigh seria 10.13.15 version from Mac OS seirra beta latest version, to reinstalling Xcode latest version, after updating all certificates. etc etc etc... as many methods as you can think I did. –