Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for Swift 5.0 and Xcode 10.3 #72

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
language: objective-c #1
osx_image: xcode9.3 #2
osx_image: xcode10.3 #2
xcode_workspace: Example/EPSignature.xcworkspace #3
xcode_scheme: EPSignature #4
xcode_sdk: iphonesimulator10.3 #5
Expand Down
18 changes: 11 additions & 7 deletions Example/EPSignature.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -204,18 +204,18 @@
isa = PBXProject;
attributes = {
LastSwiftUpdateCheck = 0720;
LastUpgradeCheck = 0900;
LastUpgradeCheck = 1010;
ORGANIZATIONNAME = CocoaPods;
TargetAttributes = {
607FACCF1AFB9204008FA782 = {
CreatedOnToolsVersion = 6.3.1;
DevelopmentTeam = DG779MAMM2;
LastSwiftMigration = 0900;
LastSwiftMigration = 1010;
};
607FACE41AFB9204008FA782 = {
CreatedOnToolsVersion = 6.3.1;
DevelopmentTeam = DG779MAMM2;
LastSwiftMigration = 0900;
LastSwiftMigration = 1010;
TestTargetID = 607FACCF1AFB9204008FA782;
};
};
Expand Down Expand Up @@ -424,12 +424,14 @@
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = 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_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
Expand Down Expand Up @@ -477,12 +479,14 @@
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = 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_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
Expand Down Expand Up @@ -523,7 +527,7 @@
MODULE_NAME = ExampleApp;
PRODUCT_BUNDLE_IDENTIFIER = "org.cocoapods.demo.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 4.0;
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Debug;
Expand All @@ -540,7 +544,7 @@
MODULE_NAME = ExampleApp;
PRODUCT_BUNDLE_IDENTIFIER = "org.cocoapods.demo.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 4.0;
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Release;
Expand All @@ -560,7 +564,7 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "org.cocoapods.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 4.0;
SWIFT_VERSION = 4.2;
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/EPSignature_Example.app/EPSignature_Example";
};
name = Debug;
Expand All @@ -576,7 +580,7 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "org.cocoapods.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 4.0;
SWIFT_VERSION = 4.2;
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/EPSignature_Example.app/EPSignature_Example";
};
name = Release;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0900"
LastUpgradeVersion = "1010"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down Expand Up @@ -40,7 +40,6 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
language = ""
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
<TestableReference
Expand Down Expand Up @@ -70,7 +69,6 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
language = ""
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
Expand Down
2 changes: 1 addition & 1 deletion Example/EPSignature/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import UIKit
class AppDelegate: UIResponder, UIApplicationDelegate {

var window: UIWindow?
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey : Any]? = nil) -> Bool {
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil) -> Bool {
// Application launch state
return true
}
Expand Down
12 changes: 8 additions & 4 deletions Example/Pods/Pods.xcodeproj/project.pbxproj

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Pod/Classes/EPExtensions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ extension UIViewController {
}

