Skip to content

Commit 212e0bf

Browse files
authored
Merge pull request #127 from baidikoff/swift-4.2-migration
Swift 4.2 migration
2 parents bf65f05 + 25bb983 commit 212e0bf

File tree

13 files changed

+61
-31
lines changed

13 files changed

+61
-31
lines changed

.swift-version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
4.0
1+
4.2

Example/Code/Code.xcodeproj/project.pbxproj

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@
175175
attributes = {
176176
LastSwiftMigration = 0700;
177177
LastSwiftUpdateCheck = 0700;
178-
LastUpgradeCheck = 0900;
178+
LastUpgradeCheck = 1000;
179179
ORGANIZATIONNAME = "Kyohei Yamaguchi";
180180
TargetAttributes = {
181181
41E2DB1C1B0641C80023FD9E = {
@@ -285,12 +285,14 @@
285285
CLANG_WARN_BOOL_CONVERSION = YES;
286286
CLANG_WARN_COMMA = YES;
287287
CLANG_WARN_CONSTANT_CONVERSION = YES;
288+
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
288289
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
289290
CLANG_WARN_EMPTY_BODY = YES;
290291
CLANG_WARN_ENUM_CONVERSION = YES;
291292
CLANG_WARN_INFINITE_RECURSION = YES;
292293
CLANG_WARN_INT_CONVERSION = YES;
293294
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
295+
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
294296
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
295297
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
296298
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
@@ -339,12 +341,14 @@
339341
CLANG_WARN_BOOL_CONVERSION = YES;
340342
CLANG_WARN_COMMA = YES;
341343
CLANG_WARN_CONSTANT_CONVERSION = YES;
344+
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
342345
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
343346
CLANG_WARN_EMPTY_BODY = YES;
344347
CLANG_WARN_ENUM_CONVERSION = YES;
345348
CLANG_WARN_INFINITE_RECURSION = YES;
346349
CLANG_WARN_INT_CONVERSION = YES;
347350
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
351+
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
348352
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
349353
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
350354
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
@@ -383,7 +387,7 @@
383387
PRODUCT_BUNDLE_IDENTIFIER = "com.ykyohei.$(PRODUCT_NAME:rfc1034identifier)";
384388
PRODUCT_NAME = "$(TARGET_NAME)";
385389
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
386-
SWIFT_VERSION = 4.0;
390+
SWIFT_VERSION = 4.2;
387391
};
388392
name = Debug;
389393
};
@@ -398,7 +402,7 @@
398402
PRODUCT_NAME = "$(TARGET_NAME)";
399403
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
400404
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
401-
SWIFT_VERSION = 4.0;
405+
SWIFT_VERSION = 4.2;
402406
};
403407
name = Release;
404408
};
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<key>IDEDidComputeMac32BitWarning</key>
6+
<true/>
7+
</dict>
8+
</plist>

Example/Code/Code/AppDelegate.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
2727

2828
var window: UIWindow?
2929

