WatchOS 2 App无法在带有dyld_fatal_error的设备上启动,但未加载我的框架库:找不到图像 [英] WatchOS 2 App fails to launch on device with dyld_fatal_error for my Framework Library not loaded: Image not found

查看:90
本文介绍了WatchOS 2 App无法在带有dyld_fatal_error的设备上启动,但未加载我的框架库:找不到图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚遵循了苹果过渡指南,将我的ObjectiveC应用升级到WatchOS 2

I've just followed the apple transition guide to upgrade my ObjectiveC app to WatchOS 2

https://developer.apple.com/库/watchos/documentation/General/Conceptual/AppleWatch2TransitionGuide/ConfiguretheXcodeProject.html

在iOS应用程序与watchOS应用程序之间共享代码"部分描述了如何将现有的iOS框架复制到WatchOS框架目标中,以供WatchOS使用,如下所示.

With the section "Sharing Code Between an iOS App and a watchOS App" describing how to duplicate an existing iOS framework into a WatchOS framework target for use by WatchOS as follows.

"如果您已经有一个与iOS应用程序共享框架的watchOS 1应用程序,请复制您的iOS框架目标并对其进行修改以支持watchOS 2.

"If you already have a watchOS 1 app that shares a framework with your iOS app, duplicate your iOS framework target and modify it to support watchOS 2.

要为watchOS 2复制并配置框架目标

  1. 打开Xcode的项目编辑器窗格. (窗格通常是关闭的.)
  2. 按住Control键并单击目标,以使用Duplicate命令显示上下文菜单.
  3. 更改目标的名称,以便以后可以轻松识别它.
  4. 在构建设置"中,更改以下值:
    • 将支持的平台"设置更改为watchOS.
    • 将基本SDK设置更改为最新的watchOS.
    • 更改产品名称"设置,使其与iOS框架的名称匹配.您希望两个框架都使用相同的名称构建.
  1. Open the project editor pane of Xcode. (The pane is normally closed.)
  2. Control-click the target to display a context menu with a Duplicate command.
  3. Change the name of the target so that you can identify it easily later.
  4. In Build settings, change the following values:
    • Change the Supported Platforms setting to watchOS.
    • Change the Base SDK setting to the latest watchOS.
    • Change the Product Name setting so that it matches the name of your iOS framework. You want both frameworks to be built with the same name.

我已经按照以下步骤克隆了我的框架,该框架与iOS框架称为MyFramework,现在新的WatchOS框架称为MyFrameworkWatch.但是如上所述,产品名称设置为MyFramework而不是MyFrameworkWatch.我认为这种命名方式是为了使我可以使用

I've followed these steps to clone my framework which with the iOS framework was called MyFramework, and now the new WatchOS framework is called MyFrameworkWatch. But as described above the Product Name is set to MyFramework instead of MyFrameworkWatch. I presume this naming shift is so that I can include from my framework using

#import <MyFramework/SharedUtils.h>

不必将其更改为

#import <MyFrameworkWatch/SharedUtils.h>

我不介意后者,但是我会承认它更好地保持了框架名称不变.

I wouldn't mind the latter but I'll admit its nicer keeping the framework name the same.

在完成了最初的自动转换之后的更多工作之后,我设法使我的应用程序在模拟器上运行良好,但是现在切换到设备我只是无法启动.

After a bit more work beyond the initial automatic transition I managed to get my app working perfectly well on the simulator, but now switching to device i just can't get it to launch.

在设备上启动我的应用程序会使它旋转几秒钟,然后崩溃.瞥一眼只会使其无限旋转.尝试从Xcode运行它并运行该应用程序会导致该应用程序最终启动并旋转,旋转有时可能无限期地持续,但最终它通过了,我得到了如下所示的实际错误

Launching my app on the device causes it to spin for a few seconds and then just crash. Launching the glance just causes it to spin indefinitely. Trying to run it from Xcode and running the app causes the app to eventually launch and spin, the spinning can last indefinitely sometimes, but eventually it gets through and i get the actual error reported as follows

dyld_fatal_error - dyld: Library not loaded: @rpath/MyFramework.framework/MyFramework referenced from WatchKit Extension Reason: image not found

这是我的Watch App Extension,它试图链接到Watch框架,并在其中查找MyFramework名称,而不是MyFrameworkWatch名称.我想知道这个名称冲突是否引起混淆?

