Skip to content

Commit 0e633b2

Browse files
authored
Merge pull request #17 from hyperoslo/swift-3
Swift 3 migration
2 parents 35aa6f9 + f65bb2b commit 0e633b2

17 files changed

Lines changed: 305 additions & 225 deletions

File tree

.travis.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
1-
osx_image: xcode7.3
1+
osx_image: xcode8
22
language: objective-c
33

44
script:
5-
- xcodebuild clean build -project BarcodeScanner.xcodeproj -scheme BarcodeScanner-iOS -sdk iphonesimulator
5+
- xcodebuild clean build -project BarcodeScanner.xcodeproj -scheme "BarcodeScanner-iOS" -sdk iphonesimulator
6+
7+
notifications:
8+
email: false

BarcodeScanner.xcodeproj/project.pbxproj

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@
130130
isa = PBXProject;
131131
attributes = {
132132
LastSwiftUpdateCheck = 0720;
133-
LastUpgradeCheck = 0720;
133+
LastUpgradeCheck = 0800;
134134
ORGANIZATIONNAME = "Hyper Interaktiv AS";
135135
TargetAttributes = {
136136
D5B2E89E1C3A780C00C0327D = {
@@ -198,8 +198,10 @@
198198
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
199199
CLANG_WARN_EMPTY_BODY = YES;
200200
CLANG_WARN_ENUM_CONVERSION = YES;
201+
CLANG_WARN_INFINITE_RECURSION = YES;
201202
CLANG_WARN_INT_CONVERSION = YES;
202203
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
204+
CLANG_WARN_SUSPICIOUS_MOVE = YES;
203205
CLANG_WARN_UNREACHABLE_CODE = YES;
204206
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
205207
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
@@ -246,8 +248,10 @@
246248
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
247249
CLANG_WARN_EMPTY_BODY = YES;
248250
CLANG_WARN_ENUM_CONVERSION = YES;
251+
CLANG_WARN_INFINITE_RECURSION = YES;
249252
CLANG_WARN_INT_CONVERSION = YES;
250253
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
254+
CLANG_WARN_SUSPICIOUS_MOVE = YES;
251255
CLANG_WARN_UNREACHABLE_CODE = YES;
252256
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
253257
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
@@ -267,6 +271,7 @@
267271
IPHONEOS_DEPLOYMENT_TARGET = 9.2;
268272
MTL_ENABLE_DEBUG_INFO = NO;
269273
SDKROOT = iphoneos;
274+
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
270275
TARGETED_DEVICE_FAMILY = "1,2";
271276
VALIDATE_PRODUCT = YES;
272277
VERSIONING_SYSTEM = "apple-generic";
@@ -278,6 +283,7 @@
278283
isa = XCBuildConfiguration;
279284
buildSettings = {
280285
CLANG_ENABLE_MODULES = YES;
286+
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "";
281287
DEFINES_MODULE = YES;
282288
DYLIB_COMPATIBILITY_VERSION = 1;
283289
DYLIB_CURRENT_VERSION = 1;
@@ -294,13 +300,15 @@
294300
PRODUCT_NAME = BarcodeScanner;
295301
SKIP_INSTALL = YES;
296302
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
303+
SWIFT_VERSION = 3.0;
297304
};
298305
name = Debug;
299306
};
300307
D5B2E8B51C3A780C00C0327D /* Release */ = {
301308
isa = XCBuildConfiguration;
302309
buildSettings = {
303310
CLANG_ENABLE_MODULES = YES;
311+
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "";
304312
DEFINES_MODULE = YES;
305313
DYLIB_COMPATIBILITY_VERSION = 1;
306314
DYLIB_CURRENT_VERSION = 1;
@@ -316,6 +324,7 @@
316324
PRODUCT_BUNDLE_IDENTIFIER = "no.hyper.BarcodeScanner-iOS";
317325
PRODUCT_NAME = BarcodeScanner;
318326
SKIP_INSTALL = YES;
327+
SWIFT_VERSION = 3.0;
319328
};
320329
name = Release;
321330
};

BarcodeScanner.xcodeproj/xcshareddata/xcschemes/BarcodeScanner-iOS.xcscheme

Lines changed: 1 addition & 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 = "0720"
3+
LastUpgradeVersion = "0800"
44
version = "1.3">
55
<BuildAction
66
parallelizeBuildables = "YES"

Cartfile

Lines changed: 0 additions & 1 deletion
This file was deleted.

Cartfile.resolved

Lines changed: 0 additions & 3 deletions
This file was deleted.

Example/BarcodeScannerExample/BarcodeScannerExample.xcodeproj/project.pbxproj

Lines changed: 63 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,12 +92,15 @@
9292
isa = PBXNativeTarget;
9393
buildConfigurationList = D50BE4071C9FE8870000A34C /* Build configuration list for PBXNativeTarget "BarcodeScannerExample" */;
9494
buildPhases = (
95+
BDF82C3FF3E7C5A57E2534BE /* [CP] Check Pods Manifest.lock */,
9596
36F8214472FD1CA639982CE8 /* [CP] Check Pods Manifest.lock */,
9697
D50BE3F11C9FE8870000A34C /* Sources */,
9798
D50BE3F21C9FE8870000A34C /* Frameworks */,
9899
D50BE3F31C9FE8870000A34C /* Resources */,
99100
E090C912AA824DD28A310598 /* [CP] Embed Pods Frameworks */,
100101
B23721B8976E46E75F5C472C /* [CP] Copy Pods Resources */,
102+
C6637BE832A43C8F49FCF84D /* 📦 Embed Pods Frameworks */,
103+
A8D9BF9C6304351F12DE8E23 /* 📦 Copy Pods Resources */,
101104
);
102105
buildRules = (
103106
);
@@ -115,12 +118,13 @@
115118
isa = PBXProject;
116119
attributes = {
117120
LastSwiftUpdateCheck = 0720;
118-
LastUpgradeCheck = 0720;
121+
LastUpgradeCheck = 0800;
119122
ORGANIZATIONNAME = "Hyper Interaktiv AS";
120123
TargetAttributes = {
121124
D50BE3F41C9FE8870000A34C = {
122125
CreatedOnToolsVersion = 7.2.1;
123126
DevelopmentTeam = LG4DBY4QF9;
127+
LastSwiftMigration = 0800;
124128
};
125129
};
126130
};
@@ -170,6 +174,21 @@
170174
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";
171175
showEnvVarsInLog = 0;
172176
};
177+
A8D9BF9C6304351F12DE8E23 /* 📦 Copy Pods Resources */ = {
178+
isa = PBXShellScriptBuildPhase;
179+
buildActionMask = 2147483647;
180+
files = (
181+
);
182+
inputPaths = (
183+
);
184+
name = "📦 Copy Pods Resources";
185+
outputPaths = (
186+
);
187+
runOnlyForDeploymentPostprocessing = 0;
188+
shellPath = /bin/sh;
189+
shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-BarcodeScannerExample/Pods-BarcodeScannerExample-resources.sh\"\n";
190+
showEnvVarsInLog = 0;
191+
};
173192
B23721B8976E46E75F5C472C /* [CP] Copy Pods Resources */ = {
174193
isa = PBXShellScriptBuildPhase;
175194
buildActionMask = 2147483647;
@@ -185,6 +204,36 @@
185204
shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-BarcodeScannerExample/Pods-BarcodeScannerExample-resources.sh\"\n";
186205
showEnvVarsInLog = 0;
187206
};
207+
BDF82C3FF3E7C5A57E2534BE /* [CP] Check Pods Manifest.lock */ = {
208+
isa = PBXShellScriptBuildPhase;
209+
buildActionMask = 2147483647;
210+
files = (
211+
);
212+
inputPaths = (
213+
);
214+
name = "[CP] Check Pods Manifest.lock";
215+
outputPaths = (
216+
);
217+
runOnlyForDeploymentPostprocessing = 0;
218+
shellPath = /bin/sh;
219+
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";
220+
showEnvVarsInLog = 0;
221+
};
222+
C6637BE832A43C8F49FCF84D /* 📦 Embed Pods Frameworks */ = {
223+
isa = PBXShellScriptBuildPhase;
224+
buildActionMask = 2147483647;
225+
files = (
226+
);
227+
inputPaths = (
228+
);
229+
name = "📦 Embed Pods Frameworks";
230+
outputPaths = (
231+
);
232+
runOnlyForDeploymentPostprocessing = 0;
233+
shellPath = /bin/sh;
234+
shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-BarcodeScannerExample/Pods-BarcodeScannerExample-frameworks.sh\"\n";
235+
showEnvVarsInLog = 0;
236+
};
188237
E090C912AA824DD28A310598 /* [CP] Embed Pods Frameworks */ = {
189238
isa = PBXShellScriptBuildPhase;
190239
buildActionMask = 2147483647;
@@ -229,6 +278,7 @@
229278
D50BE4051C9FE8870000A34C /* Debug */ = {
230279
isa = XCBuildConfiguration;
231280
buildSettings = {
281+
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = "$(inherited)";
232282
ALWAYS_SEARCH_USER_PATHS = NO;
233283
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
234284
CLANG_CXX_LIBRARY = "libc++";
@@ -239,8 +289,10 @@
239289
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
240290
CLANG_WARN_EMPTY_BODY = YES;
241291
CLANG_WARN_ENUM_CONVERSION = YES;
292+
CLANG_WARN_INFINITE_RECURSION = YES;
242293
CLANG_WARN_INT_CONVERSION = YES;
243294
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
295+
CLANG_WARN_SUSPICIOUS_MOVE = YES;
244296
CLANG_WARN_UNREACHABLE_CODE = YES;
245297
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
246298
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
@@ -267,12 +319,14 @@
267319
ONLY_ACTIVE_ARCH = YES;
268320
SDKROOT = iphoneos;
269321
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
322+
SWIFT_VERSION = 3.0;
270323
};
271324
name = Debug;
272325
};
273326
D50BE4061C9FE8870000A34C /* Release */ = {
274327
isa = XCBuildConfiguration;
275328
buildSettings = {
329+
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = "$(inherited)";
276330
ALWAYS_SEARCH_USER_PATHS = NO;
277331
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
278332
CLANG_CXX_LIBRARY = "libc++";
@@ -283,8 +337,10 @@
283337
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
284338
CLANG_WARN_EMPTY_BODY = YES;
285339
CLANG_WARN_ENUM_CONVERSION = YES;
340+
CLANG_WARN_INFINITE_RECURSION = YES;
286341
CLANG_WARN_INT_CONVERSION = YES;
287342
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
343+
CLANG_WARN_SUSPICIOUS_MOVE = YES;
288344
CLANG_WARN_UNREACHABLE_CODE = YES;
289345
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
290346
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
@@ -303,6 +359,8 @@
303359
IPHONEOS_DEPLOYMENT_TARGET = 9.2;
304360
MTL_ENABLE_DEBUG_INFO = NO;
305361
SDKROOT = iphoneos;
362+
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
363+
SWIFT_VERSION = 3.0;
306364
VALIDATE_PRODUCT = YES;
307365
};
308366
name = Release;
@@ -311,6 +369,7 @@
311369
isa = XCBuildConfiguration;
312370
baseConfigurationReference = 560D7A8F00215E8F16A67009 /* Pods-BarcodeScannerExample.debug.xcconfig */;
313371
buildSettings = {
372+
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = "$(inherited)";
314373
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
315374
CODE_SIGN_IDENTITY = "iPhone Developer";
316375
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
@@ -319,13 +378,15 @@
319378
PRODUCT_BUNDLE_IDENTIFIER = no.hyper.BarcodeScannerExample2;
320379
PRODUCT_NAME = "$(TARGET_NAME)";
321380
PROVISIONING_PROFILE = "";
381+
SWIFT_VERSION = 3.0;
322382
};
323383
name = Debug;
324384
};
325385
D50BE4091C9FE8870000A34C /* Release */ = {
326386
isa = XCBuildConfiguration;
327387
baseConfigurationReference = B2BB8B30EF0245DC64F4025A /* Pods-BarcodeScannerExample.release.xcconfig */;
328388
buildSettings = {
389+
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = "$(inherited)";
329390
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
330391
CODE_SIGN_IDENTITY = "iPhone Developer";
331392
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
@@ -334,6 +395,7 @@
334395
PRODUCT_BUNDLE_IDENTIFIER = no.hyper.BarcodeScannerExample2;
335396
PRODUCT_NAME = "$(TARGET_NAME)";
336397
PROVISIONING_PROFILE = "";
398+
SWIFT_VERSION = 3.0;
337399
};
338400
name = Release;
339401
};

Example/BarcodeScannerExample/BarcodeScannerExample/AppDelegate.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
1111
return controller
1212
}()
1313

14-
func application(application: UIApplication,
15-
didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
16-
window = UIWindow(frame: UIScreen.mainScreen().bounds)
14+
func application(_ application: UIApplication,
15+
didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
16+
window = UIWindow(frame: UIScreen.main.bounds)
1717
window?.rootViewController = viewController
1818
window?.makeKeyAndVisible()
1919

Example/BarcodeScannerExample/BarcodeScannerExample/Info.plist

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@
2222
<string>1</string>
2323
<key>LSRequiresIPhoneOS</key>
2424
<true/>
25+
<key>NSPhotoLibraryUsageDescription</key>
26+
<string>This app uses the library for testing purposes</string>
27+
<key>NSCameraUsageDescription</key>
28+
<string>This app uses the camera for testing purposes</string>
2529
<key>UILaunchStoryboardName</key>
2630
<string>LaunchScreen</string>
2731
<key>UIRequiredDeviceCapabilities</key>

Example/BarcodeScannerExample/BarcodeScannerExample/ViewController.swift

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,20 @@ import BarcodeScanner
44
class ViewController: UIViewController {
55

66
lazy var button: UIButton = {
7-
let button = UIButton(type: .System)
8-
button.backgroundColor = UIColor.blackColor()
9-
button.titleLabel?.font = UIFont.systemFontOfSize(28)
10-
button.setTitleColor(UIColor.whiteColor(), forState: .Normal)
11-
button.setTitle("Scan", forState: .Normal)
12-
button.addTarget(self, action: #selector(buttonDidPress), forControlEvents: .TouchUpInside)
7+
let button = UIButton(type: .system)
8+
button.backgroundColor = UIColor.black
9+
button.titleLabel?.font = UIFont.systemFont(ofSize: 28)
10+
button.setTitleColor(UIColor.white, for: UIControlState())
11+
button.setTitle("Scan", for: UIControlState())
12+
button.addTarget(self, action: #selector(buttonDidPress), for: .touchUpInside)
1313

1414
return button
1515
}()
1616

1717
override func viewDidLoad() {
1818
super.viewDidLoad()
1919

20-
view.backgroundColor = UIColor.whiteColor()
20+
view.backgroundColor = UIColor.white
2121
view.addSubview(button)
2222
}
2323

@@ -34,33 +34,33 @@ class ViewController: UIViewController {
3434
controller.errorDelegate = self
3535
controller.dismissalDelegate = self
3636

37-
presentViewController(controller, animated: true, completion: nil)
37+
present(controller, animated: true, completion: nil)
3838
}
3939
}
4040

4141
extension ViewController: BarcodeScannerCodeDelegate {
4242

43-
func barcodeScanner(controller: BarcodeScannerController, didCapturedCode code: String, type: String) {
43+
func barcodeScanner(_ controller: BarcodeScannerController, didCaptureCode code: String, type: String) {
4444
print(code)
4545
print(type)
4646

47-
let delayTime = dispatch_time(DISPATCH_TIME_NOW, Int64(6 * Double(NSEC_PER_SEC)))
48-
dispatch_after(delayTime, dispatch_get_main_queue()) {
47+
let delayTime = DispatchTime.now() + Double(Int64(6 * Double(NSEC_PER_SEC))) / Double(NSEC_PER_SEC)
48+
DispatchQueue.main.asyncAfter(deadline: delayTime) {
4949
controller.resetWithError()
5050
}
5151
}
5252
}
5353

5454
extension ViewController: BarcodeScannerErrorDelegate {
5555

56-
func barcodeScanner(controller: BarcodeScannerController, didReceiveError error: ErrorType) {
56+
func barcodeScanner(_ controller: BarcodeScannerController, didReceiveError error: Error) {
5757
print(error)
5858
}
5959
}
6060

6161
extension ViewController: BarcodeScannerDismissalDelegate {
6262

63-
func barcodeScannerDidDismiss(controller: BarcodeScannerController) {
64-
controller.dismissViewControllerAnimated(true, completion: nil)
63+
func barcodeScannerDidDismiss(_ controller: BarcodeScannerController) {
64+
controller.dismiss(animated: true, completion: nil)
6565
}
6666
}

Example/BarcodeScannerExample/Podfile.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@ SPEC CHECKSUMS:
1313

1414
PODFILE CHECKSUM: 5ef23317899e015b0a239f469648c11cbee75aaa
1515

16-
COCOAPODS: 1.0.1
16+
COCOAPODS: 1.1.0.rc.2

0 commit comments

Comments
 (0)