Try Sample AVCAM from apple found error
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,
changeAVCaptureDevice.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
Update 14 Sept 2017:
Issue reoccurs in Xcode 9.0 GM (9A235).
Filed new bug report for reference: rdar://34420979
Previous:
Update: Fixed in Xcode Beta 6.
Filed a bug report rdar://33935456
for Xcode Version 9.0 beta 5 (9M202q).
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,
changeAVCaptureDevice.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
Weird compile error with AVCapture after updating to Xcode 9 / Swift 4
So I managed to solve this issue.
Somehow , with Xcode 9 you cannot have "free" code implemented that will not work on iOS Simulator.
The error - after solving it off - was pretty simple.
I cannot use the camera in the simulator, because it will not work.
I think Xcode could give more useful error information.
In order to solve this, in my CameraController class
I had to edit my handleCapturePhoto()
function.
I has to check that if the used architecture wasn't x86_64
(simulator) , then I could present the camera output.
This is the function solved state:
@objc func handleCapturePhoto() {
// processes the captured photo
let settings = AVCapturePhotoSettings()
// doesn't show in the simulator
#if (!arch(x86_64))
guard let preview = settings.previewPhotoFormat?.first else { return }
settings.previewPhotoFormat = [kCVPixelBufferPixelFormatTypeKey as String: preview]
output.capturePhoto(with: settings, delegate: self)
#endif
}
Hope this helps someone in the future.
How do I make use of SSLSetALPNProtocols?
As of the latest macOS and Xcode beta with Swift 4.1 I've got this up and running.
Related Topics
Uinavigationcontroller Interactivepopgesturerecognizer Working Abnormal in iOS7
Multiple Checkmark When Row Selected in Uitableview iOS
How to Tell If Blocks in Loop All Have Completed Executing
iOS 11+ How to Migrate Existing Core Data to Shared App Group for Use in Extension
How to Play Movie with a Url Using a Custom Nsurlprotocol
Sqlite Database on Phonegap/iOS - More Than 5Mb Possible
The Simulator Can't Be Launched Because It Is Already in Use
Invalid Redeclaration in Auto Code Generate Nsmanagedobject Subclass Swift 3
Keep Getting Error Messages When Compiling Newest Version of Admob on iOS6 Sdk
Always Stop in App Delegate After Enabling All Exceptions Break Point
Reload Section Without Reloading Section Header
Customizing the Colors of a Uisegmentedcontrol
How to Reset the Application Data After Each Test with Xcode 7 UI Testing
iOS 10 Heading Arrow for Mkuserlocation Dot
Detect Moment When Newline Starts in Uitextview
Unrecognized Selector Sent to Instance While Archiving Data (Nscoding)
In Os X 10.10 (Yosemite Beta), How to Test Using iOS 6.1 Simulator