diff --git a/ios/Action Extension/ActionViewController.swift b/ios/Action Extension/ActionViewController.swift index 43e1af74..492a4cdc 100644 --- a/ios/Action Extension/ActionViewController.swift +++ b/ios/Action Extension/ActionViewController.swift @@ -13,7 +13,7 @@ class ActionViewController: UIViewController { let hostAppBundleIdentifier = "com.jiaqi.hacki" let sharedKey = "ShareKey" var sharedText: [String] = [] - let urlContentType = kUTTypeURL as String + let urlContentType = UTType.url @IBOutlet weak var imageView: UIImageView! override func viewDidLoad() { @@ -32,7 +32,7 @@ class ActionViewController: UIViewController { } private func handleUrl (content: NSExtensionItem, attachment: NSItemProvider, index: Int) { - attachment.loadItem(forTypeIdentifier: urlContentType, options: nil) { [weak self] data, error in + attachment.loadItem(forTypeIdentifier: urlContentType.identifier, options: nil) { [weak self] data, error in if error == nil, let item = data as? URL, let this = self { this.sharedText.append(item.absoluteString) diff --git a/ios/Runner.xcodeproj/project.pbxproj b/ios/Runner.xcodeproj/project.pbxproj index 7fcd16f7..1c3b0bbe 100644 --- a/ios/Runner.xcodeproj/project.pbxproj +++ b/ios/Runner.xcodeproj/project.pbxproj @@ -55,7 +55,7 @@ }; E51D52B8283B464E00FC8DD8 /* Embed App Extensions */ = { isa = PBXCopyFilesBuildPhase; - buildActionMask = 12; + buildActionMask = 8; dstPath = ""; dstSubfolderSpec = 13; files = ( @@ -63,7 +63,7 @@ E530B1B4283B54DA004E8EB6 /* Action Extension.appex in Embed App Extensions */, ); name = "Embed App Extensions"; - runOnlyForDeploymentPostprocessing = 0; + runOnlyForDeploymentPostprocessing = 1; }; /* End PBXCopyFilesBuildPhase section */ @@ -537,6 +537,7 @@ CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; COPY_PHASE_STRIP = NO; + CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; ENABLE_NS_ASSERTIONS = NO; ENABLE_STRICT_OBJC_MSGSEND = YES; @@ -549,6 +550,7 @@ GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; IPHONEOS_DEPLOYMENT_TARGET = 15.0; + MARKETING_VERSION = "$(FLUTTER_BUILD_NAME)"; MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = iphoneos; SUPPORTED_PLATFORMS = iphoneos; @@ -567,7 +569,7 @@ CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements; CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; + CURRENT_PROJECT_VERSION = ""; DEVELOPMENT_TEAM = QMWX3X2NF7; ENABLE_BITCODE = NO; INFOPLIST_FILE = Runner/Info.plist; @@ -578,7 +580,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - MARKETING_VERSION = 0.3.0; + MARKETING_VERSION = ""; PRODUCT_BUNDLE_IDENTIFIER = com.jiaqi.hacki; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = ""; @@ -619,6 +621,7 @@ CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; COPY_PHASE_STRIP = NO; + CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; DEBUG_INFORMATION_FORMAT = dwarf; ENABLE_STRICT_OBJC_MSGSEND = YES; ENABLE_TESTABILITY = YES; @@ -637,6 +640,7 @@ GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; IPHONEOS_DEPLOYMENT_TARGET = 15.0; + MARKETING_VERSION = "$(FLUTTER_BUILD_NAME)"; MTL_ENABLE_DEBUG_INFO = YES; ONLY_ACTIVE_ARCH = YES; SDKROOT = iphoneos; @@ -674,6 +678,7 @@ CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; COPY_PHASE_STRIP = NO; + CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; ENABLE_NS_ASSERTIONS = NO; ENABLE_STRICT_OBJC_MSGSEND = YES; @@ -686,6 +691,7 @@ GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; IPHONEOS_DEPLOYMENT_TARGET = 15.0; + MARKETING_VERSION = "$(FLUTTER_BUILD_NAME)"; MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = iphoneos; SUPPORTED_PLATFORMS = iphoneos; @@ -706,7 +712,7 @@ CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements; CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; + CURRENT_PROJECT_VERSION = ""; DEVELOPMENT_TEAM = QMWX3X2NF7; ENABLE_BITCODE = NO; INFOPLIST_FILE = Runner/Info.plist; @@ -717,7 +723,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - MARKETING_VERSION = 0.3.0; + MARKETING_VERSION = ""; PRODUCT_BUNDLE_IDENTIFIER = com.jiaqi.hacki; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = ""; @@ -740,7 +746,7 @@ CODE_SIGN_IDENTITY = "Apple Development"; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Distribution"; CODE_SIGN_STYLE = Manual; - CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; + CURRENT_PROJECT_VERSION = ""; DEVELOPMENT_TEAM = ""; "DEVELOPMENT_TEAM[sdk=iphoneos*]" = QMWX3X2NF7; ENABLE_BITCODE = NO; @@ -752,7 +758,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - MARKETING_VERSION = 0.3.0; + MARKETING_VERSION = ""; PRODUCT_BUNDLE_IDENTIFIER = com.jiaqi.hacki; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = ""; @@ -789,7 +795,7 @@ "@executable_path/Frameworks", "@executable_path/../../Frameworks", ); - MARKETING_VERSION = 1.0; + MARKETING_VERSION = ""; MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; MTL_FAST_MATH = YES; PRODUCT_BUNDLE_IDENTIFIER = "com.jiaqi.hacki.Share-Extension"; @@ -831,7 +837,7 @@ "@executable_path/Frameworks", "@executable_path/../../Frameworks", ); - MARKETING_VERSION = 1.0; + MARKETING_VERSION = ""; MTL_FAST_MATH = YES; PRODUCT_BUNDLE_IDENTIFIER = "com.jiaqi.hacki.Share-Extension"; PRODUCT_NAME = "$(TARGET_NAME)"; @@ -869,7 +875,7 @@ "@executable_path/Frameworks", "@executable_path/../../Frameworks", ); - MARKETING_VERSION = 1.0; + MARKETING_VERSION = ""; MTL_FAST_MATH = YES; PRODUCT_BUNDLE_IDENTIFIER = "com.jiaqi.hacki.Share-Extension"; PRODUCT_NAME = "$(TARGET_NAME)"; @@ -908,7 +914,7 @@ "@executable_path/Frameworks", "@executable_path/../../Frameworks", ); - MARKETING_VERSION = 1.0; + MARKETING_VERSION = ""; MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; MTL_FAST_MATH = YES; PRODUCT_BUNDLE_IDENTIFIER = "com.jiaqi.hacki.Action-Extension"; @@ -952,7 +958,7 @@ "@executable_path/Frameworks", "@executable_path/../../Frameworks", ); - MARKETING_VERSION = 1.0; + MARKETING_VERSION = ""; MTL_FAST_MATH = YES; PRODUCT_BUNDLE_IDENTIFIER = "com.jiaqi.hacki.Action-Extension"; PRODUCT_NAME = "$(TARGET_NAME)"; @@ -992,7 +998,7 @@ "@executable_path/Frameworks", "@executable_path/../../Frameworks", ); - MARKETING_VERSION = 1.0; + MARKETING_VERSION = ""; MTL_FAST_MATH = YES; PRODUCT_BUNDLE_IDENTIFIER = "com.jiaqi.hacki.Action-Extension"; PRODUCT_NAME = "$(TARGET_NAME)"; diff --git a/ios/Runner/AppDelegate.swift b/ios/Runner/AppDelegate.swift index d980181b..108bda2f 100644 --- a/ios/Runner/AppDelegate.swift +++ b/ios/Runner/AppDelegate.swift @@ -22,7 +22,7 @@ import flutter_local_notifications WorkmanagerPlugin.registerTask(withIdentifier: "workmanager.background.task") if #available(iOS 10.0, *) { - UNUserNotificationCenter.current().delegate = self as? UNUserNotificationCenterDelegate + UNUserNotificationCenter.current().delegate = self as UNUserNotificationCenterDelegate } UIApplication.shared.setMinimumBackgroundFetchInterval(TimeInterval(60*15)) diff --git a/ios/Share Extension/ShareViewController.swift b/ios/Share Extension/ShareViewController.swift index 41ede0cc..48c3608a 100644 --- a/ios/Share Extension/ShareViewController.swift +++ b/ios/Share Extension/ShareViewController.swift @@ -8,11 +8,11 @@ class ShareViewController: SLComposeServiceViewController { let sharedKey = "ShareKey" var sharedMedia: [SharedMediaFile] = [] var sharedText: [String] = [] - let imageContentType = kUTTypeImage as String - let videoContentType = kUTTypeMovie as String - let textContentType = kUTTypeText as String - let urlContentType = kUTTypeURL as String - let fileURLType = kUTTypeFileURL as String; + let imageContentType = UTType.image + let videoContentType = UTType.movie + let textContentType = UTType.text + let urlContentType = UTType.url + let fileURLType = UTType.fileURL override func isContentValid() -> Bool { return true @@ -29,15 +29,15 @@ class ShareViewController: SLComposeServiceViewController { if let content = extensionContext!.inputItems[0] as? NSExtensionItem { if let contents = content.attachments { for (index, attachment) in (contents).enumerated() { - if attachment.hasItemConformingToTypeIdentifier(imageContentType) { + if attachment.hasItemConformingToTypeIdentifier(imageContentType.identifier) { handleImages(content: content, attachment: attachment, index: index) - } else if attachment.hasItemConformingToTypeIdentifier(textContentType) { + } else if attachment.hasItemConformingToTypeIdentifier(textContentType.identifier) { handleText(content: content, attachment: attachment, index: index) - } else if attachment.hasItemConformingToTypeIdentifier(fileURLType) { + } else if attachment.hasItemConformingToTypeIdentifier(fileURLType.identifier) { handleFiles(content: content, attachment: attachment, index: index) - } else if attachment.hasItemConformingToTypeIdentifier(urlContentType) { + } else if attachment.hasItemConformingToTypeIdentifier(urlContentType.identifier) { handleUrl(content: content, attachment: attachment, index: index) - } else if attachment.hasItemConformingToTypeIdentifier(videoContentType) { + } else if attachment.hasItemConformingToTypeIdentifier(videoContentType.identifier) { handleVideos(content: content, attachment: attachment, index: index) } } @@ -55,8 +55,8 @@ class ShareViewController: SLComposeServiceViewController { } private func handleText (content: NSExtensionItem, attachment: NSItemProvider, index: Int) { - attachment.loadItem(forTypeIdentifier: textContentType, options: nil) { [weak self] data, error in - + attachment.loadItem(forTypeIdentifier: textContentType.identifier, options: nil) { [weak self] data, error in + if error == nil, let item = data as? String, let this = self { this.sharedText.append(item) @@ -76,8 +76,8 @@ class ShareViewController: SLComposeServiceViewController { } private func handleUrl (content: NSExtensionItem, attachment: NSItemProvider, index: Int) { - attachment.loadItem(forTypeIdentifier: urlContentType, options: nil) { [weak self] data, error in - + attachment.loadItem(forTypeIdentifier: urlContentType.identifier, options: nil) { [weak self] data, error in + if error == nil, let item = data as? URL, let this = self { this.sharedText.append(item.absoluteString) @@ -85,7 +85,6 @@ class ShareViewController: SLComposeServiceViewController { // If this is the last item, save imagesData in userDefaults and redirect to host app if index == (content.attachments?.count)! - 1 { let userDefaults = UserDefaults(suiteName: "group.\(this.hostAppBundleIdentifier)") - userDefaults?.set("this", forKey: "fuck") userDefaults?.set(this.sharedText, forKey: this.sharedKey) userDefaults?.synchronize() @@ -99,8 +98,8 @@ class ShareViewController: SLComposeServiceViewController { } private func handleImages (content: NSExtensionItem, attachment: NSItemProvider, index: Int) { - attachment.loadItem(forTypeIdentifier: imageContentType, options: nil) { [weak self] data, error in - + attachment.loadItem(forTypeIdentifier: imageContentType.identifier, options: nil) { [weak self] data, error in + if error == nil, let url = data as? URL, let this = self { // Always copy @@ -128,8 +127,8 @@ class ShareViewController: SLComposeServiceViewController { } private func handleVideos (content: NSExtensionItem, attachment: NSItemProvider, index: Int) { - attachment.loadItem(forTypeIdentifier: videoContentType, options: nil) { [weak self] data, error in - + attachment.loadItem(forTypeIdentifier: videoContentType.identifier, options: nil) { [weak self] data, error in + if error == nil, let url = data as? URL, let this = self { // Always copy @@ -160,8 +159,8 @@ class ShareViewController: SLComposeServiceViewController { } private func handleFiles (content: NSExtensionItem, attachment: NSItemProvider, index: Int) { - attachment.loadItem(forTypeIdentifier: fileURLType, options: nil) { [weak self] data, error in - + attachment.loadItem(forTypeIdentifier: fileURLType.identifier, options: nil) { [weak self] data, error in + if error == nil, let url = data as? URL, let this = self { // Always copy @@ -205,8 +204,6 @@ class ShareViewController: SLComposeServiceViewController { var responder = self as UIResponder? let selectorOpenURL = sel_registerName("openURL:") - print("fuck \(url)") - while (responder != nil) { if (responder?.responds(to: selectorOpenURL))! { let _ = responder?.perform(selectorOpenURL, with: url) @@ -315,7 +312,7 @@ class ShareViewController: SLComposeServiceViewController { // Debug method to print out SharedMediaFile details in the console func toString() { - print("[SharedMediaFile] \n\tpath: \(self.path)\n\tthumbnail: \(self.thumbnail)\n\tduration: \(self.duration)\n\ttype: \(self.type)") + print("[SharedMediaFile] \n\tpath: \(self.path)\n\tthumbnail: \(String(describing: self.thumbnail))\n\tduration: \(String(describing: self.duration))\n\ttype: \(self.type)") } }