加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

Xcode有时会删除链接库

发布时间:2020-12-14 19:06:11 所属栏目:百科 来源:网络整理
导读:在 Xcode中使用不同的框架时,编译器和链接器有时不在库中包含该框架.结果是在启动期间立即崩溃,并显示以下消息: dyld: Library not loaded: /System/Library/Frameworks/UserNotifications.framework/UserNotifications Referenced from: /var/containers/B
在 Xcode中使用不同的框架时,编译器和链接器有时不在库中包含该框架.结果是在启动期间立即崩溃,并显示以下消息:

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

我发现了一种避免这种情况的方法.它只是在应用程序代码中直接提到该库的部分,如下所示:

UNNotificationRequest *unr = [UNNotificationRequest alloc];

只需在#include< UserNotifications / UserNotifications.h>中包含该框架中的文件不解决它. @import UserNotifications也不是;

对于不同的ios版本,我已经在不同的xcode版本上看到了不同的库.

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

1)CABTMidiCentralViewController used in Storyboard only working if using code reference

2)Switching to Xcode 10 causes `UserNotifications.framekwor dyld: Library not loaded crash` for iOS9

有人知道为什么会这样吗?如何避免代码的愚蠢部分,但仍然链接/嵌入所需的框架?

附:

>我将Always Embed Swift标准库设置为YES
>我已将Link Frameworks Automatically设置为YES

更新#1

UserNotifications框架的问题:

iOS9& XCode 9 – 工作

No crash on iOS9 with XCode9

带有XCode 10的iOS9 – CRASH

Crash on iOS9 with XCode10

使用模拟器:

iOS9 & XCode 10 Crashh - simulator

使用真实设备:

enter image description here

更新#2

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

解决方法

UserNotifications.framework是一个系统框架,要使用它必须存在于运行应用程序的系统上.它是在最近才添加的,所以我猜你在运行早于框架存在的旧iOS版本时会看到它丢失的错误.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读