Search code examples
iosapptentive

Apptentive: `Undefined symbols for architecture...` error in Cordova project


I'm trying to use Apptentive in Cordova project. While building my Xcode project I'm getting error:

Undefined symbols for architecture arm64:
"_CGImageSourceCreateWithURL", referenced from:
  -[ATFileAttachment createThumbnailOfSize:] in libApptentiveConnect.a(ATFileAttachment.o)
"_kCGImageSourceCreateThumbnailWithTransform", referenced from:
  -[ATFileAttachment createThumbnailOfSize:] in libApptentiveConnect.a(ATFileAttachment.o)
"_kCGImageSourceThumbnailMaxPixelSize", referenced from:
  -[ATFileAttachment createThumbnailOfSize:] in libApptentiveConnect.a(ATFileAttachment.o)
"_OBJC_CLASS_$_QLPreviewController", referenced from:
  objc-class-ref in libApptentiveConnect.a(ATAttachmentController.o)
  objc-class-ref in libApptentiveConnect.a(ATMessageCenterViewController.o)
"_kCGImageSourceCreateThumbnailFromImageAlways", referenced from:
  -[ATFileAttachment createThumbnailOfSize:] in libApptentiveConnect.a(ATFileAttachment.o)
"_CGImageSourceCreateThumbnailAtIndex", referenced from:
  -[ATFileAttachment createThumbnailOfSize:] in libApptentiveConnect.a(ATFileAttachment.o)
"_CGImageSourceCopyTypeIdentifiers", referenced from:
  ___50+[ATFileAttachment canCreateThumbnailForMIMEType:]_block_invoke in libApptentiveConnect.a(ATFileAttachment.o)
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

There is a similar question on StackOverflow, but the solution didn't work for me :/

Looks like I have all the required dependencies, also I've added -lApptentiveConnect flag for linker.

Frameworks


Solution

  • It looks like there are some required system frameworks that aren't being linked automatically.

    You need to link against AVFoundation, CoreData, CoreGraphics, Foundation, ImageIO, MobileCoreServices, QuartzCore, SystemConfiguration, UIKit and weak link StoreKit and CoreTelephony.

    Step by step:

    1. Select your project in the project navigator in Xcode.
    2. Select your target from the list of targets.
    3. Select the Build Phases tab.
    4. Expand the Link Binary with Libraries group.
    5. Click the + Button and select the aforementioned frameworks (including the two weak-linked ones). You can -click to select more than one.
    6. When you're back at the list of libraries, select "Optional" for the two weak-linked frameworks.

    You should then be able to build and run successfully.