I’m concentrating on iOS 17.4 and macOS 14.2 with a iOS/macCatalyst app. The app is offering a photograph picker or entry the digital camera to seize a picture. My Signing and Capabilities has the next settings:
App Sandbox – {Hardware} – Digital camera
{Hardware} Runtime – Digital camera and Picture Library
The information.plist consists of the Privateness - Digital camera Utilization Description
String – stating why the digital camera is required.
in my SwiftUI view controller I’ve the next code:
struct NewGreetingCardView: View {
@State var frontImageSelected: Picture? = Picture("frontImage")
@State var frontPhoto = false
@State var sourceType: UIImagePickerController.SourceType = .photoLibrary
@State var captureFrontImage: Bool = false
@State personal var cameraNotAuthorized = false
@State personal var isCameraPresented = false
var physique: some View {
NavigationView {
Kind {
// eliminated different sections for readability
Part("Picture") {
ZStack {
frontImageSelected?
.resizable()
.aspectRatio(contentMode: .match)
.shadow(radius: 10 )
Picture(systemName: "digital camera.fill")
.foregroundColor(.white)
.font(.largeTitle)
.shadow(radius: 10)
.body(width: 150)
.onTapGesture { self.frontPhoto = true }
.actionSheet(isPresented: $frontPhoto) { () -> ActionSheet in
ActionSheet(
title: Textual content("Select mode"),
message: Textual content("Choose one."),
buttons: [
ActionSheet.Button.default(Text("Camera"), action: {
checkCameraAuthorization()
self.captureFrontImage.toggle()
self.sourceType = .camera
}),
ActionSheet.Button.default(Text("Photo Library"), action: {
self.captureFrontImage.toggle()
self.sourceType = .photoLibrary
}),
ActionSheet.Button.cancel()
]
)
}
.sheet(isPresented: $captureFrontImage) {
ImagePicker(
sourceType: sourceType,
picture: $frontImageSelected)
}
}
.body(width: 300, peak: 300)
}
}
.onAppear(carry out: {
checkCameraAuthorization()
})
.alert(isPresented: $cameraNotAuthorized) {
Alert(
title: Textual content("Unable to entry the Digital camera"),
message: Textual content("To allow entry, go to Settings > Privateness > Digital camera and activate Digital camera entry for this app."),
primaryButton: .default(Textual content("Settings")) {
openSettings()
}
,
secondaryButton: .cancel()
)
}
}
}
func openSettings() {
#if os(macOS)
SettingsLink {
Textual content("Settings")
}
#else
guard let settingsUrl = URL(string: UIApplication.openSettingsURLString) else { return }
if UIApplication.shared.canOpenURL(settingsUrl) {
UIApplication.shared.open(settingsUrl, completionHandler: { _ in })
}
#endif
}
func checkCameraAuthorization() {
var checkCamera: Bool
checkCamera = AVCaptureDevice.authorizationStatus(for: .video) == .approved
if checkCamera == true {
cameraNotAuthorized = false
} else {
cameraNotAuthorized = true
}
}
}
The code accurately prompts the consumer for authentication on iOS and macCataylst, however once I current the digital camera view body, on macOS I get a clean display, and the app crashes with the error:
Thread 1: EXC_BAD_ACCESS(code=1, tackle=0x1c8)
and a stack hint of
Thread 1 Queue : com.apple.main-thread (serial)
#0 0x000000018107365c in class_getMethodImplementation ()
#1 0x000000018260aad8 in _NSKVONotifyingOriginalClassForIsa ()
#2 0x000000018262ad44 in _NSKeyValueObservationInfoGetObservances ()
#3 0x0000000182d46b10 in NSKeyValueWillChangeWithPerThreadPendingNotifications ()
#4 0x000000019f120c10 in -[AVCaptureFigVideoDevice _setVideoHDREnabled:forceResetVideoHDRSuspended:] ()
#5 0x000000019f16d2fc in -[AVCaptureSession _updateVideoHDREnabledForDevice:forceResetVideoHDRSuspended:] ()
#6 0x000000019f16b600 in -[AVCaptureSession _updateDeviceActiveFormatsAndActiveConnections] ()
#7 0x000000019f169aa0 in -[AVCaptureSession _buildAndRunGraph:] ()
#8 0x000000019f161684 in -[AVCaptureSession _commitConfiguration] ()
#9 0x000000019f161288 in -[AVCaptureSession commitConfiguration] ()
#10 0x000000019f12c97c in -[AVCaptureVideoPreviewLayer dealloc] ()
#11 0x0000000182d47898 in _NSKVOPerformWithDeallocatingObservable ()
#12 0x00000001826659b8 in NSKVODeallocate ()
#13 0x0000000189713888 in CA::Transaction::commit() ()
#14 0x00000001898e8bc8 in CA::Transaction::flush_as_runloop_observer(bool) ()
#15 0x0000000181521254 in __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ ()
#16 0x0000000181521140 in __CFRunLoopDoObservers ()
#17 0x000000018151fe58 in CFRunLoopRunSpecific ()
#18 0x000000018bcc0000 in RunCurrentEventLoopInMode ()
#19 0x000000018bcbfe3c in ReceiveNextEventCommon ()
#20 0x000000018bcbfb94 in _BlockUntilNextEventMatchingListInModeWithFilter ()
#21 0x0000000184d77970 in _DPSNextEvent ()
#22 0x0000000185569dec in -[NSApplication(NSEventRouting) _nextEventMatchingEventMask:untilDate:inMode:dequeue:] ()
#23 0x0000000184d6acb8 in -[NSApplication run] ()
#24 0x0000000184d41f54 in NSApplicationMain ()
#25 0x0000000184f94610 in _NSApplicationMainWithInfoDictionary ()
#26 0x000000019a7b00dc in UINSApplicationMain ()
#27 0x00000001b089c778 in UIApplicationMain ()
#28 0x00000001ca74affc in ___lldb_unnamed_symbol178559 ()
#29 0x00000001ca74ae44 in ___lldb_unnamed_symbol178557 ()
#30 0x00000001ca3802bc in static App.essential() ()
#31 0x0000000100cddf28 in static GreetKeeperApp.$essential() ()
#32 0x0000000100cde090 in essential at /Customers/michaelrowe/Paperwork/TheApApp/CardTracker/CardTracker/GreetKeeperApp.swift:13
#33 0x00000001810ba0e0 in begin ()
There are a number of messages within the debug log that must do with CMIQHardware doesn’t assist async nonetheless seize, however I’m not positive the place how that matches in for a easy image.
Are there particular issues that needs to be checked out for Mac Catalyst. In a previous model of this app, (earlier than macOS 14) I did nothing in any respect particular for Mac Catalyst.