From a9393ede8616c5ff5ff42090dc141fa728df5ced Mon Sep 17 00:00:00 2001 From: Guillaume Bellut Date: Sat, 12 Oct 2019 14:55:24 +0200 Subject: [PATCH 01/20] Updated default team --- ALCameraViewController.xcodeproj/project.pbxproj | 7 ++++--- .../xcshareddata/IDEWorkspaceChecks.plist | 8 ++++++++ 2 files changed, 12 insertions(+), 3 deletions(-) create mode 100644 ALCameraViewController.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist diff --git a/ALCameraViewController.xcodeproj/project.pbxproj b/ALCameraViewController.xcodeproj/project.pbxproj index 720f06f0..9fe78544 100644 --- a/ALCameraViewController.xcodeproj/project.pbxproj +++ b/ALCameraViewController.xcodeproj/project.pbxproj @@ -283,7 +283,7 @@ }; FAF0583E1B31618D008E5592 = { CreatedOnToolsVersion = 6.3.2; - DevelopmentTeam = 2466624KEK; + DevelopmentTeam = 9E43V6CC9L; LastSwiftMigration = 0900; ProvisioningStyle = Automatic; }; @@ -294,6 +294,7 @@ developmentRegion = English; hasScannedForEncodings = 0; knownRegions = ( + English, en, Base, ); @@ -548,7 +549,7 @@ buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; - DEVELOPMENT_TEAM = 2466624KEK; + DEVELOPMENT_TEAM = 9E43V6CC9L; INFOPLIST_FILE = "Example/Supporting Files/Info.plist"; IPHONEOS_DEPLOYMENT_TARGET = 9.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; @@ -564,7 +565,7 @@ buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; - DEVELOPMENT_TEAM = 2466624KEK; + DEVELOPMENT_TEAM = 9E43V6CC9L; INFOPLIST_FILE = "Example/Supporting Files/Info.plist"; IPHONEOS_DEPLOYMENT_TARGET = 9.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; diff --git a/ALCameraViewController.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/ALCameraViewController.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 00000000..18d98100 --- /dev/null +++ b/ALCameraViewController.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + From 05d896f35aa0518ea558b8c5acd162a30401ab9a Mon Sep 17 00:00:00 2001 From: Guillaume Bellut Date: Sat, 12 Oct 2019 14:57:25 +0200 Subject: [PATCH 02/20] Upgraded to Swift 5 --- .../project.pbxproj | 6 ++-- .../Utilities/Utilities.swift | 2 +- .../Utilities/VolumeControl.swift | 2 +- .../ViewController/CameraViewController.swift | 8 ++--- .../CameraViewControllerConstraint.swift | 32 +++++++++---------- .../ConfirmViewController.swift | 4 +-- .../PhotoLibraryViewController.swift | 4 +-- ALCameraViewController/Views/CameraView.swift | 4 +-- .../Views/PermissionsView.swift | 12 +++---- Example/AppDelegate.swift | 2 +- 10 files changed, 38 insertions(+), 38 deletions(-) diff --git a/ALCameraViewController.xcodeproj/project.pbxproj b/ALCameraViewController.xcodeproj/project.pbxproj index 9fe78544..19c21023 100644 --- a/ALCameraViewController.xcodeproj/project.pbxproj +++ b/ALCameraViewController.xcodeproj/project.pbxproj @@ -284,7 +284,7 @@ FAF0583E1B31618D008E5592 = { CreatedOnToolsVersion = 6.3.2; DevelopmentTeam = 9E43V6CC9L; - LastSwiftMigration = 0900; + LastSwiftMigration = 1110; ProvisioningStyle = Automatic; }; }; @@ -556,7 +556,7 @@ PRODUCT_BUNDLE_IDENTIFIER = com.alx.zero.CameraViewController; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_SWIFT3_OBJC_INFERENCE = Default; - SWIFT_VERSION = 4.0; + SWIFT_VERSION = 5.0; }; name = Debug; }; @@ -572,7 +572,7 @@ PRODUCT_BUNDLE_IDENTIFIER = com.alx.zero.CameraViewController; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_SWIFT3_OBJC_INFERENCE = Default; - SWIFT_VERSION = 4.0; + SWIFT_VERSION = 5.0; }; name = Release; }; diff --git a/ALCameraViewController/Utilities/Utilities.swift b/ALCameraViewController/Utilities/Utilities.swift index 804ad970..707cc5c7 100644 --- a/ALCameraViewController/Utilities/Utilities.swift +++ b/ALCameraViewController/Utilities/Utilities.swift @@ -68,7 +68,7 @@ internal func errorWithKey(_ key: String, domain: String) -> NSError { return error } -internal func normalizedRect(_ rect: CGRect, orientation: UIImageOrientation) -> CGRect { +internal func normalizedRect(_ rect: CGRect, orientation: UIImage.Orientation) -> CGRect { let normalizedX = rect.origin.x let normalizedY = rect.origin.y diff --git a/ALCameraViewController/Utilities/VolumeControl.swift b/ALCameraViewController/Utilities/VolumeControl.swift index 36172f8a..f66e2bc6 100644 --- a/ALCameraViewController/Utilities/VolumeControl.swift +++ b/ALCameraViewController/Utilities/VolumeControl.swift @@ -27,7 +27,7 @@ public class VolumeControl { init(view: UIView, onVolumeChange: VolumeChangeAction?) { self.onVolumeChange = onVolumeChange view.addSubview(volumeView) - view.sendSubview(toBack: volumeView) + view.sendSubviewToBack(volumeView) try? AVAudioSession.sharedInstance().setActive(true) NotificationCenter.default.addObserver(self, selector: #selector(volumeChanged), name: NSNotification.Name(rawValue: changeKey), object: nil) diff --git a/ALCameraViewController/ViewController/CameraViewController.swift b/ALCameraViewController/ViewController/CameraViewController.swift index d9e07099..03a5b157 100644 --- a/ALCameraViewController/ViewController/CameraViewController.swift +++ b/ALCameraViewController/ViewController/CameraViewController.swift @@ -56,7 +56,7 @@ open class CameraViewController: UIViewController { var animationDuration: TimeInterval = 0.5 var animationSpring: CGFloat = 0.5 - var rotateAnimation: UIViewAnimationOptions = .curveLinear + var rotateAnimation: UIView.AnimationOptions = .curveLinear var cameraButtonEdgeConstraint: NSLayoutConstraint? var cameraButtonGravityConstraint: NSLayoutConstraint? @@ -349,7 +349,7 @@ open class CameraViewController: UIViewController { NotificationCenter.default.addObserver( self, selector: #selector(rotateCameraView), - name: NSNotification.Name.UIDeviceOrientationDidChange, + name: UIDevice.orientationDidChangeNotification, object: nil) } @@ -631,12 +631,12 @@ open class CameraViewController: UIViewController { private func showSpinner() -> UIActivityIndicatorView { let spinner = UIActivityIndicatorView() - spinner.activityIndicatorViewStyle = .white + spinner.style = .white spinner.center = view.center spinner.startAnimating() view.addSubview(spinner) - view.bringSubview(toFront: spinner) + view.bringSubviewToFront(spinner) return spinner } diff --git a/ALCameraViewController/ViewController/CameraViewControllerConstraint.swift b/ALCameraViewController/ViewController/CameraViewControllerConstraint.swift index 37e518c9..7998f038 100644 --- a/ALCameraViewController/ViewController/CameraViewControllerConstraint.swift +++ b/ALCameraViewController/ViewController/CameraViewControllerConstraint.swift @@ -44,7 +44,7 @@ extension CameraViewController { func configCameraButtonEdgeConstraint(_ statusBarOrientation: UIInterfaceOrientation) { view.autoRemoveConstraint(cameraButtonEdgeConstraint) - let attribute : NSLayoutAttribute = { + let attribute : NSLayoutConstraint.Attribute = { switch statusBarOrientation { case .portrait: return .bottomMargin case .landscapeRight: return .rightMargin @@ -72,7 +72,7 @@ extension CameraViewController { */ func configCameraButtonGravityConstraint(_ portrait: Bool) { view.autoRemoveConstraint(cameraButtonGravityConstraint) - let attribute : NSLayoutAttribute = portrait ? .centerX : .centerY + let attribute : NSLayoutConstraint.Attribute = portrait ? .centerX : .centerY cameraButtonGravityConstraint = NSLayoutConstraint( item: cameraButton, attribute: attribute, @@ -100,8 +100,8 @@ extension CameraViewController { */ func configContainerEdgeConstraint(_ statusBarOrientation : UIInterfaceOrientation) { - let attributeOne : NSLayoutAttribute - let attributeTwo : NSLayoutAttribute + let attributeOne : NSLayoutConstraint.Attribute + let attributeTwo : NSLayoutConstraint.Attribute switch statusBarOrientation { case .portrait: @@ -149,7 +149,7 @@ extension CameraViewController { * orientation of the device. */ func configContainerGravityConstraint(_ statusBarOrientation : UIInterfaceOrientation) { - let attributeCenter : NSLayoutAttribute = statusBarOrientation.isPortrait ? .centerY : .centerX + let attributeCenter : NSLayoutConstraint.Attribute = statusBarOrientation.isPortrait ? .centerY : .centerX containerButtonsGravityConstraint = NSLayoutConstraint( item: containerSwapLibraryButton, attribute: attributeCenter, @@ -179,8 +179,8 @@ extension CameraViewController { */ func configSwapButtonEdgeConstraint(_ statusBarOrientation : UIInterfaceOrientation) { - let attributeOne : NSLayoutAttribute - let attributeTwo : NSLayoutAttribute + let attributeOne : NSLayoutConstraint.Attribute + let attributeTwo : NSLayoutConstraint.Attribute switch statusBarOrientation { case .portrait: @@ -249,7 +249,7 @@ extension CameraViewController { */ func configCloseButtonEdgeConstraint(_ statusBarOrientation : UIInterfaceOrientation) { - let attribute : NSLayoutAttribute = { + let attribute : NSLayoutConstraint.Attribute = { switch statusBarOrientation { case .portrait: return .left case .landscapeRight, .landscapeLeft: return .centerX @@ -278,7 +278,7 @@ extension CameraViewController { */ func configCloseButtonGravityConstraint(_ statusBarOrientation : UIInterfaceOrientation) { - let attribute : NSLayoutAttribute + let attribute : NSLayoutConstraint.Attribute let constant : CGFloat switch statusBarOrientation { @@ -331,8 +331,8 @@ extension CameraViewController { */ func configLibraryEdgeButtonConstraint(_ statusBarOrientation : UIInterfaceOrientation) { - let attributeOne : NSLayoutAttribute - let attributeTwo : NSLayoutAttribute + let attributeOne : NSLayoutConstraint.Attribute + let attributeTwo : NSLayoutConstraint.Attribute switch statusBarOrientation { case .portrait: @@ -401,7 +401,7 @@ extension CameraViewController { view.autoRemoveConstraint(flashButtonEdgeConstraint) let constraintRight = statusBarOrientation == .portrait || statusBarOrientation == .landscapeRight - let attribute : NSLayoutAttribute = constraintRight ? .topMargin : .bottomMargin + let attribute : NSLayoutConstraint.Attribute = constraintRight ? .topMargin : .bottomMargin flashButtonEdgeConstraint = NSLayoutConstraint( item: flashButton, @@ -425,7 +425,7 @@ extension CameraViewController { view.autoRemoveConstraint(flashButtonGravityConstraint) let constraintRight = statusBarOrientation == .portrait || statusBarOrientation == .landscapeLeft - let attribute : NSLayoutAttribute = constraintRight ? .right : .left + let attribute : NSLayoutConstraint.Attribute = constraintRight ? .right : .left flashButtonGravityConstraint = NSLayoutConstraint( item: flashButton, @@ -466,7 +466,7 @@ extension CameraViewController { */ func configCameraOverlayCenterConstraint(_ portrait: Bool) { view.autoRemoveConstraint(cameraOverlayCenterConstraint) - let attribute : NSLayoutAttribute = portrait ? .centerY : .centerX + let attribute : NSLayoutConstraint.Attribute = portrait ? .centerY : .centerX cameraOverlayCenterConstraint = NSLayoutConstraint( item: cameraOverlay, attribute: attribute, @@ -494,7 +494,7 @@ extension CameraViewController { the view will be pinned. */ func configCameraOverlayEdgeOneContraint(_ portrait: Bool, padding: CGFloat) { - let attribute : NSLayoutAttribute = portrait ? .left : .bottom + let attribute : NSLayoutConstraint.Attribute = portrait ? .left : .bottom cameraOverlayEdgeOneConstraint = NSLayoutConstraint( item: cameraOverlay, attribute: attribute, @@ -513,7 +513,7 @@ extension CameraViewController { the view will be pinned. */ func configCameraOverlayEdgeTwoConstraint(_ portrait: Bool, padding: CGFloat) { - let attributeTwo : NSLayoutAttribute = portrait ? .right : .top + let attributeTwo : NSLayoutConstraint.Attribute = portrait ? .right : .top cameraOverlayEdgeTwoConstraint = NSLayoutConstraint( item: cameraOverlay, attribute: attributeTwo, diff --git a/ALCameraViewController/ViewController/ConfirmViewController.swift b/ALCameraViewController/ViewController/ConfirmViewController.swift index 5c7fb257..55d091cc 100644 --- a/ALCameraViewController/ViewController/ConfirmViewController.swift +++ b/ALCameraViewController/ViewController/ConfirmViewController.swift @@ -273,12 +273,12 @@ public class ConfirmViewController: UIViewController, UIScrollViewDelegate { func showSpinner() -> UIActivityIndicatorView { let spinner = UIActivityIndicatorView() - spinner.activityIndicatorViewStyle = .white + spinner.style = .white spinner.center = view.center spinner.startAnimating() view.addSubview(spinner) - view.bringSubview(toFront: spinner) + view.bringSubviewToFront(spinner) return spinner } diff --git a/ALCameraViewController/ViewController/PhotoLibraryViewController.swift b/ALCameraViewController/ViewController/PhotoLibraryViewController.swift index 8bdc9cd6..28c06f50 100644 --- a/ALCameraViewController/ViewController/PhotoLibraryViewController.swift +++ b/ALCameraViewController/ViewController/PhotoLibraryViewController.swift @@ -40,10 +40,10 @@ public class PhotoLibraryViewController: UIViewController { setNeedsStatusBarAppearanceUpdate() - let buttonImage = UIImage(named: "libraryCancel", in: CameraGlobals.shared.bundle, compatibleWith: nil)?.withRenderingMode(UIImageRenderingMode.alwaysOriginal) + let buttonImage = UIImage(named: "libraryCancel", in: CameraGlobals.shared.bundle, compatibleWith: nil)?.withRenderingMode(UIImage.RenderingMode.alwaysOriginal) navigationItem.leftBarButtonItem = UIBarButtonItem(image: buttonImage, - style: UIBarButtonItemStyle.plain, + style: UIBarButtonItem.Style.plain, target: self, action: #selector(dismissLibrary)) diff --git a/ALCameraViewController/Views/CameraView.swift b/ALCameraViewController/Views/CameraView.swift index b008924b..771d378c 100644 --- a/ALCameraViewController/Views/CameraView.swift +++ b/ALCameraViewController/Views/CameraView.swift @@ -119,9 +119,9 @@ public class CameraView: UIView { focusView.alpha = 0 focusView.transform = CGAffineTransform(scaleX: 1.2, y: 1.2) - bringSubview(toFront: focusView) + bringSubviewToFront(focusView) - UIView.animateKeyframes(withDuration: 1.5, delay: 0, options: UIViewKeyframeAnimationOptions(), animations: { + UIView.animateKeyframes(withDuration: 1.5, delay: 0, options: UIView.KeyframeAnimationOptions(), animations: { UIView.addKeyframe(withRelativeStartTime: 0, relativeDuration: 0.15, animations: { [weak self] in self?.focusView.alpha = 1 diff --git a/ALCameraViewController/Views/PermissionsView.swift b/ALCameraViewController/Views/PermissionsView.swift index d814558b..4e30dab3 100644 --- a/ALCameraViewController/Views/PermissionsView.swift +++ b/ALCameraViewController/Views/PermissionsView.swift @@ -39,7 +39,7 @@ internal class PermissionsView: UIView { descriptionLabel.text = description closeButton.action = completion - closeButton.setImage(UIImage(named: "retakeButton", in: CameraGlobals.shared.bundle, compatibleWith: nil), for: UIControlState()) + closeButton.setImage(UIImage(named: "retakeButton", in: CameraGlobals.shared.bundle, compatibleWith: nil), for: UIControl.State()) closeButton.sizeToFit() let size = view.frame.size @@ -69,13 +69,13 @@ internal class PermissionsView: UIView { let icon = UIImage(named: "permissionsIcon", in: CameraGlobals.shared.bundle, compatibleWith: nil)! iconView.image = icon - settingsButton.contentEdgeInsets = UIEdgeInsetsMake(6, 12, 6, 12) - settingsButton.setTitle(localizedString("permissions.settings"), for: UIControlState()) - settingsButton.setTitleColor(UIColor.white, for: UIControlState()) + settingsButton.contentEdgeInsets = UIEdgeInsets.init(top: 6, left: 12, bottom: 6, right: 12) + settingsButton.setTitle(localizedString("permissions.settings"), for: UIControl.State()) + settingsButton.setTitleColor(UIColor.white, for: UIControl.State()) settingsButton.layer.cornerRadius = 4 settingsButton.titleLabel?.font = UIFont(name: "AppleSDGothicNeo-Regular", size: 14) settingsButton.backgroundColor = UIColor(red: 52.0/255.0, green: 183.0/255.0, blue: 250.0/255.0, alpha: 1) - settingsButton.addTarget(self, action: #selector(PermissionsView.openSettings), for: UIControlEvents.touchUpInside) + settingsButton.addTarget(self, action: #selector(PermissionsView.openSettings), for: UIControl.Event.touchUpInside) addSubview(iconView) addSubview(titleLabel) @@ -84,7 +84,7 @@ internal class PermissionsView: UIView { } @objc func openSettings() { - if let appSettings = URL(string: UIApplicationOpenSettingsURLString) { + if let appSettings = URL(string: UIApplication.openSettingsURLString) { UIApplication.shared.openURL(appSettings) } } diff --git a/Example/AppDelegate.swift b/Example/AppDelegate.swift index c8de81bf..85e656c0 100644 --- a/Example/AppDelegate.swift +++ b/Example/AppDelegate.swift @@ -13,7 +13,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate { var window: UIWindow? - func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey : Any]? = nil) -> Bool { + func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil) -> Bool { let viewController = ViewController(nibName: "ViewController", bundle: Bundle.main) window = UIWindow(frame: UIScreen.main.bounds) From f7e65bfbb27ded37eeafccb5bfab89a8b780332d Mon Sep 17 00:00:00 2001 From: Guillaume Bellut Date: Sat, 12 Oct 2019 15:03:37 +0200 Subject: [PATCH 03/20] Changed default settings for testing project --- Example/ViewController.swift | 28 ++++++------------ Example/ViewController.xib | 55 +++++++++++++----------------------- 2 files changed, 28 insertions(+), 55 deletions(-) diff --git a/Example/ViewController.swift b/Example/ViewController.swift index e4c6aa1b..4c666c4e 100644 --- a/Example/ViewController.swift +++ b/Example/ViewController.swift @@ -10,28 +10,29 @@ import UIKit class ViewController: UIViewController { - var libraryEnabled: Bool = true - var croppingEnabled: Bool = false - var allowResizing: Bool = true - var allowMoving: Bool = false var minimumSize: CGSize = CGSize(width: 60, height: 60) var croppingParameters: CroppingParameters { - return CroppingParameters(isEnabled: croppingEnabled, allowResizing: allowResizing, allowMoving: allowMoving, minimumSize: minimumSize) + return CroppingParameters(isEnabled: croppingSwitch.isOn, allowResizing: resizableSwitch.isOn, allowMoving: movableSwitch.isOn, minimumSize: minimumSize) } @IBOutlet weak var imageView: UIImageView! @IBOutlet weak var croppingParametersView: UIView! @IBOutlet weak var minimumSizeLabel: UILabel! - + @IBOutlet weak var librarySwitch: UISwitch! + @IBOutlet weak var croppingSwitch: UISwitch! + @IBOutlet weak var resizableSwitch: UISwitch! + @IBOutlet weak var movableSwitch: UISwitch! + override func viewDidLoad() { super.viewDidLoad() self.imageView.contentMode = .scaleAspectFit + croppingParametersView.isHidden = !croppingSwitch.isOn } @IBAction func openCamera(_ sender: Any) { - let cameraViewController = CameraViewController(croppingParameters: croppingParameters, allowsLibraryAccess: libraryEnabled) { [weak self] image, asset in + let cameraViewController = CameraViewController(croppingParameters: croppingParameters, allowsLibraryAccess: librarySwitch.isOn) { [weak self] image, asset in self?.imageView.image = image self?.dismiss(animated: true, completion: nil) } @@ -48,23 +49,10 @@ class ViewController: UIViewController { present(libraryViewController, animated: true, completion: nil) } - @IBAction func libraryChanged(_ sender: Any) { - libraryEnabled = !libraryEnabled - } - @IBAction func croppingChanged(_ sender: UISwitch) { - croppingEnabled = sender.isOn croppingParametersView.isHidden = !sender.isOn } - @IBAction func resizingChanged(_ sender: UISwitch) { - allowResizing = sender.isOn - } - - @IBAction func movingChanged(_ sender: UISwitch) { - allowMoving = sender.isOn - } - @IBAction func minimumSizeChanged(_ sender: UISlider) { let newValue = sender.value minimumSize = CGSize(width: CGFloat(newValue), height: CGFloat(newValue)) diff --git a/Example/ViewController.xib b/Example/ViewController.xib index 969010cb..1048f940 100644 --- a/Example/ViewController.xib +++ b/Example/ViewController.xib @@ -1,25 +1,22 @@ - - - - + + - + - - - AppleSDGothicNeo-Regular - - + + + + @@ -32,10 +29,10 @@ - + - - + + - - - - +