[iOS] A Roundup of Common iOS Build Issues

1. Error: App Transport Security has blocked a cleartext HTTP
Starting with iOS 9.x, apps don’t allow HTTP connections by default. When you use a library that makes an HTTP connection, you may see the following error:
App Transport Security has blocked a cleartext HTTP (http://) resource load since it is insecure.
Temporary exceptions can be configured via your app‘s Info.plist file.

To change this setting, add the following two lines to Info.plist:
C3F5AB7F-D24D-4F20-92FD-A6031FC6AAC4

Alternatively, edit Info.plist directly and add the following before the final tag:

NSAppTransportSecurity

    NSAllowsArbitraryLoads
    

2. Error: Undefined symbols for architecture arm64: “std::basic_ofstream >::basic_ofstream()”
If you see the following error during compilation:
Undefined symbols for architecture arm64:
"std::basic_ofstream >::basic_ofstream()

This usually happens because the relevant Controller files don’t have the .mm extension. Change the extension of any Controller file that uses the .a library to .mm.
Screen Shot 2016-08-08 at 8.14.35 PM

You also need to add libc++.tbd under Build Phases > Link Binary With Libraries:
Screen Shot 2016-08-08 at 8.14.21 PM

3. Error: Undefined symbols for architecture arm64: “_get_crc_table”
If you see the following error during compilation:
Undefined symbols for architecture arm64:
"_get_crc_table", referenced from:
_unzOpenCurrentFile3 in libZipArchive.a(unzip.o)

This usually happens because the libz library isn’t linked. Just add libz.tbd under Build Phases > Link Binary With Libraries:
E03D7493-FE45-4DAB-9D1B-3B27CE3209CE

4. Error: This app has crashed because it attempted to access privacy-sensitive data without a usage description.
If the app crashes at runtime with the following error:
This app has crashed because it attempted to access privacy-sensitive data without a usage description. The app’s Info.plist must contain an NSPhotoLibraryUsageDescription key with a string value explaining to the user how the app uses this data.

This usually happens because newer versions of iOS require a usage description when an app accesses a user’s private data. In this example, the error tells us to add an NSPhotoLibraryUsageDescription entry because the code below uses the UIImageWriteToSavedPhotosAlbum function to access the user’s photo library.

- (void)btnTakePhoto
{
    UIImage *arImage = [_arController getCurrentARImage];
    
    UIImageWriteToSavedPhotosAlbum(arImage, nil, nil, nil);
}

Here’s how to add a usage description:

1) In your target settings, click the Info tab, then right-click anywhere in the list and select Add Row:
screen-shot-2016-10-10-at-3-50-15-pm

2) In the new row, open the drop-down menu and select Privacy -> Photo Library Usage Description. In the Value column, enter why your app needs access to the user’s photo library. For example, in my AR app I entered “Photo library is needed for saving AR image”. Use whatever wording fits your app.
screen-shot-2016-10-10-at-3-48-57-pm

3) Run the app again. When you tap a feature that uses the photo library, a permission dialog will appear with the reason you just entered:
wechatimg1

Other privacy-sensitive features also need usage descriptions, such as camera access or access to GPS data. You can add them the same way.

5. Error: Undefined symbols for architecture x86_64: “_objc_msgSend”
If you see the following error during compilation:
Undefined symbols for architecture x86_64:
"_OBJC_CLASS_$_MakClass", referenced from:
objc-class-ref in helloworld-XEijke.o
"_objc_msgSend", referenced from:
_main in helloworld-XEijke.o
"_objc_msgSend_fixup", referenced from:
l_objc_msgSend_fixup_alloc in helloworld-XEijke.o
l_objc_msgSend_fixup_release in helloworld-XEijke.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

This usually happens because Foundation.framework isn’t linked. Just add it under Build Phase.

6. Error: Undefined symbols for architecture x86_64: “_NSAppKitVersionNumber”
If you see the following error during compilation:
Undefined symbols for architecture x86_64:
"_NSAppKitVersionNumber", referenced from:
_cvInitSystem in libopencv_highgui.a(window_cocoa.mm.o)
_cvNamedWindow in libopencv_highgui.a(window_cocoa.mm.o)
"_NSDeviceRGBColorSpace", referenced from:
-[CVView setImageData:] in libopencv_highgui.a(window_cocoa.mm.o)
"_NSFullScreenModeSetting", referenced from:
cvSetModeWindow_COCOA(char const*, double) in libopencv_highgui.a(window_cocoa.mm.o)
"_OBJC_CLASS_$_NSApplication", referenced from:
objc-class-ref in libopencv_highgui.a(window_cocoa.mm.o)
"_OBJC_CLASS_$_NSBitmapImageRep", referenced from:
objc-class-ref in libopencv_highgui.a(window_cocoa.mm.o)
"_OBJC_CLASS_$_NSEvent", referenced from:
objc-class-ref in libopencv_highgui.a(window_cocoa.mm.o)
"_OBJC_CLASS_$_NSImage", referenced from:
objc-class-ref in libopencv_highgui.a(window_cocoa.mm.o)
"_OBJC_CLASS_$_NSScreen", referenced from:
objc-class-ref in libopencv_highgui.a(window_cocoa.mm.o)
"_OBJC_CLASS_$_NSSlider", referenced from:
objc-class-ref in libopencv_highgui.a(window_cocoa.mm.o)
"_OBJC_CLASS_$_NSTextField", referenced from:
objc-class-ref in libopencv_highgui.a(window_cocoa.mm.o)
"_OBJC_CLASS_$_NSView", referenced from:
_OBJC_CLASS_$_CVView in libopencv_highgui.a(window_cocoa.mm.o)
_OBJC_CLASS_$_CVSlider in libopencv_highgui.a(window_cocoa.mm.o)
"_OBJC_CLASS_$_NSWindow", referenced from:
objc-class-ref in libopencv_highgui.a(window_cocoa.mm.o)
_OBJC_CLASS_$_CVWindow in libopencv_highgui.a(window_cocoa.mm.o)
"_OBJC_METACLASS_$_NSView", referenced from:
_OBJC_METACLASS_$_CVView in libopencv_highgui.a(window_cocoa.mm.o)
_OBJC_METACLASS_$_CVSlider in libopencv_highgui.a(window_cocoa.mm.o)
"_OBJC_METACLASS_$_NSWindow", referenced from:
_OBJC_METACLASS_$_CVWindow in libopencv_highgui.a(window_cocoa.mm.o)
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Showing first 200 warnings only

This usually happens because Cocoa.framework isn’t linked. Just add it under Build Phase.

Add a Comment

Your email address will not be published. Required fields are marked *