Posts

Post not yet marked as solved
0 Replies
699 Views
I'm looking at the open source code for the pmset command and attempting to modify the DisableSleep key in macOS's power management settings.It seems to come down to running the following line of code where msdict contains a boolean value for "SleepDisabled":let PMEyeIOCFPrefsPath = "com.apple.PowerManagement" let PMEIOSystemPowerSettingsKey = "SystemPowerSettings" CFPreferencesSetValue(PMEIOSystemPowerSettingsKey as CFString, msdict as CFDictionary, PMEyeIOCFPrefsPath as CFString, kCFPreferencesAnyUser, kCFPreferencesCurrentHost)You need to be root to do this, and this code won't run from the pmset command line tool unless run as root. When I run the above from a menubar app I'm writing, I get the following explanation...2020-03-19 16:15:03.527875+0000 Open Eye[16320:301001] [User Defaults] attempt to set { SleepDisabled = 1; "Update DarkWakeBG Setting" = 1;} for key in SystemPowerSettings in read-only (due to a previously logged write error) preferences domain CFPrefsPlistSource<0x600002c14e80> (Domain: com.apple.PowerManagement, User: kCFPreferencesAnyUser, ByHost: Yes, Container: (null), Contents Need Refresh: No)Ultimately I'm trying to run a few pmset commands from a menubar app so I don't have to continually lookup keys and open the terminal just to keep my system awake. So how can I get this code to run with or without a popup to authenticate as root?
Posted Last updated
.
Post not yet marked as solved
0 Replies
477 Views
I was hoping to write some automation around the simctl utility and I'm wondering if anyone knows how to deteremine which app has been launched most recently on a simulator?I've tried inspecting the modification timestamps on files and directories with varying degrees of success. Maybe there's a SQLite store or plist for the Springboard that I could query? Any advice would be greatly welcomed.
Posted Last updated
.
Post marked as solved
5 Replies
1.9k Views
I just opened up a Swift Package in Xcode that I'm developing and the majority of the Swift files are disabled. I click on them and I get a system noise but that is all. In the Inspector pane, they aren't even recognised as Swift source. If I select Swift source from the Type drop down list, I notice that the text encoding is set to No Explicit Encoding. If I select UTF-8 it prompts me to confirm conversion, so I backed out. The reason I did, is that from the command line, if I use the `file -I` command it tells me that the files are indeed UTF-8. Also, for a project that had schemes, it now has none. I know the default is to create a Swift Package without a scheme, but I prefer what I'm familiar with.I recloned the repo from bitbucket, but the results were exactly that same. So now I'm not sure where the problem is. Did Bitbucket corrupt my files? Are both Xcode 11.1 and Xcode 11.2 Beta 2 to blame? I doubt it, but the files are clearly Swift UTF-8. Any ideas on how I can get Xcode to recognise my Swift source and magically restore my schemes? :-(
Posted Last updated
.
Post not yet marked as solved
2 Replies
1.3k Views
I'm wanting to perform an rsync style backup (where only the diff is pushed to a remote machine) of my working directories. I've read that rsync isn't able to handle all of the advances APFS has made with regard to the various file system properties one would want to retain in a backup. Encryption keys etc. Is it possible to do this just using Apple tools, and if not, is there an open source tool out there that could help? All I'm really doing is copying an hourly diff to iCloud. As a Developer, I don't really feel I should have to resort to using something like Carbon Copy Cloner for this.BTW I'm already Time Machining to two seperate devices, so I'm wanting an off-site copy of select directories of my laptop. I'm also not sure if working directly off of the iCloud container is a good idea when using Xcode and doing Zsh/Vim work.
Posted Last updated
.
Post not yet marked as solved
4 Replies
1.4k Views
I’m a bit baffled by the tell statement. While its very easy to simply write `tell application “Xcode”` all the time and just get on with life, I’m not so inclined. I want to learn and use AppleScript's object-oriented type system. The documentation for the tell command clearly states the syntax as:tell referenceToObject [ statement ]... end [ tell ]Where referenceToObject is defined asreferenceToObject Any object. Typically an object specifier or a reference object (which contains an object specifier).I have two different attempts at this one line of code. The first one is using the "application “Name”" method, the second is more indirect. And even though I’ve also tried setting the xcode property to a reference to the application specifier, the code still won’t compile.Direct: all is calm, all is bright :-)on direct() tell application "Xcode" get the name of the active run destination of the active workspace document end tell end directIndirect: armageddonproperty xcode : application "Xcode" on indirect() tell xcode get the name of the active run destination of the active workspace document end tell end indirectWhen compiling, it highlights the word “destination” and displays the following error reason:Expected “given”, “with”, “without”, other parameter name, etc. but found identifier.Note: “active run destination” is a property on a “workspace document” class, of which “active workspace document” is a property on the Xcode application object.Even with xcode defined as `property xcode : a reference to application "Xcode”` it still gives the same error message.Why does the second approach not work, when the documentation says it should work with a reference or a specifier? Is something wrong with my `tell xcode` clause? How do I get the second approach to work?
Posted Last updated
.
Post not yet marked as solved
2 Replies
701 Views
I'm experimenting with using Core Data for CloudKit as the main store for my app. It's a brilliant bit of technology that can save you a ton of time. It's great that the background syncing just happens. And that's great today, but I've been thinking about usage scenarios that will only occur in the future, and I have some questions for the Core Data team.A brief explanation of my apps data model so you understand the issue I'll have. I don't think this issue will be unique to me however, far from it. My app's data model represents something a lot like the file system on macOS. It's a tree structure and at the very root of that tree are system owned directories. Without these directories present, users can't add their own directories and content. So there's this dependency. The reason the system owned directories are stored in Core Data and not hard-coded somewhere is to allow users to move and hide them etc. Plus user content needs to be related to them, and I want to implement CloudKit sharing of them too.Now let's say I have a user that only owns an iPhone. They download my app and use it for a year, generating 10,000+ managed objects all stored as CKRecords up in the cloud. They then decide to buy an iPad and install my app on it. The CloudKit backed store is loaded on their device and an initial sync occurs. What gets downloaded first during this sync? Can we control what gets downloaded first? Is there some priority we can set? If my system directories aren't downloaded first, I'm very concerned that my users will end up having to wait an extended period of time before they can actually use the app. Even without system directories, if you look at an app like the Apple Notes app, users would expect to see the list of top level folders first. (I'm assuming Notes uses CloudKit API directly.) Is Core Data for CloudKit a good fit, or can it cater for the above scenario I've described? It doesn't really matter what your data model looks like, I think a lot of develops will come to this same scenario sooner or later. I've wondered whether storing the system folders in CloudKit is a better approach, because I can fetch them on-demand before I even begin a Core Data for CloudKit load/initial sync. But then I'll have to manage the relationships across this bridge manually, and lose some of CD4CKs awesomeness. Even if I do this, my users will still have 10,000s of CKRecords that will need to be synced down to a new install, so what can we expect to happen in this scenario? Will my users discover that their existing content simply appears in the new app like the pieces of a puzzle being filled in randomly? Some enlightenment would be great. Thanks.
Posted Last updated
.
Post not yet marked as solved
0 Replies
517 Views
I have a MOM that has multiple configurations. One configuration is for Core Data for CloudKit, and another is for a local store. There are no relationships between the entities in the local configration and the cloudkit configuration, so practically I could load my local store into a seperate NSPersistentContainer, if I moved my local configuration to a new MOM. However, is it possible to delay the loading of some stores in a MOM? The more I think about it, the less feasable it probably is. At present all stores are loaded into an NSPersistentCloudKitContainer in one shot, but I would like to just set the local store description on the container, and perform loadPersistentStores. Once my app is in a specific state, I would like to add the cloudkit store description to the container's list of persistent store descriptions and then call loadPersistentStores again, hoping that the container would load the cloudkit configuration's newly added store description, and not attempt to reload the local store.I can see why this could be problematic, given that you could have relationships that can't be realized until all store descriptions/configurationss for a container are loaded.Is this an approach I can take, or are containers not designed to be used in this way?
Posted Last updated
.
Post marked as solved
1 Replies
410 Views
In the 2019 WWDC sessiom 202 "Using Core Data With CloudKit" it was mentioned...“we're also introducing a new sample application this year that's designed to give you something to hold in your hands, to feel how NSPersistentCloudKitContainer works along with all these other features of Core Data.”Does anyone know if that's available yet, and if so, where to find it? Or even when it might be available? Thanks.
Posted Last updated
.
Post not yet marked as solved
1 Replies
1.5k Views
By the time this debug output is printed, I've loaded 2 store descriptions, into a NSPersistentCloudKitContainer, that both have the NSPersistentCloudKitContainerOptionsKey set, both with differing containerIdentifiers that exist in iCloud. Yet, attempting to initialize the schema fails saying none of my store descriptions in the coordinator are configured to use CloudKit. They definitely are configured in the MOM. Other observations: I'm beginning to think it's not advisable to have 2 configurations in one MOM that both point to different iCloud containers, because Xcode tells me that I have to add entities from one CloudKit configuration into another CloudKit configuration in order to get it to compile. Yet the one configuration contains just a single entity with no relationships at all. So that's really unexpected. Will Core Data attempt to generate CKRecords in both containers for the entities that appear in both CloudKit configurations? Perhaps it's best to use seperate MOMs (and an associated NSPersistentCloudKitContainer) for seperate CloudKit container backed configurations/stores. Any help, from anyone on this issue would be greatly appreciated. 2019-08-20 22:08:00.401657+0100 TerrestrialTester[78354:2511978] Initialization options: NSPersistentCloudKitContainerSchemaInitializationOptions(rawValue: 4)CoreData: debug: CoreData+CloudKit: -[PFCloudKitOptionsValidator validateOptions:andStoreOptions:error:](35): Validating options: <NSCloudKitMirroringDelegateOptions: 0x6000037096c0> containerIdentifier:iCloud.com.terrestrialbytes.Terrestrial ckAssetThresholdBytes:<null> operationMemoryThresholdBytes:<null> useEncryptedStorage:NO automaticallyDownloadFileBackedFutures:NO automaticallyScheduleImportAndExportOperations:YES skipCloudKitSetup:NO preserveLegacyRecordMetadataBehavior:NO useDaemon:YES apsConnectionMachServiceName:<null> containerProvider:<PFCloudKitContainerProvider: 0x600001e18320> storeMonitorProvider:<PFCloudKitStoreMonitorProvider: 0x600001e18350> scheduler:<null> notificationListener:<null> containerOptions:<null>storeOptions: { NSAddStoreAsynchronouslyOption = 1; NSInferMappingModelAutomaticallyOption = 1; NSMigratePersistentStoresAutomaticallyOption = 1; NSPersistentCloudKitContainerOptionsKey = "<NSPersistentCloudKitContainerOptions: 0x600001c55be0>"; NSPersistentHistoryTrackingKey = 1; NSPersistentStoreMirroringOptionsKey = { NSPersistentStoreMirroringDelegateOptionKey = "<NSCloudKitMirroringDelegate: 0x600002d0d220>"; };}CoreData: debug: CoreData+CloudKit: -[PFCloudKitOptionsValidator validateOptions:andStoreOptions:error:](35): Validating options: <NSCloudKitMirroringDelegateOptions: 0x600003703410> containerIdentifier:iCloud.com.terrestrialbytes.Appture ckAssetThresholdBytes:<null> operationMemoryThresholdBytes:<null> useEncryptedStorage:NO automaticallyDownloadFileBackedFutures:NO automaticallyScheduleImportAndExportOperations:YES skipCloudKitSetup:NO preserveLegacyRecordMetadataBehavior:NO useDaemon:YES apsConnectionMachServiceName:<null> containerProvider:<PFCloudKitContainerProvider: 0x600001e00710> storeMonitorProvider:<PFCloudKitStoreMonitorProvider: 0x600001e00730> scheduler:<null> notificationListener:<null> containerOptions:<null>storeOptions: { NSAddStoreAsynchronouslyOption = 1; NSInferMappingModelAutomaticallyOption = 1; NSMigratePersistentStoresAutomaticallyOption = 1; NSPersistentCloudKitContainerOptionsKey = "<NSPersistentCloudKitContainerOptions: 0x600001c55ba0>"; NSPersistentHistoryTrackingKey = 1; NSPersistentStoreMirroringOptionsKey = { NSPersistentStoreMirroringDelegateOptionKey = "<NSCloudKitMirroringDelegate: 0x600002d014a0>"; };}2019-08-20 22:08:00.408956+0100 TerrestrialTester[78354:2511978] error: A Core Data error occurred.2019-08-20 22:08:00.409321+0100 TerrestrialTester[78354:2511978] userInfo: { NSLocalizedFailureReason = "Couldn't initialize CloudKit schema because no stores in the coordinator are configured to use CloudKit: (\n)";}
Posted Last updated
.
Post not yet marked as solved
0 Replies
599 Views
I have managed to successfully initialize a schema in this zone before, but on this ocassion I'm told that it can't find the com.apple.coredata.cloudkit.zone zone. I could submit the entire schema generation output as a bug report if someone at Apple want's to investigate this. I don't know how much use it will be. CoreData: error: CoreData+CloudKit: -[NSCloudKitMirroringDelegate _performSchemaInitializationRequest:]_block_invoke(2396): <NSCloudKitMirroringDelegate: 0x60000303c000>: Schema initialization failed for store: 706C5130-0E19-4FE7-8C37-E7A22B32FF3E with error:<CKError 0x600000fdc330: "Partial Failure" (2/1011); "Failed to modify some records"; uuid = 8BF219C9-62F8-410C-89F0-045B787090BC; container ID = "iCloud.com.terrestrialbytes.Appture"; partial errors: { CD_FAKE_Version_AC792676-AE70-471B-BD2C-CB33335B5166:(com.apple.coredata.cloudkit.zone:__defaultOwner__) = <CKError 0x600000ff0ff0: "Zone Not Found" (26/2036); server message = "Zone 'com.apple.coredata.cloudkit.zone' does not exist"; uuid = 8BF219C9-62F8-410C-89F0-045B787090BC> CD_FAKE_App_9CC399C2-47B2-4D36-AFEC-F58695083518:(com.apple.coredata.cloudkit.zone:__defaultOwner__) = <CKError 0x600000fde0a0: "Zone Not Found" (26/2036); server message = "Zone 'com.apple.coredata.cloudkit.zone' does not exist"; uuid = 8BF219C9-62F8-410C-89F0-045B787090BC> CD_FAKE_Feature_2B727DD6-8246-4BE4-99A6-123DC4F56FED:(com.apple.coredata.cloudkit.zone:__defaultOwner__) = <CKError 0x600000fa1c20: "Zone Not Found" (26/2036); server message = "Zone 'com.apple.coredata.cloudkit.zone' does not exist"; uuid = 8BF219C9-62F8-410C-89F0-045B787090BC> ... 1 "Batch Request Failed" CKError's omited ...}>
Posted Last updated
.
Post not yet marked as solved
6 Replies
1.4k Views
I get a plugin loading error when I launch the latest Xcode beta. Anyone else seeing this? It looks like I might need a more recent version of Swift, but I have installed the Command Line Tools that are for Beta 5. And I'm really not keen on installing Development Snapshots of Swift even though there is one for Xcode published on the 25 July. Which is more recent than my libswiftCore.dylib that seems to be missing a symbol."Symbol not found: _$s2IDs12IdentifiablePTl\n Referenced from: /Applications/Xcode-beta.app/Contents/PlugIns/UVKit.framework/UVKit\n Expected in: /usr/lib/swift/libswiftCore.dylib" Anyone know how to fix this? Or what I could try? Thanks.
Posted Last updated
.
Post marked as solved
1 Replies
2.4k Views
In one of this year's (2019) WWDC presentations, a speaker briefly demonstrated dragging an editor pane around in a window to reorganise the panes he had open. A thin blue line appears when you're hovering between other editor panes to show you where the pane you're dragging will land. (He did one or two similar actions but didn't reveal how he was doing it.) I can't find anything in the Xcode "help", or online (yet). There are a few posts on reddit regarding Xcode shortcuts but I didn't see any reference to this. Does anyone remember how to do this?
Posted Last updated
.
Post not yet marked as solved
0 Replies
345 Views
I'm new to Core Data, and busy trying to design my data model. I have tried to search for the answer in the forums as it's a rather classic issue I'm asking about, but couldn't find any relevent answers.I'm planning to tag content and store this content and the tags in my data model. Whenever I present the content in the app, I'll also present the tags. I thought it might be a good idea to denormalize this relationship by adding a 'tags' field to the Content entity and store the space delimited set of tags as a string. Then I could possibly do without a Tag entity. Part of my app allows users to define custom queries so a user could possibly want to see all content tagged with 4 or 5 (or more) tags. So they'd be building up a compond predicate with 4 or 5 AND clauses that are all evaluating the contents of the 'tag' string. Is this going to perform worse than simply creating a many-to-many join between a Content entity and Tag entity and querying across these tables? These queries are going to be used as shortcuts in the app, so it's really important that they are performant. I realise that I could possibly implement both approaches and evaluate the performance once I've got some data to play with. Does anyone have any real-world experience with this issue they'd like to share or advice they can share with me?
Posted Last updated
.
Post marked as solved
3 Replies
890 Views
I'm going through the newly published SwiftUI tutorials, in particular Drawing Paths and Shapes here: https://developer.apple.com/tutorials/swiftui/drawing-paths-and-shapesIn Step 4 of 5 "Combine the Badge Foreground and Background", intermediate step 3 you are required to add the GeometryReader code to the body variable...var body: some View { ZStack { BadgeBackground() GeometryReader { geometry in self.badgeSymbols .scaleEffect(1.0 / 4.0, anchor: .top) .position(x: geometry.size.width / 2.0, y: (3.0 / 4.0) * geometry.size.height) } }}But Xcode complains after adding the GeometryReader that the ZStack trailing closure is "Unable to infer complex closure return type; add explicit type to disambiguate"Am I missing something? To my eyes, my code is identical to the tutorials.I decided to compile the Complete version of the tutorial that comes with the downloaded zip. That seems to compile without complaint. Here's a screenshot of the two source code files side by side. https://imgur.com/azzjjx9
Posted Last updated
.