userscripts icon indicating copy to clipboard operation
userscripts copied to clipboard

Better iCloud sync integration

Open ACTCD opened this issue 2 years ago • 16 comments

Currently, we tell users in the README:

Tip: for optimal cross platform experience it's a good idea to use an iCloud folder for syncing between macOS and iOS

But the current iCloud sync has some doubts for users:

  • We don't really support iCloud in the app, so it won't appear in the list of Apps using iCloud.
  • Not out of the box, users need to manually set and select the same path in iCloud Drive in different devices.
  • The folder is not indicated as belonging to the App in iCloud (there is a folder icon containing the App Icon)
  • Syncing process of script files is delayed, uncertain and uncontrolled
  • For devices with limited space, local files may be evictioned due to iCloud optimization
    • Could be resolved by the Keep Downloaded feature introduced in macOS 15 / iOS 18
  • May be briefly inaccessible due to synching, downloading, etc.; remove bookmark and restore default path

We may need to officially support iCloud features, and the synchronization mechanism and process will be managed by the App.

References: https://developer.apple.com/library/archive/documentation/DataManagement/Conceptual/CloudKitQuickStart/Introduction/Introduction.html https://developer.apple.com/documentation/cloudkit/ https://developer.apple.com/documentation/technotes/tn3162-understanding-cloudkit-throttles

ACTCD avatar Feb 20 '23 01:02 ACTCD

Will the data saved with GM.setValue also be synced to iCloud?

biuuu avatar Jun 01 '23 13:06 biuuu

@biuuu No, not at the moment.

ACTCD avatar Jun 02 '23 08:06 ACTCD

Send me the link so the .js i can copy over into a scriptable application or web extension.

keycommander avatar Oct 07 '23 04:10 keycommander

@keycommander Sorry, I don't understand what you are talking about. Can you explain it in more detail?

ACTCD avatar Oct 07 '23 06:10 ACTCD

@keycommander Sorry, I don't understand what you are talking about. Can you explain it in more detail?

Im just wondering how I use this repository

keycommander avatar Oct 07 '23 08:10 keycommander

@keycommander I don't understand what you are talking about, if your question is not related to this issue I will delete your comments.

Regarding this project, you should read the README, and any other questions you should ask and elaborate in Discussions.

To learn how to use GitHub, please refer to the community documentations.

ACTCD avatar Oct 08 '23 05:10 ACTCD

For devices with limited space, local files may be evictioned due to iCloud optimization

I just hit this and was confused as to why my scripts suddenly weren't working anymore. Seems like Userscripts doesn't pick up the files when they get evicted until manually downloaded again through Finder. Is this known?

dblsaiko avatar Feb 22 '24 09:02 dblsaiko

@2xsaiko As I wrote. Since the extension does not currently use the iCloud related APIs, we won't know when the system decides to evict a file, and we won't be able to read it again. Thanks for your feedback.

ACTCD avatar Feb 22 '24 16:02 ACTCD

Sure, but usually, files will download on access, and non-downloaded files are visible in directories. You can see this by opening iCloud Drive in your terminal and e.g. running ls, cat or cp on a couple files. Everything is there, just accessing it might block a few seconds while it downloads, and these commands don't use the iCloud API either. Userscripts doesn't even pick the files up however.

dblsaiko avatar Feb 22 '24 18:02 dblsaiko

@2xsaiko Check out our code, this is how it currently works, if you'd like to debug it, or know of a simple way to improve it, please let us know or submit a PR and we'll be happy to improve the experience.

https://github.com/quoid/userscripts/blob/7cb18578a9975335fae27f185bbf1a4e26f05450/xcode/Ext-Safari/Functions.swift#L695-L717

ACTCD avatar Feb 22 '24 21:02 ACTCD

Ah, that's the NSFileManager API. That might behave differently than the POSIX readdir, not sure. I'm not familiar with native macOS development at all apart from writing a handful lines of Objective-C. Might mess around with it.

dblsaiko avatar Feb 23 '24 20:02 dblsaiko

@2xsaiko The same is true for us, learning native/swift from scratch, building and refactoring the extension.

I personally do not currently use icloud sync, and there's a lot more main refactoring to do. Therefore, this issue is not currently on the foreseeable task list, unless someone is willing to investigate and contribute. I will add a label to this issue.

ACTCD avatar Feb 24 '24 02:02 ACTCD

Well, a simple test program lists the files and automatically downloads the contents, so something else is going on here.

How do you get started with this? I tried just opening the project and running the "Mac" configuration in Xcode (not even sure if that would work for a Safari extension) but it said "No such file or directory" for Resources/_locales, /dist and /images.

dblsaiko avatar Feb 24 '24 10:02 dblsaiko

@2xsaiko Please check: https://github.com/quoid/userscripts/blob/main/docs/dev.md

Those missing parts need to be built by executing the npm command.

ACTCD avatar Feb 24 '24 15:02 ACTCD

There we go: https://github.com/quoid/userscripts/pull/629

dblsaiko avatar Feb 27 '24 19:02 dblsaiko

Interestingly, one issue should be officially resolved in the upcoming macOS 15 / iOS 18, with an additional menu item "Keep Downloaded" in the iCloud Drive of the new version of the system, which allows you to mark a specific folder not to be automatically evicted by the system.

We would like to thank our users (@JOJOforshaun) for providing us with the above information.

ACTCD avatar Jul 01 '24 19:07 ACTCD