Post

Replies

Boosts

Views

Activity

Permission issue accessing Reminders through EventKit in MacOS app
Hello, I have an app that I would like to have read and write access to Reminders using EventKit, but on MacOS 14 (14.2.1) when I call requestFullAccessToReminders I get error = nil, success = false (even when access is granted) and there is no permission prompt to use user when access has not yet been granted. Note this is not an issue in iOS. Here's a stripped down example of what I'm talking about import EventKit struct ContentView: View { let store = EKEventStore() @State var permissionState = "Ready to Request" var body: some View { VStack { Text(permissionState).font(.title) Button("Request Access") { requestFullAccessToEvents() }.padding() } .padding() } func requestFullAccessToEvents() { store.requestFullAccessToReminders { (granted, error) in if let foundError = error { permissionState = "Error: " + foundError.localizedDescription } else if granted { permissionState = "Permission Granted" } else { permissionState = "Permission Denied" } } } } then the plist <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> <key>NSRemindersFullAccessUsageDescription</key> <string>something meaningful</string> </dict> </plist> I managed to find an error in the log saying Received error from calaccessd connection: Error Domain=NSCocoaErrorDomain Code=4099 "The connection to service named com.apple.CalendarAgent was invalidated: failed at lookup with error 159 - Sandbox restriction." UserInfo={NSDebugDescription=The connection to service named com.apple.CalendarAgent was invalidated: failed at lookup with error 159 - Sandbox restriction.}. Attempting to call any reply handler. So in the Signing & Capabilities tab I added Calendars to the App Sandbox, and that seemed to fix the issue, after that the user gets prompted for access to Reminders as expected or gets access depending on the access granted. Then I tried to release the app and I got rejected from the App Store because my app isn't using calendars, but of course I'm asking for access in the sandbox. So is this the wrong way to get permission for access, and if so, what is the correct way? Thanks!
1
0
1k
Feb ’24
@available(iOS 15.0, *) crashing on iOS 14.8 in TestFlight
I'm having an issue where iOS devices running iOS 14 are crashing, at first it was happening on the first view, so I decided I could probably live without the functionality and removed it, which worked, but then the same error happened in the next screen (one from a Sheet, the other from a NavigationView). I am unable to reproduce the error on physical devices deployed directly from Xcode (13.2 and 13.3) or in the simulator. One of the instances is the following (I stripped some things out for simplicity, just to show how I'm using it) struct TimeView: View { @State var time: Double var body: some View { VStack{ if #available(iOS 15.0, *) { TimeEditorView } else { TimeEditorView14 } } @available(iOS 15.0, *) var TimeEditorView: some View { TextField(Constants.Times.emptyTextHours, value: $time, format: .number) .keyboardType(.decimalPad) } var TimeEditorView14: some View { Text("\(time)") } } Since it's completely different code in different places, I'm thinking maybe it's a bug or a project setting or something like that (if I am using it wrong I would think it would crash locally). #0 (null) in closure #1 in TimeView.body.getter () #1 0x0000000102bdb190 in init at #2 (null) in body.get () #3 (null) in protocol witness for View.body.getter in conformance TimeView () #4 (null) in partial apply for closure #1 in ViewBodyAccessor.updateBody(of:changed:) () #5 (null) in closure #1 in BodyAccessor.setBody(_:) () #6 (null) in ViewBodyAccessor.updateBody(of:changed:) () Any suggestions of things to try are welcome, thanks! Edit: corrected the second view variable name
1
0
1k
Apr ’22
Fatal error: Index out of range: file Swift/ContiguousArrayBuffer.swift, line 444
I'm trying to present the items of an array in multiline text by looping over them in a ForEach. I need them to be able to be deleted, reordered and edited. I'm getting the index out of range error when I try to delete any of the items, and it's getting thrown in the AppDelegate (I tried stepping through to see where it was). If I replace the TextEditor with a regular text field I can delete without issue (TextField also crashes). It seems like the loop is throwing the error instead of updating the array? I can pass in the text as a constant and it doesn't crash, but then I can't edit it. Here is a simplified version of my code that I created to troubleshoot the issue. struct ContentView: View {   @State private var editMode: EditMode = .active   @State var array = ["one", "two", "three", "four"]       var body: some View {               List{         ForEach (0..<array.count, id: \.self) { index in           //Text(array[index])           //TextField("", text: array[$0])           TextEditor(text: $array[index])         }         .onDelete { indexSet in           let removeIndex = Int(Array(indexSet).first!)           array.remove(at: removeIndex)         }       }     } } I created another View that takes in the unbound value and displays it in a TextEditor, but I feel like that's not a good solution. I am new to Swift, so maybe I'm missing something simple? Is this how I should be creating this screen to do what I want in SwiftUI? Thanks!
4
1
8.0k
Dec ’20