Agent skills for iOS, iPadOS, Swift, SwiftUI, and modern Apple framework development.
71
89%
Does it follow best practices?
Impact
—
No eval scenarios have been run
Advisory
Suggest reviewing before use
Overflow reference for the device-integrity skill. Contains server verification details, advanced error handling, and integration patterns.
Your server must:
nonce in the attestation matches SHA256(challenge).See Validating apps that connect to your server for the full server verification algorithm.
Your server must:
clientDataHash matches the SHA-256 of the received request body.| Phase | When | What It Proves | Frequency |
|---|---|---|---|
| Attestation | After key generation | The key lives on a genuine Apple device running your unmodified app | Once per key |
| Assertion | With each sensitive request | The request came from the attested app instance | Per request |
keyId.Combine App Attest with fraud risk assessment for defense in depth. App Attest alone does not guarantee the user is not abusing the app -- it confirms the app is genuine.
import DeviceCheck
func handleAttestError(_ error: Error) {
if let dcError = error as? DCError {
switch dcError.code {
case .unknownSystemFailure:
// Transient system error -- retry with exponential backoff
break
case .featureUnsupported:
// Device or OS does not support this feature
// Fall back to alternative verification
break
case .invalidKey:
// Key is corrupted or was invalidated
// Generate a new key and re-attest
break
case .invalidInput:
// The clientDataHash or keyId was malformed
break
case .serverUnavailable:
// Apple's attestation server is unreachable -- retry later
break
@unknown default:
break
}
}
}extension AppAttestManager {
func attestKeyWithRetry(maxAttempts: Int = 3) async throws -> Data {
var lastError: Error?
for attempt in 0..<maxAttempts {
do {
return try await attestKey()
} catch let error as DCError where error.code == .serverUnavailable {
lastError = error
if attempt < maxAttempts - 1 {
try await Task.sleep(for: .seconds(pow(2.0, Double(attempt + 1))))
}
} catch {
throw error // Non-retryable errors propagate immediately
}
}
throw lastError ?? DeviceIntegrityError.attestationFailed
}
}If attestKey returns DCError.invalidKey, the Secure Enclave key has been
invalidated (e.g., OS update, Secure Enclave reset). Delete the stored keyId
from Keychain and generate a new key:
extension AppAttestManager {
func handleInvalidKey() async throws -> String {
deleteKeyIdFromKeychain()
keyId = nil
return try await generateKeyIfNeeded()
}
private func deleteKeyIdFromKeychain() {
let query: [String: Any] = [
kSecClass as String: kSecClassGenericPassword,
kSecAttrAccount as String: "app-attest-key-id",
kSecAttrService as String: Bundle.main.bundleIdentifier ?? ""
]
SecItemDelete(query as CFDictionary)
}
}Combine the patterns above into a single actor that manages the full lifecycle:
isSupported and fall back to DCDevice tokens on unsupported devices.generateKeyIfNeeded() on launch to create or load the persisted key.attestKeyWithRetry() once after key generation.generateAssertion(for:) on each sensitive server request.DCError.invalidKey by regenerating and re-attesting.Apple recommends a gradual rollout. Gate App Attest behind a remote feature
flag and fall back to DCDevice tokens on unsupported devices.
Set the App Attest environment in your entitlements file. Use development
during testing and production for App Store builds:
<key>com.apple.developer.devicecheck.appattest-environment</key>
<string>production</string>When the entitlement is missing, the system uses development in debug builds
and production for App Store and TestFlight builds.
enum DeviceIntegrityError: Error {
case deviceCheckUnsupported
case keyNotGenerated
case attestationFailed
case attestationVerificationFailed
case assertionFailed
case serverVerificationFailed
}skills
accessorysetupkit
references
activitykit
references
adattributionkit
references
alarmkit
references
app-clips
app-intents
references
app-store-optimization
app-store-review
apple-on-device-ai
appmigrationkit
references
audioaccessorykit
references
authentication
references
avkit
references
background-processing
references
browserenginekit
references
callkit
references
carplay
references
cloudkit
references
contacts-framework
references
core-bluetooth
references
core-data
core-motion
references
core-nfc
references
coreml
references
cryptokit
references
cryptotokenkit
references
debugging-instruments
device-integrity
references
dockkit
references
energykit
references
eventkit
references
financekit
references
focus-engine
gamekit
references
healthkit
references
homekit
references
ios-accessibility
ios-localization
ios-networking
ios-simulator
references
mapkit
metrickit
references
musickit
references
natural-language
references
paperkit
references
passkit
references
pdfkit
references
pencilkit
references
permissionkit
references
photokit
push-notifications
realitykit
references
relevancekit
references
scenekit
references
sensorkit
references
speech-recognition
spritekit
references
storekit
swift-api-design-guidelines
swift-architecture
swift-charts
references
swift-codable
swift-concurrency
swift-formatstyle
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-uikit-interop
swiftui-webkit
tabletopkit
references
tipkit
references
vision-framework
weatherkit
references
widgetkit
references