Skip to content
This repository has been archived by the owner on Jul 1, 2022. It is now read-only.

Commit

Permalink
Merge branch 'release/3.0.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexLittlejohn committed Sep 27, 2017
2 parents 96fac14 + 441b9cc commit f954573
Show file tree
Hide file tree
Showing 12 changed files with 47 additions and 44 deletions.
3 changes: 2 additions & 1 deletion ALCameraViewController.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |spec|
spec.name = "ALCameraViewController"
spec.version = "2.0.3"
spec.version = "3.0.0"
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
Expand All @@ -10,4 +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" => "[email protected]" }
spec.pod_target_xcconfig = { 'SWIFT_VERSION' => '4.0' }
end
26 changes: 15 additions & 11 deletions ALCameraViewController.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -276,12 +276,12 @@
TargetAttributes = {
C4829FFA1CAEB16C00541D08 = {
CreatedOnToolsVersion = 7.3;
LastSwiftMigration = 0800;
LastSwiftMigration = 0900;
};
FAF0583E1B31618D008E5592 = {
CreatedOnToolsVersion = 6.3.2;
DevelopmentTeam = GAPQH4AM76;
LastSwiftMigration = 0800;
DevelopmentTeam = 2466624KEK;
LastSwiftMigration = 0900;
ProvisioningStyle = Automatic;
};
};
Expand Down Expand Up @@ -407,7 +407,8 @@
PRODUCT_BUNDLE_IDENTIFIER = com.zero.CameraViewController;
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
SWIFT_VERSION = 3.0;
SWIFT_SWIFT3_OBJC_INFERENCE = On;
SWIFT_VERSION = 4.0;
VERSIONING_SYSTEM = "apple-generic";
VERSION_INFO_PREFIX = "";
};
Expand All @@ -430,7 +431,8 @@
PRODUCT_BUNDLE_IDENTIFIER = com.zero.CameraViewController;
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
SWIFT_VERSION = 3.0;
SWIFT_SWIFT3_OBJC_INFERENCE = On;
SWIFT_VERSION = 4.0;
VERSIONING_SYSTEM = "apple-generic";
VERSION_INFO_PREFIX = "";
};
Expand Down Expand Up @@ -543,13 +545,14 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
DEVELOPMENT_TEAM = GAPQH4AM76;
DEVELOPMENT_TEAM = 2466624KEK;
INFOPLIST_FILE = "Example/Supporting Files/Info.plist";
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.zero.CameraViewController;
PRODUCT_BUNDLE_IDENTIFIER = com.alx.zero.CameraViewController;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 3.0;
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
SWIFT_VERSION = 4.0;
};
name = Debug;
};
Expand All @@ -559,13 +562,14 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
DEVELOPMENT_TEAM = GAPQH4AM76;
DEVELOPMENT_TEAM = 2466624KEK;
INFOPLIST_FILE = "Example/Supporting Files/Info.plist";
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.zero.CameraViewController;
PRODUCT_BUNDLE_IDENTIFIER = com.alx.zero.CameraViewController;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 3.0;
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
SWIFT_VERSION = 4.0;
};
name = Release;
};
Expand Down
2 changes: 1 addition & 1 deletion ALCameraViewController/Utilities/CameraGlobals.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
4 changes: 2 additions & 2 deletions ALCameraViewController/Utilities/CameraShot.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ import AVFoundation

public typealias CameraShotCompletion = (UIImage?) -> Void

