0

We have an app that is working properly with the UserNotification.framework being linked as required framework in Xcode 9. Everything works smooth here.

Now we are switching to Xcode 10. But there linking this framework as required leads to

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

If I switch it to optional push notification (via Intercom) won't work anymore.

What is the reason? How can we fix that? Why is it even working in Xcode 9?

Update #1

using

@import UserNotification

does not fix it

Update #2

Its fixed by importing and using it actually (in AppDelegate.m) like this

UNNotificationRequest* unr = [UNNotificationRequest alloc];
unr = nil;

Why?

It is related to the same issue I have experienced already.

CABTMidiCentralViewController used in Storyboard only working if using code reference

Update #3

More generic question

Xcode sometimes removes linked library

Cœur
  • 37,241
  • 25
  • 195
  • 267
Martin Mlostek
  • 2,755
  • 1
  • 28
  • 57
  • What is your Always Embed Swift Standard Libraries value in Build settings? Did you try to clear derived data and build folder? – Satheesh Jan 24 '19 at 10:33
  • It's saying `yes`. Yes i have tried that. (Same happening from builds from our Nevercode CI, and thats a blank sandbox always, so its not an caching issue) – Martin Mlostek Jan 24 '19 at 11:14
  • Why do you even link the framework manually? `CLANG_MODULES_AUTOLINK` (Link Frameworks Automatically) should be enabled by default, and you just `import` the framework and check for availability in your code (you'll also get fixit prompts for older os versions) – Alladinian Jan 24 '19 at 12:25
  • @Alladinian Its set to `yes` but somehow the compiler seems to optimize the code and removes some frameworks that are not explicitly mentioned in my code. See the updated answer – Martin Mlostek Jan 24 '19 at 13:33
  • You must link this framework as `optional` if your Deployment Target is below iOS 10. – Cœur Apr 18 '22 at 06:58

2 Answers2

0

UserNotification SDK is available on iOS 10+, Try to update the deployment Target to iOS 10 +

Ajay Singh Mehra
  • 1,313
  • 9
  • 19
-2

Can your please try removing the framework and adding that again ? I just created a new project this framework added in Xcode 10 and was able to run in the device without any errors.

humblePilgrim
  • 1,818
  • 4
  • 25
  • 47