So this is my Watch App Extension trying to link to the Watch framework, and doing so looking for the MyFramework name, not the MyFrameworkWatch name. I wonder if this name clashing has caused it to get confused?

当我尝试在Xcode中的Products文件夹下找到引用的框架时,我可以看到两个框架

When I try to find the frameworks referenced under the Products folder in Xcode I can see two frameworks

MyFramework
MyFramework

它们都引用相同的路径

/Users/jim/Library/Developer/Xcode/DerivedData/MyApp-byegspjumgwlfpahhwjgzpmfkcdx/Build/Products/Debug-iphoneos/MyFramework.framework

尽管您可以看到目标成员资格将两个框架分开,但是顶部的MyFramework与主应用程序(今天是widget和框架测试项目)相关联.较低的MyFramework仅与我的Watch扩展相关.这些确实确定引用了完全相同的路径,这感觉不对吗?

though you can see the target membership is separating the two frameworks, the top MyFramework is associated with the main app, today widget and framework tests project. The lower MyFramework is just associated with my Watch extension. It doesn't feel right that these are referencing the exact same path surely?

最后,当谷歌搜索这个问题时,尽管在这里找到了CocoaPods的参考文献,但也有类似的问题

Finally when googling for this issue I've found reference of CocoaPods having similar problems though according to their site here

https://github.com/CocoaPods/CocoaPods/issues/4180

自9月起已在0.39.0版中进行了修复,该版本是pod --version报告的版本.所以我想我已经解决了.我很想从我的框架中删除可可豆荚,看看是否有帮助.

It's been fixed since September in version 0.39.0, which is the version that pod --version reports. So I presume I have their fix. I'm tempted to remove the cocoa pods from my framework to see if it helps.

是否有人遵循过渡指南的建议来创建重复的框架,然后设法使应用程序和框架真正安装在他们的手表上?

Has anyone else followed the transition guide suggestions for creating a duplicate framework and then managed to get the app and framework actually installing on their watch ok?

是否有任何方法可以分析构建完成以尝试查看是否可以看到构建文件的问题,因此我不必等待手表未能启动应用进行调试.

Is there any way to analyse the build that is done to try and see if i can see problems with the built files so i don't have to wait for the watch to fail to launch the app to debug it.

任何帮助都一如既往地受到赞赏!干杯!

Any help is really appreciated as always! Cheers!

我认为我已经通过注释掉我的pod文件中的目标部分并运行pod update/pod install来从有问题的MyFrameworkWatch目标中删除了可可粉荚...它似乎并没有清除目标很好,因此我必须在后期构建步骤中手动删除可可豆荚步骤.也许我没有正确地删除它,我发现知道可可豆荚的内在发生了什么让我有些困惑.不管发生了同样的错误,所以我没有正确删除它,或者对这个特定问题没有影响

I think I've managed to remove cocoa pods from the offending MyFrameworkWatch target by commenting out the target section in my pod file and running pod update/pod install... it didn't seem to clean up the target very well so i had to manually remove the cocoa pod steps in the post build step. Maybe i've not removed it properly, i find it a little confusing to know what is going on under the hood with cocoa pods. Regardless the same error occurred, so either i didn't remove it properly or it has no effect on this particular problem

推荐答案

好吧,这是由于Apple文档中关于转换错误或我将其解释为错误而引起的.它说

Ok, this was caused by the apple documentation for transitioning being wrong, or me interpreting it wrong. It says

将框架添加到WatchKit扩展的链接框架列表中.

Add the framework to your WatchKit extension’s list of linked frameworks.

实际上,正确的解决方法是将框架添加到嵌入式二进制文件部分(无论如何它都会自动向链接的框架添加条目),并将框架正确地放置在watchs扩展中的Frameworks目录下.然后哪个应用程序可以正常加载!实在令人沮丧,几天之内,我为此付出了数小时!!

Where as actually the correct fix was to add the framework to the embedded binaries section (which automatically adds an entry to the linked frameworks anyways) and correctly places the framework within the watch extension under a Frameworks directory. Which the app then loads fine! So much frustration, I lost hours to this across a few days!!

这篇关于WatchOS 2 App无法在带有dyld_fatal_error的设备上启动,但未加载我的框架库:找不到图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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