func showAlert(_ message: String, andTitle title: String) {
let alert = UIAlertController(title: title, message: message, preferredStyle: UIAlertControllerStyle.alert)
let alert = UIAlertController(title: title, message: message, preferredStyle: .alert)

// add an action (button)
alert.addAction(UIAlertAction(title: "OK", style: UIAlertActionStyle.default, handler: nil))
alert.addAction(UIAlertAction(title: "OK", style: .default, handler: nil))

// show the alert
self.present(alert, animated: true, completion: nil)
Expand Down
28 changes: 18 additions & 10 deletions Pod/Classes/EPSignatureViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,22 +30,25 @@ open class EPSignatureViewController: UIViewController {

open var showsDate: Bool = true
open var showsSaveSignatureOption: Bool = true
open var alertTitle: String = "Please draw your signature"
open var alertMessage: String = "You did not sign"
open weak var signatureDelegate: EPSignatureDelegate?
open var subtitleText = "Sign Here"
open var tintColor = UIColor.defaultTintColor()
open var statusBarStyle: UIStatusBarStyle?

// MARK: - Life cycle methods

override open func viewDidLoad() {
super.viewDidLoad()

let cancelButton = UIBarButtonItem(barButtonSystemItem: UIBarButtonSystemItem.cancel, target: self, action: #selector(EPSignatureViewController.onTouchCancelButton))
let cancelButton = UIBarButtonItem(barButtonSystemItem: .cancel, target: self, action: #selector(EPSignatureViewController.onTouchCancelButton))
cancelButton.tintColor = tintColor
self.navigationItem.leftBarButtonItem = cancelButton

let doneButton = UIBarButtonItem(barButtonSystemItem: UIBarButtonSystemItem.done, target: self, action: #selector(EPSignatureViewController.onTouchDoneButton))
let doneButton = UIBarButtonItem(barButtonSystemItem: .done, target: self, action: #selector(EPSignatureViewController.onTouchDoneButton))
doneButton.tintColor = tintColor
let clearButton = UIBarButtonItem(barButtonSystemItem: UIBarButtonSystemItem.trash, target: self, action: #selector(EPSignatureViewController.onTouchClearButton))
let clearButton = UIBarButtonItem(barButtonSystemItem: .trash, target: self, action: #selector(EPSignatureViewController.onTouchClearButton))
clearButton.tintColor = tintColor

if showsDate {
Expand All @@ -58,19 +61,24 @@ open class EPSignatureViewController: UIViewController {
}

if showsSaveSignatureOption {
let actionButton = UIBarButtonItem(barButtonSystemItem: UIBarButtonSystemItem.action, target: self, action: #selector(EPSignatureViewController.onTouchActionButton(_:)))
let actionButton = UIBarButtonItem(barButtonSystemItem: .action, target: self, action: #selector(EPSignatureViewController.onTouchActionButton(_:)))
actionButton.tintColor = tintColor
self.navigationItem.rightBarButtonItems = [doneButton, clearButton, actionButton]
switchSaveSignature.onTintColor = tintColor
} else {
self.navigationItem.rightBarButtonItems = [doneButton, clearButton]
self.navigationItem.rightBarButtonItems = [doneButton]
self.navigationItem.leftBarButtonItems = [cancelButton, clearButton]
lblDefaultSignature.isHidden = true
switchSaveSignature.isHidden = true
}

lblSignatureSubtitle.text = subtitleText
switchSaveSignature.setOn(false, animated: true)
}

open override var preferredStatusBarStyle: UIStatusBarStyle {
return statusBarStyle ?? .default
}

override open func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
Expand Down Expand Up @@ -116,25 +124,25 @@ open class EPSignatureViewController: UIViewController {
signatureDelegate?.epSignature!(self, didSign: signature, boundingRect: signatureView.getSignatureBoundsInCanvas())
dismiss(animated: true, completion: nil)
} else {
showAlert("You did not sign", andTitle: "Please draw your signature")
showAlert(alertMessage, andTitle: alertTitle)
}
}

@objc func onTouchActionButton(_ barButton: UIBarButtonItem) {
let action = UIAlertController(title: "Action", message: "", preferredStyle: UIAlertControllerStyle.actionSheet)
let action = UIAlertController(title: "Action", message: "", preferredStyle: .actionSheet)
action.view.tintColor = tintColor

action.addAction(UIAlertAction(title: "Load default signature", style: UIAlertActionStyle.default, handler: { action in
action.addAction(UIAlertAction(title: "Load default signature", style: .default, handler: { action in
let docPath = NSSearchPathForDirectoriesInDomains(.documentDirectory, .userDomainMask, true).first
let filePath = (docPath! as NSString).appendingPathComponent("sig.data")
self.signatureView.loadSignature(filePath)
}))

action.addAction(UIAlertAction(title: "Delete default signature", style: UIAlertActionStyle.destructive, handler: { action in
action.addAction(UIAlertAction(title: "Delete default signature", style: .destructive, handler: { action in
self.signatureView.removeSignature()
}))

action.addAction(UIAlertAction(title: "Cancel", style: UIAlertActionStyle.cancel, handler: nil))
action.addAction(UIAlertAction(title: "Cancel", style: .cancel, handler: nil))

if let popOver = action.popoverPresentationController {
popOver.barButtonItem = barButton
Expand Down