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

查看:27
本文介绍了WatchOS 2 应用程序无法在我的框架库未加载的 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/library/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 键单击目标以显示带有复制命令的上下文菜单.
  3. 更改目标的名称,以便您以后可以轻松识别.
  4. 在构建设置中,更改以下值:
    • 将支持的平台设置更改为 watchOS.
    • 将基础 SDK 设置更改为最新的 watchOS.
    • 更改产品名称设置,使其与您的 iOS 框架的名称相匹配.您希望使用相同的名称构建两个框架.

我按照这些步骤克隆了我的框架,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>

而不是大概必须将其更改为

instead of presumably having to change it to

#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

它们都引用了相同的路径

they're both reference the same path

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

虽然您可以看到目标成员资格将两个框架分开,但顶部的 MyFramework 与主应用程序、今天的小部件和框架测试项目相关联.较低的 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

推荐答案

好的,这是因为苹果的转换文档有误,或者是我的理解有误.它说

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.

实际上正确的修复方法是将框架添加到嵌入式二进制文件部分(无论如何它会自动向链接的框架添加一个条目),并将框架正确放置在框架目录下的监视扩展中.然后应用程序加载正常!太沮丧了,几天之内我为此损失了几个小时!!

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 应用程序无法在我的框架库未加载的 dyld_fatal_error 的设备上启动:找不到图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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