Xcode有时会删除链接库 [英] Xcode sometimes removes linked library

查看:154
本文介绍了Xcode有时会删除链接库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Xcode中使用不同的Frameworks时,编译器和链接器有时不在库中包含该Framework.结果是在启动过程中立即崩溃,并显示以下消息:

When using different Frameworks in Xcode, the compiler and linker sometimes do not include that Framework in the library. The result is an immediate crash during the startup with the following message:

dyld: Library not loaded: /System/Library/Frameworks/UserNotifications.framework/UserNotifications
  Referenced from: /var/containers/Bundle/Application/1D41BD68-9B88-4D5D-B7AB-0D1C31979964/App.app/App
  Reason: image not found

我找到了避免这种情况的一种方法.它只是像这样直接在应用程序代码中提到该库的各个部分:

I found one way to avoid this. Its just mentioning the parts of that library within the apps code directly like this:

UNNotificationRequest *unr = [UNNotificationRequest alloc];

仅使用#include <UserNotifications/UserNotifications.h>包含该框架中的文件并不能修复该文件. @import UserNotifications;

Just including a file from that framework with #include <UserNotifications/UserNotifications.h> does not fix it. Nor does @import UserNotifications;

我已经在不同的xcode版本和不同的ios版本的不同库中看到了它.

I have seen it with different libraries on different xcode versions for different ios versions.

以下是另外两个具有更特定用例的问题:

Here are two other issues that have a more specific use case:

1)在Storyboard中使用的CABTMidiCentralViewController仅在以下情况下有效使用代码参考

2)切换到Xcode 10的原因"UserNotifications.framekwor dyld:iOS9的库未加载崩溃"

有人知道为什么会这样吗?以及如何避免代码中那些笨拙的部分却仍然链接/嵌入所需的框架?

  1. 我已将Always Embed Swift Standard Libraries设置为YES
  2. 我已将Link Frameworks Automatically设置为YES
  1. I have set Always Embed Swift Standard Libraries to YES
  2. I have set Link Frameworks Automatically to YES

更新#1

UserNotifications框架的问题:

使用模拟器:

使用真实设备:

当我将框架从Required更改为Optional时,它并没有崩溃,但是推送通知不起作用.

It is not crashing when I change the framework from Required to Optional but then the push notifications are not working.

推荐答案

UserNotifications.framework是一个系统框架,要使用该框架,它必须存在于您的应用程序所运行的系统上.它是在最近才添加的,所以我想您会发现在早于框架存在的较旧版本的iOS上运行时,缺少该错误的错误.

UserNotifications.framework is a system framework, and to be used it must exist on the system your application is running on. It was added relatively recently, so my guess is you're seeing the error about it being missing when running on older iOS versions that predate the framework's existence.

这篇关于Xcode有时会删除链接库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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