30-
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey : Any]? = nil) -> Bool {
30+
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil) -> Bool {
3131
// Override point for customization after application launch.
3232

3333
let mainViewController = MainViewController()

Example/Code/Code/DrawerViewController.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,13 @@ class DrawerViewController: UIViewController {
3030
// Do any additional setup after loading the view.
3131
let closeButton = UIButton()
3232
closeButton.translatesAutoresizingMaskIntoConstraints = false
33-
closeButton.setTitle("Close", for: UIControlState())
33+
closeButton.setTitle("Close", for: UIControl.State())
3434
closeButton.addTarget(self,
3535
action: #selector(didTapCloseButton),
3636
for: .touchUpInside
3737
)
3838
closeButton.sizeToFit()
39-
closeButton.setTitleColor(UIColor.blue, for: UIControlState())
39+
closeButton.setTitleColor(UIColor.blue, for: UIControl.State())
4040
view.addSubview(closeButton)
4141
view.addConstraint(
4242
NSLayoutConstraint(

Example/Code/Code/MainViewController.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class MainViewController: UIViewController {
3232
title = "MainViewController"
3333
navigationItem.leftBarButtonItem = UIBarButtonItem(
3434
title: "Open",
35-
style: UIBarButtonItemStyle.plain,
35+
style: UIBarButtonItem.Style.plain,
3636
target: self,
3737
action: #selector(didTapOpenButton)
3838
)

Example/Storyboard/Storyboard.xcodeproj/project.pbxproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -403,7 +403,7 @@
403403
SWIFT_OBJC_BRIDGING_HEADER = "Storyboard/Storyboard-Bridging-Header.h";
404404
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
405405
SWIFT_SWIFT3_OBJC_INFERENCE = On;
406-
SWIFT_VERSION = 4.0;
406+
SWIFT_VERSION = 4.2;
407407
};
408408
name = Debug;
409409
};
@@ -422,7 +422,7 @@
422422
SWIFT_OBJC_BRIDGING_HEADER = "Storyboard/Storyboard-Bridging-Header.h";
423423
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
424424
SWIFT_SWIFT3_OBJC_INFERENCE = On;
425-
SWIFT_VERSION = 4.0;
425+
SWIFT_VERSION = 4.2;
426426
};
427427
name = Release;
428428
};
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<key>IDEDidComputeMac32BitWarning</key>
6+
<true/>
7+
</dict>
8+
</plist>

Example/Storyboard/Storyboard/AppDelegate.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
1313

1414
var window: UIWindow?
1515

16-
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey : Any]? = nil) -> Bool {
16+
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil) -> Bool {
1717
return true
1818
}
1919

KYDrawerController.xcodeproj/project.pbxproj

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@
119119
411540731BEF3AE100531D08 /* Project object */ = {
120120
isa = PBXProject;
121121
attributes = {
122-
LastUpgradeCheck = 0900;
122+
LastUpgradeCheck = 1000;
123123
ORGANIZATIONNAME = kyo__hei;
124124
TargetAttributes = {
125125
4115407B1BEF3AE100531D08 = {
@@ -181,12 +181,14 @@
181181
CLANG_WARN_BOOL_CONVERSION = YES;
182182
CLANG_WARN_COMMA = YES;
183183
CLANG_WARN_CONSTANT_CONVERSION = YES;
184+
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
184185
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
185186
CLANG_WARN_EMPTY_BODY = YES;
186187
CLANG_WARN_ENUM_CONVERSION = YES;
187188
CLANG_WARN_INFINITE_RECURSION = YES;
188189
CLANG_WARN_INT_CONVERSION = YES;
189190
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
191+
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
190192
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
191193
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
192194
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
@@ -237,12 +239,14 @@
237239
CLANG_WARN_BOOL_CONVERSION = YES;
238240
CLANG_WARN_COMMA = YES;
239241
CLANG_WARN_CONSTANT_CONVERSION = YES;
242+
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
240243
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
241244
CLANG_WARN_EMPTY_BODY = YES;
242245
CLANG_WARN_ENUM_CONVERSION = YES;
243246
CLANG_WARN_INFINITE_RECURSION = YES;
244247
CLANG_WARN_INT_CONVERSION = YES;
245248
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
249+
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
246250
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
247251
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
248252
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
@@ -292,7 +296,7 @@
292296
SKIP_INSTALL = YES;
293297
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
294298
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
295-
SWIFT_VERSION = 4.0;
299+
SWIFT_VERSION = 4.2;
296300
};
297301
name = Debug;
298302
};
@@ -314,7 +318,7 @@
314318
SKIP_INSTALL = YES;
315319
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
316320
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
317-
SWIFT_VERSION = 4.0;
321+
SWIFT_VERSION = 4.2;
318322
};
319323
name = Release;
320324
};
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<key>IDEDidComputeMac32BitWarning</key>
6+
<true/>
7+
</dict>
8+
</plist>

KYDrawerController.xcodeproj/xcshareddata/xcschemes/KYDrawerController.xcscheme

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<Scheme
3-
LastUpgradeVersion = "0900"
3+
LastUpgradeVersion = "1000"
44
version = "1.3">
55
<BuildAction
66
parallelizeBuildables = "YES"
@@ -26,7 +26,6 @@
2626
buildConfiguration = "Debug"
2727
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
2828
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
29-
language = ""
3029
shouldUseLaunchSchemeArgsEnv = "YES">
3130
<Testables>
3231
</Testables>
@@ -37,7 +36,6 @@
3736
buildConfiguration = "Debug"
3837
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
3938
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
40-
language = ""
4139
launchStyle = "0"
4240
useCustomWorkingDirectory = "NO"
4341
ignoresPersistentStateOnLaunch = "NO"

