TagSpaces is an offline, open source, document manager with tagging support
feat: added basic icloud support
Ilian Sapundshievcd068267f302
diff --git a/capacitor/ios/App/App.xcodeproj/project.pbxproj b/capacitor/ios/App/App.xcodeproj/project.pbxprojindex 7f1c0699c..5969ad950 100644--- a/capacitor/ios/App/App.xcodeproj/project.pbxproj+++ b/capacitor/ios/App/App.xcodeproj/project.pbxproj@@ -16,6 +16,7 @@504EC3121FED79650016851F /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 504EC3101FED79650016851F /* LaunchScreen.storyboard */; };50B271D11FEDC1A000F3C39B /* public in Resources */ = {isa = PBXBuildFile; fileRef = 50B271D01FEDC1A000F3C39B /* public */; };D1F87A2C0000000000000002 /* PrivacyInfo.xcprivacy in Resources */ = {isa = PBXBuildFile; fileRef = D1F87A2C0000000000000001 /* PrivacyInfo.xcprivacy */; };+ D1F87A2C0000000000000011 /* ICloudPlugin.swift in Sources */ = {isa = PBXBuildFile; fileRef = D1F87A2C0000000000000010 /* ICloudPlugin.swift */; };/* End PBXBuildFile section *//* Begin PBXFileReference section */@@ -30,6 +31,8 @@50B271D01FEDC1A000F3C39B /* public */ = {isa = PBXFileReference; lastKnownFileType = folder; path = public; sourceTree = "<group>"; };958DCC722DB07C7200EA8C5F /* debug.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = debug.xcconfig; path = ../debug.xcconfig; sourceTree = SOURCE_ROOT; };D1F87A2C0000000000000001 /* PrivacyInfo.xcprivacy */ = {isa = PBXFileReference; lastKnownFileType = text.xml; path = PrivacyInfo.xcprivacy; sourceTree = "<group>"; };+ D1F87A2C0000000000000003 /* App.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = App.entitlements; sourceTree = "<group>"; };+ D1F87A2C0000000000000010 /* ICloudPlugin.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ICloudPlugin.swift; sourceTree = "<group>"; };/* End PBXFileReference section *//* Begin PBXFrameworksBuildPhase section */@@ -66,11 +69,13 @@children = (50379B222058CBB4000EE86E /* capacitor.config.json */,504EC3071FED79650016851F /* AppDelegate.swift */,+ D1F87A2C0000000000000010 /* ICloudPlugin.swift */,504EC30B1FED79650016851F /* Main.storyboard */,504EC30E1FED79650016851F /* Assets.xcassets */,504EC3101FED79650016851F /* LaunchScreen.storyboard */,504EC3131FED79650016851F /* Info.plist */,D1F87A2C0000000000000001 /* PrivacyInfo.xcprivacy */,+ D1F87A2C0000000000000003 /* App.entitlements */,2FAD9762203C412B000D30F8 /* config.xml */,50B271D01FEDC1A000F3C39B /* public */,);@@ -160,6 +165,7 @@buildActionMask = 2147483647;files = (504EC3081FED79650016851F /* AppDelegate.swift in Sources */,+ D1F87A2C0000000000000011 /* ICloudPlugin.swift in Sources */,);runOnlyForDeploymentPostprocessing = 0;};@@ -299,8 +305,9 @@baseConfigurationReference = 958DCC722DB07C7200EA8C5F /* debug.xcconfig */;buildSettings = {ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;+ CODE_SIGN_ENTITLEMENTS = App/App.entitlements;CODE_SIGN_STYLE = Automatic;- CURRENT_PROJECT_VERSION = 1;+ CURRENT_PROJECT_VERSION = 2;DEVELOPMENT_TEAM = DLK22E2679;INFOPLIST_FILE = App/Info.plist;IPHONEOS_DEPLOYMENT_TARGET = 15.0;@@ -322,8 +329,9 @@isa = XCBuildConfiguration;buildSettings = {ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;+ CODE_SIGN_ENTITLEMENTS = App/App.entitlements;CODE_SIGN_STYLE = Automatic;- CURRENT_PROJECT_VERSION = 1;+ CURRENT_PROJECT_VERSION = 2;DEVELOPMENT_TEAM = DLK22E2679;INFOPLIST_FILE = App/Info.plist;IPHONEOS_DEPLOYMENT_TARGET = 15.0;diff --git a/capacitor/ios/App/App/App.entitlements b/capacitor/ios/App/App/App.entitlementsnew file mode 100644index 000000000..a96bb4e6e--- /dev/null+++ b/capacitor/ios/App/App/App.entitlements@@ -0,0 +1,20 @@+<?xml version="1.0" encoding="UTF-8"?>+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">+<plist version="1.0">+<dict>+ <key>aps-environment</key>+ <string>development</string>+ <key>com.apple.developer.icloud-container-identifiers</key>+ <array>+ <string>iCloud.org.tagspaces.mobileapp</string>+ </array>+ <key>com.apple.developer.icloud-services</key>+ <array>+ <string>CloudDocuments</string>+ </array>+ <key>com.apple.developer.ubiquity-container-identifiers</key>+ <array>+ <string>iCloud.org.tagspaces.mobileapp</string>+ </array>+</dict>+</plist>diff --git a/capacitor/ios/App/App/AppDelegate.swift b/capacitor/ios/App/App/AppDelegate.swiftindex 5e097b3bf..06403cda2 100644--- a/capacitor/ios/App/App/AppDelegate.swift+++ b/capacitor/ios/App/App/AppDelegate.swift@@ -9,9 +9,25 @@ class AppDelegate: UIResponder, UIApplicationDelegate {func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {configureAudioSession()+ registerUbiquityContainer()return true}+ private func registerUbiquityContainer() {+ // Touching the ubiquity URL once at launch makes iOS register the+ // container with iCloud Drive, which is what surfaces the "TagSpaces"+ // folder in the iOS Files app and macOS Finder. Without this, the+ // folder can stay hidden until something in the app first reads/writes.+ DispatchQueue.global(qos: .background).async {+ guard let containerURL = FileManager.default.url(forUbiquityContainerIdentifier: nil) else {+ return+ }+ let documents = containerURL.appendingPathComponent("Documents", isDirectory: true)+ try? FileManager.default.createDirectory(at: documents,+ withIntermediateDirectories: true)+ }+ }+private func configureAudioSession() {// .playAndRecord supports both audiobook playback (continues when screen// locks, paired with UIBackgroundModes=audio in Info.plist) and voice-memodiff --git a/capacitor/ios/App/App/ICloudPlugin.swift b/capacitor/ios/App/App/ICloudPlugin.swiftnew file mode 100644index 000000000..dff7344e7--- /dev/null+++ b/capacitor/ios/App/App/ICloudPlugin.swift@@ -0,0 +1,47 @@+import Foundation+import Capacitor++@objc(ICloudPlugin)+public class ICloudPlugin: CAPPlugin, CAPBridgedPlugin {+ public let identifier = "ICloudPlugin"+ public let jsName = "ICloud"+ public let pluginMethods: [CAPPluginMethod] = [+ CAPPluginMethod(name: "getUbiquityContainer", returnType: CAPPluginReturnPromise),+ CAPPluginMethod(name: "startDownload", returnType: CAPPluginReturnPromise)+ ]++ @objc func getUbiquityContainer(_ call: CAPPluginCall) {+ // forUbiquityContainerIdentifier: nil → use the first container declared+ // in the entitlement (iCloud.org.tagspaces.mobileapp). Returns nil if+ // iCloud Drive is disabled, the user isn't signed in, or the container+ // hasn't been provisioned yet on Apple's side.+ DispatchQueue.global(qos: .userInitiated).async {+ guard let containerURL = FileManager.default.url(forUbiquityContainerIdentifier: nil) else {+ call.resolve(["available": false])+ return+ }+ let documentsURL = containerURL.appendingPathComponent("Documents", isDirectory: true)+ try? FileManager.default.createDirectory(at: documentsURL,+ withIntermediateDirectories: true)+ call.resolve([+ "available": true,+ "containerPath": containerURL.path,+ "documentsPath": documentsURL.path+ ])+ }+ }++ @objc func startDownload(_ call: CAPPluginCall) {+ guard let path = call.getString("path") else {+ call.reject("path is required")+ return+ }+ let url = URL(fileURLWithPath: path)+ do {+ try FileManager.default.startDownloadingUbiquitousItem(at: url)+ call.resolve(["started": true])+ } catch {+ call.reject("startDownloadingUbiquitousItem failed: \(error.localizedDescription)")+ }+ }+}diff --git a/capacitor/ios/App/App/Info.plist b/capacitor/ios/App/App/Info.plistindex 1f81f42af..6503b2bcc 100644--- a/capacitor/ios/App/App/Info.plist+++ b/capacitor/ios/App/App/Info.plist@@ -41,6 +41,18 @@<string>This app requires photo library access to save photos.</string><key>NSPhotoLibraryUsageDescription</key><string>This app requires photo library access to organize and tag your photos.</string>+ <key>NSUbiquitousContainers</key>+ <dict>+ <key>iCloud.org.tagspaces.mobileapp</key>+ <dict>+ <key>NSUbiquitousContainerIsDocumentScopePublic</key>+ <true/>+ <key>NSUbiquitousContainerSupportedFolderLevels</key>+ <string>Any</string>+ <key>NSUbiquitousContainerName</key>+ <string>TagSpaces</string>+ </dict>+ </dict><key>UIBackgroundModes</key><array><string>audio</string>