Skip to content

Commit f107bb4

Browse files
committed
support swift 4.0
1 parent fbdbb18 commit f107bb4

File tree

9 files changed

+40
-18
lines changed

9 files changed

+40
-18
lines changed

README.md

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,17 @@
33
44
[![Swift Version][swift-image]][swift-url]
55
[![License MIT](https://img.shields.io/badge/license-MIT-green.svg?style=flat)](https://raw.githubusercontent.com/TBXark/TKSwitcherCollection/master/LICENSE)
6-
[![CocoaPods](http://img.shields.io/cocoapods/v/TKSwitcherCollection.svg?style=flat)](http://cocoapods.org/?q= TKSwitcherCollection)
7-
[![CocoaPods](http://img.shields.io/cocoapods/p/TKSwitcherCollection.svg?style=flat)](http://cocoapods.org/?q= TKSwitcherCollection)
6+
[![CocoaPods](http://img.shields.io/cocoapods/v/TKSwitcherCollection.svg?style=flat)](http://cocoapods.org/?q=TKSwitcherCollection)
7+
[![CocoaPods](http://img.shields.io/cocoapods/p/TKSwitcherCollection.svg?style=flat)](http://cocoapods.org/?q=TKSwitcherCollection)
88
[![Carthage compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage)
99
[![Support](https://img.shields.io/badge/support-iOS%208%2B%20-blue.svg?style=flat)](https://www.apple.com/nl/ios/)
1010

1111

1212
## Requirements
1313

1414
- iOS 8.0+
15-
- Xcode 8.0
16-
- Swift 3.0
15+
- Xcode 9.0
16+
- Swift 4.0
1717

1818
## Installation
1919

@@ -39,7 +39,7 @@ Create a `Cartfile` that lists the framework and run `carthage update`. Follow t
3939
github "tbxark/TKSwitcherCollection"
4040
```
4141
#### Manually
42-
1. Download and drop ```SwitchCollection/Classes``` in your project.
42+
1. Download and drop ```TKSwitcherCollection``` in your project.
4343
2. Congratulations!
4444

4545
## Usage example
@@ -54,6 +54,8 @@ github "tbxark/TKSwitcherCollection"
5454

5555

5656
## Release History
57+
* 1.4.0
58+
support swift 4.0
5759
* 1.3.1
5860
support swift 3.0
5961
* 1.0.3

SwitcherCollection.xcodeproj/project.pbxproj

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -190,18 +190,18 @@
190190
attributes = {
191191
CLASSPREFIX = TK;
192192
LastSwiftUpdateCheck = 0710;
193-
LastUpgradeCheck = 0800;
193+
LastUpgradeCheck = 0900;
194194
ORGANIZATIONNAME = TBXark;
195195
TargetAttributes = {
196196
6A555E961BDCA58700FC36E6 = {
197197
CreatedOnToolsVersion = 7.1;
198198
DevelopmentTeam = 858CBVXSWP;
199-
LastSwiftMigration = 0800;
199+
LastSwiftMigration = 0900;
200200
};
201201
6A9104111D53A8740009451B = {
202202
CreatedOnToolsVersion = 7.3.1;
203203
DevelopmentTeam = 858CBVXSWP;
204-
LastSwiftMigration = 0820;
204+
LastSwiftMigration = 0900;
205205
};
206206
};
207207
};
@@ -305,14 +305,20 @@
305305
CLANG_CXX_LIBRARY = "libc++";
306306
CLANG_ENABLE_MODULES = YES;
307307
CLANG_ENABLE_OBJC_ARC = YES;
308+
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
308309
CLANG_WARN_BOOL_CONVERSION = YES;
310+
CLANG_WARN_COMMA = YES;
309311
CLANG_WARN_CONSTANT_CONVERSION = YES;
310312
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
311313
CLANG_WARN_EMPTY_BODY = YES;
312314
CLANG_WARN_ENUM_CONVERSION = YES;
313315
CLANG_WARN_INFINITE_RECURSION = YES;
314316
CLANG_WARN_INT_CONVERSION = YES;
317+
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
318+
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
315319
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
320+
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
321+
CLANG_WARN_STRICT_PROTOTYPES = YES;
316322
CLANG_WARN_SUSPICIOUS_MOVE = YES;
317323
CLANG_WARN_UNREACHABLE_CODE = YES;
318324
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
@@ -351,14 +357,20 @@
351357
CLANG_CXX_LIBRARY = "libc++";
352358
CLANG_ENABLE_MODULES = YES;
353359
CLANG_ENABLE_OBJC_ARC = YES;
360+
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
354361
CLANG_WARN_BOOL_CONVERSION = YES;
362+
CLANG_WARN_COMMA = YES;
355363
CLANG_WARN_CONSTANT_CONVERSION = YES;
356364
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
357365
CLANG_WARN_EMPTY_BODY = YES;
358366
CLANG_WARN_ENUM_CONVERSION = YES;
359367
CLANG_WARN_INFINITE_RECURSION = YES;
360368
CLANG_WARN_INT_CONVERSION = YES;
369+
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
370+
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
361371
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
372+
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
373+
CLANG_WARN_STRICT_PROTOTYPES = YES;
362374
CLANG_WARN_SUSPICIOUS_MOVE = YES;
363375
CLANG_WARN_UNREACHABLE_CODE = YES;
364376
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
@@ -394,7 +406,8 @@
394406
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
395407
PRODUCT_BUNDLE_IDENTIFIER = com.TBXark.SwitcherCollection;
396408
PRODUCT_NAME = "$(TARGET_NAME)";
397-
SWIFT_VERSION = 3.0;
409+
SWIFT_SWIFT3_OBJC_INFERENCE = On;
410+
SWIFT_VERSION = 4.0;
398411
};
399412
name = Debug;
400413
};
@@ -409,7 +422,8 @@
409422
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
410423
PRODUCT_BUNDLE_IDENTIFIER = com.TBXark.SwitcherCollection;
411424
PRODUCT_NAME = "$(TARGET_NAME)";
412-
SWIFT_VERSION = 3.0;
425+
SWIFT_SWIFT3_OBJC_INFERENCE = On;
426+
SWIFT_VERSION = 4.0;
413427
};
414428
name = Release;
415429
};
@@ -433,7 +447,8 @@
433447
PRODUCT_NAME = "$(TARGET_NAME)";
434448
SKIP_INSTALL = YES;
435449
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
436-
SWIFT_VERSION = 3.0;
450+
SWIFT_SWIFT3_OBJC_INFERENCE = On;
451+
SWIFT_VERSION = 4.0;
437452
TARGETED_DEVICE_FAMILY = "1,2";
438453
VERSIONING_SYSTEM = "apple-generic";
439454
VERSION_INFO_PREFIX = "";
@@ -459,7 +474,8 @@
459474
PRODUCT_BUNDLE_IDENTIFIER = com.TBXark.TKSwitcherCollection;
460475
PRODUCT_NAME = "$(TARGET_NAME)";
461476
SKIP_INSTALL = YES;
462-
SWIFT_VERSION = 3.0;
477+
SWIFT_SWIFT3_OBJC_INFERENCE = On;
478+
SWIFT_VERSION = 4.0;
463479
TARGETED_DEVICE_FAMILY = "1,2";
464480
VERSIONING_SYSTEM = "apple-generic";
465481
VERSION_INFO_PREFIX = "";

SwitcherCollection.xcodeproj/xcshareddata/xcschemes/TKSwitcherCollection.xcscheme

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<Scheme
3-
LastUpgradeVersion = "0800"
3+
LastUpgradeVersion = "0900"
44
version = "1.3">
55
<BuildAction
66
parallelizeBuildables = "YES"
@@ -26,6 +26,7 @@
2626
buildConfiguration = "Debug"
2727
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
2828
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
29+
language = ""
2930
shouldUseLaunchSchemeArgsEnv = "YES">
3031
<Testables>
3132
</Testables>
@@ -36,6 +37,7 @@
3637
buildConfiguration = "Debug"
3738
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
3839
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
40+
language = ""
3941
launchStyle = "0"
4042
useCustomWorkingDirectory = "NO"
4143
ignoresPersistentStateOnLaunch = "NO"

SwitcherCollection.xcodeproj/xcuserdata/Tbxark.xcuserdatad/xcschemes/SwitcherCollection.xcscheme

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<Scheme
3-
LastUpgradeVersion = "0800"
3+
LastUpgradeVersion = "0900"
44
version = "1.3">
55
<BuildAction
66
parallelizeBuildables = "YES"
@@ -26,6 +26,7 @@
2626
buildConfiguration = "Debug"
2727
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
2828
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
29+
language = ""
2930
shouldUseLaunchSchemeArgsEnv = "YES">
3031
<Testables>
3132
</Testables>
@@ -45,6 +46,7 @@
4546
buildConfiguration = "Debug"
4647
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
4748
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
49+
language = ""
4850
launchStyle = "0"
4951
useCustomWorkingDirectory = "NO"
5052
ignoresPersistentStateOnLaunch = "NO"

SwitcherCollection/ViewController.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class ViewController: UIViewController {
1818
super.viewDidLoad()
1919
}
2020

21-
func animateSwitch(_ timer:Timer){
21+
@objc func animateSwitch(_ timer:Timer){
2222
let switcher = switchArray[count]
2323
switcher.setOn(switcher.isOn, animate: true)
2424
count += 1

TKSwitcherCollection/TKBaseSwitcher.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ open class TKBaseSwitch: UIControl {
7676
self.addGestureRecognizer(tap)
7777
}
7878

79-
internal func changeValue(){
79+
@objc internal func changeValue(){
8080
on = !on
8181
valueChange?(!isOn)
8282
sendActions(for: UIControlEvents.valueChanged);

TKSwitcherCollection/TKSimpleSwitch.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ open class TKSimpleSwitch: TKBaseSwitch {
134134
// 旋转动画
135135
if rotateWhenValueChange{
136136
UIView.animate(withDuration: duration, animations: { () -> Void in
137-
self.transform = self.transform.rotated(by: CGFloat(M_PI))
137+
self.transform = self.transform.rotated(by: CGFloat.pi)
138138
})
139139
}
140140

TKSwitcherCollection/TKSmileSwitch.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ private class TKSmileFaceView : UIView {
171171

172172
func rotation(_ duration:Double,count:Int,clockwise:Bool){
173173
let rotationTransformAnim = CAKeyframeAnimation(keyPath:"transform.rotation.z")
174-
rotationTransformAnim.values = [0,180 * CGFloat(M_PI/180) * CGFloat(count) * (clockwise ? 1 : -1)]
174+
rotationTransformAnim.values = [0,180 * CGFloat.pi/180 * CGFloat(count) * (clockwise ? 1 : -1)]
175175
rotationTransformAnim.keyTimes = [0, 1]
176176
rotationTransformAnim.isRemovedOnCompletion = false
177177
rotationTransformAnim.duration = duration

0 commit comments

Comments
 (0)