Xcode sometimes removes linked library

天涯浪子 提交于 2019-12-30 18:57:13

问题


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];

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

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) 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

Does anybody know why this is happening? And how to avoid that dumb part of code but still link / embed the desired framework?

P.S.

  1. I have set Always Embed Swift Standard Libraries to YES
  2. I have set Link Frameworks Automatically to YES

Update #1

The issue with the UserNotifications framework:

iOS9 & XCode 9 - WORKS

iOS9 with XCode 10 - CRASH

Using the simulator:

Using a real device:

Update #2

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


回答1:


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.



来源:https://stackoverflow.com/questions/54349985/xcode-sometimes-removes-linked-library

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!