Skip to content

Commit 7d9e9ed

Browse files
authored
Merge pull request #5 from bcylin/feature/swift-3
Swift 3
2 parents c19d19e + a8fb63f commit 7d9e9ed

23 files changed

Lines changed: 259 additions & 239 deletions

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
#### Changes
44

5+
* Swift 3.0
6+
57
## v1.2.0
68

79
#### Changes

Example/Example.xcodeproj/project.pbxproj

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@
187187
isa = PBXProject;
188188
attributes = {
189189
LastSwiftUpdateCheck = 0720;
190-
LastUpgradeCheck = 0720;
190+
LastUpgradeCheck = 0800;
191191
ORGANIZATIONNAME = "Polydice, Inc.";
192192
TargetAttributes = {
193193
B548C5C11C8E91B0009D5AEE = {
@@ -269,7 +269,7 @@
269269
);
270270
runOnlyForDeploymentPostprocessing = 0;
271271
shellPath = /bin/sh;
272-
shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [[ $? != 0 ]] ; then\n cat << EOM\nerror: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\nEOM\n exit 1\nfi\n";
272+
shellScript = "diff \"${PODS_ROOT}/../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";
273273
showEnvVarsInLog = 0;
274274
};
275275
B5C50ADD1C917F4A0059032B /* Swift Lint */ = {
@@ -359,11 +359,12 @@
359359
B548C5C91C8E91B0009D5AEE /* Debug */ = {
360360
isa = XCBuildConfiguration;
361361
buildSettings = {
362+
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = "$(inherited)";
362363
INFOPLIST_FILE = ICInputAccessoryUITests/Info.plist;
363364
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
364365
PRODUCT_BUNDLE_IDENTIFIER = com.polydice.ICInputAccessoryUITests;
365366
PRODUCT_NAME = "$(TARGET_NAME)";
366-
SWIFT_VERSION = 2.3;
367+
SWIFT_VERSION = 3.0;
367368
TEST_TARGET_NAME = Example;
368369
USES_XCTRUNNER = YES;
369370
};
@@ -372,11 +373,13 @@
372373
B548C5CA1C8E91B0009D5AEE /* Release */ = {
373374
isa = XCBuildConfiguration;
374375
buildSettings = {
376+
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = "$(inherited)";
375377
INFOPLIST_FILE = ICInputAccessoryUITests/Info.plist;
376378
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
377379
PRODUCT_BUNDLE_IDENTIFIER = com.polydice.ICInputAccessoryUITests;
378380
PRODUCT_NAME = "$(TARGET_NAME)";
379-
SWIFT_VERSION = 2.3;
381+
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
382+
SWIFT_VERSION = 3.0;
380383
TEST_TARGET_NAME = Example;
381384
USES_XCTRUNNER = YES;
382385
};
@@ -385,6 +388,7 @@
385388
B5E9F90B1C8D3B6E00443DC7 /* Debug */ = {
386389
isa = XCBuildConfiguration;
387390
buildSettings = {
391+
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
388392
ALWAYS_SEARCH_USER_PATHS = NO;
389393
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
390394
CLANG_CXX_LIBRARY = "libc++";
@@ -395,8 +399,10 @@
395399
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
396400
CLANG_WARN_EMPTY_BODY = YES;
397401
CLANG_WARN_ENUM_CONVERSION = YES;
402+
CLANG_WARN_INFINITE_RECURSION = YES;
398403
CLANG_WARN_INT_CONVERSION = YES;
399404
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
405+
CLANG_WARN_SUSPICIOUS_MOVE = YES;
400406
CLANG_WARN_UNREACHABLE_CODE = YES;
401407
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
402408
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "";
@@ -429,6 +435,7 @@
429435
B5E9F90C1C8D3B6E00443DC7 /* Release */ = {
430436
isa = XCBuildConfiguration;
431437
buildSettings = {
438+
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
432439
ALWAYS_SEARCH_USER_PATHS = NO;
433440
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
434441
CLANG_CXX_LIBRARY = "libc++";
@@ -439,8 +446,10 @@
439446
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
440447
CLANG_WARN_EMPTY_BODY = YES;
441448
CLANG_WARN_ENUM_CONVERSION = YES;
449+
CLANG_WARN_INFINITE_RECURSION = YES;
442450
CLANG_WARN_INT_CONVERSION = YES;
443451
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
452+
CLANG_WARN_SUSPICIOUS_MOVE = YES;
444453
CLANG_WARN_UNREACHABLE_CODE = YES;
445454
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
446455
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "";
@@ -467,13 +476,14 @@
467476
isa = XCBuildConfiguration;
468477
baseConfigurationReference = CA708B7D49E7D80A75ED81E3 /* Pods-Example.debug.xcconfig */;
469478
buildSettings = {
479+
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = "$(inherited)";
470480
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
471481
INFOPLIST_FILE = Example/Info.plist;
472482
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
473483
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
474484
PRODUCT_BUNDLE_IDENTIFIER = com.polydice.ICInputAccessoryExample;
475485
PRODUCT_NAME = "$(TARGET_NAME)";
476-
SWIFT_VERSION = 2.3;
486+
SWIFT_VERSION = 3.0;
477487
TARGETED_DEVICE_FAMILY = "1,2";
478488
};
479489
name = Debug;
@@ -482,13 +492,15 @@
482492
isa = XCBuildConfiguration;
483493
baseConfigurationReference = FE1A89C8A77ED0438A206A24 /* Pods-Example.release.xcconfig */;
484494
buildSettings = {
495+
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = "$(inherited)";
485496
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
486497
INFOPLIST_FILE = Example/Info.plist;
487498
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
488499
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
489500
PRODUCT_BUNDLE_IDENTIFIER = com.polydice.ICInputAccessoryExample;
490501
PRODUCT_NAME = "$(TARGET_NAME)";
491-
SWIFT_VERSION = 2.3;
502+
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
503+
SWIFT_VERSION = 3.0;
492504
TARGETED_DEVICE_FAMILY = "1,2";
493505
};
494506
name = Release;

Example/Example/AppDelegate.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,9 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
3131

3232
var window: UIWindow?
3333

34-
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
35-
window = UIWindow(frame: UIScreen.mainScreen().bounds)
36-
window?.backgroundColor = UIColor.whiteColor()
34+
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey : Any]? = nil) -> Bool {
35+
window = UIWindow(frame: UIScreen.main.bounds)
36+
window?.backgroundColor = UIColor.white
3737
window?.rootViewController = UINavigationController(rootViewController: ExampleViewController())
3838
window?.makeKeyAndVisible()
3939
return true

Example/Example/CustomizedTokenField.swift

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -52,31 +52,31 @@ extension ICTokenField {
5252

5353
layer.cornerRadius = 5
5454
layer.shouldRasterize = true
55-
layer.rasterizationScale = UIScreen.mainScreen().scale
55+
layer.rasterizationScale = UIScreen.main.scale
5656
backgroundColor = UIColor(red:0.8, green:0.32, blue:0.24, alpha:1)
5757

58-
textField.textColor = UIColor.whiteColor()
59-
textField.tintColor = UIColor.whiteColor()
60-
textField.font = UIFont.boldSystemFontOfSize(14)
58+
textField.textColor = UIColor.white
59+
textField.tintColor = UIColor.white
60+
textField.font = UIFont.boldSystemFont(ofSize: 14)
6161

6262
attributedPlaceholder = NSAttributedString(
63-
string: String(self.dynamicType),
63+
string: String(describing: type(of: self)),
6464
attributes: [
65-
NSForegroundColorAttributeName: UIColor.whiteColor().colorWithAlphaComponent(0.5),
66-
NSFontAttributeName: UIFont.boldSystemFontOfSize(14)
65+
NSForegroundColorAttributeName: UIColor.white.withAlphaComponent(0.5),
66+
NSFontAttributeName: UIFont.boldSystemFont(ofSize: 14)
6767
]
6868
)
6969

7070
normalTokenAttributes = [
71-
NSForegroundColorAttributeName: UIColor.whiteColor(),
72-
NSBackgroundColorAttributeName: UIColor.whiteColor().colorWithAlphaComponent(0.25),
73-
NSFontAttributeName: UIFont.boldSystemFontOfSize(14)
71+
NSForegroundColorAttributeName: UIColor.white,
72+
NSBackgroundColorAttributeName: UIColor.white.withAlphaComponent(0.25),
73+
NSFontAttributeName: UIFont.boldSystemFont(ofSize: 14)
7474
]
7575

7676
highlightedTokenAttributes = [
7777
NSForegroundColorAttributeName: UIColor(red:0.8, green:0.32, blue:0.24, alpha:1),
78-
NSBackgroundColorAttributeName: UIColor.whiteColor(),
79-
NSFontAttributeName: UIFont.boldSystemFontOfSize(14)
78+
NSBackgroundColorAttributeName: UIColor.white,
79+
NSFontAttributeName: UIFont.boldSystemFont(ofSize: 14)
8080
]
8181
}
8282

Example/Example/CustomizedTokenViewController.swift

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -36,73 +36,74 @@ class CustomizedTokenViewController: UIViewController, ICTokenFieldDelegate {
3636

3737
override func loadView() {
3838
super.loadView()
39-
view.backgroundColor = UIColor.whiteColor()
39+
view.backgroundColor = UIColor.white
4040
textView.text = "[\n\n]";
41-
textView.font = UIFont.preferredFontForTextStyle(UIFontTextStyleSubheadline)
41+
textView.font = UIFont.preferredFont(forTextStyle: .subheadline)
4242
textView.frame = view.bounds.insetBy(dx: 10, dy: 10)
43-
textView.autoresizingMask = [.FlexibleWidth, .FlexibleHeight]
43+
textView.autoresizingMask = [.flexibleWidth, .flexibleHeight]
4444
view.addSubview(textView)
4545
}
4646

4747
override func viewDidLoad() {
4848
super.viewDidLoad()
4949
navigationController?.navigationBar.barTintColor = UIColor(red:0.96, green:0.48, blue:0.4, alpha:1)
50-
navigationController?.navigationBar.translucent = false
51-
navigationController?.navigationBar.barStyle = .Black
50+
navigationController?.navigationBar.isTranslucent = false
51+
navigationController?.navigationBar.barStyle = .black
5252

53-
let cancelBarButton = UIBarButtonItem(barButtonSystemItem: .Cancel, target: self, action: .dismiss)
54-
cancelBarButton.tintColor = UIColor.whiteColor()
53+
let cancelBarButton = UIBarButtonItem(barButtonSystemItem: .cancel, target: self, action: .dismiss)
54+
cancelBarButton.tintColor = UIColor.white
5555
navigationItem.rightBarButtonItem = cancelBarButton
5656

5757
navigationItem.titleView = tokenField
5858
tokenField.delegate = self
5959
}
6060

61-
override func viewWillAppear(animated: Bool) {
61+
override func viewWillAppear(_ animated: Bool) {
6262
super.viewWillAppear(animated)
63-
tokenField.becomeFirstResponder()
63+
_ = tokenField.becomeFirstResponder()
6464
}
6565

66-
override func viewWillDisappear(animated: Bool) {
66+
override func viewWillDisappear(_ animated: Bool) {
6767
super.viewWillAppear(animated)
68-
tokenField.resignFirstResponder()
68+
_ = tokenField.resignFirstResponder()
6969
textView.endEditing(true)
7070
}
7171

7272
// MARK: - ICTokenFieldDelegate
7373

74-
func tokenFieldDidBeginEditing(tokenField: ICTokenField) {
74+
func tokenFieldDidBeginEditing(_ tokenField: ICTokenField) {
7575
print(#function)
7676
}
7777

78-
func tokenFieldDidEndEditing(tokenField: ICTokenField) {
78+
func tokenFieldDidEndEditing(_ tokenField: ICTokenField) {
7979
print(#function)
8080
}
8181

82-
func tokenFieldWillReturn(tokenField: ICTokenField) {
82+
func tokenFieldWillReturn(_ tokenField: ICTokenField) {
8383
print(#function)
8484
}
8585

86-
func tokenField(tokenField: ICTokenField, didEnterText text: String) {
86+
func tokenField(_ tokenField: ICTokenField, didEnterText text: String) {
8787
print("Add: \"\(text)\"")
8888
updateTexts()
8989
}
9090

91-
func tokenField(tokenField: ICTokenField, didDeleteText text: String, atIndex index: Int) {
91+
func tokenField(_ tokenField: ICTokenField, didDeleteText text: String, atIndex index: Int) {
9292
print("Delete: \"\(text)\"")
9393
updateTexts()
9494
}
9595

9696
// MARK: - UIResponder Callbacks
9797

98-
@objc private func dismiss(sender: UIBarButtonItem) {
99-
presentingViewController?.dismissViewControllerAnimated(true, completion: nil)
98+
@objc fileprivate func dismiss(_ sender: UIBarButtonItem) {
99+
presentingViewController?.dismiss(animated: true, completion: nil)
100100
}
101101

102102
// MARK: - Private Methods
103103

104104
private func updateTexts() {
105-
textView.text = "[\n " + tokenField.texts.map { "\"" + $0 + "\"" } .joinWithSeparator(",\n ") + "\n]"
105+
let tokens = tokenField.texts.map { "\"" + $0 + "\"" } .joined(separator: ",\n ")
106+
textView.text = "[\n " + tokens + "\n]"
106107
}
107108

108109
}

Example/Example/ExampleCell.swift

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,14 @@ class ExampleCell: UITableViewCell {
3636
displayingView.translatesAutoresizingMaskIntoConstraints = false
3737

3838
if #available(iOS 9.0, *) {
39-
displayingView.topAnchor.constraintEqualToAnchor(contentView.topAnchor).active = true
40-
displayingView.leftAnchor.constraintEqualToAnchor(contentView.leftAnchor).active = true
41-
displayingView.bottomAnchor.constraintEqualToAnchor(contentView.bottomAnchor).active = true
42-
displayingView.rightAnchor.constraintEqualToAnchor(contentView.rightAnchor).active = true
39+
displayingView.topAnchor.constraint(equalTo: contentView.topAnchor).isActive = true
40+
displayingView.leftAnchor.constraint(equalTo: contentView.leftAnchor).isActive = true
41+
displayingView.bottomAnchor.constraint(equalTo: contentView.bottomAnchor).isActive = true
42+
displayingView.rightAnchor.constraint(equalTo: contentView.rightAnchor).isActive = true
4343
} else {
4444
let views = ["view": displayingView]
45-
contentView.addConstraints(NSLayoutConstraint.constraintsWithVisualFormat("H:|[view]|", options: [], metrics: nil, views: views))
46-
contentView.addConstraints(NSLayoutConstraint.constraintsWithVisualFormat("V:|[view]|", options: [], metrics: nil, views: views))
45+
contentView.addConstraints(NSLayoutConstraint.constraints(withVisualFormat: "H:|[view]|", options: [], metrics: nil, views: views))
46+
contentView.addConstraints(NSLayoutConstraint.constraints(withVisualFormat: "V:|[view]|", options: [], metrics: nil, views: views))
4747
}
4848
}
4949
}
@@ -56,7 +56,7 @@ class ExampleCell: UITableViewCell {
5656
showcase?.removeFromSuperview()
5757
showcase = nil
5858
textLabel?.text = nil
59-
accessoryType = .None
59+
accessoryType = .none
6060
}
6161

6262
}

0 commit comments

Comments
 (0)