diff --git a/Tatsi.xcodeproj/project.pbxproj b/Tatsi.xcodeproj/project.pbxproj index 4a8cb73..2480f99 100644 --- a/Tatsi.xcodeproj/project.pbxproj +++ b/Tatsi.xcodeproj/project.pbxproj @@ -3,7 +3,7 @@ archiveVersion = 1; classes = { }; - objectVersion = 46; + objectVersion = 54; objects = { /* Begin PBXBuildFile section */ @@ -19,8 +19,8 @@ 0C5B61491F0D2293005A25CE /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0C5B61481F0D2293005A25CE /* ViewController.swift */; }; 0C5B614E1F0D2293005A25CE /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 0C5B614D1F0D2293005A25CE /* Assets.xcassets */; }; 0C5B61611F0D231E005A25CE /* Tatsi.h in Headers */ = {isa = PBXBuildFile; fileRef = 0C5B615F1F0D231D005A25CE /* Tatsi.h */; settings = {ATTRIBUTES = (Public, ); }; }; - 0C5B61641F0D231E005A25CE /* Tatsi.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 0C5B615D1F0D231D005A25CE /* Tatsi.framework */; }; - 0C5B61651F0D231E005A25CE /* Tatsi.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 0C5B615D1F0D231D005A25CE /* Tatsi.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; + 0C5B61641F0D231E005A25CE /* Tatsi.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 0C5B615D1F0D231D005A25CE /* Tatsi.framework */; platformFilter = ios; }; + 0C5B61651F0D231E005A25CE /* Tatsi.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 0C5B615D1F0D231D005A25CE /* Tatsi.framework */; platformFilter = ios; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; 0C5B61781F0D250F005A25CE /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 0C5B61741F0D250F005A25CE /* LaunchScreen.storyboard */; }; 0C5B61791F0D250F005A25CE /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 0C5B61761F0D250F005A25CE /* Main.storyboard */; }; 0C5B617B1F0E302C005A25CE /* TatsiPickerViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0C5B617A1F0E302C005A25CE /* TatsiPickerViewController.swift */; }; @@ -558,6 +558,7 @@ }; 0C5B61631F0D231E005A25CE /* PBXTargetDependency */ = { isa = PBXTargetDependency; + platformFilter = ios; target = 0C5B615C1F0D231D005A25CE /* Tatsi */; targetProxy = 0C5B61621F0D231E005A25CE /* PBXContainerItemProxy */; }; @@ -589,10 +590,17 @@ DEVELOPMENT_TEAM = N4KR5KV52L; INFOPLIST_FILE = TatsiTests/Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 10.3; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + "@loader_path/Frameworks", + ); PRODUCT_BUNDLE_IDENTIFIER = co.awkward.TatsiTests; PRODUCT_NAME = "$(TARGET_NAME)"; + SUPPORTED_PLATFORMS = "iphoneos iphonesimulator xros xrsimulator"; + SUPPORTS_MACCATALYST = YES; SWIFT_VERSION = 4.2; + TARGETED_DEVICE_FAMILY = "1,7"; TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Tatsi Example.app/Tatsi Example"; }; name = Debug; @@ -603,10 +611,17 @@ DEVELOPMENT_TEAM = N4KR5KV52L; INFOPLIST_FILE = TatsiTests/Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 10.3; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + "@loader_path/Frameworks", + ); PRODUCT_BUNDLE_IDENTIFIER = co.awkward.TatsiTests; PRODUCT_NAME = "$(TARGET_NAME)"; + SUPPORTED_PLATFORMS = "iphoneos iphonesimulator xros xrsimulator"; + SUPPORTS_MACCATALYST = YES; SWIFT_VERSION = 4.2; + TARGETED_DEVICE_FAMILY = "1,7"; TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Tatsi Example.app/Tatsi Example"; }; name = Release; @@ -717,7 +732,8 @@ IPHONEOS_DEPLOYMENT_TARGET = 10.0; MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = iphoneos; - SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; + SWIFT_COMPILATION_MODE = wholemodule; + SWIFT_OPTIMIZATION_LEVEL = "-O"; VALIDATE_PRODUCT = YES; }; name = Release; @@ -730,10 +746,16 @@ DEVELOPMENT_TEAM = N4KR5KV52L; INFOPLIST_FILE = Example/Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 10.0; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); PRODUCT_BUNDLE_IDENTIFIER = "co.awkward.tatsi-example"; PRODUCT_NAME = "$(TARGET_NAME)"; + SUPPORTED_PLATFORMS = "iphoneos iphonesimulator xros xrsimulator"; + SUPPORTS_MACCATALYST = NO; SWIFT_VERSION = 5.0; + TARGETED_DEVICE_FAMILY = "1,7"; }; name = Debug; }; @@ -745,10 +767,16 @@ DEVELOPMENT_TEAM = N4KR5KV52L; INFOPLIST_FILE = Example/Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 10.0; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); PRODUCT_BUNDLE_IDENTIFIER = "co.awkward.tatsi-example"; PRODUCT_NAME = "$(TARGET_NAME)"; + SUPPORTED_PLATFORMS = "iphoneos iphonesimulator xros xrsimulator"; + SUPPORTS_MACCATALYST = NO; SWIFT_VERSION = 5.0; + TARGETED_DEVICE_FAMILY = "1,7"; }; name = Release; }; @@ -766,13 +794,19 @@ INFOPLIST_FILE = Tatsi/Info.plist; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; IPHONEOS_DEPLOYMENT_TARGET = 10.0; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + "@loader_path/Frameworks", + ); PRODUCT_BUNDLE_IDENTIFIER = co.awkward.tatsi; PRODUCT_NAME = "$(TARGET_NAME)"; SKIP_INSTALL = YES; + SUPPORTED_PLATFORMS = "iphoneos iphonesimulator xros xrsimulator"; + SUPPORTS_MACCATALYST = YES; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; SWIFT_VERSION = 5.0; - TARGETED_DEVICE_FAMILY = "1,2"; + TARGETED_DEVICE_FAMILY = "1,2,7"; VERSIONING_SYSTEM = "apple-generic"; VERSION_INFO_PREFIX = ""; }; @@ -792,12 +826,18 @@ INFOPLIST_FILE = Tatsi/Info.plist; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; IPHONEOS_DEPLOYMENT_TARGET = 10.0; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + "@loader_path/Frameworks", + ); PRODUCT_BUNDLE_IDENTIFIER = co.awkward.tatsi; PRODUCT_NAME = "$(TARGET_NAME)"; SKIP_INSTALL = YES; + SUPPORTED_PLATFORMS = "iphoneos iphonesimulator xros xrsimulator"; + SUPPORTS_MACCATALYST = YES; SWIFT_VERSION = 5.0; - TARGETED_DEVICE_FAMILY = "1,2"; + TARGETED_DEVICE_FAMILY = "1,2,7"; VERSIONING_SYSTEM = "apple-generic"; VERSION_INFO_PREFIX = ""; }; diff --git a/Tatsi/Extensions/PHAssetCollectionExtensions.swift b/Tatsi/Extensions/PHAssetCollectionExtensions.swift index 63268b9..9c1c4ee 100644 --- a/Tatsi/Extensions/PHAssetCollectionExtensions.swift +++ b/Tatsi/Extensions/PHAssetCollectionExtensions.swift @@ -31,7 +31,12 @@ extension PHAssetCollection { let requestOptions = PHImageRequestOptions() requestOptions.isSynchronous = false requestOptions.resizeMode = PHImageRequestOptionsResizeMode.exact - PHImageManager.default().requestImage(for: asset, targetSize: targetSize.scaled(with: UIScreen.main.scale), contentMode: PHImageContentMode.aspectFill, options: requestOptions, resultHandler: { (image, _) in + #if !os(visionOS) + let scale = UIScreen.main.scale + #else + let scale = CGFloat(1) + #endif + PHImageManager.default().requestImage(for: asset, targetSize: targetSize.scaled(with: scale), contentMode: PHImageContentMode.aspectFill, options: requestOptions, resultHandler: { (image, _) in DispatchQueue.main.async { completionHandler(image, asset) } diff --git a/Tatsi/UIElements/AlbumImageView.swift b/Tatsi/UIElements/AlbumImageView.swift index cfe7cb9..f1d310a 100644 --- a/Tatsi/UIElements/AlbumImageView.swift +++ b/Tatsi/UIElements/AlbumImageView.swift @@ -61,12 +61,17 @@ final internal class AlbumImageView: UIView { // Only override drawRect: if you perform custom drawing. // An empty implementation adversely affects performance during animation. override func draw(_ rect: CGRect) { + #if !os(visionOS) + let scale = UIScreen.main.scale + #else + let scale = CGFloat(1) + #endif // Drawing code - let firstLinePath = UIBezierPath(rect: CGRect(x: 7, y: 0, width: rect.width - ( 7 * 2 ), height: 1 / UIScreen.main.scale)) + let firstLinePath = UIBezierPath(rect: CGRect(x: 7, y: 0, width: rect.width - ( 7 * 2 ), height: 1 / scale)) self.linesColor.withAlphaComponent(0.4).setFill() firstLinePath.fill() - let secondLinePath = UIBezierPath(rect: CGRect(x: 4, y: 2, width: rect.width - ( 4 * 2 ), height: 1 / UIScreen.main.scale)) + let secondLinePath = UIBezierPath(rect: CGRect(x: 4, y: 2, width: rect.width - ( 4 * 2 ), height: 1 / scale)) self.linesColor.withAlphaComponent(0.6).setFill() secondLinePath.fill() } diff --git a/Tatsi/Views/Assets Grid/AssetsGridViewController.swift b/Tatsi/Views/Assets Grid/AssetsGridViewController.swift index 02220b7..4511200 100644 --- a/Tatsi/Views/Assets Grid/AssetsGridViewController.swift +++ b/Tatsi/Views/Assets Grid/AssetsGridViewController.swift @@ -48,10 +48,14 @@ final internal class AssetsGridViewController: UICollectionViewController, Picke // MARK: - Private Properties fileprivate var showCameraButton: Bool { + #if os(visionOS) + return false + #else guard self.album.isUserLibrary, UIImagePickerController.isSourceTypeAvailable(UIImagePickerController.SourceType.camera) else { return false } return self.config?.showCameraOption ?? false + #endif } fileprivate var emptyView: AlbumEmptyView? { @@ -327,7 +331,9 @@ final internal class AssetsGridViewController: UICollectionViewController, Picke override func viewDidLayoutSubviews() { super.viewDidLayoutSubviews() + #if !os(visionOS) self.emptyView?.layoutMargins = UIEdgeInsets(top: self.topLayoutGuide.length + 20, left: 20, bottom: self.bottomLayoutGuide.length + 20, right: 20) + #endif } override func traitCollectionDidChange(_ previousTraitCollection: UITraitCollection?) { @@ -463,11 +469,13 @@ extension AssetsGridViewController { } } } else { + #if !os(visionOS) let cameraController = UIImagePickerController() cameraController.sourceType = UIImagePickerController.SourceType.camera cameraController.delegate = self self.present(cameraController, animated: true, completion: nil) collectionView.deselectItem(at: indexPath, animated: true) + #endif } } diff --git a/Tatsi/Views/Assets Grid/Cells/AssetCollectionViewCell.swift b/Tatsi/Views/Assets Grid/Cells/AssetCollectionViewCell.swift index 32aecba..86c7382 100644 --- a/Tatsi/Views/Assets Grid/Cells/AssetCollectionViewCell.swift +++ b/Tatsi/Views/Assets Grid/Cells/AssetCollectionViewCell.swift @@ -156,7 +156,11 @@ final internal class AssetCollectionViewCell: UICollectionViewCell { self.imageView.image = nil DispatchQueue.global(qos: .userInteractive).async { [weak self] in autoreleasepool { + #if !os(visionOS) let scale = UIScreen.main.scale > 2 ? 2 : UIScreen.main.scale + #else + let scale = CGFloat(1) + #endif guard let targetSize = self?.imageSize.scaled(with: scale), self?.asset?.localIdentifier == asset.localIdentifier else { return } diff --git a/Tatsi/Views/AuthorizationViewController.swift b/Tatsi/Views/AuthorizationViewController.swift index 7a0485a..2154408 100644 --- a/Tatsi/Views/AuthorizationViewController.swift +++ b/Tatsi/Views/AuthorizationViewController.swift @@ -117,10 +117,12 @@ final internal class AuthorizationViewController: UIViewController, PickerViewCo guard let url = URL(string: UIApplication.openSettingsURLString) else { return } - if #available(iOS 10, *) { + if #available(iOS 10, visionOS 1, *) { UIApplication.shared.open(url, options: [:], completionHandler: nil) } else { + #if !os(visionOS) UIApplication.shared.openURL(url) + #endif } }