Apple Mach-O Linker (ld) Error Group with Swift 3 & Xcode 9 GM Apple Mach-O Linker (ld) Error Group with Swift 3 & Xcode 9 GM xcode xcode

Apple Mach-O Linker (ld) Error Group with Swift 3 & Xcode 9 GM


Update 15 Sept 2017:

Official response from Apple:

Our apologies. For apps using Swift 3.2 or Swift 4.0, several AVFoundation capture APIs (public extensions on external protocol) were inadvertently marked private in Xcode 9. The following AVFoundation API are temporarily unavailable:

  • AVCaptureDevice.Format.supportedColorSpaces

  • AVCaptureDevice.supportedFlashModes

  • AVCapturePhotoOutput.availablePhotoPixelFormatTypes

  • AVCapturePhotoOutput.availableRawPhotoPixelFormatTypes

  • AVCapturePhotoSettings.availablePreviewPhotoPixelFormatTypes

    As a workaround you can use the SwiftPrivate versions of these API by prepending each API with double underscore (__). For example, change AVCaptureDevice.Format.supportedColorSpaces to AVCaptureDevice.Format.__supportedColorSpaces.

I can confirm using __availablePreviewPhotoPixelFormatTypes fixes the build errors.

E.g.

let settings = AVCapturePhotoSettings()let previewPixelType = settings.__availablePreviewPhotoPixelFormatTypes.first!

Source: https://forums.developer.apple.com/thread/86810#259270


This bug was present in earlier beta versions of Xcode 9 (rdar://33903950) and was apparently resolved (see this SO question). It's returned for me as well in the GM build. I'm filing rdar ://34412264 about this issue. Hopefully it's resolved soon and another GM build is related; until then, I you can continue working using earlier beta versions of Xcode 9, but won't be able to release that work. This is a total show-stopper for my app.

Edit: I'll also mention that commenting lines pertaining to AVCapturePhotoSettings' preview properties (previewPhotoFormat, kCVPixelBufferPixelFormatTypeKey, kCVPixelBufferWidthKey, etc.) allows your project to build. If it's possible for you to omit these in your project, this may be a good workaround for now.


I've changed:

if cameraOutput.supportedFlashModes.contains(NSNumber(value: flashMode.rawValue)) {

to:

if cameraOutput.__supportedFlashModes.contains(NSNumber(value: flashMode.rawValue)) {

and

let previewPixelType = settings.availablePreviewPhotoPixelFormatTypes.first!

to

let previewPixelType = settings.__availablePreviewPhotoPixelFormatTypes.first!

and the app started.