admin管理员组文章数量:1406178
I'm developing a macOS app using EventKit to access calendar events, but I'm facing an issue where my app doesn't appear in System Settings > Privacy & Security > Calendar even after explicitly requesting permission. This makes it impossible for users to grant access to their calendars.
What I've tried
I've included all the required entitlements and Info.plist keys for calendar access:
Entitlements file:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" ".0.dtd">
<plist version="1.0">
<dict>
<key>com.apple.security.app-sandbox</key>
<true/>
<key>com.apple.security.files.user-selected.read-only</key>
<true/>
<key>com.apple.security.personal-information.calendars</key>
<true/>
</dict>
</plist>
Info.plist relevant entries:
<key>NSCalendarsUsageDescription</key>
<string>This app needs access to your calendar to display today's events</string>
<key>NSCalendarsFullAccessUsageDescription</key>
<string>This app needs full access to your calendar to display today's events</string>
<key>NSCalendarsWriteOnlyAccessUsageDescription</key>
<string>This app needs write access to your calendar to add and update events</string>
Code to request calendar access:
@available(macOS 14.0, *)
func requestAccess() {
Task {
// Try to access calendar events to trigger permission dialog
let calendar = Calendar.current
let startDate = calendar.startOfDay(for: Date())
let endDate = calendar.date(byAdding: .day, value: 1, to: startDate)!
let predicate = eventStore.predicateForEvents(withStart: startDate, end: endDate, calendars: nil)
let _ = eventStore.events(matching: predicate)
// Basic access request
let basicPromise = DispatchGroup()
basicPromise.enter()
eventStore.requestAccess(to: .event) { (granted, error) in
basicPromise.leave()
}
_ = basicPromise.wait(timeout: .now() + 5)
// Open system settings
if let url = URL(string: "x-apple.systempreferences:com.apple.settings.Privacy.Calendars") {
NSWorkspace.shared.open(url)
}
// Check status
let currentStatus = EKEventStore.authorizationStatus(for: .event)
// If basic access is granted, request full access
if currentStatus == .authorized || currentStatus == .fullAccess {
do {
let _ = try await eventStore.requestFullAccessToEvents()
} catch {
print("Full access error: \(error.localizedDescription)")
}
}
}
}
I've also tried:
- Manually opening System Settings > Privacy & Security > Calendar
- Using both the basic requestAccess(to: .event) and full access requestFullAccessToEvents() methods (macOS 14+)
- Force accessing calendar events before explicitly requesting permission
- Checking authorization status before and after requests
Environment
- macOS Sonoma (14.x)
- Xcode 15
- App is signed with a development certificate
- App is sandboxed
Expected behavior
After requesting calendar access, my app should appear in System Settings > Privacy & Security > Calendar, allowing users to grant permission.
Actual behavior
The app doesn't appear in the list of apps requesting calendar access. The permission dialog is never shown, and EKEventStore.authorizationStatus(for: .event) returns .notDetermined.
Any ideas why my app isn't showing up in the privacy settings and how to fix this issue?
I'm developing a macOS app using EventKit to access calendar events, but I'm facing an issue where my app doesn't appear in System Settings > Privacy & Security > Calendar even after explicitly requesting permission. This makes it impossible for users to grant access to their calendars.
What I've tried
I've included all the required entitlements and Info.plist keys for calendar access:
Entitlements file:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>com.apple.security.app-sandbox</key>
<true/>
<key>com.apple.security.files.user-selected.read-only</key>
<true/>
<key>com.apple.security.personal-information.calendars</key>
<true/>
</dict>
</plist>
Info.plist relevant entries:
<key>NSCalendarsUsageDescription</key>
<string>This app needs access to your calendar to display today's events</string>
<key>NSCalendarsFullAccessUsageDescription</key>
<string>This app needs full access to your calendar to display today's events</string>
<key>NSCalendarsWriteOnlyAccessUsageDescription</key>
<string>This app needs write access to your calendar to add and update events</string>
Code to request calendar access:
@available(macOS 14.0, *)
func requestAccess() {
Task {
// Try to access calendar events to trigger permission dialog
let calendar = Calendar.current
let startDate = calendar.startOfDay(for: Date())
let endDate = calendar.date(byAdding: .day, value: 1, to: startDate)!
let predicate = eventStore.predicateForEvents(withStart: startDate, end: endDate, calendars: nil)
let _ = eventStore.events(matching: predicate)
// Basic access request
let basicPromise = DispatchGroup()
basicPromise.enter()
eventStore.requestAccess(to: .event) { (granted, error) in
basicPromise.leave()
}
_ = basicPromise.wait(timeout: .now() + 5)
// Open system settings
if let url = URL(string: "x-apple.systempreferences:com.apple.settings.Privacy.Calendars") {
NSWorkspace.shared.open(url)
}
// Check status
let currentStatus = EKEventStore.authorizationStatus(for: .event)
// If basic access is granted, request full access
if currentStatus == .authorized || currentStatus == .fullAccess {
do {
let _ = try await eventStore.requestFullAccessToEvents()
} catch {
print("Full access error: \(error.localizedDescription)")
}
}
}
}
I've also tried:
- Manually opening System Settings > Privacy & Security > Calendar
- Using both the basic requestAccess(to: .event) and full access requestFullAccessToEvents() methods (macOS 14+)
- Force accessing calendar events before explicitly requesting permission
- Checking authorization status before and after requests
Environment
- macOS Sonoma (14.x)
- Xcode 15
- App is signed with a development certificate
- App is sandboxed
Expected behavior
After requesting calendar access, my app should appear in System Settings > Privacy & Security > Calendar, allowing users to grant permission.
Actual behavior
The app doesn't appear in the list of apps requesting calendar access. The permission dialog is never shown, and EKEventStore.authorizationStatus(for: .event) returns .notDetermined.
Any ideas why my app isn't showing up in the privacy settings and how to fix this issue?
Share Improve this question asked Mar 6 at 13:58 cpwcpw 2992 gold badges4 silver badges9 bronze badges 2 |1 Answer
Reset to default 0Answer:
I've managed to resolve this issue. It turns out the problem stemmed from my Info.plist
file not being properly managed as a recognized Info.plist
. Specifically, it seems the system wasn't correctly registering the necessary privacy keys.
Solution:
I fixed this by completely removing the existing Info.plist
file from my project and then adding a new, properly formatted Info.plist
file through Xcode's "File > New > File..." menu (selecting "Property List"). After re-entering the required NSCalendarsFullAccessUsageDescription
key, along with ensuring the entitlements were correctly set, the app now appears in the Privacy & Security > Calendar settings as expected.
Essentially, the issue was likely due to some corruption or incorrect formatting of the original Info.plist
that prevented the system from recognizing the privacy-related keys. Recreating it from scratch ensured it was properly registered.
本文标签:
版权声明:本文标题:swift - App doesn't appear in Privacy & Security Calendar settings when using EventKit on macOS - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744971384a2635253.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
requestAccess()
method where I call:swift eventStore.requestAccess(to: .event) { (granted, error) in basicPromise.leave() }
– cpw Commented Mar 6 at 15:35