public func takePhoto(_ stillImageOutput: AVCaptureStillImageOutput, videoOrientation: AVCaptureVideoOrientation, cameraPosition: AVCaptureDevicePosition, cropSize: CGSize, completion: @escaping CameraShotCompletion) {
public func takePhoto(_ stillImageOutput: AVCaptureStillImageOutput, videoOrientation: AVCaptureVideoOrientation, cameraPosition: AVCaptureDevice.Position, cropSize: CGSize, completion: @escaping CameraShotCompletion) {

guard let videoConnection: AVCaptureConnection = stillImageOutput.connection(withMediaType: AVMediaTypeVideo) else {
guard let videoConnection: AVCaptureConnection = stillImageOutput.connection(with: AVMediaType.video) else {
completion(nil)
return
}
Expand Down
2 changes: 1 addition & 1 deletion ALCameraViewController/Utilities/UIButtonExtensions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ extension UIButton {
}
}

func performAction() {
@objc func performAction() {
guard let action = action else {
return
}
Expand Down
2 changes: 1 addition & 1 deletion ALCameraViewController/Utilities/Utilities.swift
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,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:
Expand Down
12 changes: 6 additions & 6 deletions ALCameraViewController/ViewController/CameraViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@ open class CameraViewController: UIViewController {
object: nil)
}

internal func notifyCameraReady() {
@objc internal func notifyCameraReady() {
cameraButton.isEnabled = true
}

Expand Down Expand Up @@ -391,7 +391,7 @@ open class CameraViewController: UIViewController {
libraryButton].forEach({ $0.isEnabled = enabled })
}

func rotateCameraView() {
@objc func rotateCameraView() {
cameraView.rotatePreview()
}

Expand Down Expand Up @@ -459,8 +459,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()
Expand Down Expand Up @@ -498,7 +498,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
}

Expand Down Expand Up @@ -577,7 +577,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(uiImage: UIImage) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public class PhotoLibraryViewController: UIViewController {
inViewController.present(navigationController, animated: animated, completion: nil)
}

public func dismissLibrary() {
@objc public func dismissLibrary() {
onSelectionComplete?(nil)
}

Expand Down
30 changes: 14 additions & 16 deletions ALCameraViewController/Views/CameraView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,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 {
Expand Down Expand Up @@ -107,7 +107,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 {
Expand Down Expand Up @@ -141,7 +141,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
Expand Down Expand Up @@ -175,16 +175,14 @@ public class CameraView: UIView {
private func createPreview() {

preview = AVCaptureVideoPreviewLayer(session: session)
preview.videoGravity = AVLayerVideoGravityResizeAspectFill
preview.videoGravity = AVLayerVideoGravity.resizeAspectFill
preview.frame = bounds

layer.addSublayer(preview)
}

private func cameraWithPosition(position: AVCaptureDevicePosition) -> AVCaptureDevice? {
guard let devices = AVCaptureDevice.devices(withMediaType: AVMediaTypeVideo) as? [AVCaptureDevice] else {
return nil
}
private func cameraWithPosition(position: AVCaptureDevice.Position) -> AVCaptureDevice? {
let devices = AVCaptureDevice.devices(for: AVMediaType.video)
return devices.filter { $0.position == position }.first
}

Expand Down Expand Up @@ -218,7 +216,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
Expand Down Expand Up @@ -258,11 +256,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)
}

Expand All @@ -283,16 +281,16 @@ public class CameraView: UIView {
}
switch UIApplication.shared.statusBarOrientation {
case .portrait:
preview?.connection.videoOrientation = AVCaptureVideoOrientation.portrait
preview?.connection?.videoOrientation = AVCaptureVideoOrientation.portrait
break
case .portraitUpsideDown:
preview?.connection.videoOrientation = AVCaptureVideoOrientation.portraitUpsideDown
preview?.connection?.videoOrientation = AVCaptureVideoOrientation.portraitUpsideDown
break
case .landscapeRight:
preview?.connection.videoOrientation = AVCaptureVideoOrientation.landscapeRight
preview?.connection?.videoOrientation = AVCaptureVideoOrientation.landscapeRight
break
case .landscapeLeft:
preview?.connection.videoOrientation = AVCaptureVideoOrientation.landscapeLeft
preview?.connection?.videoOrientation = AVCaptureVideoOrientation.landscapeLeft
break
default: break
}
Expand Down
2 changes: 1 addition & 1 deletion ALCameraViewController/Views/CropOverlay.swift
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ internal class CropOverlay: UIView {
return button
}

func moveCropOverlay(gestureRecognizer: UIPanGestureRecognizer) {
@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)
Expand Down
2 changes: 1 addition & 1 deletion ALCameraViewController/Views/PermissionsView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ A camera view controller with custom image picker and image cropping.
- [x] Tap to focus

### Installation & Requirements
This project requires Xcode 8.3 to run and compiles with swift 3.1
This project requires Xcode 9 to run and compiles with swift 4
> Note: This library makes use of the AVFoundation camera API's which are unavailable on the iOS simulator. You'll need a real device to run it.
CocoaPods:
Expand All @@ -30,7 +30,7 @@ pod 'ALCameraViewController'
Carthage:

```ruby
github "alexlittlejohn/CameraViewController"
github "alexlittlejohn/ALCameraViewController"
```


Expand Down

0 comments on commit f954573

Please sign in to comment.