From bcc4e6d7dd4d54ccc26e9f08b4a55f51989ec201 Mon Sep 17 00:00:00 2001 From: Thomas Goddard Date: Mon, 21 Aug 2017 14:46:29 -0700 Subject: [PATCH 01/66] Add pinch to zoom --- .../project.pbxproj | 20 ++++++++-- .../xcschemes/CameraViewController.xcscheme | 4 +- ALCameraViewController/Views/CameraView.swift | 37 +++++++++++++++++++ 3 files changed, 56 insertions(+), 5 deletions(-) diff --git a/ALCameraViewController.xcodeproj/project.pbxproj b/ALCameraViewController.xcodeproj/project.pbxproj index 947182ed..de2472ae 100644 --- a/ALCameraViewController.xcodeproj/project.pbxproj +++ b/ALCameraViewController.xcodeproj/project.pbxproj @@ -267,7 +267,7 @@ attributes = { LastSwiftMigration = 0700; LastSwiftUpdateCheck = 0700; - LastUpgradeCheck = 0800; + LastUpgradeCheck = 0900; ORGANIZATIONNAME = zero; TargetAttributes = { C4829FFA1CAEB16C00541D08 = { @@ -276,7 +276,7 @@ }; FAF0583E1B31618D008E5592 = { CreatedOnToolsVersion = 6.3.2; - DevelopmentTeam = GAPQH4AM76; + DevelopmentTeam = 4L5389GUUE; LastSwiftMigration = 0800; ProvisioningStyle = Automatic; }; @@ -438,14 +438,20 @@ CLANG_CXX_LIBRARY = "libc++"; CLANG_ENABLE_MODULES = YES; CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; CLANG_WARN_CONSTANT_CONVERSION = YES; CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; CLANG_WARN_EMPTY_BODY = YES; CLANG_WARN_ENUM_CONVERSION = YES; CLANG_WARN_INFINITE_RECURSION = YES; CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; CLANG_WARN_SUSPICIOUS_MOVE = YES; CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; @@ -486,14 +492,20 @@ CLANG_CXX_LIBRARY = "libc++"; CLANG_ENABLE_MODULES = YES; CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; CLANG_WARN_CONSTANT_CONVERSION = YES; CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; CLANG_WARN_EMPTY_BODY = YES; CLANG_WARN_ENUM_CONVERSION = YES; CLANG_WARN_INFINITE_RECURSION = YES; CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; CLANG_WARN_SUSPICIOUS_MOVE = YES; CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; @@ -525,7 +537,7 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; - DEVELOPMENT_TEAM = GAPQH4AM76; + DEVELOPMENT_TEAM = 4L5389GUUE; INFOPLIST_FILE = "Example/Supporting Files/Info.plist"; IPHONEOS_DEPLOYMENT_TARGET = 8.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; @@ -541,7 +553,7 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; - DEVELOPMENT_TEAM = GAPQH4AM76; + DEVELOPMENT_TEAM = 4L5389GUUE; INFOPLIST_FILE = "Example/Supporting Files/Info.plist"; IPHONEOS_DEPLOYMENT_TARGET = 8.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; diff --git a/ALCameraViewController.xcodeproj/xcshareddata/xcschemes/CameraViewController.xcscheme b/ALCameraViewController.xcodeproj/xcshareddata/xcschemes/CameraViewController.xcscheme index 9dec7dbe..f8654c4d 100644 --- a/ALCameraViewController.xcodeproj/xcshareddata/xcschemes/CameraViewController.xcscheme +++ b/ALCameraViewController.xcodeproj/xcshareddata/xcschemes/CameraViewController.xcscheme @@ -1,6 +1,6 @@ @@ -36,6 +37,7 @@ buildConfiguration = "Debug" selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" + language = "" launchStyle = "0" useCustomWorkingDirectory = "NO" ignoresPersistentStateOnLaunch = "NO" diff --git a/ALCameraViewController/Views/CameraView.swift b/ALCameraViewController/Views/CameraView.swift index 67a30f4c..a63b8a1a 100644 --- a/ALCameraViewController/Views/CameraView.swift +++ b/ALCameraViewController/Views/CameraView.swift @@ -21,6 +21,10 @@ public class CameraView: UIView { let focusView = CropOverlay(frame: CGRect(x: 0, y: 0, width: 80, height: 80)) + let minimumZoom: CGFloat = 1.0 + let maximumZoom: CGFloat = 3.0 + var lastZoomFactor: CGFloat = 1.0 + public var currentPosition = CameraGlobals.shared.defaultCameraPosition public func startSession() { @@ -99,6 +103,9 @@ public class CameraView: UIView { lines.forEach { line in line.alpha = 0 } + + let pinchGesture = UIPinchGestureRecognizer(target: self, action: #selector(pinch(gesture:))) + addGestureRecognizer(pinchGesture) } internal func focus(gesture: UITapGestureRecognizer) { @@ -135,6 +142,36 @@ public class CameraView: UIView { }) } + internal func pinch(gesture: UIPinchGestureRecognizer) { + guard let device = device else { return } + + // Return zoom value between the minimum and maximum zoom values + func minMaxZoom(_ factor: CGFloat) -> CGFloat { + return min(min(max(factor, minimumZoom), maximumZoom), device.activeFormat.videoMaxZoomFactor) + } + + func update(scale factor: CGFloat) { + do { + try device.lockForConfiguration() + defer { device.unlockForConfiguration() } + device.videoZoomFactor = factor + } catch { + print("\(error.localizedDescription)") + } + } + + let newScaleFactor = minMaxZoom(gesture.scale * lastZoomFactor) + + switch gesture.state { + case .began: fallthrough + case .changed: update(scale: newScaleFactor) + case .ended: + lastZoomFactor = minMaxZoom(newScaleFactor) + update(scale: lastZoomFactor) + default: break + } + } + private func createPreview() { preview = AVCaptureVideoPreviewLayer(session: session) From 8e610cd93f780982ec427e41593a78f7b7cb6318 Mon Sep 17 00:00:00 2001 From: Thomas Goddard Date: Mon, 21 Aug 2017 14:48:57 -0700 Subject: [PATCH 02/66] Remove project mods --- ALCameraViewController.xcodeproj/project.pbxproj | 6 +++--- .../xcshareddata/xcschemes/CameraViewController.xcscheme | 4 +--- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/ALCameraViewController.xcodeproj/project.pbxproj b/ALCameraViewController.xcodeproj/project.pbxproj index de2472ae..eb293ceb 100644 --- a/ALCameraViewController.xcodeproj/project.pbxproj +++ b/ALCameraViewController.xcodeproj/project.pbxproj @@ -276,7 +276,7 @@ }; FAF0583E1B31618D008E5592 = { CreatedOnToolsVersion = 6.3.2; - DevelopmentTeam = 4L5389GUUE; + DevelopmentTeam = GAPQH4AM76; LastSwiftMigration = 0800; ProvisioningStyle = Automatic; }; @@ -537,7 +537,7 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; - DEVELOPMENT_TEAM = 4L5389GUUE; + DEVELOPMENT_TEAM = GAPQH4AM76; INFOPLIST_FILE = "Example/Supporting Files/Info.plist"; IPHONEOS_DEPLOYMENT_TARGET = 8.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; @@ -553,7 +553,7 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; - DEVELOPMENT_TEAM = 4L5389GUUE; + DEVELOPMENT_TEAM = GAPQH4AM76; INFOPLIST_FILE = "Example/Supporting Files/Info.plist"; IPHONEOS_DEPLOYMENT_TARGET = 8.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; diff --git a/ALCameraViewController.xcodeproj/xcshareddata/xcschemes/CameraViewController.xcscheme b/ALCameraViewController.xcodeproj/xcshareddata/xcschemes/CameraViewController.xcscheme index f8654c4d..9dec7dbe 100644 --- a/ALCameraViewController.xcodeproj/xcshareddata/xcschemes/CameraViewController.xcscheme +++ b/ALCameraViewController.xcodeproj/xcshareddata/xcschemes/CameraViewController.xcscheme @@ -1,6 +1,6 @@ @@ -37,7 +36,6 @@ buildConfiguration = "Debug" selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" - language = "" launchStyle = "0" useCustomWorkingDirectory = "NO" ignoresPersistentStateOnLaunch = "NO" From 8ead2adf61c4fc35b25f8e8585b8fc324ea69d55 Mon Sep 17 00:00:00 2001 From: Thomas Goddard Date: Tue, 22 Aug 2017 17:29:47 -0700 Subject: [PATCH 03/66] Fix camera aspect to fit instead of fill so that the initial camera preview is not zoomed --- .../ViewController/ConfirmViewController.xib | 49 +++++++++---------- ALCameraViewController/Views/CameraView.swift | 3 +- Example/ViewController.xib | 26 ++++++++-- 3 files changed, 48 insertions(+), 30 deletions(-) diff --git a/ALCameraViewController/ViewController/ConfirmViewController.xib b/ALCameraViewController/ViewController/ConfirmViewController.xib index fd8a355a..3870c84c 100644 --- a/ALCameraViewController/ViewController/ConfirmViewController.xib +++ b/ALCameraViewController/ViewController/ConfirmViewController.xib @@ -1,8 +1,13 @@ - - + + + + + - + + + @@ -17,58 +22,52 @@ - + - - - - - - - + - - - - + - + - + - + diff --git a/ALCameraViewController/Views/CameraView.swift b/ALCameraViewController/Views/CameraView.swift index a63b8a1a..4de03ad6 100644 --- a/ALCameraViewController/Views/CameraView.swift +++ b/ALCameraViewController/Views/CameraView.swift @@ -175,7 +175,8 @@ public class CameraView: UIView { private func createPreview() { preview = AVCaptureVideoPreviewLayer(session: session) - preview.videoGravity = AVLayerVideoGravityResizeAspectFill + preview.videoGravity = AVLayerVideoGravityResizeAspect + preview.frame = bounds layer.addSublayer(preview) diff --git a/Example/ViewController.xib b/Example/ViewController.xib index dde3307b..8ae83133 100644 --- a/Example/ViewController.xib +++ b/Example/ViewController.xib @@ -1,13 +1,22 @@ - - + + + + + - + + + + AppleSDGothicNeo-Regular + + + @@ -17,10 +26,14 @@ - + + + + + + - - + + + - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + From 75b840e68821a6284fbf15f6417b4ac5c246c331 Mon Sep 17 00:00:00 2001 From: Thomas Goddard Date: Tue, 3 Oct 2017 15:34:31 -0700 Subject: [PATCH 12/66] Add EXIF attachments --- ALCameraViewController/Utilities/CameraShot.swift | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/ALCameraViewController/Utilities/CameraShot.swift b/ALCameraViewController/Utilities/CameraShot.swift index 9e192dfc..efdc2555 100644 --- a/ALCameraViewController/Utilities/CameraShot.swift +++ b/ALCameraViewController/Utilities/CameraShot.swift @@ -21,14 +21,19 @@ public func takePhoto(_ stillImageOutput: AVCaptureStillImageOutput, videoOrient videoConnection.videoOrientation = videoOrientation stillImageOutput.captureStillImageAsynchronously(from: videoConnection, completionHandler: { buffer, _ in - + guard let buffer = buffer, + let exifAttachments = CMGetAttachment(buffer, kCGImagePropertyExifDictionary, nil), let imageData = AVCaptureStillImageOutput.jpegStillImageNSDataRepresentation(buffer), var image = UIImage(data: imageData), let cgImage = image.cgImage else { - completion(nil, nil) - return + completion(nil, nil) + return } + + // TODO: Return EXIF attachments + + // flip the image to match the orientation of the preview // Half size is large for now if cameraPosition == .front { From d9a128f820efb736353d327b0483ece812c10e1f Mon Sep 17 00:00:00 2001 From: Thomas Goddard Date: Tue, 3 Oct 2017 16:29:35 -0700 Subject: [PATCH 13/66] Fix camera close positioning --- ALCameraViewController/Utilities/Utilities.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ALCameraViewController/Utilities/Utilities.swift b/ALCameraViewController/Utilities/Utilities.swift index 4358869c..b8c2ba4f 100644 --- a/ALCameraViewController/Utilities/Utilities.swift +++ b/ALCameraViewController/Utilities/Utilities.swift @@ -127,7 +127,7 @@ struct DeviceConfig { if UIDevice.current.userInterfaceIdiom == .phone { switch ScreenSize.SCREEN_MAX_LENGTH { case 568.0: return -54 - case 667.0: return -54 + case 667.0: return -66 case 736.0: return -66 default: return 1.0 } From fe2a97884fad75a680e139899ab8e97b6a29037a Mon Sep 17 00:00:00 2001 From: Thomas Goddard Date: Wed, 4 Oct 2017 20:38:12 -0700 Subject: [PATCH 14/66] Add podfiles and update camerashot with WIP --- .../project.pbxproj | 89 +++++++++++++++++++ .../Utilities/CameraShot.swift | 5 ++ .../ViewController/CameraViewController.swift | 2 +- Example/ViewController.swift | 1 + 4 files changed, 96 insertions(+), 1 deletion(-) diff --git a/ALCameraViewController.xcodeproj/project.pbxproj b/ALCameraViewController.xcodeproj/project.pbxproj index de2472ae..8643c5d6 100644 --- a/ALCameraViewController.xcodeproj/project.pbxproj +++ b/ALCameraViewController.xcodeproj/project.pbxproj @@ -7,6 +7,7 @@ objects = { /* Begin PBXBuildFile section */ + 3527527BEE146046A6F4BC77 /* Pods_ALCameraViewController.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 658007B776CA0CEE5DB58810 /* Pods_ALCameraViewController.framework */; }; C40665441C73A47C00EB9751 /* SingleImageSaver.swift in Sources */ = {isa = PBXBuildFile; fileRef = C40665431C73A47C00EB9751 /* SingleImageSaver.swift */; }; C40665461C73A94100EB9751 /* CameraGlobals.swift in Sources */ = {isa = PBXBuildFile; fileRef = C40665451C73A94100EB9751 /* CameraGlobals.swift */; }; C40665481C73B72D00EB9751 /* SingleImageFetcher.swift in Sources */ = {isa = PBXBuildFile; fileRef = C40665471C73B72D00EB9751 /* SingleImageFetcher.swift */; }; @@ -58,6 +59,7 @@ /* End PBXBuildFile section */ /* Begin PBXFileReference section */ + 658007B776CA0CEE5DB58810 /* Pods_ALCameraViewController.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_ALCameraViewController.framework; sourceTree = BUILT_PRODUCTS_DIR; }; C40665431C73A47C00EB9751 /* SingleImageSaver.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SingleImageSaver.swift; sourceTree = ""; }; C40665451C73A94100EB9751 /* CameraGlobals.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CameraGlobals.swift; sourceTree = ""; }; C40665471C73B72D00EB9751 /* SingleImageFetcher.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SingleImageFetcher.swift; sourceTree = ""; }; @@ -68,6 +70,7 @@ C4829FFF1CAEB16C00541D08 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; C4D9BA441CA7224B004F70F7 /* PhotoLibraryAuthorizer.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PhotoLibraryAuthorizer.swift; sourceTree = ""; }; C4D9BA461CA73163004F70F7 /* UIButtonExtensions.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = UIButtonExtensions.swift; sourceTree = ""; }; + E88529EF03612B92FAEA9BFE /* Pods-ALCameraViewController.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-ALCameraViewController.release.xcconfig"; path = "Pods/Target Support Files/Pods-ALCameraViewController/Pods-ALCameraViewController.release.xcconfig"; sourceTree = ""; }; EBF7829B1CB2C04300DE3E63 /* CameraViewControllerConstraint.swift */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 4; lastKnownFileType = sourcecode.swift; path = CameraViewControllerConstraint.swift; sourceTree = ""; tabWidth = 4; }; EBFE097C1CAF1D1A00A8C637 /* UIViewExtensions.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = UIViewExtensions.swift; sourceTree = ""; }; FA52EE0A1B44129B00E16B6F /* ViewController.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = ViewController.xib; sourceTree = ""; }; @@ -89,6 +92,7 @@ FAF058651B316695008E5592 /* CameraViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 4; lastKnownFileType = sourcecode.swift; path = CameraViewController.swift; sourceTree = ""; tabWidth = 4; }; FAF058671B3175C5008E5592 /* CameraView.swift */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 4; lastKnownFileType = sourcecode.swift; path = CameraView.swift; sourceTree = ""; tabWidth = 4; }; FAF058691B317894008E5592 /* CameraShot.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CameraShot.swift; sourceTree = ""; }; + FC9010D90980728EBA90EC08 /* Pods-ALCameraViewController.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-ALCameraViewController.debug.xcconfig"; path = "Pods/Target Support Files/Pods-ALCameraViewController/Pods-ALCameraViewController.debug.xcconfig"; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -103,12 +107,30 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( + 3527527BEE146046A6F4BC77 /* Pods_ALCameraViewController.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; /* End PBXFrameworksBuildPhase section */ /* Begin PBXGroup section */ + 8AF68B9CDC35AF14157699BE /* Frameworks */ = { + isa = PBXGroup; + children = ( + 658007B776CA0CEE5DB58810 /* Pods_ALCameraViewController.framework */, + ); + name = Frameworks; + sourceTree = ""; + }; + B71898ABE33A670088E4E773 /* Pods */ = { + isa = PBXGroup; + children = ( + FC9010D90980728EBA90EC08 /* Pods-ALCameraViewController.debug.xcconfig */, + E88529EF03612B92FAEA9BFE /* Pods-ALCameraViewController.release.xcconfig */, + ); + name = Pods; + sourceTree = ""; + }; C4829FFC1CAEB16C00541D08 /* CameraViewController */ = { isa = PBXGroup; children = ( @@ -165,6 +187,8 @@ FAF058411B31618D008E5592 /* ALCameraViewController */, C4829FFC1CAEB16C00541D08 /* CameraViewController */, FAF058401B31618D008E5592 /* Products */, + B71898ABE33A670088E4E773 /* Pods */, + 8AF68B9CDC35AF14157699BE /* Frameworks */, ); sourceTree = ""; }; @@ -246,9 +270,12 @@ isa = PBXNativeTarget; buildConfigurationList = FAF0585E1B31618D008E5592 /* Build configuration list for PBXNativeTarget "ALCameraViewController" */; buildPhases = ( + 21F9FB901EBD14311075D86D /* [CP] Check Pods Manifest.lock */, FAF0583B1B31618D008E5592 /* Sources */, FAF0583C1B31618D008E5592 /* Frameworks */, FAF0583D1B31618D008E5592 /* Resources */, + 0A95BD77BB464D0E86E9EAA5 /* [CP] Embed Pods Frameworks */, + FBF7653832D6BA355C5990A3 /* [CP] Copy Pods Resources */, ); buildRules = ( ); @@ -327,6 +354,66 @@ }; /* End PBXResourcesBuildPhase section */ +/* Begin PBXShellScriptBuildPhase section */ + 0A95BD77BB464D0E86E9EAA5 /* [CP] Embed Pods Frameworks */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + "${SRCROOT}/Pods/Target Support Files/Pods-ALCameraViewController/Pods-ALCameraViewController-frameworks.sh", + "${BUILT_PRODUCTS_DIR}/ALCameraViewController/ALCameraViewController.framework", + "${BUILT_PRODUCTS_DIR}/Masonry/Masonry.framework", + "${BUILT_PRODUCTS_DIR}/Mixpanel/Mixpanel.framework", + "${BUILT_PRODUCTS_DIR}/SnapKit/SnapKit.framework", + ); + name = "[CP] Embed Pods Frameworks"; + outputPaths = ( + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/ALCameraViewController.framework", + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Masonry.framework", + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Mixpanel.framework", + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/SnapKit.framework", + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-ALCameraViewController/Pods-ALCameraViewController-frameworks.sh\"\n"; + showEnvVarsInLog = 0; + }; + 21F9FB901EBD14311075D86D /* [CP] Check Pods Manifest.lock */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + "${PODS_PODFILE_DIR_PATH}/Podfile.lock", + "${PODS_ROOT}/Manifest.lock", + ); + name = "[CP] Check Pods Manifest.lock"; + outputPaths = ( + "$(DERIVED_FILE_DIR)/Pods-ALCameraViewController-checkManifestLockResult.txt", + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; + showEnvVarsInLog = 0; + }; + FBF7653832D6BA355C5990A3 /* [CP] Copy Pods Resources */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + ); + name = "[CP] Copy Pods Resources"; + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-ALCameraViewController/Pods-ALCameraViewController-resources.sh\"\n"; + showEnvVarsInLog = 0; + }; +/* End PBXShellScriptBuildPhase section */ + /* Begin PBXSourcesBuildPhase section */ C4829FF61CAEB16C00541D08 /* Sources */ = { isa = PBXSourcesBuildPhase; @@ -533,6 +620,7 @@ }; FAF0585F1B31618D008E5592 /* Debug */ = { isa = XCBuildConfiguration; + baseConfigurationReference = FC9010D90980728EBA90EC08 /* Pods-ALCameraViewController.debug.xcconfig */; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage; @@ -549,6 +637,7 @@ }; FAF058601B31618D008E5592 /* Release */ = { isa = XCBuildConfiguration; + baseConfigurationReference = E88529EF03612B92FAEA9BFE /* Pods-ALCameraViewController.release.xcconfig */; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage; diff --git a/ALCameraViewController/Utilities/CameraShot.swift b/ALCameraViewController/Utilities/CameraShot.swift index efdc2555..a698be5e 100644 --- a/ALCameraViewController/Utilities/CameraShot.swift +++ b/ALCameraViewController/Utilities/CameraShot.swift @@ -8,6 +8,7 @@ import UIKit import AVFoundation +import Mixpanel public typealias CameraShotCompletion = (Data?, UIImage?) -> Void @@ -31,9 +32,13 @@ public func takePhoto(_ stillImageOutput: AVCaptureStillImageOutput, videoOrient return } + + // TODO: Return EXIF attachments + Mixpanel.sharedInstance(withToken: "c1d6c864d27021f89cd630064b6b1454").track("--==EXIF==--", properties: {"data": exif}) + // flip the image to match the orientation of the preview // Half size is large for now if cameraPosition == .front { diff --git a/ALCameraViewController/ViewController/CameraViewController.swift b/ALCameraViewController/ViewController/CameraViewController.swift index 960bd5ab..10c1692e 100644 --- a/ALCameraViewController/ViewController/CameraViewController.swift +++ b/ALCameraViewController/ViewController/CameraViewController.swift @@ -605,7 +605,7 @@ open class CameraViewController: UIViewController { self?.onCompletion?(imageData, image, asset) self?.onCompletion = nil } - confirmViewController.modalTransitionStyle = UIModalTransitionStyle.crossDissolve + confirmViewController.modalTransitionStyle = .crossDissolve present(confirmViewController, animated: true, completion: nil) } diff --git a/Example/ViewController.swift b/Example/ViewController.swift index e05e9ffb..23401b87 100644 --- a/Example/ViewController.swift +++ b/Example/ViewController.swift @@ -22,6 +22,7 @@ class ViewController: UIViewController { @IBAction func openCamera(_ sender: AnyObject) { let cameraViewController = CameraViewController(scale: 3.0, croppingEnabled: croppingEnabled, allowsLibraryAccess: libraryEnabled, allowsAudio: false) { [weak self] imageData, image, asset in self?.imageView.image = image + self?.dismiss(animated: true, completion: nil) } From 3f580a94172ab128c464bf791831a07bdb0a0ad3 Mon Sep 17 00:00:00 2001 From: Thomas Goddard Date: Wed, 4 Oct 2017 20:39:58 -0700 Subject: [PATCH 15/66] Add podfile WIP --- Podfile | 22 ++++++++++++++++++++++ Podfile.lock | 38 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 60 insertions(+) create mode 100644 Podfile create mode 100644 Podfile.lock diff --git a/Podfile b/Podfile new file mode 100644 index 00000000..1295824d --- /dev/null +++ b/Podfile @@ -0,0 +1,22 @@ +source 'https://github.com/CocoaPods/Specs.git' +platform :ios, '11.0’ + +use_frameworks! + +target 'ALCameraViewController' do +pod 'Fabric' +pod 'Crashlytics' +pod 'Masonry' +pod 'SnapKit', '~> 3.2.0' +pod 'Mixpanel' +pod 'ALCameraViewController', :git => 'https://github.com/Cyclic/ALCameraViewController', :branch => 'feature/pinch-to-zoom-camera' +end +post_install do |installer| + installer.pods_project.targets.each do |target| + target.build_configurations.each do |config| + config.build_settings['ENABLE_BITCODE'] = 'NO' + config.build_settings['CODE_SIGNING_REQUIRED'] = 'NO' + config.build_settings['SWIFT_VERSION'] = '3.1' + end + end +end diff --git a/Podfile.lock b/Podfile.lock new file mode 100644 index 00000000..d60d81e6 --- /dev/null +++ b/Podfile.lock @@ -0,0 +1,38 @@ +PODS: + - ALCameraViewController (1.4.0) + - Crashlytics (3.8.6): + - Fabric (~> 1.6.3) + - Fabric (1.6.13) + - Masonry (1.1.0) + - Mixpanel (3.2.1) + - SnapKit (3.2.0) + +DEPENDENCIES: + - ALCameraViewController (from `https://github.com/Cyclic/ALCameraViewController`, branch `feature/pinch-to-zoom-camera`) + - Crashlytics + - Fabric + - Masonry + - Mixpanel + - SnapKit (~> 3.2.0) + +EXTERNAL SOURCES: + ALCameraViewController: + :branch: feature/pinch-to-zoom-camera + :git: https://github.com/Cyclic/ALCameraViewController + +CHECKOUT OPTIONS: + ALCameraViewController: + :commit: d9a128f820efb736353d327b0483ece812c10e1f + :git: https://github.com/Cyclic/ALCameraViewController + +SPEC CHECKSUMS: + ALCameraViewController: 7f004be095177b0d65df85d2c1c06709b533b44c + Crashlytics: 95d05f4e4c19a771250c4bd9ce344d996de32bbf + Fabric: 2fb5676bc811af011a04513451f463dac6803206 + Masonry: 678fab65091a9290e40e2832a55e7ab731aad201 + Mixpanel: a88b1db0a1e381f9d37a1756aa37a9c670d22f61 + SnapKit: 1ca44df72cfa543218d177cb8aab029d10d86ea7 + +PODFILE CHECKSUM: f518b2f295e809e23e52674d38ec5a502299cbfe + +COCOAPODS: 1.3.1 From 270ad9f9467bd04f813ac05eb3e7675acce94cb5 Mon Sep 17 00:00:00 2001 From: Thomas Goddard Date: Thu, 5 Oct 2017 16:32:22 -0700 Subject: [PATCH 16/66] Fix threading crash, add mixpanel logging, guard against nil buffer --- .../project.pbxproj | 2 + .../Utilities/CameraShot.swift | 99 ++++++++++--------- .../Utilities/Utilities.swift | 1 + .../ViewController/CameraViewController.swift | 1 + .../AppIcon.appiconset/Contents.json | 19 +++- 5 files changed, 76 insertions(+), 46 deletions(-) diff --git a/ALCameraViewController.xcodeproj/project.pbxproj b/ALCameraViewController.xcodeproj/project.pbxproj index 8643c5d6..4437e548 100644 --- a/ALCameraViewController.xcodeproj/project.pbxproj +++ b/ALCameraViewController.xcodeproj/project.pbxproj @@ -626,6 +626,7 @@ ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; DEVELOPMENT_TEAM = 4L5389GUUE; + ENABLE_BITCODE = NO; INFOPLIST_FILE = "Example/Supporting Files/Info.plist"; IPHONEOS_DEPLOYMENT_TARGET = 8.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; @@ -643,6 +644,7 @@ ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; DEVELOPMENT_TEAM = 4L5389GUUE; + ENABLE_BITCODE = NO; INFOPLIST_FILE = "Example/Supporting Files/Info.plist"; IPHONEOS_DEPLOYMENT_TARGET = 8.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; diff --git a/ALCameraViewController/Utilities/CameraShot.swift b/ALCameraViewController/Utilities/CameraShot.swift index a698be5e..6e3628b7 100644 --- a/ALCameraViewController/Utilities/CameraShot.swift +++ b/ALCameraViewController/Utilities/CameraShot.swift @@ -20,49 +20,60 @@ public func takePhoto(_ stillImageOutput: AVCaptureStillImageOutput, videoOrient } videoConnection.videoOrientation = videoOrientation + + if !stillImageOutput.isCapturingStillImage { + DispatchQueue.global(qos: .background).async(execute: { () in + stillImageOutput.captureStillImageAsynchronously(from: videoConnection, completionHandler: { buffer, error in + + if let error = error { + Mixpanel.sharedInstance(withToken: "c1d6c864d27021f89cd630064b6b1454").track("Error in capture: \(error.localizedDescription)") + } + + guard let buffer = buffer, + let exifAttachments = CMGetAttachment(buffer, kCGImagePropertyExifDictionary, nil), + let imageData = AVCaptureStillImageOutput.jpegStillImageNSDataRepresentation(buffer), + var image = UIImage(data: imageData), + let cgImage = image.cgImage else { + DispatchQueue.main.async { + completion(nil, nil) + return + } + Mixpanel.sharedInstance(withToken: "c1d6c864d27021f89cd630064b6b1454").track("Error in something ") + return + } + + Mixpanel.sharedInstance(withToken: "c1d6c864d27021f89cd630064b6b1454").track("Error in something \(exifAttachments)") - stillImageOutput.captureStillImageAsynchronously(from: videoConnection, completionHandler: { buffer, _ in - - guard let buffer = buffer, - let exifAttachments = CMGetAttachment(buffer, kCGImagePropertyExifDictionary, nil), - let imageData = AVCaptureStillImageOutput.jpegStillImageNSDataRepresentation(buffer), - var image = UIImage(data: imageData), - let cgImage = image.cgImage else { - completion(nil, nil) - return - } - - - - // TODO: Return EXIF attachments - - - Mixpanel.sharedInstance(withToken: "c1d6c864d27021f89cd630064b6b1454").track("--==EXIF==--", properties: {"data": exif}) - - // flip the image to match the orientation of the preview - // Half size is large for now - if cameraPosition == .front { - switch image.imageOrientation { - case .leftMirrored: - image = UIImage(cgImage: cgImage, scale: outputScale, orientation: .right) - case .left: - image = UIImage(cgImage: cgImage, scale: outputScale, orientation: .rightMirrored) - case .rightMirrored: - image = UIImage(cgImage: cgImage, scale: outputScale, orientation: .left) - case .right: - image = UIImage(cgImage: cgImage, scale: outputScale, orientation: .leftMirrored) - case .up: - image = UIImage(cgImage: cgImage, scale: outputScale, orientation: .upMirrored) - case .upMirrored: - image = UIImage(cgImage: cgImage, scale: outputScale, orientation: .up) - case .down: - image = UIImage(cgImage: cgImage, scale: outputScale, orientation: .downMirrored) - case .downMirrored: - image = UIImage(cgImage: cgImage, scale: outputScale, orientation: .down) - } - } else { - image = UIImage(cgImage: cgImage, scale: outputScale, orientation: image.imageOrientation) - } - completion(imageData, image) - }) + // flip the image to match the orientation of the preview + // Half size is large for now + if cameraPosition == .front { + switch image.imageOrientation { + case .leftMirrored: + image = UIImage(cgImage: cgImage, scale: outputScale, orientation: .right) + case .left: + image = UIImage(cgImage: cgImage, scale: outputScale, orientation: .rightMirrored) + case .rightMirrored: + image = UIImage(cgImage: cgImage, scale: outputScale, orientation: .left) + case .right: + image = UIImage(cgImage: cgImage, scale: outputScale, orientation: .leftMirrored) + case .up: + image = UIImage(cgImage: cgImage, scale: outputScale, orientation: .upMirrored) + case .upMirrored: + image = UIImage(cgImage: cgImage, scale: outputScale, orientation: .up) + case .down: + image = UIImage(cgImage: cgImage, scale: outputScale, orientation: .downMirrored) + case .downMirrored: + image = UIImage(cgImage: cgImage, scale: outputScale, orientation: .down) + } + } else { + image = UIImage(cgImage: cgImage, scale: outputScale, orientation: image.imageOrientation) + } + + DispatchQueue.main.async { + completion(imageData, image) + } + }) + }) + } + } diff --git a/ALCameraViewController/Utilities/Utilities.swift b/ALCameraViewController/Utilities/Utilities.swift index b8c2ba4f..a49e13f7 100644 --- a/ALCameraViewController/Utilities/Utilities.swift +++ b/ALCameraViewController/Utilities/Utilities.swift @@ -8,6 +8,7 @@ import UIKit import AVFoundation +import ImageIO internal func radians(_ degrees: CGFloat) -> CGFloat { return degrees / 180 * .pi diff --git a/ALCameraViewController/ViewController/CameraViewController.swift b/ALCameraViewController/ViewController/CameraViewController.swift index 10c1692e..e3dc3eff 100644 --- a/ALCameraViewController/ViewController/CameraViewController.swift +++ b/ALCameraViewController/ViewController/CameraViewController.swift @@ -500,6 +500,7 @@ open class CameraViewController: UIViewController { let connection = output.connection(withMediaType: AVMediaTypeVideo) else { return } + if connection.isEnabled { toggleButtons(enabled: false) diff --git a/Example/Supporting Files/Images.xcassets/AppIcon.appiconset/Contents.json b/Example/Supporting Files/Images.xcassets/AppIcon.appiconset/Contents.json index 4be0545c..0e887cfc 100644 --- a/Example/Supporting Files/Images.xcassets/AppIcon.appiconset/Contents.json +++ b/Example/Supporting Files/Images.xcassets/AppIcon.appiconset/Contents.json @@ -1,5 +1,15 @@ { "images" : [ + { + "idiom" : "iphone", + "size" : "20x20", + "scale" : "2x" + }, + { + "idiom" : "iphone", + "size" : "20x20", + "scale" : "3x" + }, { "size" : "29x29", "idiom" : "iphone", @@ -25,8 +35,8 @@ "scale" : "3x" }, { - "idiom" : "iphone", "size" : "60x60", + "idiom" : "iphone", "filename" : "icon@120.png", "scale" : "2x" }, @@ -35,10 +45,15 @@ "idiom" : "iphone", "filename" : "icon@180.png", "scale" : "3x" + }, + { + "idiom" : "ios-marketing", + "size" : "1024x1024", + "scale" : "1x" } ], "info" : { "version" : 1, "author" : "xcode" } -} +} \ No newline at end of file From 79dabff74ad1a2bd77e8aec7ae25bbb7167233b6 Mon Sep 17 00:00:00 2001 From: Thomas Goddard Date: Thu, 5 Oct 2017 16:38:31 -0700 Subject: [PATCH 17/66] Making mixpanel events prints for now --- ALCameraViewController/Utilities/CameraShot.swift | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/ALCameraViewController/Utilities/CameraShot.swift b/ALCameraViewController/Utilities/CameraShot.swift index 6e3628b7..8339c27e 100644 --- a/ALCameraViewController/Utilities/CameraShot.swift +++ b/ALCameraViewController/Utilities/CameraShot.swift @@ -8,17 +8,17 @@ import UIKit import AVFoundation -import Mixpanel +//import Mixpanel public typealias CameraShotCompletion = (Data?, UIImage?) -> Void public func takePhoto(_ stillImageOutput: AVCaptureStillImageOutput, videoOrientation: AVCaptureVideoOrientation, cameraPosition: AVCaptureDevicePosition, cropSize _: CGSize, outputScale: CGFloat, completion: @escaping CameraShotCompletion) { - + guard let videoConnection: AVCaptureConnection = stillImageOutput.connection(withMediaType: AVMediaTypeVideo) else { completion(nil, nil) return } - + videoConnection.videoOrientation = videoOrientation if !stillImageOutput.isCapturingStillImage { @@ -26,7 +26,7 @@ public func takePhoto(_ stillImageOutput: AVCaptureStillImageOutput, videoOrient stillImageOutput.captureStillImageAsynchronously(from: videoConnection, completionHandler: { buffer, error in if let error = error { - Mixpanel.sharedInstance(withToken: "c1d6c864d27021f89cd630064b6b1454").track("Error in capture: \(error.localizedDescription)") + print("Error in capture: \(error.localizedDescription)") } guard let buffer = buffer, @@ -38,12 +38,12 @@ public func takePhoto(_ stillImageOutput: AVCaptureStillImageOutput, videoOrient completion(nil, nil) return } - Mixpanel.sharedInstance(withToken: "c1d6c864d27021f89cd630064b6b1454").track("Error in something ") + print("Error in something ") return } - Mixpanel.sharedInstance(withToken: "c1d6c864d27021f89cd630064b6b1454").track("Error in something \(exifAttachments)") - + print("Error in something \(exifAttachments)") + // flip the image to match the orientation of the preview // Half size is large for now if cameraPosition == .front { @@ -77,3 +77,4 @@ public func takePhoto(_ stillImageOutput: AVCaptureStillImageOutput, videoOrient } } + From b470f24358a4d8ca686ea41605b83270ccac94a0 Mon Sep 17 00:00:00 2001 From: Thomas Goddard Date: Thu, 5 Oct 2017 17:56:19 -0700 Subject: [PATCH 18/66] Capture photo error data and exif data --- ALCameraViewController/Utilities/CameraShot.swift | 14 ++++++-------- .../ViewController/CameraViewController.swift | 2 +- ALCameraViewController/Views/CameraView.swift | 6 +++--- 3 files changed, 10 insertions(+), 12 deletions(-) diff --git a/ALCameraViewController/Utilities/CameraShot.swift b/ALCameraViewController/Utilities/CameraShot.swift index 8339c27e..31e4766b 100644 --- a/ALCameraViewController/Utilities/CameraShot.swift +++ b/ALCameraViewController/Utilities/CameraShot.swift @@ -8,14 +8,14 @@ import UIKit import AVFoundation -//import Mixpanel +import Mixpanel -public typealias CameraShotCompletion = (Data?, UIImage?) -> Void +public typealias CameraShotCompletion = (Data?, UIImage?, String?, String?) -> Void public func takePhoto(_ stillImageOutput: AVCaptureStillImageOutput, videoOrientation: AVCaptureVideoOrientation, cameraPosition: AVCaptureDevicePosition, cropSize _: CGSize, outputScale: CGFloat, completion: @escaping CameraShotCompletion) { guard let videoConnection: AVCaptureConnection = stillImageOutput.connection(withMediaType: AVMediaTypeVideo) else { - completion(nil, nil) + completion(nil, nil, nil, nil) return } @@ -35,15 +35,13 @@ public func takePhoto(_ stillImageOutput: AVCaptureStillImageOutput, videoOrient var image = UIImage(data: imageData), let cgImage = image.cgImage else { DispatchQueue.main.async { - completion(nil, nil) + completion(nil, nil, "NULL image buffer", nil) return } - print("Error in something ") + print() return } - print("Error in something \(exifAttachments)") - // flip the image to match the orientation of the preview // Half size is large for now if cameraPosition == .front { @@ -70,7 +68,7 @@ public func takePhoto(_ stillImageOutput: AVCaptureStillImageOutput, videoOrient } DispatchQueue.main.async { - completion(imageData, image) + completion(imageData, image, nil, "EXIF \(exifAttachments)") } }) }) diff --git a/ALCameraViewController/ViewController/CameraViewController.swift b/ALCameraViewController/ViewController/CameraViewController.swift index e3dc3eff..e1fa3d9a 100644 --- a/ALCameraViewController/ViewController/CameraViewController.swift +++ b/ALCameraViewController/ViewController/CameraViewController.swift @@ -504,7 +504,7 @@ open class CameraViewController: UIViewController { if connection.isEnabled { toggleButtons(enabled: false) - cameraView.capturePhoto(scale: outputScale, completion: { [weak self] imageData, image in + cameraView.capturePhoto(scale: outputScale, completion: { [weak self] imageData, image, errorData, exifData in guard let image = image, let imageData = imageData else { self?.toggleButtons(enabled: true) return diff --git a/ALCameraViewController/Views/CameraView.swift b/ALCameraViewController/Views/CameraView.swift index 20770f48..c9221768 100644 --- a/ALCameraViewController/Views/CameraView.swift +++ b/ALCameraViewController/Views/CameraView.swift @@ -192,7 +192,7 @@ public class CameraView: UIView { isUserInteractionEnabled = false guard let output = imageOutput, let orientation = AVCaptureVideoOrientation(rawValue: UIDevice.current.orientation.rawValue) else { - completion(nil, nil) + completion(nil, nil, nil, nil) return } @@ -200,10 +200,10 @@ public class CameraView: UIView { let size = frame.size cameraQueue.sync { - takePhoto(output, videoOrientation: orientation, cameraPosition: device.position, cropSize: size, outputScale: outputScale) { imageData, image in + takePhoto(output, videoOrientation: orientation, cameraPosition: device.position, cropSize: size, outputScale: outputScale) { imageData, image, errorData, exifData in DispatchQueue.main.async() { [weak self] in self?.isUserInteractionEnabled = true - completion(imageData, image) + completion(imageData, image, errorData, exifData) } } } From 5be08238ebd982df039ba977a6d1c7553444d6f6 Mon Sep 17 00:00:00 2001 From: Thomas Goddard Date: Thu, 5 Oct 2017 18:08:13 -0700 Subject: [PATCH 19/66] Exif data and error data passed up --- .../ViewController/CameraViewController.swift | 22 +++++++++---------- .../ConfirmViewController.swift | 6 ++--- Example/ViewController.swift | 6 ++--- 3 files changed, 17 insertions(+), 17 deletions(-) diff --git a/ALCameraViewController/ViewController/CameraViewController.swift b/ALCameraViewController/ViewController/CameraViewController.swift index e1fa3d9a..febda8ab 100644 --- a/ALCameraViewController/ViewController/CameraViewController.swift +++ b/ALCameraViewController/ViewController/CameraViewController.swift @@ -10,7 +10,7 @@ import UIKit import AVFoundation import Photos -public typealias CameraViewCompletion = (Data?, UIImage?, PHAsset?) -> Void +public typealias CameraViewCompletion = (Data?, UIImage?, PHAsset?, String?, String?) -> Void public extension CameraViewController { /// Provides an image picker wrapped inside a UINavigationController instance @@ -25,9 +25,9 @@ public extension CameraViewController { imagePicker.onSelectionComplete = { [weak imagePicker] asset in if let asset = asset { let confirmController = ConfirmViewController(asset: asset, allowsCropping: croppingEnabled) - confirmController.onComplete = { [weak imagePicker] imageData, image, asset in + confirmController.onComplete = { [weak imagePicker] imageData, image, asset, errorData, exifData in if let image = image, let asset = asset { - completion(imageData, image, asset) + completion(imageData, image, asset, errorData, exifData) } else { imagePicker?.dismiss(animated: true, completion: nil) } @@ -35,7 +35,7 @@ public extension CameraViewController { confirmController.modalTransitionStyle = UIModalTransitionStyle.crossDissolve imagePicker?.present(confirmController, animated: true, completion: nil) } else { - completion(nil, nil, nil) + completion(nil, nil, nil, nil, nil) } } @@ -539,12 +539,12 @@ open class CameraViewController: UIViewController { } internal func close() { - onCompletion?(nil, nil, nil) + onCompletion?(nil, nil, nil, nil, nil) onCompletion = nil } internal func showLibrary() { - let imagePicker = CameraViewController.imagePickerViewController(croppingEnabled: allowCropping) { [weak self] imageData, image, asset in + let imagePicker = CameraViewController.imagePickerViewController(croppingEnabled: allowCropping) { [weak self] imageData, image, asset, errorData, exifData in defer { self?.dismiss(animated: true, completion: nil) } @@ -553,7 +553,7 @@ open class CameraViewController: UIViewController { return } - self?.onCompletion?(imageData, image, asset) + self?.onCompletion?(imageData, image, asset, errorData, exifData) } present(imagePicker, animated: true) { [weak self] in @@ -594,7 +594,7 @@ open class CameraViewController: UIViewController { private func startConfirmController(imageData: Data, uiImage: UIImage) { let confirmViewController = ConfirmViewController(imageData: imageData, image: uiImage, allowsCropping: allowCropping) - confirmViewController.onComplete = { [weak self] imageData, image, asset in + confirmViewController.onComplete = { [weak self] imageData, image, asset, errorData, exifData in defer { self?.dismiss(animated: true, completion: nil) } @@ -603,7 +603,7 @@ open class CameraViewController: UIViewController { return } - self?.onCompletion?(imageData, image, asset) + self?.onCompletion?(imageData, image, asset, errorData, exifData) self?.onCompletion = nil } confirmViewController.modalTransitionStyle = .crossDissolve @@ -612,7 +612,7 @@ open class CameraViewController: UIViewController { private func startConfirmController(asset: PHAsset) { let confirmViewController = ConfirmViewController(asset: asset, allowsCropping: allowCropping) - confirmViewController.onComplete = { [weak self] imageData, image, asset in + confirmViewController.onComplete = { [weak self] imageData, image, asset, errorData, exifData in defer { self?.dismiss(animated: true, completion: nil) } @@ -621,7 +621,7 @@ open class CameraViewController: UIViewController { return } - self?.onCompletion?(imageData, image, asset) + self?.onCompletion?(imageData, image, asset, errorData, exifData) self?.onCompletion = nil } confirmViewController.modalTransitionStyle = UIModalTransitionStyle.crossDissolve diff --git a/ALCameraViewController/ViewController/ConfirmViewController.swift b/ALCameraViewController/ViewController/ConfirmViewController.swift index 43d0af1f..641e9f86 100644 --- a/ALCameraViewController/ViewController/ConfirmViewController.swift +++ b/ALCameraViewController/ViewController/ConfirmViewController.swift @@ -222,7 +222,7 @@ public class ConfirmViewController: UIViewController, UIScrollViewDelegate { } internal func cancel() { - onComplete?(nil, nil, nil) + onComplete?(nil, nil, nil, nil, nil) } internal func confirmPhoto() { @@ -240,7 +240,7 @@ public class ConfirmViewController: UIViewController, UIScrollViewDelegate { if let asset = asset { var fetcher = SingleImageFetcher() .onSuccess { [weak self] image in - self?.onComplete?(nil, image, self?.asset) + self?.onComplete?(nil, image, self?.asset, nil, nil) self?.hideSpinner(spinner) self?.enable() } @@ -267,7 +267,7 @@ public class ConfirmViewController: UIViewController, UIScrollViewDelegate { newImage = image.crop(rect: resizedCropRect) } - onComplete?(imageData, newImage, nil) + onComplete?(imageData, newImage, nil, nil, nil) hideSpinner(spinner) enable() } diff --git a/Example/ViewController.swift b/Example/ViewController.swift index 23401b87..da248fca 100644 --- a/Example/ViewController.swift +++ b/Example/ViewController.swift @@ -20,9 +20,9 @@ class ViewController: UIViewController { } @IBAction func openCamera(_ sender: AnyObject) { - let cameraViewController = CameraViewController(scale: 3.0, croppingEnabled: croppingEnabled, allowsLibraryAccess: libraryEnabled, allowsAudio: false) { [weak self] imageData, image, asset in + let cameraViewController = CameraViewController(scale: 3.0, croppingEnabled: croppingEnabled, allowsLibraryAccess: libraryEnabled, allowsAudio: false) { [weak self] imageData, image, asset, errorData, exifData in self?.imageView.image = image - + print(exifData) self?.dismiss(animated: true, completion: nil) } @@ -30,7 +30,7 @@ class ViewController: UIViewController { } @IBAction func openLibrary(_ sender: AnyObject) { - let libraryViewController = CameraViewController.imagePickerViewController(croppingEnabled: croppingEnabled) { [weak self] imageData, image, asset in + let libraryViewController = CameraViewController.imagePickerViewController(croppingEnabled: croppingEnabled) { [weak self] imageData, image, asset, errorData, exifData in self?.imageView.image = image self?.dismiss(animated: true, completion: nil) } From f53a5285e87d236ceb0e6bec6f60093786b70a33 Mon Sep 17 00:00:00 2001 From: Thomas Goddard Date: Fri, 6 Oct 2017 12:22:45 -0700 Subject: [PATCH 20/66] Add error data and exif data output from capture --- .../ViewController/CameraViewController.swift | 14 +++++++------- .../ViewController/ConfirmViewController.swift | 12 ++++++++++-- Podfile.lock | 2 +- 3 files changed, 18 insertions(+), 10 deletions(-) diff --git a/ALCameraViewController/ViewController/CameraViewController.swift b/ALCameraViewController/ViewController/CameraViewController.swift index febda8ab..7d72261a 100644 --- a/ALCameraViewController/ViewController/CameraViewController.swift +++ b/ALCameraViewController/ViewController/CameraViewController.swift @@ -509,12 +509,12 @@ open class CameraViewController: UIViewController { self?.toggleButtons(enabled: true) return } - self?.saveImage(imageData: imageData, image: image) + self?.saveImage(imageData: imageData, image: image, errorData: errorData, exifData: exifData) }) } } - internal func saveImage(imageData: Data, image: UIImage) { + internal func saveImage(imageData: Data, image: UIImage, errorData: String?, exifData: String?) { let spinner = showSpinner() cameraView.preview.isHidden = true @@ -533,7 +533,7 @@ open class CameraViewController: UIViewController { } .save() } else { - layoutCameraResult(imageData: imageData, uiImage: image) + layoutCameraResult(imageData: imageData, uiImage: image, errorData: errorData, exifData: exifData) hideSpinner(spinner) } } @@ -580,9 +580,9 @@ open class CameraViewController: UIViewController { flashButton.isHidden = cameraView.currentPosition == AVCaptureDevicePosition.front } - internal func layoutCameraResult(imageData: Data, uiImage: UIImage) { + internal func layoutCameraResult(imageData: Data, uiImage: UIImage, errorData: String?, exifData: String?) { cameraView.stopSession() - startConfirmController(imageData: imageData, uiImage: uiImage) + startConfirmController(imageData: imageData, uiImage: uiImage, errorData: errorData, exifData: exifData) toggleButtons(enabled: true) } @@ -592,8 +592,8 @@ open class CameraViewController: UIViewController { toggleButtons(enabled: true) } - private func startConfirmController(imageData: Data, uiImage: UIImage) { - let confirmViewController = ConfirmViewController(imageData: imageData, image: uiImage, allowsCropping: allowCropping) + private func startConfirmController(imageData: Data, uiImage: UIImage, errorData: String?, exifData: String?) { + let confirmViewController = ConfirmViewController(imageData: imageData, image: uiImage, errorData:errorData, exifData:exifData, allowsCropping: allowCropping) confirmViewController.onComplete = { [weak self] imageData, image, asset, errorData, exifData in defer { self?.dismiss(animated: true, completion: nil) diff --git a/ALCameraViewController/ViewController/ConfirmViewController.swift b/ALCameraViewController/ViewController/ConfirmViewController.swift index 641e9f86..4ef69dd9 100644 --- a/ALCameraViewController/ViewController/ConfirmViewController.swift +++ b/ALCameraViewController/ViewController/ConfirmViewController.swift @@ -27,12 +27,16 @@ public class ConfirmViewController: UIViewController, UIScrollViewDelegate { let asset: PHAsset? let image: UIImage? let imageData: Data? + let errorData: String? + let exifData: String? - public init(imageData: Data, image: UIImage, allowsCropping: Bool) { + public init(imageData: Data, image: UIImage, errorData: String?, exifData: String?, allowsCropping: Bool) { self.allowsCropping = allowsCropping asset = nil self.imageData = imageData self.image = image + self.errorData = errorData + self.exifData = exifData super.init(nibName: "ConfirmViewController", bundle: CameraGlobals.shared.bundle) } @@ -41,6 +45,8 @@ public class ConfirmViewController: UIViewController, UIScrollViewDelegate { self.asset = asset image = nil imageData = nil + errorData = nil + exifData = nil super.init(nibName: "ConfirmViewController", bundle: CameraGlobals.shared.bundle) } @@ -48,6 +54,8 @@ public class ConfirmViewController: UIViewController, UIScrollViewDelegate { asset = nil image = nil imageData = nil + errorData = nil + exifData = nil super.init(coder: aDecoder) } @@ -267,7 +275,7 @@ public class ConfirmViewController: UIViewController, UIScrollViewDelegate { newImage = image.crop(rect: resizedCropRect) } - onComplete?(imageData, newImage, nil, nil, nil) + onComplete?(imageData, newImage, nil, errorData, exifData) hideSpinner(spinner) enable() } diff --git a/Podfile.lock b/Podfile.lock index d60d81e6..9004420d 100644 --- a/Podfile.lock +++ b/Podfile.lock @@ -22,7 +22,7 @@ EXTERNAL SOURCES: CHECKOUT OPTIONS: ALCameraViewController: - :commit: d9a128f820efb736353d327b0483ece812c10e1f + :commit: 5be08238ebd982df039ba977a6d1c7553444d6f6 :git: https://github.com/Cyclic/ALCameraViewController SPEC CHECKSUMS: From 4a7e7c3ffd46d1e3a37aa71aa411d8ffa2e38d9c Mon Sep 17 00:00:00 2001 From: Thomas Goddard Date: Fri, 6 Oct 2017 12:39:25 -0700 Subject: [PATCH 21/66] Increment version --- ALCameraViewController.podspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ALCameraViewController.podspec b/ALCameraViewController.podspec index 6e160401..2af2d3a9 100644 --- a/ALCameraViewController.podspec +++ b/ALCameraViewController.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |spec| spec.name = "ALCameraViewController" - spec.version = "1.4.0" + spec.version = "1.5.0" spec.summary = "A camera view controller with custom image picker and image cropping. Written in Swift." spec.source = { :git => "https://github.com/AlexLittlejohn/ALCameraViewController.git", :tag => spec.version.to_s } spec.requires_arc = true From e20de0e958f8d90b2a26fd65905c06eeb3d78e46 Mon Sep 17 00:00:00 2001 From: Thomas Goddard Date: Fri, 6 Oct 2017 12:49:35 -0700 Subject: [PATCH 22/66] Add completion handler code --- ALCameraViewController/Utilities/CameraShot.swift | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/ALCameraViewController/Utilities/CameraShot.swift b/ALCameraViewController/Utilities/CameraShot.swift index 31e4766b..6bd1caec 100644 --- a/ALCameraViewController/Utilities/CameraShot.swift +++ b/ALCameraViewController/Utilities/CameraShot.swift @@ -8,7 +8,6 @@ import UIKit import AVFoundation -import Mixpanel public typealias CameraShotCompletion = (Data?, UIImage?, String?, String?) -> Void @@ -26,7 +25,7 @@ public func takePhoto(_ stillImageOutput: AVCaptureStillImageOutput, videoOrient stillImageOutput.captureStillImageAsynchronously(from: videoConnection, completionHandler: { buffer, error in if let error = error { - print("Error in capture: \(error.localizedDescription)") + completion(nil, nil, "Error in image capture: \(error.localizedDescription)", nil) } guard let buffer = buffer, @@ -35,10 +34,9 @@ public func takePhoto(_ stillImageOutput: AVCaptureStillImageOutput, videoOrient var image = UIImage(data: imageData), let cgImage = image.cgImage else { DispatchQueue.main.async { - completion(nil, nil, "NULL image buffer", nil) + completion(nil, nil, "Error capture, NULL image buffer or NULL EXIF data", nil) return } - print() return } From 2a8a42c0b4491d4a082b9e91cfe4dabe4726d062 Mon Sep 17 00:00:00 2001 From: Thomas Goddard Date: Fri, 6 Oct 2017 12:55:20 -0700 Subject: [PATCH 23/66] Increment build --- ALCameraViewController.podspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ALCameraViewController.podspec b/ALCameraViewController.podspec index 2af2d3a9..5413203f 100644 --- a/ALCameraViewController.podspec +++ b/ALCameraViewController.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |spec| spec.name = "ALCameraViewController" - spec.version = "1.5.0" + spec.version = "1.6.0" spec.summary = "A camera view controller with custom image picker and image cropping. Written in Swift." spec.source = { :git => "https://github.com/AlexLittlejohn/ALCameraViewController.git", :tag => spec.version.to_s } spec.requires_arc = true From 56a5e95134bc576171588a1cf0dc2bdb9eb253e9 Mon Sep 17 00:00:00 2001 From: Thomas Goddard Date: Fri, 6 Oct 2017 12:55:49 -0700 Subject: [PATCH 24/66] Build bump --- ALCameraViewController.podspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ALCameraViewController.podspec b/ALCameraViewController.podspec index 5413203f..06e1abf5 100644 --- a/ALCameraViewController.podspec +++ b/ALCameraViewController.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |spec| spec.name = "ALCameraViewController" - spec.version = "1.6.0" + spec.version = "1.7.0" spec.summary = "A camera view controller with custom image picker and image cropping. Written in Swift." spec.source = { :git => "https://github.com/AlexLittlejohn/ALCameraViewController.git", :tag => spec.version.to_s } spec.requires_arc = true From 4075ef74422b5a62c658dc9205e0c6d5c0a3e737 Mon Sep 17 00:00:00 2001 From: Thomas Goddard Date: Wed, 11 Oct 2017 13:58:44 -0700 Subject: [PATCH 25/66] Linting and exif print cleanup --- ALCameraViewController/Views/CameraView.swift | 3 --- Example/ViewController.swift | 1 - 2 files changed, 4 deletions(-) diff --git a/ALCameraViewController/Views/CameraView.swift b/ALCameraViewController/Views/CameraView.swift index c9221768..26b779f8 100644 --- a/ALCameraViewController/Views/CameraView.swift +++ b/ALCameraViewController/Views/CameraView.swift @@ -172,12 +172,9 @@ public class CameraView: UIView { } private func createPreview() { - preview = AVCaptureVideoPreviewLayer(session: session) preview.videoGravity = AVLayerVideoGravityResizeAspect - preview.frame = bounds - layer.addSublayer(preview) } diff --git a/Example/ViewController.swift b/Example/ViewController.swift index da248fca..cb1d964c 100644 --- a/Example/ViewController.swift +++ b/Example/ViewController.swift @@ -22,7 +22,6 @@ class ViewController: UIViewController { @IBAction func openCamera(_ sender: AnyObject) { let cameraViewController = CameraViewController(scale: 3.0, croppingEnabled: croppingEnabled, allowsLibraryAccess: libraryEnabled, allowsAudio: false) { [weak self] imageData, image, asset, errorData, exifData in self?.imageView.image = image - print(exifData) self?.dismiss(animated: true, completion: nil) } From e9bad72ace117683b7994f8311a2ae6f74e493d6 Mon Sep 17 00:00:00 2001 From: Thomas Goddard Date: Fri, 13 Oct 2017 10:12:20 -0700 Subject: [PATCH 26/66] Linting cleanup --- .../Utilities/CameraShot.swift | 24 +++++++++---------- .../Utilities/Utilities.swift | 1 + .../ViewController/CameraViewController.swift | 9 ++++--- .../CameraViewControllerConstraint.swift | 2 +- Example/AppDelegate.swift | 4 ++-- Example/ViewController.swift | 17 +++++++------ 6 files changed, 27 insertions(+), 30 deletions(-) diff --git a/ALCameraViewController/Utilities/CameraShot.swift b/ALCameraViewController/Utilities/CameraShot.swift index 6bd1caec..71cd7f7a 100644 --- a/ALCameraViewController/Utilities/CameraShot.swift +++ b/ALCameraViewController/Utilities/CameraShot.swift @@ -12,34 +12,34 @@ import AVFoundation public typealias CameraShotCompletion = (Data?, UIImage?, String?, String?) -> Void public func takePhoto(_ stillImageOutput: AVCaptureStillImageOutput, videoOrientation: AVCaptureVideoOrientation, cameraPosition: AVCaptureDevicePosition, cropSize _: CGSize, outputScale: CGFloat, completion: @escaping CameraShotCompletion) { - + guard let videoConnection: AVCaptureConnection = stillImageOutput.connection(withMediaType: AVMediaTypeVideo) else { completion(nil, nil, nil, nil) return } - + videoConnection.videoOrientation = videoOrientation - + if !stillImageOutput.isCapturingStillImage { DispatchQueue.global(qos: .background).async(execute: { () in stillImageOutput.captureStillImageAsynchronously(from: videoConnection, completionHandler: { buffer, error in - + if let error = error { completion(nil, nil, "Error in image capture: \(error.localizedDescription)", nil) } - + guard let buffer = buffer, let exifAttachments = CMGetAttachment(buffer, kCGImagePropertyExifDictionary, nil), let imageData = AVCaptureStillImageOutput.jpegStillImageNSDataRepresentation(buffer), var image = UIImage(data: imageData), let cgImage = image.cgImage else { - DispatchQueue.main.async { - completion(nil, nil, "Error capture, NULL image buffer or NULL EXIF data", nil) - return - } + DispatchQueue.main.async { + completion(nil, nil, "Error capture, NULL image buffer or NULL EXIF data", nil) return + } + return } - + // flip the image to match the orientation of the preview // Half size is large for now if cameraPosition == .front { @@ -64,13 +64,11 @@ public func takePhoto(_ stillImageOutput: AVCaptureStillImageOutput, videoOrient } else { image = UIImage(cgImage: cgImage, scale: outputScale, orientation: image.imageOrientation) } - + DispatchQueue.main.async { completion(imageData, image, nil, "EXIF \(exifAttachments)") } }) }) } - } - diff --git a/ALCameraViewController/Utilities/Utilities.swift b/ALCameraViewController/Utilities/Utilities.swift index a49e13f7..52bad1f7 100644 --- a/ALCameraViewController/Utilities/Utilities.swift +++ b/ALCameraViewController/Utilities/Utilities.swift @@ -124,6 +124,7 @@ struct DeviceConfig { return 1.0 } }() + static let CLOSE_BUTTON_SPACING: CGFloat = { if UIDevice.current.userInterfaceIdiom == .phone { switch ScreenSize.SCREEN_MAX_LENGTH { diff --git a/ALCameraViewController/ViewController/CameraViewController.swift b/ALCameraViewController/ViewController/CameraViewController.swift index 7d72261a..2599a874 100644 --- a/ALCameraViewController/ViewController/CameraViewController.swift +++ b/ALCameraViewController/ViewController/CameraViewController.swift @@ -53,7 +53,7 @@ open class CameraViewController: UIViewController { var lastInterfaceOrientation: UIInterfaceOrientation? open var onCompletion: CameraViewCompletion? var volumeControl: VolumeControl? - + var outputScale: CGFloat = 1.0 var animationDuration: TimeInterval = 0.5 @@ -334,7 +334,7 @@ open class CameraViewController: UIViewController { NotificationCenter.default.addObserver( self, selector: #selector(notifyCameraReady), - name: NSNotification.Name.AVCaptureSessionDidStartRunning, + name: .AVCaptureSessionDidStartRunning, object: nil) } @@ -346,7 +346,7 @@ open class CameraViewController: UIViewController { NotificationCenter.default.addObserver( self, selector: #selector(rotateCameraView), - name: NSNotification.Name.UIDeviceOrientationDidChange, + name: .UIDeviceOrientationDidChange, object: nil) } @@ -500,7 +500,6 @@ open class CameraViewController: UIViewController { let connection = output.connection(withMediaType: AVMediaTypeVideo) else { return } - if connection.isEnabled { toggleButtons(enabled: false) @@ -593,7 +592,7 @@ open class CameraViewController: UIViewController { } private func startConfirmController(imageData: Data, uiImage: UIImage, errorData: String?, exifData: String?) { - let confirmViewController = ConfirmViewController(imageData: imageData, image: uiImage, errorData:errorData, exifData:exifData, allowsCropping: allowCropping) + let confirmViewController = ConfirmViewController(imageData: imageData, image: uiImage, errorData: errorData, exifData: exifData, allowsCropping: allowCropping) confirmViewController.onComplete = { [weak self] imageData, image, asset, errorData, exifData in defer { self?.dismiss(animated: true, completion: nil) diff --git a/ALCameraViewController/ViewController/CameraViewControllerConstraint.swift b/ALCameraViewController/ViewController/CameraViewControllerConstraint.swift index c5b88c15..9215abfb 100644 --- a/ALCameraViewController/ViewController/CameraViewControllerConstraint.swift +++ b/ALCameraViewController/ViewController/CameraViewControllerConstraint.swift @@ -33,7 +33,7 @@ extension CameraViewController { multiplier: 1.0, constant: 0)) }) - + view.addConstraint(NSLayoutConstraint( item: cameraView, attribute: .bottom, diff --git a/Example/AppDelegate.swift b/Example/AppDelegate.swift index c8de81bf..94eba29d 100644 --- a/Example/AppDelegate.swift +++ b/Example/AppDelegate.swift @@ -13,9 +13,9 @@ class AppDelegate: UIResponder, UIApplicationDelegate { var window: UIWindow? - func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey : Any]? = nil) -> Bool { + func application(_: UIApplication, didFinishLaunchingWithOptions _: [UIApplicationLaunchOptionsKey: Any]? = nil) -> Bool { let viewController = ViewController(nibName: "ViewController", bundle: Bundle.main) - + window = UIWindow(frame: UIScreen.main.bounds) window!.rootViewController = viewController window!.makeKeyAndVisible() diff --git a/Example/ViewController.swift b/Example/ViewController.swift index cb1d964c..9d68bcf5 100644 --- a/Example/ViewController.swift +++ b/Example/ViewController.swift @@ -12,9 +12,9 @@ class ViewController: UIViewController { var croppingEnabled: Bool = false var libraryEnabled: Bool = true - + @IBOutlet weak var imageView: UIImageView! - + override func viewDidLoad() { super.viewDidLoad() } @@ -24,7 +24,7 @@ class ViewController: UIViewController { self?.imageView.image = image self?.dismiss(animated: true, completion: nil) } - + present(cameraViewController, animated: true, completion: nil) } @@ -33,16 +33,15 @@ class ViewController: UIViewController { self?.imageView.image = image self?.dismiss(animated: true, completion: nil) } - + present(libraryViewController, animated: true, completion: nil) } - - @IBAction func libraryChanged(_ sender: AnyObject) { + + @IBAction func libraryChanged(_: AnyObject) { libraryEnabled = !libraryEnabled } - - @IBAction func croppingChanged(_ sender: AnyObject) { + + @IBAction func croppingChanged(_: AnyObject) { croppingEnabled = !croppingEnabled } } - From 0d399320ef15265d4b3e6c9cf0a4e3f1e1345c0e Mon Sep 17 00:00:00 2001 From: Thomas Goddard Date: Fri, 13 Oct 2017 16:10:36 -0700 Subject: [PATCH 27/66] WIP on orientation change implementation --- ALCameraViewController/Utilities/Utilities.swift | 16 ++++++++++++++++ .../ViewController/CameraViewController.swift | 6 ++++-- .../CameraViewControllerConstraint.swift | 10 +++++----- ALCameraViewController/Views/CameraView.swift | 9 +++++---- 4 files changed, 30 insertions(+), 11 deletions(-) diff --git a/ALCameraViewController/Utilities/Utilities.swift b/ALCameraViewController/Utilities/Utilities.swift index 52bad1f7..995515de 100644 --- a/ALCameraViewController/Utilities/Utilities.swift +++ b/ALCameraViewController/Utilities/Utilities.swift @@ -80,12 +80,28 @@ internal func normalizedRect(_ rect: CGRect, orientation: UIImageOrientation) -> switch orientation { case .up, .upMirrored: +// print("NXPosition: \(normalizedX) ") +// print("NYPosition: \(normalizedY) ") +// print("NWidthX: \(normalizedWidth)") +// print("NWidthY: \(normalizedHeight)") normalizedRect = CGRect(x: normalizedX, y: normalizedY, width: normalizedWidth, height: normalizedHeight) case .down, .downMirrored: +// print("NXPosition: \(1 - normalizedX - normalizedWidth) ") +// print("NYPosition: \(1 - normalizedY - normalizedHeight) ") +// print("NWidthX: \(normalizedWidth)") +// print("NWidthY: \(normalizedHeight)") normalizedRect = CGRect(x: 1 - normalizedX - normalizedWidth, y: 1 - normalizedY - normalizedHeight, width: normalizedWidth, height: normalizedHeight) case .left, .leftMirrored: +// print("NXPosition: \(1 - normalizedY - normalizedHeight) ") +// print("NYPosition: \(normalizedX) ") +// print("NWidthX: \(normalizedHeight)") +// print("NWidthY: \(normalizedWidth)") normalizedRect = CGRect(x: 1 - normalizedY - normalizedHeight, y: normalizedX, width: normalizedHeight, height: normalizedWidth) case .right, .rightMirrored: +// print("NXPosition: \(normalizedY) ") +// print("NYPosition: \( 1 - normalizedX - normalizedWidth) ") +// print("NWidthX: \(normalizedHeight)") +// print("NWidthY: \(normalizedWidth)") normalizedRect = CGRect(x: normalizedY, y: 1 - normalizedX - normalizedWidth, width: normalizedHeight, height: normalizedWidth) } diff --git a/ALCameraViewController/ViewController/CameraViewController.swift b/ALCameraViewController/ViewController/CameraViewController.swift index 2599a874..8940c890 100644 --- a/ALCameraViewController/ViewController/CameraViewController.swift +++ b/ALCameraViewController/ViewController/CameraViewController.swift @@ -184,7 +184,7 @@ open class CameraViewController: UIViewController { } open override var preferredStatusBarUpdateAnimation: UIStatusBarAnimation { - return UIStatusBarAnimation.slide + return .slide } /** @@ -595,6 +595,7 @@ open class CameraViewController: UIViewController { let confirmViewController = ConfirmViewController(imageData: imageData, image: uiImage, errorData: errorData, exifData: exifData, allowsCropping: allowCropping) confirmViewController.onComplete = { [weak self] imageData, image, asset, errorData, exifData in defer { + confirmViewController.modalTransitionStyle = .crossDissolve self?.dismiss(animated: true, completion: nil) } @@ -613,6 +614,7 @@ open class CameraViewController: UIViewController { let confirmViewController = ConfirmViewController(asset: asset, allowsCropping: allowCropping) confirmViewController.onComplete = { [weak self] imageData, image, asset, errorData, exifData in defer { + self?.modalTransitionStyle = .partialCurl self?.dismiss(animated: true, completion: nil) } @@ -623,7 +625,7 @@ open class CameraViewController: UIViewController { self?.onCompletion?(imageData, image, asset, errorData, exifData) self?.onCompletion = nil } - confirmViewController.modalTransitionStyle = UIModalTransitionStyle.crossDissolve + confirmViewController.modalTransitionStyle = .crossDissolve present(confirmViewController, animated: true, completion: nil) } diff --git a/ALCameraViewController/ViewController/CameraViewControllerConstraint.swift b/ALCameraViewController/ViewController/CameraViewControllerConstraint.swift index 9215abfb..bf6b3688 100644 --- a/ALCameraViewController/ViewController/CameraViewControllerConstraint.swift +++ b/ALCameraViewController/ViewController/CameraViewControllerConstraint.swift @@ -56,9 +56,9 @@ extension CameraViewController { let attribute: NSLayoutAttribute = { switch statusBarOrientation { case .portrait: return .bottom - case .landscapeRight: return .right - case .landscapeLeft: return .left - default: return .top + case .landscapeRight: return .top + case .landscapeLeft: return .top + default: return .bottom } }() @@ -69,7 +69,7 @@ extension CameraViewController { toItem: view, attribute: attribute, multiplier: 1.0, - constant: attribute == .right || attribute == .bottom ? -8 : 8) + constant: attribute == .right || attribute == .bottom ? -8 : -8) view.addConstraint(cameraButtonEdgeConstraint!) } @@ -259,7 +259,7 @@ extension CameraViewController { let attribute: NSLayoutAttribute = { switch statusBarOrientation { case .portrait: return .left - case .landscapeRight, .landscapeLeft: return .centerX + case .landscapeRight, .landscapeLeft: return .left default: return .right } }() diff --git a/ALCameraViewController/Views/CameraView.swift b/ALCameraViewController/Views/CameraView.swift index 26b779f8..a48880c8 100644 --- a/ALCameraViewController/Views/CameraView.swift +++ b/ALCameraViewController/Views/CameraView.swift @@ -83,6 +83,7 @@ public class CameraView: UIView { public override func layoutSubviews() { super.layoutSubviews() preview?.frame = bounds + print("bounds updated: \(bounds)") } public func configureFocus() { @@ -281,16 +282,16 @@ public class CameraView: UIView { } switch UIApplication.shared.statusBarOrientation { case .portrait: - preview?.connection.videoOrientation = AVCaptureVideoOrientation.portrait + preview?.connection.videoOrientation = .portrait break case .portraitUpsideDown: - preview?.connection.videoOrientation = AVCaptureVideoOrientation.portraitUpsideDown + preview?.connection.videoOrientation = .portraitUpsideDown break case .landscapeRight: - preview?.connection.videoOrientation = AVCaptureVideoOrientation.landscapeRight + preview?.connection.videoOrientation = .landscapeRight break case .landscapeLeft: - preview?.connection.videoOrientation = AVCaptureVideoOrientation.landscapeLeft + preview?.connection.videoOrientation = .landscapeLeft break default: break } From 38beb21ae7ca93a490299ac819d382d95eea53ee Mon Sep 17 00:00:00 2001 From: Thomas Goddard Date: Tue, 17 Oct 2017 17:10:09 -0700 Subject: [PATCH 28/66] Update pod --- Podfile.lock | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/Podfile.lock b/Podfile.lock index 9004420d..503a4579 100644 --- a/Podfile.lock +++ b/Podfile.lock @@ -1,10 +1,10 @@ PODS: - - ALCameraViewController (1.4.0) - - Crashlytics (3.8.6): - - Fabric (~> 1.6.3) - - Fabric (1.6.13) + - ALCameraViewController (1.7.0) + - Crashlytics (3.9.0): + - Fabric (~> 1.7.0) + - Fabric (1.7.0) - Masonry (1.1.0) - - Mixpanel (3.2.1) + - Mixpanel (3.2.2) - SnapKit (3.2.0) DEPENDENCIES: @@ -22,15 +22,15 @@ EXTERNAL SOURCES: CHECKOUT OPTIONS: ALCameraViewController: - :commit: 5be08238ebd982df039ba977a6d1c7553444d6f6 + :commit: e9bad72ace117683b7994f8311a2ae6f74e493d6 :git: https://github.com/Cyclic/ALCameraViewController SPEC CHECKSUMS: - ALCameraViewController: 7f004be095177b0d65df85d2c1c06709b533b44c - Crashlytics: 95d05f4e4c19a771250c4bd9ce344d996de32bbf - Fabric: 2fb5676bc811af011a04513451f463dac6803206 + ALCameraViewController: 8c269a7e1719155e96bb4bf7af131b12b8bb3959 + Crashlytics: 64aad5dd97249dd3ff94b979fea140144590cdd3 + Fabric: e6be012366472553807dada21243c5ab8d904151 Masonry: 678fab65091a9290e40e2832a55e7ab731aad201 - Mixpanel: a88b1db0a1e381f9d37a1756aa37a9c670d22f61 + Mixpanel: 524c6880d45d71faa7d0dcd10f52221c99b6d820 SnapKit: 1ca44df72cfa543218d177cb8aab029d10d86ea7 PODFILE CHECKSUM: f518b2f295e809e23e52674d38ec5a502299cbfe From bc954da4ba25b4ea779e65a3c5ec31fe2163cec7 Mon Sep 17 00:00:00 2001 From: Thomas Goddard Date: Tue, 17 Oct 2017 17:20:07 -0700 Subject: [PATCH 29/66] Update branch reference --- Podfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Podfile b/Podfile index 1295824d..0b663e9a 100644 --- a/Podfile +++ b/Podfile @@ -9,7 +9,7 @@ pod 'Crashlytics' pod 'Masonry' pod 'SnapKit', '~> 3.2.0' pod 'Mixpanel' -pod 'ALCameraViewController', :git => 'https://github.com/Cyclic/ALCameraViewController', :branch => 'feature/pinch-to-zoom-camera' +pod 'ALCameraViewController', :git => 'https://github.com/Cyclic/ALCameraViewController', :branch => 'feature/develop' end post_install do |installer| installer.pods_project.targets.each do |target| From 20358c3fd9cf7b94b4983380dd62dd39efc81d4f Mon Sep 17 00:00:00 2001 From: Thomas Goddard Date: Tue, 17 Oct 2017 17:26:11 -0700 Subject: [PATCH 30/66] Increment the pod version --- ALCameraViewController.podspec | 2 +- Podfile | 2 +- Podfile.lock | 8 ++++---- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/ALCameraViewController.podspec b/ALCameraViewController.podspec index 06e1abf5..c88f7005 100644 --- a/ALCameraViewController.podspec +++ b/ALCameraViewController.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |spec| spec.name = "ALCameraViewController" - spec.version = "1.7.0" + spec.version = "1.8.0" spec.summary = "A camera view controller with custom image picker and image cropping. Written in Swift." spec.source = { :git => "https://github.com/AlexLittlejohn/ALCameraViewController.git", :tag => spec.version.to_s } spec.requires_arc = true diff --git a/Podfile b/Podfile index 0b663e9a..816b44b4 100644 --- a/Podfile +++ b/Podfile @@ -9,7 +9,7 @@ pod 'Crashlytics' pod 'Masonry' pod 'SnapKit', '~> 3.2.0' pod 'Mixpanel' -pod 'ALCameraViewController', :git => 'https://github.com/Cyclic/ALCameraViewController', :branch => 'feature/develop' +pod 'ALCameraViewController', :git => 'https://github.com/Cyclic/ALCameraViewController', :branch => 'develop' end post_install do |installer| installer.pods_project.targets.each do |target| diff --git a/Podfile.lock b/Podfile.lock index 503a4579..c7e4caba 100644 --- a/Podfile.lock +++ b/Podfile.lock @@ -8,7 +8,7 @@ PODS: - SnapKit (3.2.0) DEPENDENCIES: - - ALCameraViewController (from `https://github.com/Cyclic/ALCameraViewController`, branch `feature/pinch-to-zoom-camera`) + - ALCameraViewController (from `https://github.com/Cyclic/ALCameraViewController`, branch `develop`) - Crashlytics - Fabric - Masonry @@ -17,12 +17,12 @@ DEPENDENCIES: EXTERNAL SOURCES: ALCameraViewController: - :branch: feature/pinch-to-zoom-camera + :branch: develop :git: https://github.com/Cyclic/ALCameraViewController CHECKOUT OPTIONS: ALCameraViewController: - :commit: e9bad72ace117683b7994f8311a2ae6f74e493d6 + :commit: bc954da4ba25b4ea779e65a3c5ec31fe2163cec7 :git: https://github.com/Cyclic/ALCameraViewController SPEC CHECKSUMS: @@ -33,6 +33,6 @@ SPEC CHECKSUMS: Mixpanel: 524c6880d45d71faa7d0dcd10f52221c99b6d820 SnapKit: 1ca44df72cfa543218d177cb8aab029d10d86ea7 -PODFILE CHECKSUM: f518b2f295e809e23e52674d38ec5a502299cbfe +PODFILE CHECKSUM: 78686f3586dbabaa6b9428e3220eda91fc07b8dd COCOAPODS: 1.3.1 From ce5b03330c7e527382790186a0d9dd492e4788aa Mon Sep 17 00:00:00 2001 From: Thomas Goddard Date: Tue, 17 Oct 2017 17:49:46 -0700 Subject: [PATCH 31/66] Rotate camera view flash button --- .../ViewController/CameraViewController.swift | 2 +- ALCameraViewController/Views/CameraView.swift | 12 ++++++------ Example/Supporting Files/Info.plist | 3 --- 3 files changed, 7 insertions(+), 10 deletions(-) diff --git a/ALCameraViewController/ViewController/CameraViewController.swift b/ALCameraViewController/ViewController/CameraViewController.swift index 8940c890..f77ca35d 100644 --- a/ALCameraViewController/ViewController/CameraViewController.swift +++ b/ALCameraViewController/ViewController/CameraViewController.swift @@ -392,7 +392,7 @@ open class CameraViewController: UIViewController { } func rotateCameraView() { - cameraView.rotatePreview() + cameraView.rotateCameraButtons(button: flashButton) } /** diff --git a/ALCameraViewController/Views/CameraView.swift b/ALCameraViewController/Views/CameraView.swift index a48880c8..0ed80e6c 100644 --- a/ALCameraViewController/Views/CameraView.swift +++ b/ALCameraViewController/Views/CameraView.swift @@ -275,23 +275,23 @@ public class CameraView: UIView { session.commitConfiguration() } - public func rotatePreview() { - + public func rotateCameraButtons(button:UIButton) { + guard preview != nil else { return } switch UIApplication.shared.statusBarOrientation { case .portrait: - preview?.connection.videoOrientation = .portrait + button.setImage(UIImage.init(cgImage: (button.currentImage?.cgImage)!, scale: 1.0, orientation: .down), for: .normal) break case .portraitUpsideDown: - preview?.connection.videoOrientation = .portraitUpsideDown + button.setImage(UIImage.init(cgImage: (button.currentImage?.cgImage)!, scale: 1.0, orientation: .up), for: .normal) break case .landscapeRight: - preview?.connection.videoOrientation = .landscapeRight + button.setImage(UIImage.init(cgImage: (button.currentImage?.cgImage)!, scale: 1.0, orientation: .right), for: .normal) break case .landscapeLeft: - preview?.connection.videoOrientation = .landscapeLeft + button.setImage(UIImage.init(cgImage: (button.currentImage?.cgImage)!, scale: 1.0, orientation: .left), for: .normal) break default: break } diff --git a/Example/Supporting Files/Info.plist b/Example/Supporting Files/Info.plist index 9c9f832f..251d212c 100644 --- a/Example/Supporting Files/Info.plist +++ b/Example/Supporting Files/Info.plist @@ -35,9 +35,6 @@ UISupportedInterfaceOrientations UIInterfaceOrientationPortrait - UIInterfaceOrientationLandscapeLeft - UIInterfaceOrientationLandscapeRight - UIInterfaceOrientationPortraitUpsideDown UISupportedInterfaceOrientations~ipad From 1ae982509d791689faf6b60884748818608d6f55 Mon Sep 17 00:00:00 2001 From: Thomas Goddard Date: Tue, 17 Oct 2017 18:00:25 -0700 Subject: [PATCH 32/66] Supplementing with fixed orientation steps --- ALCameraViewController/Views/CameraView.swift | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/ALCameraViewController/Views/CameraView.swift b/ALCameraViewController/Views/CameraView.swift index 0ed80e6c..75a80bc2 100644 --- a/ALCameraViewController/Views/CameraView.swift +++ b/ALCameraViewController/Views/CameraView.swift @@ -276,22 +276,18 @@ public class CameraView: UIView { } public func rotateCameraButtons(button:UIButton) { - - guard preview != nil else { - return - } - switch UIApplication.shared.statusBarOrientation { + switch UIDevice.current.orientation { case .portrait: - button.setImage(UIImage.init(cgImage: (button.currentImage?.cgImage)!, scale: 1.0, orientation: .down), for: .normal) + button.setImage(UIImage.init(cgImage: (button.currentImage?.cgImage)!, scale: 1.0, orientation: .up), for: .normal) break case .portraitUpsideDown: - button.setImage(UIImage.init(cgImage: (button.currentImage?.cgImage)!, scale: 1.0, orientation: .up), for: .normal) + button.setImage(UIImage.init(cgImage: (button.currentImage?.cgImage)!, scale: 1.0, orientation: .down), for: .normal) break case .landscapeRight: - button.setImage(UIImage.init(cgImage: (button.currentImage?.cgImage)!, scale: 1.0, orientation: .right), for: .normal) + button.setImage(UIImage.init(cgImage: (button.currentImage?.cgImage)!, scale: 1.0, orientation: .left), for: .normal) break case .landscapeLeft: - button.setImage(UIImage.init(cgImage: (button.currentImage?.cgImage)!, scale: 1.0, orientation: .left), for: .normal) + button.setImage(UIImage.init(cgImage: (button.currentImage?.cgImage)!, scale: 1.0, orientation: .right), for: .normal) break default: break } From 43277b8f79f7cf19332d8e36deb6ad32cf9de8bf Mon Sep 17 00:00:00 2001 From: Thomas Goddard Date: Wed, 18 Oct 2017 10:56:34 -0700 Subject: [PATCH 33/66] Add rotate swap button --- .../ViewController/CameraViewController.swift | 1 + Podfile.lock | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/ALCameraViewController/ViewController/CameraViewController.swift b/ALCameraViewController/ViewController/CameraViewController.swift index f77ca35d..617ec0de 100644 --- a/ALCameraViewController/ViewController/CameraViewController.swift +++ b/ALCameraViewController/ViewController/CameraViewController.swift @@ -393,6 +393,7 @@ open class CameraViewController: UIViewController { func rotateCameraView() { cameraView.rotateCameraButtons(button: flashButton) + cameraView.rotateCameraButtons(button: swapButton) } /** diff --git a/Podfile.lock b/Podfile.lock index c7e4caba..f1f68b2e 100644 --- a/Podfile.lock +++ b/Podfile.lock @@ -1,5 +1,5 @@ PODS: - - ALCameraViewController (1.7.0) + - ALCameraViewController (1.8.0) - Crashlytics (3.9.0): - Fabric (~> 1.7.0) - Fabric (1.7.0) @@ -22,11 +22,11 @@ EXTERNAL SOURCES: CHECKOUT OPTIONS: ALCameraViewController: - :commit: bc954da4ba25b4ea779e65a3c5ec31fe2163cec7 + :commit: ce5b03330c7e527382790186a0d9dd492e4788aa :git: https://github.com/Cyclic/ALCameraViewController SPEC CHECKSUMS: - ALCameraViewController: 8c269a7e1719155e96bb4bf7af131b12b8bb3959 + ALCameraViewController: 3b137206ef584c8756e90e53d944a3e93ffc06e6 Crashlytics: 64aad5dd97249dd3ff94b979fea140144590cdd3 Fabric: e6be012366472553807dada21243c5ab8d904151 Masonry: 678fab65091a9290e40e2832a55e7ab731aad201 From a1146c6ca14c7cab1d39172f4486a3c856bbe370 Mon Sep 17 00:00:00 2001 From: Thomas Goddard Date: Wed, 18 Oct 2017 11:33:56 -0700 Subject: [PATCH 34/66] Orientation flip the buttons --- .../ViewController/CameraViewController.swift | 3 ++ ALCameraViewController/Views/CameraView.swift | 38 ++++++++++++------- 2 files changed, 27 insertions(+), 14 deletions(-) diff --git a/ALCameraViewController/ViewController/CameraViewController.swift b/ALCameraViewController/ViewController/CameraViewController.swift index 617ec0de..f9ba5444 100644 --- a/ALCameraViewController/ViewController/CameraViewController.swift +++ b/ALCameraViewController/ViewController/CameraViewController.swift @@ -297,6 +297,7 @@ open class CameraViewController: UIViewController { if cameraView.session?.isRunning == true { notifyCameraReady() } + rotateCameraView() } open override func viewWillDisappear(_ animated: Bool) { @@ -394,6 +395,8 @@ open class CameraViewController: UIViewController { func rotateCameraView() { cameraView.rotateCameraButtons(button: flashButton) cameraView.rotateCameraButtons(button: swapButton) + cameraView.rotateCameraButtons(button: libraryButton) + cameraView.rotateCameraButtons(button: closeButton) } /** diff --git a/ALCameraViewController/Views/CameraView.swift b/ALCameraViewController/Views/CameraView.swift index 75a80bc2..ed9ed0be 100644 --- a/ALCameraViewController/Views/CameraView.swift +++ b/ALCameraViewController/Views/CameraView.swift @@ -276,20 +276,30 @@ public class CameraView: UIView { } public func rotateCameraButtons(button:UIButton) { - switch UIDevice.current.orientation { - case .portrait: - button.setImage(UIImage.init(cgImage: (button.currentImage?.cgImage)!, scale: 1.0, orientation: .up), for: .normal) - break - case .portraitUpsideDown: - button.setImage(UIImage.init(cgImage: (button.currentImage?.cgImage)!, scale: 1.0, orientation: .down), for: .normal) - break - case .landscapeRight: - button.setImage(UIImage.init(cgImage: (button.currentImage?.cgImage)!, scale: 1.0, orientation: .left), for: .normal) - break - case .landscapeLeft: - button.setImage(UIImage.init(cgImage: (button.currentImage?.cgImage)!, scale: 1.0, orientation: .right), for: .normal) - break - default: break + if let currentImage = button.currentImage { + switch UIDevice.current.orientation { + case .portrait: + UIView.transition(with: button, duration: 0.5, options: .transitionFlipFromBottom, animations: { + button.setImage(UIImage.init(cgImage: (button.currentImage?.cgImage)!, scale: currentImage.scale, orientation: .up), for: .normal) + }, completion: nil) + break + case .portraitUpsideDown: + UIView.transition(with: button, duration: 0.5, options: .transitionFlipFromTop, animations: { + button.setImage(UIImage.init(cgImage: (button.currentImage?.cgImage)!, scale: currentImage.scale, orientation: .down), for: .normal) + }, completion: nil) + break + case .landscapeRight: + UIView.transition(with: button, duration: 0.5, options: .transitionFlipFromLeft, animations: { + button.setImage(UIImage.init(cgImage: (button.currentImage?.cgImage)!, scale: currentImage.scale, orientation: .left), for: .normal) + }, completion: nil) + break + case .landscapeLeft: + UIView.transition(with: button, duration: 0.5, options: .transitionFlipFromRight, animations: { + button.setImage(UIImage.init(cgImage: (button.currentImage?.cgImage)!, scale: currentImage.scale, orientation: .right), for: .normal) + }, completion: nil) + break + default: break + } } } } From e61a505159c587c7db48e464a1ae65a0c71bf01e Mon Sep 17 00:00:00 2001 From: Thomas Goddard Date: Wed, 18 Oct 2017 11:35:36 -0700 Subject: [PATCH 35/66] Build bump --- ALCameraViewController.podspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ALCameraViewController.podspec b/ALCameraViewController.podspec index c88f7005..2bf940c2 100644 --- a/ALCameraViewController.podspec +++ b/ALCameraViewController.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |spec| spec.name = "ALCameraViewController" - spec.version = "1.8.0" + spec.version = "1.9.0" spec.summary = "A camera view controller with custom image picker and image cropping. Written in Swift." spec.source = { :git => "https://github.com/AlexLittlejohn/ALCameraViewController.git", :tag => spec.version.to_s } spec.requires_arc = true From 0c699517aa16ea7fa6bec6d76a753fb5e25e7e8f Mon Sep 17 00:00:00 2001 From: Thomas Goddard Date: Wed, 18 Oct 2017 15:24:25 -0700 Subject: [PATCH 36/66] Update pod to 10 --- ALCameraViewController.podspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ALCameraViewController.podspec b/ALCameraViewController.podspec index 2bf940c2..9f5bf21c 100644 --- a/ALCameraViewController.podspec +++ b/ALCameraViewController.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |spec| spec.name = "ALCameraViewController" - spec.version = "1.9.0" + spec.version = "1.10.0" spec.summary = "A camera view controller with custom image picker and image cropping. Written in Swift." spec.source = { :git => "https://github.com/AlexLittlejohn/ALCameraViewController.git", :tag => spec.version.to_s } spec.requires_arc = true From 496c93d9d034ed5114a69c1e1e1cf83d33d3f88c Mon Sep 17 00:00:00 2001 From: Thomas Goddard Date: Wed, 18 Oct 2017 15:35:22 -0700 Subject: [PATCH 37/66] Remove comments --- .../Utilities/Utilities.swift | 17 +---------------- 1 file changed, 1 insertion(+), 16 deletions(-) diff --git a/ALCameraViewController/Utilities/Utilities.swift b/ALCameraViewController/Utilities/Utilities.swift index 995515de..7a4840b1 100644 --- a/ALCameraViewController/Utilities/Utilities.swift +++ b/ALCameraViewController/Utilities/Utilities.swift @@ -80,28 +80,13 @@ internal func normalizedRect(_ rect: CGRect, orientation: UIImageOrientation) -> switch orientation { case .up, .upMirrored: -// print("NXPosition: \(normalizedX) ") -// print("NYPosition: \(normalizedY) ") -// print("NWidthX: \(normalizedWidth)") -// print("NWidthY: \(normalizedHeight)") normalizedRect = CGRect(x: normalizedX, y: normalizedY, width: normalizedWidth, height: normalizedHeight) case .down, .downMirrored: -// print("NXPosition: \(1 - normalizedX - normalizedWidth) ") -// print("NYPosition: \(1 - normalizedY - normalizedHeight) ") -// print("NWidthX: \(normalizedWidth)") -// print("NWidthY: \(normalizedHeight)") normalizedRect = CGRect(x: 1 - normalizedX - normalizedWidth, y: 1 - normalizedY - normalizedHeight, width: normalizedWidth, height: normalizedHeight) case .left, .leftMirrored: -// print("NXPosition: \(1 - normalizedY - normalizedHeight) ") -// print("NYPosition: \(normalizedX) ") -// print("NWidthX: \(normalizedHeight)") -// print("NWidthY: \(normalizedWidth)") + normalizedRect = CGRect(x: 1 - normalizedY - normalizedHeight, y: normalizedX, width: normalizedHeight, height: normalizedWidth) case .right, .rightMirrored: -// print("NXPosition: \(normalizedY) ") -// print("NYPosition: \( 1 - normalizedX - normalizedWidth) ") -// print("NWidthX: \(normalizedHeight)") -// print("NWidthY: \(normalizedWidth)") normalizedRect = CGRect(x: normalizedY, y: 1 - normalizedX - normalizedWidth, width: normalizedHeight, height: normalizedWidth) } From ed4762eb8a9e901cce379dce42daaad99f092e73 Mon Sep 17 00:00:00 2001 From: Thomas Goddard Date: Wed, 18 Oct 2017 16:01:39 -0700 Subject: [PATCH 38/66] Bump the pod version --- ALCameraViewController.podspec | 2 +- ALCameraViewController/Utilities/Utilities.swift | 4 ++-- Podfile.lock | 6 +++--- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/ALCameraViewController.podspec b/ALCameraViewController.podspec index 9f5bf21c..e0460c77 100644 --- a/ALCameraViewController.podspec +++ b/ALCameraViewController.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |spec| spec.name = "ALCameraViewController" - spec.version = "1.10.0" + spec.version = "1.11.0" spec.summary = "A camera view controller with custom image picker and image cropping. Written in Swift." spec.source = { :git => "https://github.com/AlexLittlejohn/ALCameraViewController.git", :tag => spec.version.to_s } spec.requires_arc = true diff --git a/ALCameraViewController/Utilities/Utilities.swift b/ALCameraViewController/Utilities/Utilities.swift index 7a4840b1..322ea066 100644 --- a/ALCameraViewController/Utilities/Utilities.swift +++ b/ALCameraViewController/Utilities/Utilities.swift @@ -119,7 +119,7 @@ struct DeviceConfig { case 568.0: return 1.5 case 667.0: return 2.0 case 736.0: return 4.0 - default: return 1.0 + default: return 4.0 } } else { return 1.0 @@ -132,7 +132,7 @@ struct DeviceConfig { case 568.0: return -54 case 667.0: return -66 case 736.0: return -66 - default: return 1.0 + default: return -66 } } else { return 1.0 diff --git a/Podfile.lock b/Podfile.lock index f1f68b2e..07c301e5 100644 --- a/Podfile.lock +++ b/Podfile.lock @@ -1,5 +1,5 @@ PODS: - - ALCameraViewController (1.8.0) + - ALCameraViewController (1.10.0) - Crashlytics (3.9.0): - Fabric (~> 1.7.0) - Fabric (1.7.0) @@ -22,11 +22,11 @@ EXTERNAL SOURCES: CHECKOUT OPTIONS: ALCameraViewController: - :commit: ce5b03330c7e527382790186a0d9dd492e4788aa + :commit: 496c93d9d034ed5114a69c1e1e1cf83d33d3f88c :git: https://github.com/Cyclic/ALCameraViewController SPEC CHECKSUMS: - ALCameraViewController: 3b137206ef584c8756e90e53d944a3e93ffc06e6 + ALCameraViewController: 01afa9276d32f238c3e2cd691baa08c71de6f7f8 Crashlytics: 64aad5dd97249dd3ff94b979fea140144590cdd3 Fabric: e6be012366472553807dada21243c5ab8d904151 Masonry: 678fab65091a9290e40e2832a55e7ab731aad201 From f5e3336b738896d5d9737fafd84db73ff813c4e9 Mon Sep 17 00:00:00 2001 From: Thomas Goddard Date: Wed, 18 Oct 2017 16:51:01 -0700 Subject: [PATCH 39/66] Update pod --- Podfile.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Podfile.lock b/Podfile.lock index 07c301e5..3f7c258f 100644 --- a/Podfile.lock +++ b/Podfile.lock @@ -1,5 +1,5 @@ PODS: - - ALCameraViewController (1.10.0) + - ALCameraViewController (1.11.0) - Crashlytics (3.9.0): - Fabric (~> 1.7.0) - Fabric (1.7.0) @@ -22,11 +22,11 @@ EXTERNAL SOURCES: CHECKOUT OPTIONS: ALCameraViewController: - :commit: 496c93d9d034ed5114a69c1e1e1cf83d33d3f88c + :commit: ed4762eb8a9e901cce379dce42daaad99f092e73 :git: https://github.com/Cyclic/ALCameraViewController SPEC CHECKSUMS: - ALCameraViewController: 01afa9276d32f238c3e2cd691baa08c71de6f7f8 + ALCameraViewController: fd21d8da73f4e972b4461ef6cb97228bfc29b480 Crashlytics: 64aad5dd97249dd3ff94b979fea140144590cdd3 Fabric: e6be012366472553807dada21243c5ab8d904151 Masonry: 678fab65091a9290e40e2832a55e7ab731aad201 From 75b14732b9dfb411c8d187b41340d1190f3771e5 Mon Sep 17 00:00:00 2001 From: Thomas Goddard Date: Thu, 19 Oct 2017 21:28:33 -0700 Subject: [PATCH 40/66] Remove dispatch queue and fix odd leaks from leaks checker --- .../Utilities/CameraShot.swift | 78 +++++++++---------- .../ViewController/CameraViewController.swift | 2 - 2 files changed, 37 insertions(+), 43 deletions(-) diff --git a/ALCameraViewController/Utilities/CameraShot.swift b/ALCameraViewController/Utilities/CameraShot.swift index 71cd7f7a..fc274bc5 100644 --- a/ALCameraViewController/Utilities/CameraShot.swift +++ b/ALCameraViewController/Utilities/CameraShot.swift @@ -21,54 +21,50 @@ public func takePhoto(_ stillImageOutput: AVCaptureStillImageOutput, videoOrient videoConnection.videoOrientation = videoOrientation if !stillImageOutput.isCapturingStillImage { - DispatchQueue.global(qos: .background).async(execute: { () in - stillImageOutput.captureStillImageAsynchronously(from: videoConnection, completionHandler: { buffer, error in - - if let error = error { - completion(nil, nil, "Error in image capture: \(error.localizedDescription)", nil) - } - - guard let buffer = buffer, - let exifAttachments = CMGetAttachment(buffer, kCGImagePropertyExifDictionary, nil), - let imageData = AVCaptureStillImageOutput.jpegStillImageNSDataRepresentation(buffer), - var image = UIImage(data: imageData), - let cgImage = image.cgImage else { + stillImageOutput.captureStillImageAsynchronously(from: videoConnection, completionHandler: { buffer, error in + + if let error = error { + completion(nil, nil, "Error in image capture: \(error.localizedDescription)", nil) + } + + guard let buffer = buffer, + let exifAttachments = CMGetAttachment(buffer, kCGImagePropertyExifDictionary, nil), + let imageData = AVCaptureStillImageOutput.jpegStillImageNSDataRepresentation(buffer), + var image = UIImage(data: imageData), + let cgImage = image.cgImage else { DispatchQueue.main.async { completion(nil, nil, "Error capture, NULL image buffer or NULL EXIF data", nil) return } return + } + + // flip the image to match the orientation of the preview + // Half size is large for now + if cameraPosition == .front { + switch image.imageOrientation { + case .leftMirrored: + image = UIImage(cgImage: cgImage, scale: outputScale, orientation: .right) + case .left: + image = UIImage(cgImage: cgImage, scale: outputScale, orientation: .rightMirrored) + case .rightMirrored: + image = UIImage(cgImage: cgImage, scale: outputScale, orientation: .left) + case .right: + image = UIImage(cgImage: cgImage, scale: outputScale, orientation: .leftMirrored) + case .up: + image = UIImage(cgImage: cgImage, scale: outputScale, orientation: .upMirrored) + case .upMirrored: + image = UIImage(cgImage: cgImage, scale: outputScale, orientation: .up) + case .down: + image = UIImage(cgImage: cgImage, scale: outputScale, orientation: .downMirrored) + case .downMirrored: + image = UIImage(cgImage: cgImage, scale: outputScale, orientation: .down) } + } else { + image = UIImage(cgImage: cgImage, scale: outputScale, orientation: image.imageOrientation) + } + completion(imageData, image, nil, "EXIF \(exifAttachments)") - // flip the image to match the orientation of the preview - // Half size is large for now - if cameraPosition == .front { - switch image.imageOrientation { - case .leftMirrored: - image = UIImage(cgImage: cgImage, scale: outputScale, orientation: .right) - case .left: - image = UIImage(cgImage: cgImage, scale: outputScale, orientation: .rightMirrored) - case .rightMirrored: - image = UIImage(cgImage: cgImage, scale: outputScale, orientation: .left) - case .right: - image = UIImage(cgImage: cgImage, scale: outputScale, orientation: .leftMirrored) - case .up: - image = UIImage(cgImage: cgImage, scale: outputScale, orientation: .upMirrored) - case .upMirrored: - image = UIImage(cgImage: cgImage, scale: outputScale, orientation: .up) - case .down: - image = UIImage(cgImage: cgImage, scale: outputScale, orientation: .downMirrored) - case .downMirrored: - image = UIImage(cgImage: cgImage, scale: outputScale, orientation: .down) - } - } else { - image = UIImage(cgImage: cgImage, scale: outputScale, orientation: image.imageOrientation) - } - - DispatchQueue.main.async { - completion(imageData, image, nil, "EXIF \(exifAttachments)") - } - }) }) } } diff --git a/ALCameraViewController/ViewController/CameraViewController.swift b/ALCameraViewController/ViewController/CameraViewController.swift index f9ba5444..21564c68 100644 --- a/ALCameraViewController/ViewController/CameraViewController.swift +++ b/ALCameraViewController/ViewController/CameraViewController.swift @@ -599,7 +599,6 @@ open class CameraViewController: UIViewController { let confirmViewController = ConfirmViewController(imageData: imageData, image: uiImage, errorData: errorData, exifData: exifData, allowsCropping: allowCropping) confirmViewController.onComplete = { [weak self] imageData, image, asset, errorData, exifData in defer { - confirmViewController.modalTransitionStyle = .crossDissolve self?.dismiss(animated: true, completion: nil) } @@ -610,7 +609,6 @@ open class CameraViewController: UIViewController { self?.onCompletion?(imageData, image, asset, errorData, exifData) self?.onCompletion = nil } - confirmViewController.modalTransitionStyle = .crossDissolve present(confirmViewController, animated: true, completion: nil) } From f833a609a12a77a267379b87dbd7b8b7b6339fd1 Mon Sep 17 00:00:00 2001 From: Thomas Goddard Date: Thu, 19 Oct 2017 21:30:54 -0700 Subject: [PATCH 41/66] Build bump Build bump --- ALCameraViewController.podspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ALCameraViewController.podspec b/ALCameraViewController.podspec index e0460c77..01be1708 100644 --- a/ALCameraViewController.podspec +++ b/ALCameraViewController.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |spec| spec.name = "ALCameraViewController" - spec.version = "1.11.0" + spec.version = "1.12.0" spec.summary = "A camera view controller with custom image picker and image cropping. Written in Swift." spec.source = { :git => "https://github.com/AlexLittlejohn/ALCameraViewController.git", :tag => spec.version.to_s } spec.requires_arc = true From 93250121d650d56a49d24d52c5769d0ec4ba4269 Mon Sep 17 00:00:00 2001 From: Thomas Goddard Date: Tue, 31 Oct 2017 17:38:07 -0700 Subject: [PATCH 42/66] Add swift 4 support --- .../project.pbxproj | 15 ++++++++-- .../xcschemes/CameraViewController.xcscheme | 4 ++- .../ALCameraViewController-Bridging-Header.h | 5 ++++ .../Utilities/CameraGlobals.swift | 2 +- .../Utilities/CameraShot.swift | 4 +-- .../Utilities/UIButtonExtensions.swift | 2 +- .../Utilities/Utilities.swift | 2 +- .../ViewController/CameraViewController.swift | 12 ++++---- .../PhotoLibraryViewController.swift | 2 +- ALCameraViewController/Views/CameraView.swift | 20 ++++++------- .../Views/PermissionsView.swift | 2 +- Podfile | 4 +-- Podfile.lock | 28 +++++++++---------- 13 files changed, 59 insertions(+), 43 deletions(-) create mode 100644 ALCameraViewController/Utilities/ALCameraViewController-Bridging-Header.h diff --git a/ALCameraViewController.xcodeproj/project.pbxproj b/ALCameraViewController.xcodeproj/project.pbxproj index 4437e548..44bd0b8e 100644 --- a/ALCameraViewController.xcodeproj/project.pbxproj +++ b/ALCameraViewController.xcodeproj/project.pbxproj @@ -60,6 +60,7 @@ /* Begin PBXFileReference section */ 658007B776CA0CEE5DB58810 /* Pods_ALCameraViewController.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_ALCameraViewController.framework; sourceTree = BUILT_PRODUCTS_DIR; }; + A8696BF41F9ABBAA005B2B33 /* ALCameraViewController-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "ALCameraViewController-Bridging-Header.h"; sourceTree = ""; }; C40665431C73A47C00EB9751 /* SingleImageSaver.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SingleImageSaver.swift; sourceTree = ""; }; C40665451C73A94100EB9751 /* CameraGlobals.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CameraGlobals.swift; sourceTree = ""; }; C40665471C73B72D00EB9751 /* SingleImageFetcher.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SingleImageFetcher.swift; sourceTree = ""; }; @@ -166,6 +167,7 @@ FAB50C021B4140AB009905B9 /* Utilities */ = { isa = PBXGroup; children = ( + A8696BF41F9ABBAA005B2B33 /* ALCameraViewController-Bridging-Header.h */, FAB50BF01B413E8C009905B9 /* ImageFetcher.swift */, C40665431C73A47C00EB9751 /* SingleImageSaver.swift */, C40665471C73B72D00EB9751 /* SingleImageFetcher.swift */, @@ -304,7 +306,7 @@ FAF0583E1B31618D008E5592 = { CreatedOnToolsVersion = 6.3.2; DevelopmentTeam = 4L5389GUUE; - LastSwiftMigration = 0800; + LastSwiftMigration = 0900; ProvisioningStyle = Automatic; }; }; @@ -624,6 +626,7 @@ buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage; + CLANG_ENABLE_MODULES = YES; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; DEVELOPMENT_TEAM = 4L5389GUUE; ENABLE_BITCODE = NO; @@ -632,7 +635,10 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = com.zero.CameraViewController; PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_VERSION = 3.0; + SWIFT_OBJC_BRIDGING_HEADER = "ALCameraViewController/Utilities/ALCameraViewController-Bridging-Header.h"; + SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + SWIFT_SWIFT3_OBJC_INFERENCE = On; + SWIFT_VERSION = 4.0; }; name = Debug; }; @@ -642,6 +648,7 @@ buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage; + CLANG_ENABLE_MODULES = YES; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; DEVELOPMENT_TEAM = 4L5389GUUE; ENABLE_BITCODE = NO; @@ -650,7 +657,9 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = com.zero.CameraViewController; PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_VERSION = 3.0; + SWIFT_OBJC_BRIDGING_HEADER = "ALCameraViewController/Utilities/ALCameraViewController-Bridging-Header.h"; + SWIFT_SWIFT3_OBJC_INFERENCE = On; + SWIFT_VERSION = 4.0; }; name = Release; }; diff --git a/ALCameraViewController.xcodeproj/xcshareddata/xcschemes/CameraViewController.xcscheme b/ALCameraViewController.xcodeproj/xcshareddata/xcschemes/CameraViewController.xcscheme index 9dec7dbe..f8654c4d 100644 --- a/ALCameraViewController.xcodeproj/xcshareddata/xcschemes/CameraViewController.xcscheme +++ b/ALCameraViewController.xcodeproj/xcshareddata/xcschemes/CameraViewController.xcscheme @@ -1,6 +1,6 @@ @@ -36,6 +37,7 @@ buildConfiguration = "Debug" selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" + language = "" launchStyle = "0" useCustomWorkingDirectory = "NO" ignoresPersistentStateOnLaunch = "NO" diff --git a/ALCameraViewController/Utilities/ALCameraViewController-Bridging-Header.h b/ALCameraViewController/Utilities/ALCameraViewController-Bridging-Header.h new file mode 100644 index 00000000..656f9fb6 --- /dev/null +++ b/ALCameraViewController/Utilities/ALCameraViewController-Bridging-Header.h @@ -0,0 +1,5 @@ +// +// Use this file to import your target's public headers that you would like to expose to Swift. +// + +//#import diff --git a/ALCameraViewController/Utilities/CameraGlobals.swift b/ALCameraViewController/Utilities/CameraGlobals.swift index 393c09ab..3345ea2a 100644 --- a/ALCameraViewController/Utilities/CameraGlobals.swift +++ b/ALCameraViewController/Utilities/CameraGlobals.swift @@ -20,5 +20,5 @@ public class CameraGlobals { public var bundle = Bundle(for: CameraViewController.self) public var stringsTable = "CameraView" public var photoLibraryThumbnailSize = CGSize(width: thumbnailDimension, height: thumbnailDimension) - public var defaultCameraPosition = AVCaptureDevicePosition.back + public var defaultCameraPosition = AVCaptureDevice.Position.back } diff --git a/ALCameraViewController/Utilities/CameraShot.swift b/ALCameraViewController/Utilities/CameraShot.swift index fc274bc5..fedd2fc4 100644 --- a/ALCameraViewController/Utilities/CameraShot.swift +++ b/ALCameraViewController/Utilities/CameraShot.swift @@ -11,9 +11,9 @@ import AVFoundation public typealias CameraShotCompletion = (Data?, UIImage?, String?, String?) -> Void -public func takePhoto(_ stillImageOutput: AVCaptureStillImageOutput, videoOrientation: AVCaptureVideoOrientation, cameraPosition: AVCaptureDevicePosition, cropSize _: CGSize, outputScale: CGFloat, completion: @escaping CameraShotCompletion) { +public func takePhoto(_ stillImageOutput: AVCaptureStillImageOutput, videoOrientation: AVCaptureVideoOrientation, cameraPosition: AVCaptureDevice.Position, cropSize _: CGSize, outputScale: CGFloat, completion: @escaping CameraShotCompletion) { - guard let videoConnection: AVCaptureConnection = stillImageOutput.connection(withMediaType: AVMediaTypeVideo) else { + guard let videoConnection: AVCaptureConnection = stillImageOutput.connection(with: AVMediaType.video) else { completion(nil, nil, nil, nil) return } diff --git a/ALCameraViewController/Utilities/UIButtonExtensions.swift b/ALCameraViewController/Utilities/UIButtonExtensions.swift index 43d0115e..6b75ec47 100644 --- a/ALCameraViewController/Utilities/UIButtonExtensions.swift +++ b/ALCameraViewController/Utilities/UIButtonExtensions.swift @@ -43,7 +43,7 @@ extension UIButton { } } - func performAction() { + @objc func performAction() { guard let action = action else { return } diff --git a/ALCameraViewController/Utilities/Utilities.swift b/ALCameraViewController/Utilities/Utilities.swift index 322ea066..9b2435b7 100644 --- a/ALCameraViewController/Utilities/Utilities.swift +++ b/ALCameraViewController/Utilities/Utilities.swift @@ -93,7 +93,7 @@ internal func normalizedRect(_ rect: CGRect, orientation: UIImageOrientation) -> return normalizedRect } -internal func flashImage(_ mode: AVCaptureFlashMode) -> String { +internal func flashImage(_ mode: AVCaptureDevice.FlashMode) -> String { let image: String switch mode { case .auto: diff --git a/ALCameraViewController/ViewController/CameraViewController.swift b/ALCameraViewController/ViewController/CameraViewController.swift index 21564c68..42e55ede 100644 --- a/ALCameraViewController/ViewController/CameraViewController.swift +++ b/ALCameraViewController/ViewController/CameraViewController.swift @@ -351,7 +351,7 @@ open class CameraViewController: UIViewController { object: nil) } - internal func notifyCameraReady() { + @objc internal func notifyCameraReady() { cameraButton.isEnabled = true } @@ -392,7 +392,7 @@ open class CameraViewController: UIViewController { ].forEach({ $0.isEnabled = enabled }) } - func rotateCameraView() { + @objc func rotateCameraView() { cameraView.rotateCameraButtons(button: flashButton) cameraView.rotateCameraButtons(button: swapButton) cameraView.rotateCameraButtons(button: libraryButton) @@ -462,8 +462,8 @@ open class CameraViewController: UIViewController { * the user that it not allow the permissions. */ private func checkPermissions() { - if AVCaptureDevice.authorizationStatus(forMediaType: AVMediaTypeVideo) != .authorized { - AVCaptureDevice.requestAccess(forMediaType: AVMediaTypeVideo) { granted in + if AVCaptureDevice.authorizationStatus(for: AVMediaType.video) != .authorized { + AVCaptureDevice.requestAccess(for: AVMediaType.video) { granted in DispatchQueue.main.async() { [weak self] in if !granted { self?.showNoPermissionsView() @@ -501,7 +501,7 @@ open class CameraViewController: UIViewController { */ internal func capturePhoto() { guard let output = cameraView.imageOutput, - let connection = output.connection(withMediaType: AVMediaTypeVideo) else { + let connection = output.connection(with: AVMediaType.video) else { return } @@ -580,7 +580,7 @@ open class CameraViewController: UIViewController { internal func swapCamera() { cameraView.swapCameraInput() - flashButton.isHidden = cameraView.currentPosition == AVCaptureDevicePosition.front + flashButton.isHidden = cameraView.currentPosition == AVCaptureDevice.Position.front } internal func layoutCameraResult(imageData: Data, uiImage: UIImage, errorData: String?, exifData: String?) { diff --git a/ALCameraViewController/ViewController/PhotoLibraryViewController.swift b/ALCameraViewController/ViewController/PhotoLibraryViewController.swift index 4226dd5d..5f09cf8f 100644 --- a/ALCameraViewController/ViewController/PhotoLibraryViewController.swift +++ b/ALCameraViewController/ViewController/PhotoLibraryViewController.swift @@ -72,7 +72,7 @@ public class PhotoLibraryViewController: UIViewController { inViewController.present(navigationController, animated: animated, completion: nil) } - public func dismissLibrary() { + @objc public func dismissLibrary() { onSelectionComplete?(nil) } diff --git a/ALCameraViewController/Views/CameraView.swift b/ALCameraViewController/Views/CameraView.swift index ed9ed0be..956c89e0 100644 --- a/ALCameraViewController/Views/CameraView.swift +++ b/ALCameraViewController/Views/CameraView.swift @@ -29,7 +29,7 @@ public class CameraView: UIView { public func startSession() { session = AVCaptureSession() - session.sessionPreset = AVCaptureSessionPresetPhoto + session.sessionPreset = AVCaptureSession.Preset.photo device = cameraWithPosition(position: currentPosition) if let device = device, device.hasFlash { @@ -109,7 +109,7 @@ public class CameraView: UIView { addGestureRecognizer(pinchGesture) } - internal func focus(gesture: UITapGestureRecognizer) { + @objc internal func focus(gesture: UITapGestureRecognizer) { let point = gesture.location(in: self) guard focusCamera(toPoint: point) else { @@ -142,7 +142,7 @@ public class CameraView: UIView { }) } - internal func pinch(gesture: UIPinchGestureRecognizer) { + @objc internal func pinch(gesture: UIPinchGestureRecognizer) { guard let device = device else { return } // Return zoom value between the minimum and maximum zoom values @@ -174,13 +174,13 @@ public class CameraView: UIView { private func createPreview() { preview = AVCaptureVideoPreviewLayer(session: session) - preview.videoGravity = AVLayerVideoGravityResizeAspect + preview.videoGravity = AVLayerVideoGravity.resizeAspect preview.frame = bounds layer.addSublayer(preview) } - private func cameraWithPosition(position: AVCaptureDevicePosition) -> AVCaptureDevice? { - guard let devices = AVCaptureDevice.devices(withMediaType: AVMediaTypeVideo) as? [AVCaptureDevice] else { + private func cameraWithPosition(position: AVCaptureDevice.Position) -> AVCaptureDevice? { + guard let devices = AVCaptureDevice.devices(for: AVMediaType.video) as? [AVCaptureDevice] else { return nil } return devices.filter { $0.position == position }.first @@ -217,7 +217,7 @@ public class CameraView: UIView { return false } - let focusPoint = preview.captureDevicePointOfInterest(for: toPoint) + let focusPoint = preview.captureDevicePointConverted(fromLayerPoint: toPoint) device.focusPointOfInterest = focusPoint device.focusMode = .continuousAutoFocus @@ -257,11 +257,11 @@ public class CameraView: UIView { session.beginConfiguration() session.removeInput(currentInput) - if currentInput.device.position == AVCaptureDevicePosition.back { - currentPosition = AVCaptureDevicePosition.front + if currentInput.device.position == AVCaptureDevice.Position.back { + currentPosition = AVCaptureDevice.Position.front device = cameraWithPosition(position: currentPosition) } else { - currentPosition = AVCaptureDevicePosition.back + currentPosition = AVCaptureDevice.Position.back device = cameraWithPosition(position: currentPosition) } diff --git a/ALCameraViewController/Views/PermissionsView.swift b/ALCameraViewController/Views/PermissionsView.swift index 42ff9ef2..5f44b778 100644 --- a/ALCameraViewController/Views/PermissionsView.swift +++ b/ALCameraViewController/Views/PermissionsView.swift @@ -83,7 +83,7 @@ internal class PermissionsView: UIView { addSubview(settingsButton) } - func openSettings() { + @objc func openSettings() { if let appSettings = URL(string: UIApplicationOpenSettingsURLString) { UIApplication.shared.openURL(appSettings) } diff --git a/Podfile b/Podfile index 816b44b4..b5527300 100644 --- a/Podfile +++ b/Podfile @@ -7,7 +7,7 @@ target 'ALCameraViewController' do pod 'Fabric' pod 'Crashlytics' pod 'Masonry' -pod 'SnapKit', '~> 3.2.0' +pod 'SnapKit' pod 'Mixpanel' pod 'ALCameraViewController', :git => 'https://github.com/Cyclic/ALCameraViewController', :branch => 'develop' end @@ -16,7 +16,7 @@ post_install do |installer| target.build_configurations.each do |config| config.build_settings['ENABLE_BITCODE'] = 'NO' config.build_settings['CODE_SIGNING_REQUIRED'] = 'NO' - config.build_settings['SWIFT_VERSION'] = '3.1' + config.build_settings['SWIFT_VERSION'] = '4.0' end end end diff --git a/Podfile.lock b/Podfile.lock index 3f7c258f..2174909e 100644 --- a/Podfile.lock +++ b/Podfile.lock @@ -1,11 +1,11 @@ PODS: - - ALCameraViewController (1.11.0) - - Crashlytics (3.9.0): - - Fabric (~> 1.7.0) - - Fabric (1.7.0) + - ALCameraViewController (1.12.0) + - Crashlytics (3.9.3): + - Fabric (~> 1.7.2) + - Fabric (1.7.2) - Masonry (1.1.0) - - Mixpanel (3.2.2) - - SnapKit (3.2.0) + - Mixpanel (3.2.3) + - SnapKit (4.0.0) DEPENDENCIES: - ALCameraViewController (from `https://github.com/Cyclic/ALCameraViewController`, branch `develop`) @@ -13,7 +13,7 @@ DEPENDENCIES: - Fabric - Masonry - Mixpanel - - SnapKit (~> 3.2.0) + - SnapKit EXTERNAL SOURCES: ALCameraViewController: @@ -22,17 +22,17 @@ EXTERNAL SOURCES: CHECKOUT OPTIONS: ALCameraViewController: - :commit: ed4762eb8a9e901cce379dce42daaad99f092e73 + :commit: 6eb88ee991f39721bffd27e6cda0b3228cd034eb :git: https://github.com/Cyclic/ALCameraViewController SPEC CHECKSUMS: - ALCameraViewController: fd21d8da73f4e972b4461ef6cb97228bfc29b480 - Crashlytics: 64aad5dd97249dd3ff94b979fea140144590cdd3 - Fabric: e6be012366472553807dada21243c5ab8d904151 + ALCameraViewController: 25c728e09752f0b18187267da4a1dee1d46e1d54 + Crashlytics: dbb07d01876c171c5ccbdf7826410380189e452c + Fabric: 9cd6a848efcf1b8b07497e0b6a2e7d336353ba15 Masonry: 678fab65091a9290e40e2832a55e7ab731aad201 - Mixpanel: 524c6880d45d71faa7d0dcd10f52221c99b6d820 - SnapKit: 1ca44df72cfa543218d177cb8aab029d10d86ea7 + Mixpanel: 7bd8e176f088936bf6e283ade0d1f512f8e723bc + SnapKit: a42d492c16e80209130a3379f73596c3454b7694 -PODFILE CHECKSUM: 78686f3586dbabaa6b9428e3220eda91fc07b8dd +PODFILE CHECKSUM: fefc4a0fa590c7e54dcece668918f300095e7301 COCOAPODS: 1.3.1 From 3124f40d3301d502207576cb0d3fe1b2570bab36 Mon Sep 17 00:00:00 2001 From: Thomas Goddard Date: Tue, 31 Oct 2017 17:39:06 -0700 Subject: [PATCH 43/66] Pod build bump --- ALCameraViewController.podspec | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ALCameraViewController.podspec b/ALCameraViewController.podspec index 01be1708..2199601b 100644 --- a/ALCameraViewController.podspec +++ b/ALCameraViewController.podspec @@ -1,10 +1,10 @@ Pod::Spec.new do |spec| spec.name = "ALCameraViewController" - spec.version = "1.12.0" + spec.version = "1.13.0" spec.summary = "A camera view controller with custom image picker and image cropping. Written in Swift." spec.source = { :git => "https://github.com/AlexLittlejohn/ALCameraViewController.git", :tag => spec.version.to_s } spec.requires_arc = true - spec.platform = :ios, "8.0" + spec.platform = :ios, "10.0" spec.license = "MIT" spec.source_files = "ALCameraViewController/**/*.{swift}" spec.resources = ["ALCameraViewController/ViewController/ConfirmViewController.xib", "ALCameraViewController/CameraViewAssets.xcassets", "ALCameraViewController/CameraView.strings"] From 61d52eba7188c2059202764b29e0caf7272eed94 Mon Sep 17 00:00:00 2001 From: Thomas Goddard Date: Tue, 31 Oct 2017 18:08:38 -0700 Subject: [PATCH 44/66] linting... --- ALCameraViewController/Utilities/CameraShot.swift | 14 +++++++------- ALCameraViewController/Views/CameraView.swift | 10 +++++----- Example/Supporting Files/Info.plist | 2 +- Example/ViewController.swift | 12 ++++++------ 4 files changed, 19 insertions(+), 19 deletions(-) diff --git a/ALCameraViewController/Utilities/CameraShot.swift b/ALCameraViewController/Utilities/CameraShot.swift index fedd2fc4..13083172 100644 --- a/ALCameraViewController/Utilities/CameraShot.swift +++ b/ALCameraViewController/Utilities/CameraShot.swift @@ -22,23 +22,23 @@ public func takePhoto(_ stillImageOutput: AVCaptureStillImageOutput, videoOrient if !stillImageOutput.isCapturingStillImage { stillImageOutput.captureStillImageAsynchronously(from: videoConnection, completionHandler: { buffer, error in - + if let error = error { completion(nil, nil, "Error in image capture: \(error.localizedDescription)", nil) } - + guard let buffer = buffer, let exifAttachments = CMGetAttachment(buffer, kCGImagePropertyExifDictionary, nil), let imageData = AVCaptureStillImageOutput.jpegStillImageNSDataRepresentation(buffer), var image = UIImage(data: imageData), let cgImage = image.cgImage else { - DispatchQueue.main.async { - completion(nil, nil, "Error capture, NULL image buffer or NULL EXIF data", nil) - return - } + DispatchQueue.main.async { + completion(nil, nil, "Error capture, NULL image buffer or NULL EXIF data", nil) return + } + return } - + // flip the image to match the orientation of the preview // Half size is large for now if cameraPosition == .front { diff --git a/ALCameraViewController/Views/CameraView.swift b/ALCameraViewController/Views/CameraView.swift index 956c89e0..6ed13f06 100644 --- a/ALCameraViewController/Views/CameraView.swift +++ b/ALCameraViewController/Views/CameraView.swift @@ -275,27 +275,27 @@ public class CameraView: UIView { session.commitConfiguration() } - public func rotateCameraButtons(button:UIButton) { + public func rotateCameraButtons(button: UIButton) { if let currentImage = button.currentImage { switch UIDevice.current.orientation { case .portrait: UIView.transition(with: button, duration: 0.5, options: .transitionFlipFromBottom, animations: { - button.setImage(UIImage.init(cgImage: (button.currentImage?.cgImage)!, scale: currentImage.scale, orientation: .up), for: .normal) + button.setImage(UIImage(cgImage: (button.currentImage?.cgImage)!, scale: currentImage.scale, orientation: .up), for: .normal) }, completion: nil) break case .portraitUpsideDown: UIView.transition(with: button, duration: 0.5, options: .transitionFlipFromTop, animations: { - button.setImage(UIImage.init(cgImage: (button.currentImage?.cgImage)!, scale: currentImage.scale, orientation: .down), for: .normal) + button.setImage(UIImage(cgImage: (button.currentImage?.cgImage)!, scale: currentImage.scale, orientation: .down), for: .normal) }, completion: nil) break case .landscapeRight: UIView.transition(with: button, duration: 0.5, options: .transitionFlipFromLeft, animations: { - button.setImage(UIImage.init(cgImage: (button.currentImage?.cgImage)!, scale: currentImage.scale, orientation: .left), for: .normal) + button.setImage(UIImage(cgImage: (button.currentImage?.cgImage)!, scale: currentImage.scale, orientation: .left), for: .normal) }, completion: nil) break case .landscapeLeft: UIView.transition(with: button, duration: 0.5, options: .transitionFlipFromRight, animations: { - button.setImage(UIImage.init(cgImage: (button.currentImage?.cgImage)!, scale: currentImage.scale, orientation: .right), for: .normal) + button.setImage(UIImage(cgImage: (button.currentImage?.cgImage)!, scale: currentImage.scale, orientation: .right), for: .normal) }, completion: nil) break default: break diff --git a/Example/Supporting Files/Info.plist b/Example/Supporting Files/Info.plist index 251d212c..c16822c8 100644 --- a/Example/Supporting Files/Info.plist +++ b/Example/Supporting Files/Info.plist @@ -19,7 +19,7 @@ CFBundleSignature ???? CFBundleVersion - 1 + 13 LSRequiresIPhoneOS NSCameraUsageDescription diff --git a/Example/ViewController.swift b/Example/ViewController.swift index 9d68bcf5..725084d9 100644 --- a/Example/ViewController.swift +++ b/Example/ViewController.swift @@ -18,18 +18,18 @@ class ViewController: UIViewController { override func viewDidLoad() { super.viewDidLoad() } - - @IBAction func openCamera(_ sender: AnyObject) { - let cameraViewController = CameraViewController(scale: 3.0, croppingEnabled: croppingEnabled, allowsLibraryAccess: libraryEnabled, allowsAudio: false) { [weak self] imageData, image, asset, errorData, exifData in + + @IBAction func openCamera(_: AnyObject) { + let cameraViewController = CameraViewController(scale: 3.0, croppingEnabled: croppingEnabled, allowsLibraryAccess: libraryEnabled, allowsAudio: false) { [weak self] _, image, _, _, _ in self?.imageView.image = image self?.dismiss(animated: true, completion: nil) } present(cameraViewController, animated: true, completion: nil) } - - @IBAction func openLibrary(_ sender: AnyObject) { - let libraryViewController = CameraViewController.imagePickerViewController(croppingEnabled: croppingEnabled) { [weak self] imageData, image, asset, errorData, exifData in + + @IBAction func openLibrary(_: AnyObject) { + let libraryViewController = CameraViewController.imagePickerViewController(croppingEnabled: croppingEnabled) { [weak self] _, image, _, _, _ in self?.imageView.image = image self?.dismiss(animated: true, completion: nil) } From cde43f1569fb71f2fcbc6716865b430e942282ac Mon Sep 17 00:00:00 2001 From: Thomas Goddard Date: Wed, 1 Nov 2017 13:14:06 -0700 Subject: [PATCH 45/66] 1.14.0 Update pod spec --- ALCameraViewController.podspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ALCameraViewController.podspec b/ALCameraViewController.podspec index 2199601b..0bff66a1 100644 --- a/ALCameraViewController.podspec +++ b/ALCameraViewController.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |spec| spec.name = "ALCameraViewController" - spec.version = "1.13.0" + spec.version = "1.14.0" spec.summary = "A camera view controller with custom image picker and image cropping. Written in Swift." spec.source = { :git => "https://github.com/AlexLittlejohn/ALCameraViewController.git", :tag => spec.version.to_s } spec.requires_arc = true From e243cf41a5b84dede3a26a580765e60e4289e1b8 Mon Sep 17 00:00:00 2001 From: Thomas Goddard Date: Wed, 1 Nov 2017 20:48:07 -0700 Subject: [PATCH 46/66] Linting --- .../Utilities/CroppingParameters.swift | 2 +- .../Utilities/SingleImageFetcher.swift | 8 +- .../ViewController/CameraViewController.swift | 2 +- .../ConfirmViewController.swift | 43 ++-- .../Views/CropOverlay.swift | 205 +++++++++--------- Example/ViewController.swift | 6 +- 6 files changed, 132 insertions(+), 134 deletions(-) diff --git a/ALCameraViewController/Utilities/CroppingParameters.swift b/ALCameraViewController/Utilities/CroppingParameters.swift index 88f90acf..aa567093 100644 --- a/ALCameraViewController/Utilities/CroppingParameters.swift +++ b/ALCameraViewController/Utilities/CroppingParameters.swift @@ -29,7 +29,7 @@ public struct CroppingParameters { public init(isEnabled: Bool = false, allowResizing: Bool = true, allowMoving: Bool = true, - minimumSize: CGSize = CGSize(width: 60, height: 60)) { + minimumSize: CGSize = CGSize(width: 60, height: 60)) { self.isEnabled = isEnabled self.allowResizing = allowResizing diff --git a/ALCameraViewController/Utilities/SingleImageFetcher.swift b/ALCameraViewController/Utilities/SingleImageFetcher.swift index aaa5fba0..bb7473d3 100644 --- a/ALCameraViewController/Utilities/SingleImageFetcher.swift +++ b/ALCameraViewController/Utilities/SingleImageFetcher.swift @@ -78,11 +78,11 @@ public class SingleImageFetcher { options.resizeMode = .exact let targetWidth = floor(CGFloat(asset.pixelWidth) * cropRect.width) - let targetHeight = floor(CGFloat(asset.pixelHeight) * cropRect.height) - - targetSize = CGSize(width: targetWidth, height: targetHeight) + let targetHeight = floor(CGFloat(asset.pixelHeight) * cropRect.height) + + targetSize = CGSize(width: targetWidth, height: targetHeight) } - + PHImageManager.default().requestImage(for: asset, targetSize: targetSize, contentMode: .aspectFill, options: options) { image, _ in if let image = image { self.success?(image) diff --git a/ALCameraViewController/ViewController/CameraViewController.swift b/ALCameraViewController/ViewController/CameraViewController.swift index dc92e132..2e1f65ba 100644 --- a/ALCameraViewController/ViewController/CameraViewController.swift +++ b/ALCameraViewController/ViewController/CameraViewController.swift @@ -280,7 +280,7 @@ open class CameraViewController: UIViewController { setupActions() checkPermissions() cameraView.configureFocus() -// cameraView.configureZoom() + // cameraView.configureZoom() } /** diff --git a/ALCameraViewController/ViewController/ConfirmViewController.swift b/ALCameraViewController/ViewController/ConfirmViewController.swift index 440659d7..bb4e0201 100644 --- a/ALCameraViewController/ViewController/ConfirmViewController.swift +++ b/ALCameraViewController/ViewController/ConfirmViewController.swift @@ -37,7 +37,7 @@ public class ConfirmViewController: UIViewController, UIScrollViewDelegate { let exifData: String? public init(imageData: Data, image: UIImage, errorData: String?, exifData: String?, croppingParameters: CroppingParameters) { - self.croppingParameters = croppingParameters + self.croppingParameters = croppingParameters asset = nil self.imageData = imageData self.image = image @@ -46,8 +46,8 @@ public class ConfirmViewController: UIViewController, UIScrollViewDelegate { super.init(nibName: "ConfirmViewController", bundle: CameraGlobals.shared.bundle) } - public init(asset: PHAsset, croppingParameters: CroppingParameters) { - self.croppingParameters = croppingParameters + public init(asset: PHAsset, croppingParameters: CroppingParameters) { + self.croppingParameters = croppingParameters self.asset = asset image = nil imageData = nil @@ -101,7 +101,7 @@ public class ConfirmViewController: UIViewController, UIScrollViewDelegate { self?.hideSpinner(spinner) self?.enable() } - .onFailure { [weak self] error in + .onFailure { [weak self] _ in self?.hideSpinner(spinner) } .fetch() @@ -115,7 +115,7 @@ public class ConfirmViewController: UIViewController, UIScrollViewDelegate { public override func viewWillLayoutSubviews() { super.viewWillLayoutSubviews() let scale = calculateMinimumScale(view.frame.size) - let frame = croppingParameters.isEnabled ? cropOverlay.frame : view.bounds + let frame = croppingParameters.isEnabled ? cropOverlay.frame : view.bounds scrollView.contentInset = calculateScrollViewInsets(frame) scrollView.minimumZoomScale = scale @@ -130,17 +130,17 @@ public class ConfirmViewController: UIViewController, UIScrollViewDelegate { let scale = calculateMinimumScale(size) var frame = view.bounds - if croppingParameters.isEnabled { + if croppingParameters.isEnabled { frame = cropOverlay.frame let centeringFrame = centeringView.frame var origin: CGPoint if size.width > size.height { // landscape let offset = (size.width - centeringFrame.height) - let expectedX = (centeringFrame.height/2 - frame.height/2) + offset + let expectedX = (centeringFrame.height / 2 - frame.height / 2) + offset origin = CGPoint(x: expectedX, y: frame.origin.x) } else { - let expectedY = (centeringFrame.width/2 - frame.width/2) + let expectedY = (centeringFrame.width / 2 - frame.width / 2) origin = CGPoint(x: frame.origin.y, y: expectedY) } @@ -161,7 +161,7 @@ public class ConfirmViewController: UIViewController, UIScrollViewDelegate { } private func configureWithImage(_ image: UIImage) { - cropOverlay.isHidden = !croppingParameters.isEnabled + cropOverlay.isHidden = !croppingParameters.isEnabled buttonActions() @@ -173,7 +173,7 @@ public class ConfirmViewController: UIViewController, UIScrollViewDelegate { private func calculateMinimumScale(_ size: CGSize) -> CGFloat { var _size = size - if croppingParameters.isEnabled { + if croppingParameters.isEnabled { _size = cropOverlay.frame.size } @@ -186,7 +186,7 @@ public class ConfirmViewController: UIViewController, UIScrollViewDelegate { var scale: CGFloat - if croppingParameters.isEnabled { + if croppingParameters.isEnabled { scale = max(scaleWidth, scaleHeight) } else { scale = min(scaleWidth, scaleHeight) @@ -203,8 +203,8 @@ public class ConfirmViewController: UIViewController, UIScrollViewDelegate { } private func centerImageViewOnRotate() { - if croppingParameters.isEnabled { - let size = cropOverlay.frame.size + if croppingParameters.isEnabled { + let size = cropOverlay.frame.size let scrollInsets = scrollView.contentInset let imageSize = imageView.frame.size var contentOffset = CGPoint(x: -scrollInsets.left, y: -scrollInsets.top) @@ -215,7 +215,7 @@ public class ConfirmViewController: UIViewController, UIScrollViewDelegate { } private func centerScrollViewContents() { - let size = croppingParameters.isEnabled ? cropOverlay.frame.size : scrollView.frame.size + let size = croppingParameters.isEnabled ? cropOverlay.frame.size : scrollView.frame.size let imageSize = imageView.frame.size var imageOrigin = CGPoint.zero @@ -241,7 +241,7 @@ public class ConfirmViewController: UIViewController, UIScrollViewDelegate { internal func confirmPhoto() { - guard let image = imageView.image else { + guard let image = imageView.image else { return } @@ -263,7 +263,7 @@ public class ConfirmViewController: UIViewController, UIScrollViewDelegate { self?.showNoImageScreen(error) } .setAsset(asset) - if croppingParameters.isEnabled { + if croppingParameters.isEnabled { let rect = normalizedRect(makeProportionalCropRect(), orientation: image.imageOrientation) fetcher = fetcher.setCropRect(rect) } @@ -272,7 +272,7 @@ public class ConfirmViewController: UIViewController, UIScrollViewDelegate { } else { var newImage = image - if croppingParameters.isEnabled { + if croppingParameters.isEnabled { let cropRect = makeProportionalCropRect() let resizedCropRect = CGRect(x: (image.size.width) * cropRect.origin.x, y: (image.size.height) * cropRect.origin.y, @@ -329,10 +329,10 @@ public class ConfirmViewController: UIViewController, UIScrollViewDelegate { } private func makeProportionalCropRect() -> CGRect { - var cropRect = CGRect(x: cropOverlay.frame.origin.x + cropOverlay.outterGap, - y: cropOverlay.frame.origin.y + cropOverlay.outterGap, - width: cropOverlay.frame.size.width - 2 * cropOverlay.outterGap, - height: cropOverlay.frame.size.height - 2 * cropOverlay.outterGap) + var cropRect = CGRect(x: cropOverlay.frame.origin.x + cropOverlay.outterGap, + y: cropOverlay.frame.origin.y + cropOverlay.outterGap, + width: cropOverlay.frame.size.width - 2 * cropOverlay.outterGap, + height: cropOverlay.frame.size.height - 2 * cropOverlay.outterGap) cropRect.origin.x += scrollView.contentOffset.x cropRect.origin.y += scrollView.contentOffset.y @@ -344,7 +344,6 @@ public class ConfirmViewController: UIViewController, UIScrollViewDelegate { return CGRect(x: normalizedX, y: normalizedY, width: normalizedWidth, height: normalizedHeight) } - } extension UIImage { diff --git a/ALCameraViewController/Views/CropOverlay.swift b/ALCameraViewController/Views/CropOverlay.swift index 862ece42..4ac287f3 100644 --- a/ALCameraViewController/Views/CropOverlay.swift +++ b/ALCameraViewController/Views/CropOverlay.swift @@ -13,7 +13,7 @@ internal class CropOverlay: UIView { var outerLines = [UIView]() var horizontalLines = [UIView]() var verticalLines = [UIView]() - + var topLeftCornerLines = [UIView]() var topRightCornerLines = [UIView]() var bottomLeftCornerLines = [UIView]() @@ -24,14 +24,14 @@ internal class CropOverlay: UIView { let cornerLineDepth: CGFloat = 3 let cornerLineWidth: CGFloat = 22.5 var cornerButtonWidth: CGFloat { - return self.cornerLineWidth * 2 + return cornerLineWidth * 2 } let lineWidth: CGFloat = 1 - let outterGapRatio: CGFloat = 1/3 + let outterGapRatio: CGFloat = 1 / 3 var outterGap: CGFloat { - return self.cornerButtonWidth * self.outterGapRatio + return cornerButtonWidth * outterGapRatio } var isResizable: Bool = false @@ -47,13 +47,13 @@ internal class CropOverlay: UIView { super.init(coder: aDecoder) createLines() } - + override func layoutSubviews() { - - for i in 0.. UIView { let line = UIView() line.backgroundColor = UIColor.white addSubview(line) return line } - - func createButton() -> UIButton { - let button = UIButton() - button.backgroundColor = UIColor.clear - - let dragGestureRecognizer = UIPanGestureRecognizer(target: self, action: #selector(moveCropOverlay)) - button.addGestureRecognizer(dragGestureRecognizer) - - addSubview(button) - return button - } - - @objc func moveCropOverlay(gestureRecognizer: UIPanGestureRecognizer) { - if isResizable, let button = gestureRecognizer.view as? UIButton { - if gestureRecognizer.state == .began || gestureRecognizer.state == .changed { - let translation = gestureRecognizer.translation(in: self) - - var newFrame: CGRect - - switch button { - case cornerButtons[0]: // Top Left + + func createButton() -> UIButton { + let button = UIButton() + button.backgroundColor = UIColor.clear + + let dragGestureRecognizer = UIPanGestureRecognizer(target: self, action: #selector(moveCropOverlay)) + button.addGestureRecognizer(dragGestureRecognizer) + + addSubview(button) + return button + } + + @objc func moveCropOverlay(gestureRecognizer: UIPanGestureRecognizer) { + if isResizable, let button = gestureRecognizer.view as? UIButton { + if gestureRecognizer.state == .began || gestureRecognizer.state == .changed { + let translation = gestureRecognizer.translation(in: self) + + var newFrame: CGRect + + switch button { + case cornerButtons[0]: // Top Left newFrame = CGRect(x: frame.origin.x + translation.x, y: frame.origin.y + translation.y, width: frame.size.width - translation.x, height: frame.size.height - translation.y) - case cornerButtons[1]: // Top Right - newFrame = CGRect(x: frame.origin.x, y: frame.origin.y + translation.y, width: frame.size.width + translation.x, height: frame.size.height - translation.y) - case cornerButtons[2]: // Bottom Left - newFrame = CGRect(x: frame.origin.x + translation.x, y: frame.origin.y, width: frame.size.width - translation.x, height: frame.size.height + translation.y) - case cornerButtons[3]: // Bottom Right - newFrame = CGRect(x: frame.origin.x, y: frame.origin.y, width: frame.size.width + translation.x, height: frame.size.height + translation.y) - default: - newFrame = CGRect.zero - } + case cornerButtons[1]: // Top Right + newFrame = CGRect(x: frame.origin.x, y: frame.origin.y + translation.y, width: frame.size.width + translation.x, height: frame.size.height - translation.y) + case cornerButtons[2]: // Bottom Left + newFrame = CGRect(x: frame.origin.x + translation.x, y: frame.origin.y, width: frame.size.width - translation.x, height: frame.size.height + translation.y) + case cornerButtons[3]: // Bottom Right + newFrame = CGRect(x: frame.origin.x, y: frame.origin.y, width: frame.size.width + translation.x, height: frame.size.height + translation.y) + default: + newFrame = CGRect.zero + } let minimumFrame = CGRect(x: newFrame.origin.x, y: newFrame.origin.y, width: max(newFrame.size.width, minimumSize.width + 2 * outterGap), height: max(newFrame.size.height, minimumSize.height + 2 * outterGap)) - frame = minimumFrame - layoutSubviews() - - gestureRecognizer.setTranslation(CGPoint.zero, in: self) - } - } else if isMovable { - if gestureRecognizer.state == .began || gestureRecognizer.state == .changed { - let translation = gestureRecognizer.translation(in: self) - - gestureRecognizer.view!.center = CGPoint(x: gestureRecognizer.view!.center.x + translation.x, y: gestureRecognizer.view!.center.y + translation.y) - gestureRecognizer.setTranslation(CGPoint(x: 0, y: 0), in: self) - } - } - } + frame = minimumFrame + layoutSubviews() + + gestureRecognizer.setTranslation(CGPoint.zero, in: self) + } + } else if isMovable { + if gestureRecognizer.state == .began || gestureRecognizer.state == .changed { + let translation = gestureRecognizer.translation(in: self) + + gestureRecognizer.view!.center = CGPoint(x: gestureRecognizer.view!.center.x + translation.x, y: gestureRecognizer.view!.center.y + translation.y) + gestureRecognizer.setTranslation(CGPoint(x: 0, y: 0), in: self) + } + } + } override func hitTest(_ point: CGPoint, with event: UIEvent?) -> UIView? { let view = super.hitTest(point, with: event) diff --git a/Example/ViewController.swift b/Example/ViewController.swift index b19eae93..f1df30fc 100644 --- a/Example/ViewController.swift +++ b/Example/ViewController.swift @@ -26,8 +26,8 @@ class ViewController: UIViewController { override func viewDidLoad() { super.viewDidLoad() - - self.imageView.contentMode = .scaleAspectFit + + imageView.contentMode = .scaleAspectFit } @IBAction func openCamera(_: AnyObject) { @@ -51,7 +51,7 @@ class ViewController: UIViewController { @IBAction func libraryChanged(_: AnyObject) { libraryEnabled = !libraryEnabled } - + @IBAction func croppingChanged(_ sender: UISwitch) { croppingEnabled = sender.isOn croppingParametersView.isHidden = !sender.isOn From f76980d2e661a6fd06bfaa26c1990c04f22746db Mon Sep 17 00:00:00 2001 From: Thomas Goddard Date: Wed, 1 Nov 2017 20:50:32 -0700 Subject: [PATCH 47/66] Zoom is configured with device updates --- ALCameraViewController/ViewController/CameraViewController.swift | 1 - 1 file changed, 1 deletion(-) diff --git a/ALCameraViewController/ViewController/CameraViewController.swift b/ALCameraViewController/ViewController/CameraViewController.swift index 2e1f65ba..373339ba 100644 --- a/ALCameraViewController/ViewController/CameraViewController.swift +++ b/ALCameraViewController/ViewController/CameraViewController.swift @@ -280,7 +280,6 @@ open class CameraViewController: UIViewController { setupActions() checkPermissions() cameraView.configureFocus() - // cameraView.configureZoom() } /** From 788a5c9ee00ed55465fbbc60dfe374f3d813f0d7 Mon Sep 17 00:00:00 2001 From: Thomas Goddard Date: Wed, 1 Nov 2017 20:52:10 -0700 Subject: [PATCH 48/66] Remove team --- ALCameraViewController.xcodeproj/project.pbxproj | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/ALCameraViewController.xcodeproj/project.pbxproj b/ALCameraViewController.xcodeproj/project.pbxproj index 54e16d1d..d7916e94 100644 --- a/ALCameraViewController.xcodeproj/project.pbxproj +++ b/ALCameraViewController.xcodeproj/project.pbxproj @@ -280,7 +280,6 @@ }; FAF0583E1B31618D008E5592 = { CreatedOnToolsVersion = 6.3.2; - DevelopmentTeam = 4L5389GUUE; LastSwiftMigration = 0900; ProvisioningStyle = Automatic; }; @@ -545,7 +544,7 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; - DEVELOPMENT_TEAM = 4L5389GUUE; + DEVELOPMENT_TEAM = ""; INFOPLIST_FILE = "Example/Supporting Files/Info.plist"; IPHONEOS_DEPLOYMENT_TARGET = 8.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; @@ -562,7 +561,7 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; - DEVELOPMENT_TEAM = 4L5389GUUE; + DEVELOPMENT_TEAM = ""; INFOPLIST_FILE = "Example/Supporting Files/Info.plist"; IPHONEOS_DEPLOYMENT_TARGET = 8.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; From 9aa6e780e2fe8687db5bbe23a127635e34796be1 Mon Sep 17 00:00:00 2001 From: Thomas Goddard Date: Wed, 1 Nov 2017 20:53:36 -0700 Subject: [PATCH 49/66] Put URL back for pod --- Podfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Podfile b/Podfile index b5527300..c6e8bed1 100644 --- a/Podfile +++ b/Podfile @@ -9,7 +9,7 @@ pod 'Crashlytics' pod 'Masonry' pod 'SnapKit' pod 'Mixpanel' -pod 'ALCameraViewController', :git => 'https://github.com/Cyclic/ALCameraViewController', :branch => 'develop' +pod 'ALCameraViewController', :git => 'https://github.com/AlexLittlejohn/ALCameraViewController', :branch => 'develop' end post_install do |installer| installer.pods_project.targets.each do |target| From b187255c770e6601a6c09868a88eda142d923bda Mon Sep 17 00:00:00 2001 From: Thomas Goddard Date: Thu, 2 Nov 2017 11:02:22 -0700 Subject: [PATCH 50/66] Enable bitcode, update pods --- .../project.pbxproj | 89 +++++++++++++++++++ Podfile | 4 +- Podfile.lock | 12 +-- 3 files changed, 97 insertions(+), 8 deletions(-) diff --git a/ALCameraViewController.xcodeproj/project.pbxproj b/ALCameraViewController.xcodeproj/project.pbxproj index d7916e94..d559e4d0 100644 --- a/ALCameraViewController.xcodeproj/project.pbxproj +++ b/ALCameraViewController.xcodeproj/project.pbxproj @@ -7,6 +7,7 @@ objects = { /* Begin PBXBuildFile section */ + 1D4BC6A7CE46F52C503BE81A /* Pods_ALCameraViewController.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 5EA3B6D5F07E9E32F0AF2A75 /* Pods_ALCameraViewController.framework */; }; 1F3C56291F701CA7009667E9 /* CroppingParameters.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7AC96FA11F5B5166003E53F4 /* CroppingParameters.swift */; }; 7AC96FA21F5B5166003E53F4 /* CroppingParameters.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7AC96FA11F5B5166003E53F4 /* CroppingParameters.swift */; }; C40665441C73A47C00EB9751 /* SingleImageSaver.swift in Sources */ = {isa = PBXBuildFile; fileRef = C40665431C73A47C00EB9751 /* SingleImageSaver.swift */; }; @@ -60,6 +61,8 @@ /* End PBXBuildFile section */ /* Begin PBXFileReference section */ + 30992D3B789B4F8CA8705055 /* Pods-ALCameraViewController.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-ALCameraViewController.release.xcconfig"; path = "Pods/Target Support Files/Pods-ALCameraViewController/Pods-ALCameraViewController.release.xcconfig"; sourceTree = ""; }; + 5EA3B6D5F07E9E32F0AF2A75 /* Pods_ALCameraViewController.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_ALCameraViewController.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 7AC96FA11F5B5166003E53F4 /* CroppingParameters.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CroppingParameters.swift; sourceTree = ""; }; C40665431C73A47C00EB9751 /* SingleImageSaver.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SingleImageSaver.swift; sourceTree = ""; }; C40665451C73A94100EB9751 /* CameraGlobals.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CameraGlobals.swift; sourceTree = ""; }; @@ -71,6 +74,7 @@ C4829FFF1CAEB16C00541D08 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; C4D9BA441CA7224B004F70F7 /* PhotoLibraryAuthorizer.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PhotoLibraryAuthorizer.swift; sourceTree = ""; }; C4D9BA461CA73163004F70F7 /* UIButtonExtensions.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = UIButtonExtensions.swift; sourceTree = ""; }; + D4AD3E148CB26CAF275AC0AC /* Pods-ALCameraViewController.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-ALCameraViewController.debug.xcconfig"; path = "Pods/Target Support Files/Pods-ALCameraViewController/Pods-ALCameraViewController.debug.xcconfig"; sourceTree = ""; }; EBF7829B1CB2C04300DE3E63 /* CameraViewControllerConstraint.swift */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 4; lastKnownFileType = sourcecode.swift; path = CameraViewControllerConstraint.swift; sourceTree = ""; tabWidth = 4; }; EBFE097C1CAF1D1A00A8C637 /* UIViewExtensions.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = UIViewExtensions.swift; sourceTree = ""; }; FA52EE0A1B44129B00E16B6F /* ViewController.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = ViewController.xib; sourceTree = ""; }; @@ -106,12 +110,22 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( + 1D4BC6A7CE46F52C503BE81A /* Pods_ALCameraViewController.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; /* End PBXFrameworksBuildPhase section */ /* Begin PBXGroup section */ + 43256C8F415F4382CB1B01FE /* Pods */ = { + isa = PBXGroup; + children = ( + D4AD3E148CB26CAF275AC0AC /* Pods-ALCameraViewController.debug.xcconfig */, + 30992D3B789B4F8CA8705055 /* Pods-ALCameraViewController.release.xcconfig */, + ); + name = Pods; + sourceTree = ""; + }; C4829FFC1CAEB16C00541D08 /* CameraViewController */ = { isa = PBXGroup; children = ( @@ -121,6 +135,14 @@ path = CameraViewController; sourceTree = ""; }; + FA87334AA8FE91546E22FE97 /* Frameworks */ = { + isa = PBXGroup; + children = ( + 5EA3B6D5F07E9E32F0AF2A75 /* Pods_ALCameraViewController.framework */, + ); + name = Frameworks; + sourceTree = ""; + }; FAB50BEA1B413E41009905B9 /* ViewController */ = { isa = PBXGroup; children = ( @@ -169,6 +191,8 @@ FAF058411B31618D008E5592 /* ALCameraViewController */, C4829FFC1CAEB16C00541D08 /* CameraViewController */, FAF058401B31618D008E5592 /* Products */, + 43256C8F415F4382CB1B01FE /* Pods */, + FA87334AA8FE91546E22FE97 /* Frameworks */, ); sourceTree = ""; }; @@ -250,9 +274,12 @@ isa = PBXNativeTarget; buildConfigurationList = FAF0585E1B31618D008E5592 /* Build configuration list for PBXNativeTarget "ALCameraViewController" */; buildPhases = ( + B7EE613AF2C8F9F3F680AD43 /* [CP] Check Pods Manifest.lock */, FAF0583B1B31618D008E5592 /* Sources */, FAF0583C1B31618D008E5592 /* Frameworks */, FAF0583D1B31618D008E5592 /* Resources */, + 18CD297EA4D45E5795E3F66F /* [CP] Embed Pods Frameworks */, + 52854F814B04225D8FBC2683 /* [CP] Copy Pods Resources */, ); buildRules = ( ); @@ -330,6 +357,66 @@ }; /* End PBXResourcesBuildPhase section */ +/* Begin PBXShellScriptBuildPhase section */ + 18CD297EA4D45E5795E3F66F /* [CP] Embed Pods Frameworks */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + "${SRCROOT}/Pods/Target Support Files/Pods-ALCameraViewController/Pods-ALCameraViewController-frameworks.sh", + "${BUILT_PRODUCTS_DIR}/ALCameraViewController/ALCameraViewController.framework", + "${BUILT_PRODUCTS_DIR}/Masonry/Masonry.framework", + "${BUILT_PRODUCTS_DIR}/Mixpanel/Mixpanel.framework", + "${BUILT_PRODUCTS_DIR}/SnapKit/SnapKit.framework", + ); + name = "[CP] Embed Pods Frameworks"; + outputPaths = ( + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/ALCameraViewController.framework", + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Masonry.framework", + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Mixpanel.framework", + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/SnapKit.framework", + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-ALCameraViewController/Pods-ALCameraViewController-frameworks.sh\"\n"; + showEnvVarsInLog = 0; + }; + 52854F814B04225D8FBC2683 /* [CP] Copy Pods Resources */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + ); + name = "[CP] Copy Pods Resources"; + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-ALCameraViewController/Pods-ALCameraViewController-resources.sh\"\n"; + showEnvVarsInLog = 0; + }; + B7EE613AF2C8F9F3F680AD43 /* [CP] Check Pods Manifest.lock */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + "${PODS_PODFILE_DIR_PATH}/Podfile.lock", + "${PODS_ROOT}/Manifest.lock", + ); + name = "[CP] Check Pods Manifest.lock"; + outputPaths = ( + "$(DERIVED_FILE_DIR)/Pods-ALCameraViewController-checkManifestLockResult.txt", + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; + showEnvVarsInLog = 0; + }; +/* End PBXShellScriptBuildPhase section */ + /* Begin PBXSourcesBuildPhase section */ C4829FF61CAEB16C00541D08 /* Sources */ = { isa = PBXSourcesBuildPhase; @@ -540,6 +627,7 @@ }; FAF0585F1B31618D008E5592 /* Debug */ = { isa = XCBuildConfiguration; + baseConfigurationReference = D4AD3E148CB26CAF275AC0AC /* Pods-ALCameraViewController.debug.xcconfig */; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage; @@ -557,6 +645,7 @@ }; FAF058601B31618D008E5592 /* Release */ = { isa = XCBuildConfiguration; + baseConfigurationReference = 30992D3B789B4F8CA8705055 /* Pods-ALCameraViewController.release.xcconfig */; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage; diff --git a/Podfile b/Podfile index c6e8bed1..6d57ed2c 100644 --- a/Podfile +++ b/Podfile @@ -9,12 +9,12 @@ pod 'Crashlytics' pod 'Masonry' pod 'SnapKit' pod 'Mixpanel' -pod 'ALCameraViewController', :git => 'https://github.com/AlexLittlejohn/ALCameraViewController', :branch => 'develop' +pod 'ALCameraViewController', :git => 'https://github.com/cyclic/ALCameraViewController', :branch => 'develop' end post_install do |installer| installer.pods_project.targets.each do |target| target.build_configurations.each do |config| - config.build_settings['ENABLE_BITCODE'] = 'NO' + config.build_settings['ENABLE_BITCODE'] = 'YES' config.build_settings['CODE_SIGNING_REQUIRED'] = 'NO' config.build_settings['SWIFT_VERSION'] = '4.0' end diff --git a/Podfile.lock b/Podfile.lock index b4de8c06..a7b57833 100644 --- a/Podfile.lock +++ b/Podfile.lock @@ -8,7 +8,7 @@ PODS: - SnapKit (4.0.0) DEPENDENCIES: - - ALCameraViewController (from `https://github.com/Cyclic/ALCameraViewController`, branch `develop`) + - ALCameraViewController (from `https://github.com/cyclic/ALCameraViewController`, branch `develop`) - Crashlytics - Fabric - Masonry @@ -18,21 +18,21 @@ DEPENDENCIES: EXTERNAL SOURCES: ALCameraViewController: :branch: develop - :git: https://github.com/Cyclic/ALCameraViewController + :git: https://github.com/cyclic/ALCameraViewController CHECKOUT OPTIONS: ALCameraViewController: - :commit: 15b6001c800023fddeda90ac41122e7d4bfeed4e - :git: https://github.com/Cyclic/ALCameraViewController + :commit: cde43f1569fb71f2fcbc6716865b430e942282ac + :git: https://github.com/cyclic/ALCameraViewController SPEC CHECKSUMS: - ALCameraViewController: 8fd2a73d407008ae030630ab95fdb92a90f95e6b + ALCameraViewController: bcf4d45918150d7b4eaf53c244087c2c4523ae0b Crashlytics: dbb07d01876c171c5ccbdf7826410380189e452c Fabric: 9cd6a848efcf1b8b07497e0b6a2e7d336353ba15 Masonry: 678fab65091a9290e40e2832a55e7ab731aad201 Mixpanel: 7bd8e176f088936bf6e283ade0d1f512f8e723bc SnapKit: a42d492c16e80209130a3379f73596c3454b7694 -PODFILE CHECKSUM: fefc4a0fa590c7e54dcece668918f300095e7301 +PODFILE CHECKSUM: 5e3629285b33ddc1994bd127ab0489407323472a COCOAPODS: 1.3.1 From b470f724ebb5a42f85de2e24e0f2fa8acfdb1e4a Mon Sep 17 00:00:00 2001 From: Thomas Goddard Date: Thu, 2 Nov 2017 16:46:24 -0700 Subject: [PATCH 51/66] Podfile update --- ALCameraViewController.xcodeproj/project.pbxproj | 5 +++-- Podfile.lock | 6 +++--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/ALCameraViewController.xcodeproj/project.pbxproj b/ALCameraViewController.xcodeproj/project.pbxproj index d559e4d0..53e9b328 100644 --- a/ALCameraViewController.xcodeproj/project.pbxproj +++ b/ALCameraViewController.xcodeproj/project.pbxproj @@ -307,6 +307,7 @@ }; FAF0583E1B31618D008E5592 = { CreatedOnToolsVersion = 6.3.2; + DevelopmentTeam = 4L5389GUUE; LastSwiftMigration = 0900; ProvisioningStyle = Automatic; }; @@ -632,7 +633,7 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; - DEVELOPMENT_TEAM = ""; + DEVELOPMENT_TEAM = 4L5389GUUE; INFOPLIST_FILE = "Example/Supporting Files/Info.plist"; IPHONEOS_DEPLOYMENT_TARGET = 8.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; @@ -650,7 +651,7 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; - DEVELOPMENT_TEAM = ""; + DEVELOPMENT_TEAM = 4L5389GUUE; INFOPLIST_FILE = "Example/Supporting Files/Info.plist"; IPHONEOS_DEPLOYMENT_TARGET = 8.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; diff --git a/Podfile.lock b/Podfile.lock index a7b57833..85141ead 100644 --- a/Podfile.lock +++ b/Podfile.lock @@ -1,5 +1,5 @@ PODS: - - ALCameraViewController (1.13.0) + - ALCameraViewController (3.0.2) - Crashlytics (3.9.3): - Fabric (~> 1.7.2) - Fabric (1.7.2) @@ -22,11 +22,11 @@ EXTERNAL SOURCES: CHECKOUT OPTIONS: ALCameraViewController: - :commit: cde43f1569fb71f2fcbc6716865b430e942282ac + :commit: a7d447254cdb1cd2027633beab9957a56007fb7f :git: https://github.com/cyclic/ALCameraViewController SPEC CHECKSUMS: - ALCameraViewController: bcf4d45918150d7b4eaf53c244087c2c4523ae0b + ALCameraViewController: 6649b688371768b4e177596931f8f35e980465f7 Crashlytics: dbb07d01876c171c5ccbdf7826410380189e452c Fabric: 9cd6a848efcf1b8b07497e0b6a2e7d336353ba15 Masonry: 678fab65091a9290e40e2832a55e7ab731aad201 From 451635a29e82a798a549d0d9be60bfdae5eabc91 Mon Sep 17 00:00:00 2001 From: Thomas Goddard Date: Fri, 3 Nov 2017 16:16:19 -0700 Subject: [PATCH 52/66] Disable bitcode, version bump, and remove provisioning profile --- ALCameraViewController.xcodeproj/project.pbxproj | 5 ++--- Example/Supporting Files/Info.plist | 4 ++-- Podfile | 2 +- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/ALCameraViewController.xcodeproj/project.pbxproj b/ALCameraViewController.xcodeproj/project.pbxproj index 53e9b328..d559e4d0 100644 --- a/ALCameraViewController.xcodeproj/project.pbxproj +++ b/ALCameraViewController.xcodeproj/project.pbxproj @@ -307,7 +307,6 @@ }; FAF0583E1B31618D008E5592 = { CreatedOnToolsVersion = 6.3.2; - DevelopmentTeam = 4L5389GUUE; LastSwiftMigration = 0900; ProvisioningStyle = Automatic; }; @@ -633,7 +632,7 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; - DEVELOPMENT_TEAM = 4L5389GUUE; + DEVELOPMENT_TEAM = ""; INFOPLIST_FILE = "Example/Supporting Files/Info.plist"; IPHONEOS_DEPLOYMENT_TARGET = 8.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; @@ -651,7 +650,7 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; - DEVELOPMENT_TEAM = 4L5389GUUE; + DEVELOPMENT_TEAM = ""; INFOPLIST_FILE = "Example/Supporting Files/Info.plist"; IPHONEOS_DEPLOYMENT_TARGET = 8.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; diff --git a/Example/Supporting Files/Info.plist b/Example/Supporting Files/Info.plist index c16822c8..ed72c29d 100644 --- a/Example/Supporting Files/Info.plist +++ b/Example/Supporting Files/Info.plist @@ -15,11 +15,11 @@ CFBundlePackageType APPL CFBundleShortVersionString - 1.0.10 + 3.0.3 CFBundleSignature ???? CFBundleVersion - 13 + 0 LSRequiresIPhoneOS NSCameraUsageDescription diff --git a/Podfile b/Podfile index 6d57ed2c..662cd616 100644 --- a/Podfile +++ b/Podfile @@ -14,7 +14,7 @@ end post_install do |installer| installer.pods_project.targets.each do |target| target.build_configurations.each do |config| - config.build_settings['ENABLE_BITCODE'] = 'YES' + config.build_settings['ENABLE_BITCODE'] = 'NO' config.build_settings['CODE_SIGNING_REQUIRED'] = 'NO' config.build_settings['SWIFT_VERSION'] = '4.0' end From b20c678a9c1b969a4d94ba7578fd53ee987b90fa Mon Sep 17 00:00:00 2001 From: Thomas Goddard Date: Fri, 3 Nov 2017 16:23:27 -0700 Subject: [PATCH 53/66] iOS 10 target --- Podfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Podfile b/Podfile index 662cd616..c15470f5 100644 --- a/Podfile +++ b/Podfile @@ -1,5 +1,5 @@ source 'https://github.com/CocoaPods/Specs.git' -platform :ios, '11.0’ +platform :ios, '10.0’ use_frameworks! From c4cafd7db07966cfaeadcc486148f13f1e9f4273 Mon Sep 17 00:00:00 2001 From: Thomas Goddard Date: Fri, 3 Nov 2017 16:26:34 -0700 Subject: [PATCH 54/66] Build bump --- ALCameraViewController.podspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ALCameraViewController.podspec b/ALCameraViewController.podspec index 58fe93d3..d7dd9899 100644 --- a/ALCameraViewController.podspec +++ b/ALCameraViewController.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |spec| spec.name = "ALCameraViewController" - spec.version = "3.0.2" + spec.version = "3.0.3" spec.summary = "A camera view controller with custom image picker and image cropping." spec.source = { :git => "https://github.com/AlexLittlejohn/ALCameraViewController.git", :tag => spec.version.to_s } spec.requires_arc = true From 15876d10b1dc6fbb24d8d721c1687e097b0e0a31 Mon Sep 17 00:00:00 2001 From: Thomas Goddard Date: Fri, 3 Nov 2017 16:26:55 -0700 Subject: [PATCH 55/66] Build bump --- ALCameraViewController.podspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ALCameraViewController.podspec b/ALCameraViewController.podspec index 58fe93d3..d7dd9899 100644 --- a/ALCameraViewController.podspec +++ b/ALCameraViewController.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |spec| spec.name = "ALCameraViewController" - spec.version = "3.0.2" + spec.version = "3.0.3" spec.summary = "A camera view controller with custom image picker and image cropping." spec.source = { :git => "https://github.com/AlexLittlejohn/ALCameraViewController.git", :tag => spec.version.to_s } spec.requires_arc = true From 4a97e2fc61d97c234b56a5187386b6fc0ab218b0 Mon Sep 17 00:00:00 2001 From: Thomas Goddard Date: Fri, 3 Nov 2017 16:33:49 -0700 Subject: [PATCH 56/66] Add scaleFactor --- .../ViewController/CameraViewController.swift | 4 ++-- Podfile.lock | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/ALCameraViewController/ViewController/CameraViewController.swift b/ALCameraViewController/ViewController/CameraViewController.swift index 373339ba..442eddb7 100644 --- a/ALCameraViewController/ViewController/CameraViewController.swift +++ b/ALCameraViewController/ViewController/CameraViewController.swift @@ -162,7 +162,7 @@ open class CameraViewController: UIViewController { private let allowsLibraryAccess: Bool - public init(croppingParameters: CroppingParameters = CroppingParameters(), + public init(scaleFactor: CGFloat, croppingParameters: CroppingParameters = CroppingParameters(), allowsLibraryAccess: Bool = true, allowsSwapCameraOrientation: Bool = true, allowVolumeButtonCapture: Bool = true, @@ -172,7 +172,7 @@ open class CameraViewController: UIViewController { self.allowsLibraryAccess = allowsLibraryAccess self.allowVolumeButtonCapture = allowVolumeButtonCapture super.init(nibName: nil, bundle: nil) - outputScale = scale + outputScale = scaleFactor onCompletion = completion cameraOverlay.isHidden = !croppingParameters.isEnabled cameraOverlay.isUserInteractionEnabled = false diff --git a/Podfile.lock b/Podfile.lock index 85141ead..f50e8bdc 100644 --- a/Podfile.lock +++ b/Podfile.lock @@ -1,5 +1,5 @@ PODS: - - ALCameraViewController (3.0.2) + - ALCameraViewController (3.0.3) - Crashlytics (3.9.3): - Fabric (~> 1.7.2) - Fabric (1.7.2) @@ -22,17 +22,17 @@ EXTERNAL SOURCES: CHECKOUT OPTIONS: ALCameraViewController: - :commit: a7d447254cdb1cd2027633beab9957a56007fb7f + :commit: c4cafd7db07966cfaeadcc486148f13f1e9f4273 :git: https://github.com/cyclic/ALCameraViewController SPEC CHECKSUMS: - ALCameraViewController: 6649b688371768b4e177596931f8f35e980465f7 + ALCameraViewController: f4a52c7b2d75df179d5e34c1c5c4a2a219c8f368 Crashlytics: dbb07d01876c171c5ccbdf7826410380189e452c Fabric: 9cd6a848efcf1b8b07497e0b6a2e7d336353ba15 Masonry: 678fab65091a9290e40e2832a55e7ab731aad201 Mixpanel: 7bd8e176f088936bf6e283ade0d1f512f8e723bc SnapKit: a42d492c16e80209130a3379f73596c3454b7694 -PODFILE CHECKSUM: 5e3629285b33ddc1994bd127ab0489407323472a +PODFILE CHECKSUM: 046c4794531b2023333725c208f36c3b87383103 COCOAPODS: 1.3.1 From 833c9725a82e73e22a249ddc013691aee71f6587 Mon Sep 17 00:00:00 2001 From: Thomas Goddard Date: Tue, 7 Nov 2017 11:34:36 -0800 Subject: [PATCH 57/66] Because swift 4.0 --- ALCameraViewController.podspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ALCameraViewController.podspec b/ALCameraViewController.podspec index d7dd9899..966d9221 100644 --- a/ALCameraViewController.podspec +++ b/ALCameraViewController.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |spec| spec.name = "ALCameraViewController" - spec.version = "3.0.3" + spec.version = "3.0.4" spec.summary = "A camera view controller with custom image picker and image cropping." spec.source = { :git => "https://github.com/AlexLittlejohn/ALCameraViewController.git", :tag => spec.version.to_s } spec.requires_arc = true From b08905b95642ed6e89b01054b1a38c035eb4725e Mon Sep 17 00:00:00 2001 From: Thomas Goddard Date: Wed, 8 Nov 2017 08:32:29 -0800 Subject: [PATCH 58/66] Go back to swift 3.2, remove unnecessary pods, small code changes to get swift 3.2 working again, add scaleFactor to input of example --- .../project.pbxproj | 15 ++++-------- .../Utilities/CameraShot.swift | 2 +- .../ViewController/CameraViewController.swift | 6 ++--- ALCameraViewController/Views/CameraView.swift | 8 +++---- Example/ViewController.swift | 2 +- Podfile | 7 +----- Podfile.lock | 24 ++++--------------- 7 files changed, 19 insertions(+), 45 deletions(-) diff --git a/ALCameraViewController.xcodeproj/project.pbxproj b/ALCameraViewController.xcodeproj/project.pbxproj index f8b1ba80..7100fb66 100644 --- a/ALCameraViewController.xcodeproj/project.pbxproj +++ b/ALCameraViewController.xcodeproj/project.pbxproj @@ -310,6 +310,7 @@ }; FAF0583E1B31618D008E5592 = { CreatedOnToolsVersion = 6.3.2; + DevelopmentTeam = 4L5389GUUE; LastSwiftMigration = 0900; ProvisioningStyle = Automatic; }; @@ -370,16 +371,10 @@ inputPaths = ( "${SRCROOT}/Pods/Target Support Files/Pods-ALCameraViewController/Pods-ALCameraViewController-frameworks.sh", "${BUILT_PRODUCTS_DIR}/ALCameraViewController/ALCameraViewController.framework", - "${BUILT_PRODUCTS_DIR}/Masonry/Masonry.framework", - "${BUILT_PRODUCTS_DIR}/Mixpanel/Mixpanel.framework", - "${BUILT_PRODUCTS_DIR}/SnapKit/SnapKit.framework", ); name = "[CP] Embed Pods Frameworks"; outputPaths = ( "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/ALCameraViewController.framework", - "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Masonry.framework", - "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Mixpanel.framework", - "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/SnapKit.framework", ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; @@ -635,14 +630,14 @@ buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; - DEVELOPMENT_TEAM = ""; + DEVELOPMENT_TEAM = 4L5389GUUE; INFOPLIST_FILE = "Example/Supporting Files/Info.plist"; IPHONEOS_DEPLOYMENT_TARGET = 9.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = com.alx.zero.CameraViewController; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_SWIFT3_OBJC_INFERENCE = Default; - SWIFT_VERSION = 4.0; + SWIFT_VERSION = 3.0; }; name = Debug; }; @@ -652,14 +647,14 @@ buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; - DEVELOPMENT_TEAM = ""; + DEVELOPMENT_TEAM = 4L5389GUUE; INFOPLIST_FILE = "Example/Supporting Files/Info.plist"; IPHONEOS_DEPLOYMENT_TARGET = 9.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = com.alx.zero.CameraViewController; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_SWIFT3_OBJC_INFERENCE = Default; - SWIFT_VERSION = 4.0; + SWIFT_VERSION = 3.0; }; name = Release; }; diff --git a/ALCameraViewController/Utilities/CameraShot.swift b/ALCameraViewController/Utilities/CameraShot.swift index 13083172..b61f3113 100644 --- a/ALCameraViewController/Utilities/CameraShot.swift +++ b/ALCameraViewController/Utilities/CameraShot.swift @@ -13,7 +13,7 @@ public typealias CameraShotCompletion = (Data?, UIImage?, String?, String?) -> V public func takePhoto(_ stillImageOutput: AVCaptureStillImageOutput, videoOrientation: AVCaptureVideoOrientation, cameraPosition: AVCaptureDevice.Position, cropSize _: CGSize, outputScale: CGFloat, completion: @escaping CameraShotCompletion) { - guard let videoConnection: AVCaptureConnection = stillImageOutput.connection(with: AVMediaType.video) else { + guard let videoConnection: AVCaptureConnection = stillImageOutput.connection(withMediaType: AVMediaTypeVideo) else { completion(nil, nil, nil, nil) return } diff --git a/ALCameraViewController/ViewController/CameraViewController.swift b/ALCameraViewController/ViewController/CameraViewController.swift index 442eddb7..6b5cb943 100644 --- a/ALCameraViewController/ViewController/CameraViewController.swift +++ b/ALCameraViewController/ViewController/CameraViewController.swift @@ -470,8 +470,8 @@ open class CameraViewController: UIViewController { * the user that it not allow the permissions. */ private func checkPermissions() { - if AVCaptureDevice.authorizationStatus(for: AVMediaType.video) != .authorized { - AVCaptureDevice.requestAccess(for: AVMediaType.video) { granted in + if AVCaptureDevice.authorizationStatus(forMediaType: AVMediaTypeVideo) != .authorized { + AVCaptureDevice.requestAccess(forMediaType: AVMediaTypeVideo) { granted in DispatchQueue.main.async() { [weak self] in if !granted { self?.showNoPermissionsView() @@ -509,7 +509,7 @@ open class CameraViewController: UIViewController { */ internal func capturePhoto() { guard let output = cameraView.imageOutput, - let connection = output.connection(with: AVMediaType.video) else { + let connection = output.connection(withMediaType: AVMediaTypeVideo) else { return } diff --git a/ALCameraViewController/Views/CameraView.swift b/ALCameraViewController/Views/CameraView.swift index 6ed13f06..a9fff754 100644 --- a/ALCameraViewController/Views/CameraView.swift +++ b/ALCameraViewController/Views/CameraView.swift @@ -29,7 +29,7 @@ public class CameraView: UIView { public func startSession() { session = AVCaptureSession() - session.sessionPreset = AVCaptureSession.Preset.photo + session.sessionPreset = AVCaptureSessionPresetPhoto device = cameraWithPosition(position: currentPosition) if let device = device, device.hasFlash { @@ -174,13 +174,13 @@ public class CameraView: UIView { private func createPreview() { preview = AVCaptureVideoPreviewLayer(session: session) - preview.videoGravity = AVLayerVideoGravity.resizeAspect + preview.videoGravity = AVLayerVideoGravityResizeAspect preview.frame = bounds layer.addSublayer(preview) } private func cameraWithPosition(position: AVCaptureDevice.Position) -> AVCaptureDevice? { - guard let devices = AVCaptureDevice.devices(for: AVMediaType.video) as? [AVCaptureDevice] else { + guard let devices = AVCaptureDevice.devices(withMediaType: AVMediaTypeVideo) as? [AVCaptureDevice] else { return nil } return devices.filter { $0.position == position }.first @@ -217,7 +217,7 @@ public class CameraView: UIView { return false } - let focusPoint = preview.captureDevicePointConverted(fromLayerPoint: toPoint) + let focusPoint = preview.captureDevicePointOfInterest(for: toPoint) device.focusPointOfInterest = focusPoint device.focusMode = .continuousAutoFocus diff --git a/Example/ViewController.swift b/Example/ViewController.swift index f1df30fc..71568edb 100644 --- a/Example/ViewController.swift +++ b/Example/ViewController.swift @@ -31,7 +31,7 @@ class ViewController: UIViewController { } @IBAction func openCamera(_: AnyObject) { - let cameraViewController = CameraViewController(croppingParameters: croppingParameters, allowsLibraryAccess: libraryEnabled, allowsSwapCameraOrientation: true, allowVolumeButtonCapture: false) { [weak self] _, image, _, _, _ in + let cameraViewController = CameraViewController(scaleFactor: 3.0, croppingParameters: croppingParameters, allowsLibraryAccess: libraryEnabled, allowsSwapCameraOrientation: true, allowVolumeButtonCapture: false) { [weak self] _, image, _, _, _ in self?.imageView.image = image self?.dismiss(animated: true, completion: nil) } diff --git a/Podfile b/Podfile index c15470f5..61127602 100644 --- a/Podfile +++ b/Podfile @@ -4,11 +4,6 @@ platform :ios, '10.0’ use_frameworks! target 'ALCameraViewController' do -pod 'Fabric' -pod 'Crashlytics' -pod 'Masonry' -pod 'SnapKit' -pod 'Mixpanel' pod 'ALCameraViewController', :git => 'https://github.com/cyclic/ALCameraViewController', :branch => 'develop' end post_install do |installer| @@ -16,7 +11,7 @@ post_install do |installer| target.build_configurations.each do |config| config.build_settings['ENABLE_BITCODE'] = 'NO' config.build_settings['CODE_SIGNING_REQUIRED'] = 'NO' - config.build_settings['SWIFT_VERSION'] = '4.0' + config.build_settings['SWIFT_VERSION'] = '3.2' end end end diff --git a/Podfile.lock b/Podfile.lock index f50e8bdc..4412d422 100644 --- a/Podfile.lock +++ b/Podfile.lock @@ -1,19 +1,8 @@ PODS: - - ALCameraViewController (3.0.3) - - Crashlytics (3.9.3): - - Fabric (~> 1.7.2) - - Fabric (1.7.2) - - Masonry (1.1.0) - - Mixpanel (3.2.3) - - SnapKit (4.0.0) + - ALCameraViewController (3.0.4) DEPENDENCIES: - ALCameraViewController (from `https://github.com/cyclic/ALCameraViewController`, branch `develop`) - - Crashlytics - - Fabric - - Masonry - - Mixpanel - - SnapKit EXTERNAL SOURCES: ALCameraViewController: @@ -22,17 +11,12 @@ EXTERNAL SOURCES: CHECKOUT OPTIONS: ALCameraViewController: - :commit: c4cafd7db07966cfaeadcc486148f13f1e9f4273 + :commit: 8fbea7392c235658fef6274522a115b8bd8c3809 :git: https://github.com/cyclic/ALCameraViewController SPEC CHECKSUMS: - ALCameraViewController: f4a52c7b2d75df179d5e34c1c5c4a2a219c8f368 - Crashlytics: dbb07d01876c171c5ccbdf7826410380189e452c - Fabric: 9cd6a848efcf1b8b07497e0b6a2e7d336353ba15 - Masonry: 678fab65091a9290e40e2832a55e7ab731aad201 - Mixpanel: 7bd8e176f088936bf6e283ade0d1f512f8e723bc - SnapKit: a42d492c16e80209130a3379f73596c3454b7694 + ALCameraViewController: e29ad2b4967dd2550235f5222fffe83138956fdb -PODFILE CHECKSUM: 046c4794531b2023333725c208f36c3b87383103 +PODFILE CHECKSUM: a59bd38ffaa1def3b32b28ba453b82b6514b2947 COCOAPODS: 1.3.1 From 93cfc137e48be4d48c3f7c299395a3eec642cfd1 Mon Sep 17 00:00:00 2001 From: Thomas Goddard Date: Wed, 8 Nov 2017 08:34:53 -0800 Subject: [PATCH 59/66] Remove signing identity for project and build bump --- ALCameraViewController.xcodeproj/project.pbxproj | 5 ++--- Example/Supporting Files/Info.plist | 2 +- Podfile.lock | 2 +- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/ALCameraViewController.xcodeproj/project.pbxproj b/ALCameraViewController.xcodeproj/project.pbxproj index 7100fb66..de970d6d 100644 --- a/ALCameraViewController.xcodeproj/project.pbxproj +++ b/ALCameraViewController.xcodeproj/project.pbxproj @@ -310,7 +310,6 @@ }; FAF0583E1B31618D008E5592 = { CreatedOnToolsVersion = 6.3.2; - DevelopmentTeam = 4L5389GUUE; LastSwiftMigration = 0900; ProvisioningStyle = Automatic; }; @@ -630,7 +629,7 @@ buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; - DEVELOPMENT_TEAM = 4L5389GUUE; + DEVELOPMENT_TEAM = ""; INFOPLIST_FILE = "Example/Supporting Files/Info.plist"; IPHONEOS_DEPLOYMENT_TARGET = 9.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; @@ -647,7 +646,7 @@ buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; - DEVELOPMENT_TEAM = 4L5389GUUE; + DEVELOPMENT_TEAM = ""; INFOPLIST_FILE = "Example/Supporting Files/Info.plist"; IPHONEOS_DEPLOYMENT_TARGET = 9.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; diff --git a/Example/Supporting Files/Info.plist b/Example/Supporting Files/Info.plist index 018d3d8e..b5acfdc7 100644 --- a/Example/Supporting Files/Info.plist +++ b/Example/Supporting Files/Info.plist @@ -15,7 +15,7 @@ CFBundlePackageType APPL CFBundleShortVersionString - 3.0.3 + 3.0.4 CFBundleSignature ???? CFBundleVersion diff --git a/Podfile.lock b/Podfile.lock index 4412d422..bd62d1ca 100644 --- a/Podfile.lock +++ b/Podfile.lock @@ -11,7 +11,7 @@ EXTERNAL SOURCES: CHECKOUT OPTIONS: ALCameraViewController: - :commit: 8fbea7392c235658fef6274522a115b8bd8c3809 + :commit: b08905b95642ed6e89b01054b1a38c035eb4725e :git: https://github.com/cyclic/ALCameraViewController SPEC CHECKSUMS: From ce8df44bba96f506869022bbf86c4723b3e5d0f3 Mon Sep 17 00:00:00 2001 From: Thomas Goddard Date: Wed, 8 Nov 2017 08:36:52 -0800 Subject: [PATCH 60/66] Disable bitcode --- ALCameraViewController.xcodeproj/project.pbxproj | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ALCameraViewController.xcodeproj/project.pbxproj b/ALCameraViewController.xcodeproj/project.pbxproj index de970d6d..6423530e 100644 --- a/ALCameraViewController.xcodeproj/project.pbxproj +++ b/ALCameraViewController.xcodeproj/project.pbxproj @@ -630,6 +630,7 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; DEVELOPMENT_TEAM = ""; + ENABLE_BITCODE = NO; INFOPLIST_FILE = "Example/Supporting Files/Info.plist"; IPHONEOS_DEPLOYMENT_TARGET = 9.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; @@ -647,6 +648,7 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; DEVELOPMENT_TEAM = ""; + ENABLE_BITCODE = NO; INFOPLIST_FILE = "Example/Supporting Files/Info.plist"; IPHONEOS_DEPLOYMENT_TARGET = 9.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; From db908841066fbaa5ca788ddcc22594a31baf8ae4 Mon Sep 17 00:00:00 2001 From: Thomas Goddard Date: Thu, 9 Nov 2017 20:54:24 -0800 Subject: [PATCH 61/66] Remove obsoleted signatures --- ALCameraViewController/Utilities/CameraShot.swift | 2 +- .../ViewController/CameraViewController.swift | 6 +++--- ALCameraViewController/Views/CameraView.swift | 8 ++++---- Podfile.lock | 2 +- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/ALCameraViewController/Utilities/CameraShot.swift b/ALCameraViewController/Utilities/CameraShot.swift index b61f3113..13083172 100644 --- a/ALCameraViewController/Utilities/CameraShot.swift +++ b/ALCameraViewController/Utilities/CameraShot.swift @@ -13,7 +13,7 @@ public typealias CameraShotCompletion = (Data?, UIImage?, String?, String?) -> V public func takePhoto(_ stillImageOutput: AVCaptureStillImageOutput, videoOrientation: AVCaptureVideoOrientation, cameraPosition: AVCaptureDevice.Position, cropSize _: CGSize, outputScale: CGFloat, completion: @escaping CameraShotCompletion) { - guard let videoConnection: AVCaptureConnection = stillImageOutput.connection(withMediaType: AVMediaTypeVideo) else { + guard let videoConnection: AVCaptureConnection = stillImageOutput.connection(with: AVMediaType.video) else { completion(nil, nil, nil, nil) return } diff --git a/ALCameraViewController/ViewController/CameraViewController.swift b/ALCameraViewController/ViewController/CameraViewController.swift index 6b5cb943..442eddb7 100644 --- a/ALCameraViewController/ViewController/CameraViewController.swift +++ b/ALCameraViewController/ViewController/CameraViewController.swift @@ -470,8 +470,8 @@ open class CameraViewController: UIViewController { * the user that it not allow the permissions. */ private func checkPermissions() { - if AVCaptureDevice.authorizationStatus(forMediaType: AVMediaTypeVideo) != .authorized { - AVCaptureDevice.requestAccess(forMediaType: AVMediaTypeVideo) { granted in + if AVCaptureDevice.authorizationStatus(for: AVMediaType.video) != .authorized { + AVCaptureDevice.requestAccess(for: AVMediaType.video) { granted in DispatchQueue.main.async() { [weak self] in if !granted { self?.showNoPermissionsView() @@ -509,7 +509,7 @@ open class CameraViewController: UIViewController { */ internal func capturePhoto() { guard let output = cameraView.imageOutput, - let connection = output.connection(withMediaType: AVMediaTypeVideo) else { + let connection = output.connection(with: AVMediaType.video) else { return } diff --git a/ALCameraViewController/Views/CameraView.swift b/ALCameraViewController/Views/CameraView.swift index a9fff754..6ed13f06 100644 --- a/ALCameraViewController/Views/CameraView.swift +++ b/ALCameraViewController/Views/CameraView.swift @@ -29,7 +29,7 @@ public class CameraView: UIView { public func startSession() { session = AVCaptureSession() - session.sessionPreset = AVCaptureSessionPresetPhoto + session.sessionPreset = AVCaptureSession.Preset.photo device = cameraWithPosition(position: currentPosition) if let device = device, device.hasFlash { @@ -174,13 +174,13 @@ public class CameraView: UIView { private func createPreview() { preview = AVCaptureVideoPreviewLayer(session: session) - preview.videoGravity = AVLayerVideoGravityResizeAspect + preview.videoGravity = AVLayerVideoGravity.resizeAspect preview.frame = bounds layer.addSublayer(preview) } private func cameraWithPosition(position: AVCaptureDevice.Position) -> AVCaptureDevice? { - guard let devices = AVCaptureDevice.devices(withMediaType: AVMediaTypeVideo) as? [AVCaptureDevice] else { + guard let devices = AVCaptureDevice.devices(for: AVMediaType.video) as? [AVCaptureDevice] else { return nil } return devices.filter { $0.position == position }.first @@ -217,7 +217,7 @@ public class CameraView: UIView { return false } - let focusPoint = preview.captureDevicePointOfInterest(for: toPoint) + let focusPoint = preview.captureDevicePointConverted(fromLayerPoint: toPoint) device.focusPointOfInterest = focusPoint device.focusMode = .continuousAutoFocus diff --git a/Podfile.lock b/Podfile.lock index bd62d1ca..fbef6bf1 100644 --- a/Podfile.lock +++ b/Podfile.lock @@ -11,7 +11,7 @@ EXTERNAL SOURCES: CHECKOUT OPTIONS: ALCameraViewController: - :commit: b08905b95642ed6e89b01054b1a38c035eb4725e + :commit: ce8df44bba96f506869022bbf86c4723b3e5d0f3 :git: https://github.com/cyclic/ALCameraViewController SPEC CHECKSUMS: From cf389bdb363d15e73a9c135e88d725a1ebdacf84 Mon Sep 17 00:00:00 2001 From: Thomas Goddard Date: Wed, 29 Nov 2017 10:42:28 -0800 Subject: [PATCH 62/66] Fix positioning for X camera button and update to swift 4 so builds work --- ALCameraViewController.xcodeproj/project.pbxproj | 9 +++++---- .../ViewController/CameraViewControllerConstraint.swift | 2 +- ALCameraViewController/Views/CameraView.swift | 9 ++++++++- 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/ALCameraViewController.xcodeproj/project.pbxproj b/ALCameraViewController.xcodeproj/project.pbxproj index 6423530e..641e8dde 100644 --- a/ALCameraViewController.xcodeproj/project.pbxproj +++ b/ALCameraViewController.xcodeproj/project.pbxproj @@ -310,6 +310,7 @@ }; FAF0583E1B31618D008E5592 = { CreatedOnToolsVersion = 6.3.2; + DevelopmentTeam = 4L5389GUUE; LastSwiftMigration = 0900; ProvisioningStyle = Automatic; }; @@ -629,7 +630,7 @@ buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; - DEVELOPMENT_TEAM = ""; + DEVELOPMENT_TEAM = 4L5389GUUE; ENABLE_BITCODE = NO; INFOPLIST_FILE = "Example/Supporting Files/Info.plist"; IPHONEOS_DEPLOYMENT_TARGET = 9.0; @@ -637,7 +638,7 @@ PRODUCT_BUNDLE_IDENTIFIER = com.alx.zero.CameraViewController; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_SWIFT3_OBJC_INFERENCE = Default; - SWIFT_VERSION = 3.0; + SWIFT_VERSION = 4.0; }; name = Debug; }; @@ -647,7 +648,7 @@ buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; - DEVELOPMENT_TEAM = ""; + DEVELOPMENT_TEAM = 4L5389GUUE; ENABLE_BITCODE = NO; INFOPLIST_FILE = "Example/Supporting Files/Info.plist"; IPHONEOS_DEPLOYMENT_TARGET = 9.0; @@ -655,7 +656,7 @@ PRODUCT_BUNDLE_IDENTIFIER = com.alx.zero.CameraViewController; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_SWIFT3_OBJC_INFERENCE = Default; - SWIFT_VERSION = 3.0; + SWIFT_VERSION = 4.0; }; name = Release; }; diff --git a/ALCameraViewController/ViewController/CameraViewControllerConstraint.swift b/ALCameraViewController/ViewController/CameraViewControllerConstraint.swift index bf6b3688..faa4122e 100644 --- a/ALCameraViewController/ViewController/CameraViewControllerConstraint.swift +++ b/ALCameraViewController/ViewController/CameraViewControllerConstraint.swift @@ -69,7 +69,7 @@ extension CameraViewController { toItem: view, attribute: attribute, multiplier: 1.0, - constant: attribute == .right || attribute == .bottom ? -8 : -8) + constant: attribute == .right || attribute == .bottom ? -16 : -16) view.addConstraint(cameraButtonEdgeConstraint!) } diff --git a/ALCameraViewController/Views/CameraView.swift b/ALCameraViewController/Views/CameraView.swift index 6ed13f06..fe5f46de 100644 --- a/ALCameraViewController/Views/CameraView.swift +++ b/ALCameraViewController/Views/CameraView.swift @@ -43,7 +43,14 @@ public class CameraView: UIView { let outputSettings = [AVVideoCodecKey: AVVideoCodecJPEG] do { - input = try AVCaptureDeviceInput(device: device) + if TARGET_OS_SIMULATOR != 0 { + input = nil + return + } + else { + input = try AVCaptureDeviceInput(device: device) + } + } catch let error as NSError { input = nil print("Error: \(error.localizedDescription)") From 9e2f654e8e1b2f8f2425a45cfc05144f6fbeb9ce Mon Sep 17 00:00:00 2001 From: Thomas Goddard Date: Wed, 29 Nov 2017 11:03:39 -0800 Subject: [PATCH 63/66] Build bump --- ALCameraViewController.podspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ALCameraViewController.podspec b/ALCameraViewController.podspec index 966d9221..87ac6773 100644 --- a/ALCameraViewController.podspec +++ b/ALCameraViewController.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |spec| spec.name = "ALCameraViewController" - spec.version = "3.0.4" + spec.version = "3.0.5" spec.summary = "A camera view controller with custom image picker and image cropping." spec.source = { :git => "https://github.com/AlexLittlejohn/ALCameraViewController.git", :tag => spec.version.to_s } spec.requires_arc = true From 330d16263f8f89512983f5632deff119f91f7aad Mon Sep 17 00:00:00 2001 From: Thomas Goddard Date: Wed, 29 Nov 2017 11:04:14 -0800 Subject: [PATCH 64/66] Build bump --- Podfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Podfile b/Podfile index 61127602..63821574 100644 --- a/Podfile +++ b/Podfile @@ -11,7 +11,7 @@ post_install do |installer| target.build_configurations.each do |config| config.build_settings['ENABLE_BITCODE'] = 'NO' config.build_settings['CODE_SIGNING_REQUIRED'] = 'NO' - config.build_settings['SWIFT_VERSION'] = '3.2' + config.build_settings['SWIFT_VERSION'] = '4.0' end end end From a7eef63a32aa6312b3bc39d90ef50e5bcc51adb1 Mon Sep 17 00:00:00 2001 From: Thomas Goddard Date: Wed, 29 Nov 2017 13:21:15 -0800 Subject: [PATCH 65/66] Back to 4.0 --- Podfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Podfile b/Podfile index 63821574..61127602 100644 --- a/Podfile +++ b/Podfile @@ -11,7 +11,7 @@ post_install do |installer| target.build_configurations.each do |config| config.build_settings['ENABLE_BITCODE'] = 'NO' config.build_settings['CODE_SIGNING_REQUIRED'] = 'NO' - config.build_settings['SWIFT_VERSION'] = '4.0' + config.build_settings['SWIFT_VERSION'] = '3.2' end end end From 979a3aaddd3c5296ab54d066b1b9bb8db4c98c19 Mon Sep 17 00:00:00 2001 From: Thomas Goddard Date: Wed, 29 Nov 2017 13:21:46 -0800 Subject: [PATCH 66/66] Back to 3.2 --- ALCameraViewController.podspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ALCameraViewController.podspec b/ALCameraViewController.podspec index 87ac6773..1fa8c7f8 100644 --- a/ALCameraViewController.podspec +++ b/ALCameraViewController.podspec @@ -10,5 +10,5 @@ Pod::Spec.new do |spec| spec.resources = ["ALCameraViewController/ViewController/ConfirmViewController.xib", "ALCameraViewController/CameraViewAssets.xcassets", "ALCameraViewController/CameraView.strings"] spec.homepage = "https://github.com/AlexLittlejohn/ALCameraViewController" spec.author = { "Alex Littlejohn" => "alexlittlejohn@me.com" } - spec.pod_target_xcconfig = { 'SWIFT_VERSION' => '4.0' } + spec.pod_target_xcconfig = { 'SWIFT_VERSION' => '3.2' } end