Community-maintained Agent Skills for complete Swift and Apple-platform app delivery.
72
90%
Does it follow best practices?
Run evals on this skill
Adds up to 20 points to the overall score
View guide
Medium
Suggest reviewing before use
Detailed recipes for DeviceActivityMonitor, custom shield UI styling, shield actions, and inter-process sharing in Screen Time apps.
The monitor runs in a separate app extension process triggered by the system DeviceActivity daemon.
import DeviceActivity
import ManagedSettings
import Foundation
class MyDeviceActivityMonitor: DeviceActivityMonitor {
private let store = ManagedSettingsStore(named: .init("ScheduledShield"))
override func intervalDidStart(for activity: DeviceActivityName) {
super.intervalDidStart(for: activity)
guard let groupDefaults = UserDefaults(suiteName: "group.com.example.screentime"),
let data = groupDefaults.data(forKey: "ShieldedSelection"),
let selection = try? PropertyListDecoder().decode(FamilyActivitySelection.self, from: data) else {
return
}
// Apply shields when the schedule begins
store.shield.applications = selection.applicationTokens
store.shield.webDomains = selection.webDomainTokens
}
override func intervalDidEnd(for activity: DeviceActivityName) {
super.intervalDidEnd(for: activity)
// Clear shields when the scheduled window ends
store.clearAllSettings()
}
override func eventDidReachThreshold(for activity: DeviceActivityName, event: DeviceActivityEvent.Name) {
super.eventDidReachThreshold(for: activity, event: event)
// User exceeded daily quota: lock selected apps
if let groupDefaults = UserDefaults(suiteName: "group.com.example.screentime"),
let data = groupDefaults.data(forKey: "ShieldedSelection"),
let selection = try? PropertyListDecoder().decode(FamilyActivitySelection.self, from: data) {
store.shield.applications = selection.applicationTokens
}
}
}Customize the shield screen title, body, icon, and button styling displayed when a user opens a shielded application:
import ManagedSettingsUI
import UIKit
class ShieldConfigurationExtension: ShieldConfigurationDataSource {
override func configuration(shielding application: Application) -> ShieldConfiguration {
ShieldConfiguration(
backgroundBlurStyle: .systemUltraThinMaterial,
backgroundColor: UIColor.systemBackground,
title: ShieldConfiguration.Label(text: "Focus Session Active", color: .label),
subtitle: ShieldConfiguration.Label(text: "This app is shielded during your scheduled focus time.", color: .secondaryLabel),
primaryButtonLabel: ShieldConfiguration.Label(text: "Take a Break", color: .white),
primaryButtonBackgroundColor: .systemIndigo,
secondaryButtonLabel: ShieldConfiguration.Label(text: "Dismiss", color: .systemIndigo)
)
}
override func configuration(shielding webDomain: WebDomain) -> ShieldConfiguration {
ShieldConfiguration(
title: ShieldConfiguration.Label(text: "Domain Blocked", color: .label),
subtitle: ShieldConfiguration.Label(text: "Web access is restricted during focus hours.", color: .secondaryLabel),
primaryButtonLabel: ShieldConfiguration.Label(text: "Close", color: .white),
primaryButtonBackgroundColor: .systemBlue
)
}
}Handle taps on the custom primary and secondary shield buttons:
import ManagedSettings
class ShieldActionExtension: ShieldActionDelegate {
override func handle(
action: ShieldAction,
for application: ApplicationToken,
completionHandler: @escaping (ShieldActionResponse) -> Void
) {
switch action {
case .primaryButtonPressed:
// Custom logic (e.g. grant temporary emergency snooze)
completionHandler(.defer)
case .secondaryButtonPressed:
// Close the shield UI
completionHandler(.close)
@unknown default:
completionHandler(.close)
}
}
}Create cumulative time limit monitors with DeviceActivityEvent:
import DeviceActivity
import FamilyControls
final class UsageThresholdService {
private let center = DeviceActivityCenter()
func scheduleTimeLimit(selection: FamilyActivitySelection, limitMinutes: Int) throws {
let schedule = DeviceActivitySchedule(
intervalStart: DateComponents(hour: 0, minute: 0),
intervalEnd: DateComponents(hour: 23, minute: 59),
repeats: true
)
let eventName = DeviceActivityEvent.Name("DailyLimitEvent")
let event = DeviceActivityEvent(
applications: selection.applicationTokens,
categories: selection.categoryTokens,
webDomains: selection.webDomainTokens,
threshold: DateComponents(minute: limitMinutes)
)
let activityName = DeviceActivityName("DailyLimitMonitoring")
try center.startMonitoring(activityName, during: schedule, events: [eventName: event])
}
}.tessl-plugin
skills
accessorysetupkit
references
activitykit
adattributionkit
references
alarmkit
references
app-clips
app-intents
app-store-optimization
app-store-review
apple-on-device-ai
appmigrationkit
audioaccessorykit
references
authentication
references
avfoundation-audio
references
avkit
background-processing
references
browserenginekit
callkit
references
carplay
cloudkit
contacts-framework
references
core-bluetooth
references
core-data
core-haptics
references
core-motion
references
core-nfc
references
coreml
references
cryptokit
cryptotokenkit
debugging-instruments
device-integrity
references
energykit
references
eventkit
family-controls
references
financekit
focus-engine
gamekit
git-branching-workflow
references
healthkit
references
homekit
references
ios-accessibility
ios-app-workflow
references
ios-ettrace-performance
ios-localization
ios-memgraph-analysis
ios-networking
ios-simulator
references
metrickit
references
musickit
references
natural-language
paperkit
references
passkit
references
pdfkit
pencilkit
references
permissionkit
references
photokit
push-notifications
quicklook
references
realitykit
references
relevancekit
references
scenekit
sensorkit
shazamkit
references
speech-recognition
references
spritekit
storekit
swift-api-design-guidelines
swift-architecture
references
swift-charts
swift-codable
references
swift-code-review
swift-concurrency
swift-formatstyle
references
swift-language
swift-security
references
swift-testing
swiftdata
swiftlint
swiftui-animation
swiftui-gestures
references
swiftui-layout-components
swiftui-liquid-glass
references
swiftui-patterns
swiftui-performance
swiftui-responsive-layout
swiftui-uikit-interop
swiftui-webkit
tabletopkit
tipkit
vision-framework
weatherkit
references