mirror of
https://github.com/samsonjs/SwiftyCam.git
synced 2026-04-27 15:07:43 +00:00
Merge pull request #189 from jonandersen/Swift4.2
Migrate swift from 4.0 to 4.2
This commit is contained in:
commit
ac02cc2e13
8 changed files with 38 additions and 28 deletions
|
|
@ -179,7 +179,7 @@
|
||||||
isa = PBXProject;
|
isa = PBXProject;
|
||||||
attributes = {
|
attributes = {
|
||||||
LastSwiftUpdateCheck = 0810;
|
LastSwiftUpdateCheck = 0810;
|
||||||
LastUpgradeCheck = 0900;
|
LastUpgradeCheck = 1010;
|
||||||
ORGANIZATIONNAME = Cappsule;
|
ORGANIZATIONNAME = Cappsule;
|
||||||
TargetAttributes = {
|
TargetAttributes = {
|
||||||
05D2A9B31E80BE9700B479E9 = {
|
05D2A9B31E80BE9700B479E9 = {
|
||||||
|
|
@ -188,7 +188,7 @@
|
||||||
};
|
};
|
||||||
1675A9711E00A68300B80903 = {
|
1675A9711E00A68300B80903 = {
|
||||||
CreatedOnToolsVersion = 8.1;
|
CreatedOnToolsVersion = 8.1;
|
||||||
LastSwiftMigration = 0900;
|
LastSwiftMigration = 1010;
|
||||||
ProvisioningStyle = Automatic;
|
ProvisioningStyle = Automatic;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
@ -343,6 +343,7 @@
|
||||||
CLANG_WARN_BOOL_CONVERSION = YES;
|
CLANG_WARN_BOOL_CONVERSION = YES;
|
||||||
CLANG_WARN_COMMA = YES;
|
CLANG_WARN_COMMA = YES;
|
||||||
CLANG_WARN_CONSTANT_CONVERSION = YES;
|
CLANG_WARN_CONSTANT_CONVERSION = YES;
|
||||||
|
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
|
||||||
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
|
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
|
||||||
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
|
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
|
||||||
CLANG_WARN_EMPTY_BODY = YES;
|
CLANG_WARN_EMPTY_BODY = YES;
|
||||||
|
|
@ -350,6 +351,7 @@
|
||||||
CLANG_WARN_INFINITE_RECURSION = YES;
|
CLANG_WARN_INFINITE_RECURSION = YES;
|
||||||
CLANG_WARN_INT_CONVERSION = YES;
|
CLANG_WARN_INT_CONVERSION = YES;
|
||||||
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
|
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
|
||||||
|
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
|
||||||
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
|
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
|
||||||
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
|
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
|
||||||
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
|
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
|
||||||
|
|
@ -401,6 +403,7 @@
|
||||||
CLANG_WARN_BOOL_CONVERSION = YES;
|
CLANG_WARN_BOOL_CONVERSION = YES;
|
||||||
CLANG_WARN_COMMA = YES;
|
CLANG_WARN_COMMA = YES;
|
||||||
CLANG_WARN_CONSTANT_CONVERSION = YES;
|
CLANG_WARN_CONSTANT_CONVERSION = YES;
|
||||||
|
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
|
||||||
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
|
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
|
||||||
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
|
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
|
||||||
CLANG_WARN_EMPTY_BODY = YES;
|
CLANG_WARN_EMPTY_BODY = YES;
|
||||||
|
|
@ -408,6 +411,7 @@
|
||||||
CLANG_WARN_INFINITE_RECURSION = YES;
|
CLANG_WARN_INFINITE_RECURSION = YES;
|
||||||
CLANG_WARN_INT_CONVERSION = YES;
|
CLANG_WARN_INT_CONVERSION = YES;
|
||||||
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
|
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
|
||||||
|
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
|
||||||
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
|
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
|
||||||
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
|
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
|
||||||
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
|
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
|
||||||
|
|
@ -449,8 +453,7 @@
|
||||||
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
|
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
|
||||||
PRODUCT_BUNDLE_IDENTIFIER = com.Walzy.DemoSwiftyCam1;
|
PRODUCT_BUNDLE_IDENTIFIER = com.Walzy.DemoSwiftyCam1;
|
||||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||||
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
|
SWIFT_VERSION = 4.2;
|
||||||
SWIFT_VERSION = 4.0;
|
|
||||||
TARGETED_DEVICE_FAMILY = "1,2";
|
TARGETED_DEVICE_FAMILY = "1,2";
|
||||||
};
|
};
|
||||||
name = Debug;
|
name = Debug;
|
||||||
|
|
@ -465,8 +468,7 @@
|
||||||
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
|
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
|
||||||
PRODUCT_BUNDLE_IDENTIFIER = com.Walzy.DemoSwiftyCam1;
|
PRODUCT_BUNDLE_IDENTIFIER = com.Walzy.DemoSwiftyCam1;
|
||||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||||
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
|
SWIFT_VERSION = 4.2;
|
||||||
SWIFT_VERSION = 4.0;
|
|
||||||
TARGETED_DEVICE_FAMILY = "1,2";
|
TARGETED_DEVICE_FAMILY = "1,2";
|
||||||
};
|
};
|
||||||
name = Release;
|
name = Release;
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<Scheme
|
<Scheme
|
||||||
LastUpgradeVersion = "0900"
|
LastUpgradeVersion = "1010"
|
||||||
version = "1.3">
|
version = "1.3">
|
||||||
<BuildAction
|
<BuildAction
|
||||||
parallelizeBuildables = "YES"
|
parallelizeBuildables = "YES"
|
||||||
|
|
@ -26,7 +26,6 @@
|
||||||
buildConfiguration = "Debug"
|
buildConfiguration = "Debug"
|
||||||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||||
language = ""
|
|
||||||
shouldUseLaunchSchemeArgsEnv = "YES">
|
shouldUseLaunchSchemeArgsEnv = "YES">
|
||||||
<Testables>
|
<Testables>
|
||||||
</Testables>
|
</Testables>
|
||||||
|
|
@ -37,7 +36,6 @@
|
||||||
buildConfiguration = "Debug"
|
buildConfiguration = "Debug"
|
||||||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||||
language = ""
|
|
||||||
launchStyle = "0"
|
launchStyle = "0"
|
||||||
useCustomWorkingDirectory = "NO"
|
useCustomWorkingDirectory = "NO"
|
||||||
ignoresPersistentStateOnLaunch = "NO"
|
ignoresPersistentStateOnLaunch = "NO"
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
|
||||||
var window: UIWindow?
|
var window: UIWindow?
|
||||||
|
|
||||||
|
|
||||||
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
|
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
|
||||||
// Override point for customization after application launch.
|
// Override point for customization after application launch.
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -36,11 +36,11 @@ class PhotoViewController: UIViewController {
|
||||||
super.viewDidLoad()
|
super.viewDidLoad()
|
||||||
self.view.backgroundColor = UIColor.gray
|
self.view.backgroundColor = UIColor.gray
|
||||||
let backgroundImageView = UIImageView(frame: view.frame)
|
let backgroundImageView = UIImageView(frame: view.frame)
|
||||||
backgroundImageView.contentMode = UIViewContentMode.scaleAspectFit
|
backgroundImageView.contentMode = UIView.ContentMode.scaleAspectFit
|
||||||
backgroundImageView.image = backgroundImage
|
backgroundImageView.image = backgroundImage
|
||||||
view.addSubview(backgroundImageView)
|
view.addSubview(backgroundImageView)
|
||||||
let cancelButton = UIButton(frame: CGRect(x: 10.0, y: 10.0, width: 30.0, height: 30.0))
|
let cancelButton = UIButton(frame: CGRect(x: 10.0, y: 10.0, width: 30.0, height: 30.0))
|
||||||
cancelButton.setImage(#imageLiteral(resourceName: "cancel"), for: UIControlState())
|
cancelButton.setImage(#imageLiteral(resourceName: "cancel"), for: UIControl.State())
|
||||||
cancelButton.addTarget(self, action: #selector(cancel), for: .touchUpInside)
|
cancelButton.addTarget(self, action: #selector(cancel), for: .touchUpInside)
|
||||||
view.addSubview(cancelButton)
|
view.addSubview(cancelButton)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -49,20 +49,23 @@ class VideoViewController: UIViewController {
|
||||||
playerController!.showsPlaybackControls = false
|
playerController!.showsPlaybackControls = false
|
||||||
|
|
||||||
playerController!.player = player!
|
playerController!.player = player!
|
||||||
self.addChildViewController(playerController!)
|
self.addChild(playerController!)
|
||||||
self.view.addSubview(playerController!.view)
|
self.view.addSubview(playerController!.view)
|
||||||
playerController!.view.frame = view.frame
|
playerController!.view.frame = view.frame
|
||||||
NotificationCenter.default.addObserver(self, selector: #selector(playerItemDidReachEnd), name: NSNotification.Name.AVPlayerItemDidPlayToEndTime, object: self.player!.currentItem)
|
NotificationCenter.default.addObserver(self, selector: #selector(playerItemDidReachEnd), name: NSNotification.Name.AVPlayerItemDidPlayToEndTime, object: self.player!.currentItem)
|
||||||
|
|
||||||
let cancelButton = UIButton(frame: CGRect(x: 10.0, y: 10.0, width: 30.0, height: 30.0))
|
let cancelButton = UIButton(frame: CGRect(x: 10.0, y: 10.0, width: 30.0, height: 30.0))
|
||||||
cancelButton.setImage(#imageLiteral(resourceName: "cancel"), for: UIControlState())
|
cancelButton.setImage(#imageLiteral(resourceName: "cancel"), for: UIControl.State())
|
||||||
cancelButton.addTarget(self, action: #selector(cancel), for: .touchUpInside)
|
cancelButton.addTarget(self, action: #selector(cancel), for: .touchUpInside)
|
||||||
view.addSubview(cancelButton)
|
view.addSubview(cancelButton)
|
||||||
|
|
||||||
|
|
||||||
// Allow background audio to continue to play
|
// Allow background audio to continue to play
|
||||||
do {
|
do {
|
||||||
try AVAudioSession.sharedInstance().setCategory(AVAudioSessionCategoryAmbient)
|
if #available(iOS 10.0, *) {
|
||||||
|
try AVAudioSession.sharedInstance().setCategory(AVAudioSession.Category.ambient, mode: .default, options: [])
|
||||||
|
} else {
|
||||||
|
}
|
||||||
} catch let error as NSError {
|
} catch let error as NSError {
|
||||||
print(error)
|
print(error)
|
||||||
}
|
}
|
||||||
|
|
@ -85,8 +88,13 @@ class VideoViewController: UIViewController {
|
||||||
|
|
||||||
@objc fileprivate func playerItemDidReachEnd(_ notification: Notification) {
|
@objc fileprivate func playerItemDidReachEnd(_ notification: Notification) {
|
||||||
if self.player != nil {
|
if self.player != nil {
|
||||||
self.player!.seek(to: kCMTimeZero)
|
self.player!.seek(to: CMTime.zero)
|
||||||
self.player!.play()
|
self.player!.play()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Helper function inserted by Swift 4.2 migrator.
|
||||||
|
fileprivate func convertFromAVAudioSessionCategory(_ input: AVAudioSession.Category) -> String {
|
||||||
|
return input.rawValue
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -153,9 +153,9 @@ extension ViewController {
|
||||||
|
|
||||||
fileprivate func toggleFlashAnimation() {
|
fileprivate func toggleFlashAnimation() {
|
||||||
if flashEnabled == true {
|
if flashEnabled == true {
|
||||||
flashButton.setImage(#imageLiteral(resourceName: "flash"), for: UIControlState())
|
flashButton.setImage(#imageLiteral(resourceName: "flash"), for: UIControl.State())
|
||||||
} else {
|
} else {
|
||||||
flashButton.setImage(#imageLiteral(resourceName: "flashOutline"), for: UIControlState())
|
flashButton.setImage(#imageLiteral(resourceName: "flashOutline"), for: UIControl.State())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -45,7 +45,7 @@ class Orientation {
|
||||||
self.deviceOrientation = nil
|
self.deviceOrientation = nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func getImageOrientation(forCamera: SwiftyCamViewController.CameraSelection) -> UIImageOrientation {
|
func getImageOrientation(forCamera: SwiftyCamViewController.CameraSelection) -> UIImage.Orientation {
|
||||||
guard shouldUseDeviceOrientation, let deviceOrientation = self.deviceOrientation else { return forCamera == .rear ? .right : .leftMirrored }
|
guard shouldUseDeviceOrientation, let deviceOrientation = self.deviceOrientation else { return forCamera == .rear ? .right : .leftMirrored }
|
||||||
|
|
||||||
switch deviceOrientation {
|
switch deviceOrientation {
|
||||||
|
|
|
||||||
|
|
@ -269,7 +269,7 @@ open class SwiftyCamViewController: UIViewController {
|
||||||
super.viewDidLoad()
|
super.viewDidLoad()
|
||||||
previewLayer = PreviewView(frame: view.frame, videoGravity: videoGravity)
|
previewLayer = PreviewView(frame: view.frame, videoGravity: videoGravity)
|
||||||
view.addSubview(previewLayer)
|
view.addSubview(previewLayer)
|
||||||
view.sendSubview(toBack: previewLayer)
|
view.sendSubviewToBack(previewLayer)
|
||||||
|
|
||||||
// Add Gesture Recognizers
|
// Add Gesture Recognizers
|
||||||
|
|
||||||
|
|
@ -845,9 +845,9 @@ open class SwiftyCamViewController: UIViewController {
|
||||||
alertController.addAction(UIAlertAction(title: NSLocalizedString("OK", comment: "Alert OK button"), style: .cancel, handler: nil))
|
alertController.addAction(UIAlertAction(title: NSLocalizedString("OK", comment: "Alert OK button"), style: .cancel, handler: nil))
|
||||||
alertController.addAction(UIAlertAction(title: NSLocalizedString("Settings", comment: "Alert button to open Settings"), style: .default, handler: { action in
|
alertController.addAction(UIAlertAction(title: NSLocalizedString("Settings", comment: "Alert button to open Settings"), style: .default, handler: { action in
|
||||||
if #available(iOS 10.0, *) {
|
if #available(iOS 10.0, *) {
|
||||||
UIApplication.shared.openURL(URL(string: UIApplicationOpenSettingsURLString)!)
|
UIApplication.shared.openURL(URL(string: UIApplication.openSettingsURLString)!)
|
||||||
} else {
|
} else {
|
||||||
if let appSettings = URL(string: UIApplicationOpenSettingsURLString) {
|
if let appSettings = URL(string: UIApplication.openSettingsURLString) {
|
||||||
UIApplication.shared.openURL(appSettings)
|
UIApplication.shared.openURL(appSettings)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -983,12 +983,14 @@ open class SwiftyCamViewController: UIViewController {
|
||||||
|
|
||||||
do{
|
do{
|
||||||
if #available(iOS 10.0, *) {
|
if #available(iOS 10.0, *) {
|
||||||
try AVAudioSession.sharedInstance().setCategory(AVAudioSessionCategoryPlayAndRecord,
|
try AVAudioSession.sharedInstance().setCategory(.playAndRecord, mode: .default, options: [.mixWithOthers, .allowBluetooth, .allowAirPlay, .allowBluetoothA2DP])
|
||||||
with: [.mixWithOthers, .allowBluetooth, .allowAirPlay, .allowBluetoothA2DP])
|
|
||||||
} else {
|
} else {
|
||||||
try AVAudioSession.sharedInstance().setCategory(AVAudioSessionCategoryPlayAndRecord,
|
let options: [AVAudioSession.CategoryOptions] = [.mixWithOthers, .allowBluetooth]
|
||||||
with: [.mixWithOthers, .allowBluetooth])
|
let category = AVAudioSession.Category.playAndRecord
|
||||||
|
let selector = NSSelectorFromString("setCategory:withOptions:error:")
|
||||||
|
AVAudioSession.sharedInstance().perform(selector, with: category, with: options)
|
||||||
}
|
}
|
||||||
|
try AVAudioSession.sharedInstance().setActive(true)
|
||||||
session.automaticallyConfiguresApplicationAudioSession = false
|
session.automaticallyConfiguresApplicationAudioSession = false
|
||||||
}
|
}
|
||||||
catch {
|
catch {
|
||||||
|
|
@ -1058,9 +1060,9 @@ extension SwiftyCamViewController : AVCaptureFileOutputRecordingDelegate {
|
||||||
|
|
||||||
public func fileOutput(_ output: AVCaptureFileOutput, didFinishRecordingTo outputFileURL: URL, from connections: [AVCaptureConnection], error: Error?) {
|
public func fileOutput(_ output: AVCaptureFileOutput, didFinishRecordingTo outputFileURL: URL, from connections: [AVCaptureConnection], error: Error?) {
|
||||||
if let currentBackgroundRecordingID = backgroundRecordingID {
|
if let currentBackgroundRecordingID = backgroundRecordingID {
|
||||||
backgroundRecordingID = UIBackgroundTaskInvalid
|
backgroundRecordingID = UIBackgroundTaskIdentifier.invalid
|
||||||
|
|
||||||
if currentBackgroundRecordingID != UIBackgroundTaskInvalid {
|
if currentBackgroundRecordingID != UIBackgroundTaskIdentifier.invalid {
|
||||||
UIApplication.shared.endBackgroundTask(currentBackgroundRecordingID)
|
UIApplication.shared.endBackgroundTask(currentBackgroundRecordingID)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue