My question
Is there a way to perform an iCloud keychain reset in order to be able to test CKErrorUserDidResetEncryptedDataKey ?
I found this section in the CloudKit documentation
https://developer.apple.com/documentation/cloudkit/encrypting-user-data#Handle-a-User-Keychain-Reset
I want to be prepared for the zoneNotFound / CKErrorUserDidResetEncryptedDataKey case.
However, I can't find a way to actually reproduce this error with an iCloud (test-) user and can't find any Apple documentation on how to perform sucha "User Keychain Reset".
The only thing that almost looked like it I came across was in the Keychain.app's Settings "Reset Default Keychains…". However, performing this didn't seem to affect the CloudKit data used in our App at all.
I've been trying to do this with an Apple account that has 2FA active and a recovery account assigned.
We're only targetting >= iOS 18, macOS >= 15.
Post
Replies
Boosts
Views
Activity
I'm implementing a timer feature and facing the issue that the live activity I'm starting just continues showing after the timer is complete.
The body of the live activity widget is more or less:
ActivityConfiguration(for: WhendyWidgetAttributes.self) { context in
VStack {
Text(
context.state.timerEndDate,
style: .timer
)
// if Date.now < timerEndTime { Text("Done") }
self.expandedView(state: context.state)
}
} …
Ideally I could get the activity to show something else when it is done but I don't know how to get it to re-evaluate it's body once the end time is reached.
I create the activity with
let activity = try ActivityKit.Activity.request(
attributes: attributes,
content: .init(
state: .init(timerEndDate: timerEndDate),
staleDate: timerEndDate
),
pushType: nil
)
Can I schedule the activity to do a refresh it's body (and reevaluating Date.now) once the timerEndDate is reached?
Considered Approaches
trying staleDate
However, the activity never shows that it has become stale. Would it be expected that it shows the stale-ness?
scheduling dismissal
I also thought about starting and immediately stopping the activity with a delayed dismissal, but unfortunately it seems this is limited to a 4 hour window, and I'd like longer timers too.
remote updates
I understand I could use remote notifications to update the live activity, but I'd really like to keep things local as all the functionality is locally plannable.
Background Tasks
I understand these don't run reliably or at a predictable time.
A Timer in the app that updates the content
I think this would only update the activity while the app is in foreground.
Is it possible to write to an App Group's Container folder or UserDefaults from an iOS Thumbnail Extension or QuickLook Extension?
It doesn't work. It does work for a Widget extension.
I've added the App Group to the Entitlements of each extension.
For writing a file to App Group Container I get
Error Domain=NSCocoaErrorDomain Code=513 "Du hast nicht die Zugriffsrechte, um die Datei „quicklook 01 current.log“ im Ordner „DocumentInvestigation“ zu sichern." UserInfo={NSFilePath=/private/var/mobile/Containers/Shared/AppGroup/<redacted: the container UUID>/DocumentInvestigation/quicklook 01 current.log, NSUnderlyingError=0x28090bb10 {Error Domain=NSPOSIXErrorDomain Code=1 "Operation not permitted"}}
For setting App Group UserDefaults
[User Defaults] Couldn't write values for keys (
		example
) in CFPrefsPlistSource<0x2839cc700> (Domain: <redacted: the-group-identifier>, User: kCFPreferencesCurrentUser, ByHost: No, Container: (null), Contents Need Refresh: No):
setting preferences outside an application's container requires user-preference-write or file-write-data sandbox access
The use case is, that we are investigating an issue and would like to log to a file which we then can have customers send us.
We have an issue with documents stored on a shared iCloud drive folder, where the document reloads too often, sometimes even intermittently reverting to a stale older data.
A very nice DTS lab during WWDC20 (with engineer Chen) could not solve the issue.
Question to the forum crowd
Does anybody also have this iCloud drive shared folder issue, and know a work around?
How can we distinguish older data coming in from newer data?
Here is a copy of the Feedback FB7772855
The Issue
The NSDocument may intermittently reload with older data than was last saved, when storing an NSDocument in a iCloud Drive shared folder. This happens without any other device editing concurrently.
Reproduce
Create an iCloud Drive shared folder on a different AppleID
Open and Run the attached sample project, or get it at https://github.com/hannesoid/iCloudSharedFolderDocumentIssue
The attached sample project uses a text field which reads/stores a String as an NSDocument
The attached sample project shows a list of log entries indicating what data was written and read by AppKit and when FileCoordination happens
The attached sample project shows the NSDocument.lastModifiedDate
Start typing into the the textfield and occasionally hit CMD+S (Save).
Expected
NSDocument should never read older data than what was last saved
The file modification date should remain as last saved.
Actual
Sometimes the TextField reverts to a previous state
In the log you see that there can be sequences where after Writing a certain Text to disk, a bit later an older state is read from disk. This is after filecoordination relinquished to a writer (probably icloud deamon). Then, a second or so later it reads again and then has the current data again.
The file modification dates known by the NSDocument are also changed, dates get their milliseconds truncated after file coordination.
System
Tested on macOS 10.15.5