Post

Replies

Boosts

Views

Activity

Not getting CloudKit silent push notifications on macOS
I have an iOS app and macOS app that sync data using CloudKit (no CoreData involved). Syncing mostly works, except that on my development machine I don't get any push notifications when other devices make changes. For example I can make a data change on macOS and it gets pushed to my iOS app immediately, however if I make a change on iOS, the macOS app never gets a notification. I can check in CloudKit dashboard and the data has been updated, and a push was sent, but the macOS app never gets it. The subscription is set up like so (same code on macOS and iOS) and it reports success on both platforms: private func subscribeToCloudKitChanges() { 		if UserDefaults.standard.bool(forKey: ckSubscriptionStateKey) == true { return } 		 		let subscription = CKDatabaseSubscription(subscriptionID: cloudKitPrivateChangeID) 		let notificationInfo = CKSubscription.NotificationInfo() 		notificationInfo.shouldSendContentAvailable = true 		subscription.notificationInfo = notificationInfo 		 		let op = CKModifySubscriptionsOperation( 				subscriptionsToSave: [subscription], 				subscriptionIDsToDelete: [] 		) 		op.modifySubscriptionsCompletionBlock = { (_, _, error) in 				if let error = error { 						logger.error("Error setting up CloudKit subscriptions: \(error.localizedDescription)") 						UserDefaults.standard.set(false, forKey: ckSubscriptionStateKey) 				} else { 						logger.log("CloudKit subscriptions created") 						UserDefaults.standard.set(true, forKey: ckSubscriptionStateKey) 				} 		} 		op.qualityOfService = .utility 		ckContainer.privateCloudDatabase.add(op) } The remote notifications are requested like so, and always reports that is is registered. Though oddly enough I never get the callback to say it has been registered? func applicationDidFinishLaunching(_ notification: Notification) { 		NSApplication.shared.registerForRemoteNotifications() 		print("Requested remote notifications. Status: \(NSApplication.shared.isRegisteredForRemoteNotifications)") //... And finally, to receive the iCloud change notification: func application(_ application: NSApplication, didReceiveRemoteNotification userInfo: [String : Any]) {     guard let ckn = CKDatabaseNotification(fromRemoteNotificationDictionary: userInfo) else { return }     if ckn.subscriptionID == cloudKitPrivateChangeID {         DispatchQueue.main.async {             self.cloudKitPrivateDBChanges.send(ckn)         }    } }
3
2
2.1k
Jan ’21
Animating popover size changes
According to the HIG, - https://developer.apple.com/design/human-interface-guidelines/macos/windows-and-views/popovers/ changes in popover size should be animated: Animate changes in size to avoid giving the impression that a new popover replaced the old one. How can this be done in SwiftUI? No matter where I put .animate() annotations, I can't get the actual popover frame to transition smoothly. Best I can get is that the popover frame changes immediately, and then the controls awkwardly animate over to the right location.
4
2
1.5k
Nov ’20
System keychain from daemon access requires root?
I have a macOS daemon that needs to store a password. If I run the daemon as root, I can store and retrieve the password in the system keychain, but if I create a dedicated user/group for the daemon (so it runs as user _myDaemon for example), adding the password to the keychain fails with -61 (errSecWrPerm). My daemon will be responding to network requests so I would prefer it to not run as root for security reasons. I'm not sure what is the best way to proceed: Is there a way to grant system keychain access for a dedicated daemon user? Should I split off the keychain access into a "helper daemon" that runs as root? Something else?
2
0
1.5k
Aug ’20
Xcode 12 can't add package dependency from ssh?
I have a local file server with git repositories and ssh access. I have several swift packages stored there, and some of them have been successfully added as dependencies in projects using Xcode 11. I am now unable to add any package dependencies like this in Xcode 12. I can successfully clone the repo from the Source Control -> Clone... menu so I know the repo is valid. The steps I am following are to add the dependency: File -> Swift Packages -> Add Package Dependency... Enter: ssh://MyServer.local/path/to/git/repo Xcode prompts for credentials -> success Xcode asks for the import rules, with correctly filled in version numbers (so I know it can access the repo at this point) I accept the defaults, click "next" I get the following error: The source control operation failed because no working copy could be found. Make sure the file is in a valid working copy and try again. Any idea how resolve this? Existing SPM packages resolve and work correctly, but I can't add any new ones.
1
0
7.0k
Jul ’20
When is DispatchIO cleanup handler called?
I am creating DispatchIO channels using the file descriptor constructor:self.channel = DispatchIO(type: .random, fileDescriptor: self.file, queue: fileProcessingQueue, cleanupHandler: { (errorCode) in // clean up when the channel closes })The documentation for cleanupHandler states:"The handler to execute once the channel is closed."The better documentation (when you switch language to ObjC) states:"The block to enqueue when the system relinquishes control of the channel’s file descriptor.""... the system takes control of the specified file descriptor until one of the following occurs:You close the channel by calling the dispatch_io_close function. ..."So from both of these, I expect the handler gets enqueued and executed if I callself.channel.close(flags [.stop])But it seems to never get executed under this condition. In fact, it's very difficult to get the cleanup handler to be called at all. The only way so far I have been able to get it to execute is by calling close() on the underlying file descriptor. Am I doing something wrong here? There's cleanup that I want to do when the channel closes that is different than the cleanup I want to do when I'm done with the file descriptor. Is this not the correct place to do it?
7
0
1.2k
Jun ’20
GKRidgeNoiseSource broken?
Prior to Mac OS X 10.12.2 I had been using the code below to generate ridge noise the looked more or less like the picture in the documentation for GKRidgeNoiseSource:let srcRidges = GKRidgedNoiseSource(frequency: 0.1, octaveCount: 2, lacunarity: 1.5, seed: 12345) let noise = GKNoise(srcRidges) let map = GKNoiseMap(noise, size: vector_double2(x:200, y: 200), origin: vector_double2(x:0, y:0), sampleCount: vector_int2(x:200, y:200), seamless: false) let tex = SKTexture(noiseMap: map) let cgimg = tex.cgImage() let nsimg = NSImage(cgImage: cgimg, size: NSSize(width: 200, height: 200))The same code after 10.12.2 produces mostly garbage, as can be seen by pasting this into a playground. Am I using it wrong, or did something break with this noise source?
1
0
1.1k
May ’17