diff --git a/.circleci/config.yml b/.circleci/config.yml index 0c0a10cfd..bf04b6dbd 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -7,33 +7,38 @@ orbs: workflows: test_and_validate: jobs: + - ios/test: + name: Carthage Update + xcode-version: "12.1.0" + workspace: Aztec.xcworkspace + scheme: CarthageBuild + device: iPhone 11 + - ios/test: name: Test - xcode-version: "11.0" - carthage-update: true - carthage-working-directory: Example + xcode-version: "12.1.0" bundle-install: false pod-install: false workspace: Aztec.xcworkspace scheme: AztecExample device: iPhone 11 - ios-version: "13.0" + ios-version: "14.0" - ios/validate-podspec: name: Validate WordPress-Aztec-iOS.podspec - xcode-version: "11.0" + xcode-version: "12.1.0" podspec-path: WordPress-Aztec-iOS.podspec - ios/validate-podspec: name: Validate WordPress-Editor-iOS.podspec - xcode-version: "11.0" + xcode-version: "12.1.0" podspec-path: WordPress-Editor-iOS.podspec # Reference WordPress-Aztec-iOS.podspec locally so we don't have to get it from the specs repo additional-parameters: --include-podspecs=WordPress-Aztec-iOS.podspec - ios/publish-podspec: name: Publish WordPress-Aztec-iOS to Trunk - xcode-version: "11.0" + xcode-version: "12.1.0" podspec-path: WordPress-Aztec-iOS.podspec post-to-slack: true filters: @@ -45,7 +50,7 @@ workflows: - ios/publish-podspec: name: Publish WordPress-Editor-iOS to Trunk requires: [ "Publish WordPress-Aztec-iOS to Trunk" ] - xcode-version: "11.0" + xcode-version: "12.1.0" podspec-path: WordPress-Editor-iOS.podspec post-to-slack: true filters: diff --git a/Aztec.xcodeproj/xcshareddata/xcschemes/Aztec.xcscheme b/Aztec.xcodeproj/xcshareddata/xcschemes/Aztec.xcscheme index 02bb0c855..1cf5571d4 100644 --- a/Aztec.xcodeproj/xcshareddata/xcschemes/Aztec.xcscheme +++ b/Aztec.xcodeproj/xcshareddata/xcschemes/Aztec.xcscheme @@ -1,6 +1,6 @@ + shouldUseLaunchSchemeArgsEnv = "YES" + onlyGenerateCoverageForSpecifiedTargets = "YES"> + + + + - - - - - - - - + BlueprintIdentifier = "FFB801A425A4DE2000B5A78F" + BuildableName = "Chartage Update" + BlueprintName = "Chartage Update" + ReferencedContainer = "container:AztecExample.xcodeproj"> @@ -29,8 +29,6 @@ shouldUseLaunchSchemeArgsEnv = "YES"> - - - - - - - - + BlueprintIdentifier = "FFB801A425A4DE2000B5A78F" + BuildableName = "Chartage Update" + BlueprintName = "Chartage Update" + ReferencedContainer = "container:AztecExample.xcodeproj"> diff --git a/Example/Example/EditorDemoController+PHPicker.swift b/Example/Example/EditorDemoController+PHPicker.swift new file mode 100644 index 000000000..a15ac50ad --- /dev/null +++ b/Example/Example/EditorDemoController+PHPicker.swift @@ -0,0 +1,68 @@ +import Foundation +import UniformTypeIdentifiers +import PhotosUI + +@available(iOS 14, *) +extension EditorDemoController: PHPickerViewControllerDelegate { + + func showPHPicker() { + var configuration = PHPickerConfiguration() + configuration.selectionLimit = 10 + configuration.filter = PHPickerFilter.any(of: [.images, .videos]); + let viewController = PHPickerViewController(configuration: configuration) + viewController.delegate = self + present(viewController, animated: true, completion: nil) + } + + func picker(_ picker: PHPickerViewController, didFinishPicking results: [PHPickerResult]) { + for result in results { + print("ID: \(result.assetIdentifier ?? "")\n") + print("Type Identifiers: \(result.itemProvider.registeredTypeIdentifiers)\n") + + let mediaTypesPriority: [UTType] = [.heic, .jpeg, .gif] + for mediaType in mediaTypesPriority { + if result.itemProvider.hasItemConformingToTypeIdentifier(mediaType.identifier) { + exportImage(in: result.itemProvider, forTypeIdentifier: mediaType.identifier) + break + } + } + let videoTypesPriority: [UTType] = [.movie, .mpeg] + for mediaType in videoTypesPriority { + if result.itemProvider.hasItemConformingToTypeIdentifier(mediaType.identifier) { + exportVideo(in: result.itemProvider, forTypeIdentifier: mediaType.identifier) + break + } + } + } + self.dismiss(animated: true, completion: nil) + } + + func exportImage(in item: NSItemProvider, forTypeIdentifier typeIdentifier: String) { + item.loadDataRepresentation(forTypeIdentifier: typeIdentifier) { (data, error) in + guard let imageData = data, let image = UIImage(data: imageData) else { + return + } + DispatchQueue.main.async { + self.mediaInserter.insertImage(image) + } + } + } + + func exportVideo(in item: NSItemProvider, forTypeIdentifier typeIdentifier: String) { + item.loadInPlaceFileRepresentation(forTypeIdentifier: typeIdentifier) { (url, result, error) in + guard let videoURL = url else { + return + } + let fileCoordinator: NSFileCoordinator = NSFileCoordinator.init(filePresenter: nil) + fileCoordinator.coordinate(readingItemAt: videoURL, options: [], error: nil) { (url) in + let fileManager = FileManager.init() + let destinationURL = URL(fileURLWithPath: NSTemporaryDirectory()+UUID().uuidString+".mp4") + try? fileManager.copyItem(at: url, to: destinationURL) + DispatchQueue.main.async { + self.mediaInserter.insertVideo(destinationURL) + } + } + } + } + +} diff --git a/Example/Example/EditorDemoController.swift b/Example/Example/EditorDemoController.swift index 792e6771e..9a3e246a3 100644 --- a/Example/Example/EditorDemoController.swift +++ b/Example/Example/EditorDemoController.swift @@ -1012,7 +1012,12 @@ extension EditorDemoController { } toolbar.leadingItemHandler = { [weak self] item in - self?.showImagePicker() + if #available(iOS 14, *) { + self?.showPHPicker() + } else { + // Fallback on earlier versions + self?.showImagePicker() + } } return toolbar