UNUserNotificationCenter link error

Patrick Bodet picture Patrick Bodet · Nov 19, 2016 · Viewed 9.2k times · Source

I have an Xcode project, Xcode 8.1 (8B62) with two targets, one for the paid version of the application and the other for the free version. They both manage remotes push notifications. Since I made the changes for iOS 10 with the new framework UNUserNotificationCenter.framwork, everything is fine for the first target and I have a link error for the second. It worked well under iOS 9 with the old methods. What I did for both targets:

  • Capabilities: Enabled Push Notifications (Entitlements are properly updated)
  • In AppDelegate.h: #import
  • In AppDelegate.m: Updated the code with the new methods

It's the same code for both targets.

Unfortunately, for the second target, I have the following error:

Undefined symbols for architecture arm64:   "_OBJC_CLASS _ $ _ UNUserNotificationCenter", referenced from:       Objc-class-ref in AppDelegate.o Ld: symbol (s) not found for architecture Clang: error: linker command failed with exit code 1 (use -v to see invocation)

I have done several times clean and clean build target folder, re-start Xcode, re-start the computer but nothing is done.

Nothing found in the different forums ...

Help would be welcome. Thank you in advance.

Answer

shallowThought picture shallowThought · Nov 19, 2016

You are not linking to the UserNotifications.framework.

  • Select your target
  • Show its "Build Phases"
  • Assure UserNotifications.framework exists in "Link Binary With Libraries"

If it does not:

  • Click "+" button and add it