KYDrawerController/Classes/KYDrawerController.swift

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -143,13 +143,13 @@ open class KYDrawerController: UIViewController, UIGestureRecognizerDelegate {
143143
public var mainViewController: UIViewController! {
144144
didSet {
145145
if let oldController = oldValue {
146-
oldController.willMove(toParentViewController: nil)
146+
oldController.willMove(toParent: nil)
147147
oldController.view.removeFromSuperview()
148-
oldController.removeFromParentViewController()
148+
oldController.removeFromParent()
149149
}
150150

151151
guard let mainViewController = mainViewController else { return }
152-
addChildViewController(mainViewController)
152+
addChild(mainViewController)
153153

154154
mainViewController.view.translatesAutoresizingMaskIntoConstraints = false
155155
view.insertSubview(mainViewController.view, at: 0)
@@ -172,29 +172,29 @@ open class KYDrawerController: UIViewController, UIGestureRecognizerDelegate {
172172
)
173173
)
174174

175-
mainViewController.didMove(toParentViewController: self)
175+
mainViewController.didMove(toParent: self)
176176
}
177177
}
178178

179179
public var drawerViewController : UIViewController? {
180180
didSet {
181181
if let oldController = oldValue {
182-
oldController.willMove(toParentViewController: nil)
182+
oldController.willMove(toParent: nil)
183183
oldController.view.removeFromSuperview()
184-
oldController.removeFromParentViewController()
184+
oldController.removeFromParent()
185185
}
186186

187187
guard let drawerViewController = drawerViewController else { return }
188-
addChildViewController(drawerViewController)
188+
addChild(drawerViewController)
189189

190190
drawerViewController.view.layer.shadowColor = UIColor.black.cgColor
191191
drawerViewController.view.layer.shadowOpacity = 0.4
192192
drawerViewController.view.layer.shadowRadius = 5.0
193193
drawerViewController.view.translatesAutoresizingMaskIntoConstraints = false
194194
_containerView.addSubview(drawerViewController.view)
195195

196-
let itemAttribute: NSLayoutAttribute
197-
let toItemAttribute: NSLayoutAttribute
196+
let itemAttribute: NSLayoutConstraint.Attribute
197+
let toItemAttribute: NSLayoutConstraint.Attribute
198198
switch drawerDirection {
199199
case .left:
200200
itemAttribute = .right
@@ -206,10 +206,10 @@ open class KYDrawerController: UIViewController, UIGestureRecognizerDelegate {
206206

207207
_drawerWidthConstraint = NSLayoutConstraint(
208208
item: drawerViewController.view,
209-
attribute: NSLayoutAttribute.width,
210-
relatedBy: NSLayoutRelation.equal,
209+
attribute: NSLayoutConstraint.Attribute.width,
210+
relatedBy: NSLayoutConstraint.Relation.equal,
211211
toItem: nil,
212-
attribute: NSLayoutAttribute.width,
212+
attribute: NSLayoutConstraint.Attribute.width,
213213
multiplier: 1,
214214
constant: drawerWidth
215215
)
@@ -218,7 +218,7 @@ open class KYDrawerController: UIViewController, UIGestureRecognizerDelegate {
218218
_drawerConstraint = NSLayoutConstraint(
219219
item: drawerViewController.view,
220220
attribute: itemAttribute,
221-
relatedBy: NSLayoutRelation.equal,
221+
relatedBy: NSLayoutConstraint.Relation.equal,
222222
toItem: _containerView,
223223
attribute: toItemAttribute,
224224
multiplier: 1,
@@ -237,7 +237,7 @@ open class KYDrawerController: UIViewController, UIGestureRecognizerDelegate {
237237
)
238238

239239
_containerView.layoutIfNeeded()
240-
drawerViewController.didMove(toParentViewController: self)
240+
drawerViewController.didMove(toParent: self)
241241
}
242242
}
243243

0 commit comments

Comments
 (0)