Skip to content

Commit cdafb41

Browse files
Merge pull request #220 from hyperoslo/swift-3
Swift 3
2 parents e409d9f + 183af70 commit cdafb41

36 files changed

+659
-617
lines changed

.swift-version

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
3.0

.travis.yml

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

4-
before_install:
5-
- brew update
6-
- if brew outdated | grep -qx xctool; then brew upgrade xctool; fi
7-
84
script:
9-
- xctool clean build -project ImagePicker.xcodeproj -scheme ImagePicker-iOS -sdk iphonesimulator
5+
- xcodebuild clean build -project ImagePicker.xcodeproj -scheme "ImagePicker-iOS" -sdk iphonesimulator

Demo/ImagePickerDemo/ImagePickerDemo.xcodeproj/project.pbxproj

Lines changed: 12 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
29D699DF1B70ABFC0021FA73 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 29D699DE1B70ABFC0021FA73 /* AppDelegate.swift */; };
1111
29D699E61B70ABFC0021FA73 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 29D699E51B70ABFC0021FA73 /* Images.xcassets */; };
1212
29D699E91B70ABFC0021FA73 /* LaunchScreen.xib in Resources */ = {isa = PBXBuildFile; fileRef = 29D699E71B70ABFC0021FA73 /* LaunchScreen.xib */; };
13-
29D699FF1B70ACD50021FA73 /* Podfile in Resources */ = {isa = PBXBuildFile; fileRef = 29D699FE1B70ACD50021FA73 /* Podfile */; };
1413
4221AE1F43A643A689082012 /* Pods_ImagePickerDemo.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F1148A4E4BFF9A0AAED07754 /* Pods_ImagePickerDemo.framework */; };
1514
D20AA8A51D5330100085FF5B /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = D20AA8A41D5330100085FF5B /* ViewController.swift */; };
1615
/* End PBXBuildFile section */
@@ -21,9 +20,6 @@
2120
29D699DE1B70ABFC0021FA73 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
2221
29D699E51B70ABFC0021FA73 /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = "<group>"; };
2322
29D699E81B70ABFC0021FA73 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/LaunchScreen.xib; sourceTree = "<group>"; };
24-
29D699F31B70ABFC0021FA73 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
25-
29D699F41B70ABFC0021FA73 /* ImagePickerDemoTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ImagePickerDemoTests.swift; sourceTree = "<group>"; };
26-
29D699FE1B70ACD50021FA73 /* Podfile */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = Podfile; sourceTree = "<group>"; };
2723
6F9E1FF802198DC16F260795 /* Pods-ImagePickerDemo.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-ImagePickerDemo.release.xcconfig"; path = "Pods/Target Support Files/Pods-ImagePickerDemo/Pods-ImagePickerDemo.release.xcconfig"; sourceTree = "<group>"; };
2824
733A7AD0105A657A80502E72 /* Pods.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods.framework; sourceTree = BUILT_PRODUCTS_DIR; };
2925
C4392341AC7391C01AD9F350 /* Pods-ImagePickerDemo.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-ImagePickerDemo.debug.xcconfig"; path = "Pods/Target Support Files/Pods-ImagePickerDemo/Pods-ImagePickerDemo.debug.xcconfig"; sourceTree = "<group>"; };
@@ -47,7 +43,6 @@
4743
isa = PBXGroup;
4844
children = (
4945
29D699DB1B70ABFC0021FA73 /* ImagePickerDemo */,
50-
29D699F11B70ABFC0021FA73 /* ImagePickerDemoTests */,
5146
29D699DA1B70ABFC0021FA73 /* Products */,
5247
DD112158CF9886DE925FED5E /* Frameworks */,
5348
A067DFAD5749963FA2D2ADED /* Pods */,
@@ -79,29 +74,11 @@
7974
29D699DC1B70ABFC0021FA73 /* Supporting Files */ = {
8075
isa = PBXGroup;
8176
children = (
82-
29D699FE1B70ACD50021FA73 /* Podfile */,
8377
29D699DD1B70ABFC0021FA73 /* Info.plist */,
8478
);
8579
name = "Supporting Files";
8680
sourceTree = "<group>";
8781
};
88-
29D699F11B70ABFC0021FA73 /* ImagePickerDemoTests */ = {
89-
isa = PBXGroup;
90-
children = (
91-
29D699F41B70ABFC0021FA73 /* ImagePickerDemoTests.swift */,
92-
29D699F21B70ABFC0021FA73 /* Supporting Files */,
93-
);
94-
path = ImagePickerDemoTests;
95-
sourceTree = "<group>";
96-
};
97-
29D699F21B70ABFC0021FA73 /* Supporting Files */ = {
98-
isa = PBXGroup;
99-
children = (
100-
29D699F31B70ABFC0021FA73 /* Info.plist */,
101-
);
102-
name = "Supporting Files";
103-
sourceTree = "<group>";
104-
};
10582
A067DFAD5749963FA2D2ADED /* Pods */ = {
10683
isa = PBXGroup;
10784
children = (
@@ -150,12 +127,13 @@
150127
isa = PBXProject;
151128
attributes = {
152129
LastSwiftUpdateCheck = 0700;
153-
LastUpgradeCheck = 0700;
130+
LastUpgradeCheck = 0800;
154131
ORGANIZATIONNAME = "Ramon Gilabert Llop";
155132
TargetAttributes = {
156133
29D699D81B70ABFC0021FA73 = {
157134
CreatedOnToolsVersion = 6.4;
158135
DevelopmentTeam = LG4DBY4QF9;
136+
LastSwiftMigration = 0800;
159137
};
160138
};
161139
};
@@ -183,7 +161,6 @@
183161
buildActionMask = 2147483647;
184162
files = (
185163
29D699E91B70ABFC0021FA73 /* LaunchScreen.xib in Resources */,
186-
29D699FF1B70ACD50021FA73 /* Podfile in Resources */,
187164
29D699E61B70ABFC0021FA73 /* Images.xcassets in Resources */,
188165
);
189166
runOnlyForDeploymentPostprocessing = 0;
@@ -233,7 +210,7 @@
233210
);
234211
runOnlyForDeploymentPostprocessing = 0;
235212
shellPath = /bin/sh;
236-
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";
213+
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";
237214
showEnvVarsInLog = 0;
238215
};
239216
/* End PBXShellScriptBuildPhase section */
@@ -275,8 +252,10 @@
275252
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
276253
CLANG_WARN_EMPTY_BODY = YES;
277254
CLANG_WARN_ENUM_CONVERSION = YES;
255+
CLANG_WARN_INFINITE_RECURSION = YES;
278256
CLANG_WARN_INT_CONVERSION = YES;
279257
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
258+
CLANG_WARN_SUSPICIOUS_MOVE = YES;
280259
CLANG_WARN_UNREACHABLE_CODE = YES;
281260
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
282261
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
@@ -321,8 +300,10 @@
321300
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
322301
CLANG_WARN_EMPTY_BODY = YES;
323302
CLANG_WARN_ENUM_CONVERSION = YES;
303+
CLANG_WARN_INFINITE_RECURSION = YES;
324304
CLANG_WARN_INT_CONVERSION = YES;
325305
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
306+
CLANG_WARN_SUSPICIOUS_MOVE = YES;
326307
CLANG_WARN_UNREACHABLE_CODE = YES;
327308
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
328309
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
@@ -341,6 +322,7 @@
341322
IPHONEOS_DEPLOYMENT_TARGET = 8.2;
342323
MTL_ENABLE_DEBUG_INFO = NO;
343324
SDKROOT = iphoneos;
325+
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
344326
TARGETED_DEVICE_FAMILY = "1,2";
345327
VALIDATE_PRODUCT = YES;
346328
};
@@ -350,6 +332,7 @@
350332
isa = XCBuildConfiguration;
351333
baseConfigurationReference = C4392341AC7391C01AD9F350 /* Pods-ImagePickerDemo.debug.xcconfig */;
352334
buildSettings = {
335+
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
353336
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
354337
CODE_SIGN_IDENTITY = "iPhone Developer";
355338
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
@@ -359,13 +342,15 @@
359342
PRODUCT_BUNDLE_IDENTIFIER = no.hyper.ImagePickerDemo2;
360343
PRODUCT_NAME = "$(TARGET_NAME)";
361344
PROVISIONING_PROFILE = "";
345+
SWIFT_VERSION = 3.0;
362346
};
363347
name = Debug;
364348
};
365349
29D699FA1B70ABFC0021FA73 /* Release */ = {
366350
isa = XCBuildConfiguration;
367351
baseConfigurationReference = 6F9E1FF802198DC16F260795 /* Pods-ImagePickerDemo.release.xcconfig */;
368352
buildSettings = {
353+
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
369354
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
370355
CODE_SIGN_IDENTITY = "iPhone Developer";
371356
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
@@ -375,6 +360,7 @@
375360
PRODUCT_BUNDLE_IDENTIFIER = no.hyper.ImagePickerDemo2;
376361
PRODUCT_NAME = "$(TARGET_NAME)";
377362
PROVISIONING_PROFILE = "";
363+
SWIFT_VERSION = 3.0;
378364
};
379365
name = Release;
380366
};

Demo/ImagePickerDemo/ImagePickerDemo/AppDelegate.swift

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,15 @@ import UIKit
33
@UIApplicationMain
44
class AppDelegate: UIResponder, UIApplicationDelegate {
55

6-
lazy var window: UIWindow? = UIWindow(frame: UIScreen.mainScreen().bounds)
6+
lazy var controller: UIViewController = ViewController()
77

8-
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
8+
var window: UIWindow?
99

10-
window?.rootViewController = ViewController()
10+
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
11+
window = UIWindow()
12+
window?.rootViewController = controller
1113
window?.makeKeyAndVisible()
12-
14+
1315
return true
1416
}
1517
}

Demo/ImagePickerDemo/ImagePickerDemo/Images.xcassets/AppIcon.appiconset/Contents.json

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
11
{
22
"images" : [
3+
{
4+
"idiom" : "iphone",
5+
"size" : "20x20",
6+
"scale" : "2x"
7+
},
8+
{
9+
"idiom" : "iphone",
10+
"size" : "20x20",
11+
"scale" : "3x"
12+
},
313
{
414
"idiom" : "iphone",
515
"size" : "29x29",
@@ -50,6 +60,16 @@
5060
"filename" : "[email protected]",
5161
"scale" : "3x"
5262
},
63+
{
64+
"idiom" : "ipad",
65+
"size" : "20x20",
66+
"scale" : "1x"
67+
},
68+
{
69+
"idiom" : "ipad",
70+
"size" : "20x20",
71+
"scale" : "2x"
72+
},
5373
{
5474
"size" : "29x29",
5575
"idiom" : "ipad",
@@ -115,6 +135,20 @@
115135
"filename" : "[email protected]",
116136
"scale" : "2x"
117137
},
138+
{
139+
"size" : "24x24",
140+
"idiom" : "watch",
141+
"scale" : "2x",
142+
"role" : "notificationCenter",
143+
"subtype" : "38mm"
144+
},
145+
{
146+
"size" : "27.5x27.5",
147+
"idiom" : "watch",
148+
"scale" : "2x",
149+
"role" : "notificationCenter",
150+
"subtype" : "42mm"
151+
},
118152
{
119153
"size" : "29x29",
120154
"idiom" : "watch",
@@ -128,6 +162,27 @@
128162
"filename" : "[email protected]",
129163
"role" : "companionSettings",
130164
"scale" : "3x"
165+
},
166+
{
167+
"size" : "40x40",
168+
"idiom" : "watch",
169+
"scale" : "2x",
170+
"role" : "appLauncher",
171+
"subtype" : "38mm"
172+
},
173+
{
174+
"size" : "86x86",
175+
"idiom" : "watch",
176+
"scale" : "2x",
177+
"role" : "quickLook",
178+
"subtype" : "38mm"
179+
},
180+
{
181+
"size" : "98x98",
182+
"idiom" : "watch",
183+
"scale" : "2x",
184+
"role" : "quickLook",
185+
"subtype" : "42mm"
131186
}
132187
],
133188
"info" : {

Demo/ImagePickerDemo/ImagePickerDemo/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>NSCameraUsageDescription</key>
26+
<string>This app uses the camera for testing purposes</string>
27+
<key>NSPhotoLibraryUsageDescription</key>
28+
<string>This app uses the library for testing purposes</string>
2529
<key>UILaunchStoryboardName</key>
2630
<string>LaunchScreen</string>
2731
<key>UIRequiredDeviceCapabilities</key>

Demo/ImagePickerDemo/ImagePickerDemo/Podfile

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

Demo/ImagePickerDemo/ImagePickerDemo/ViewController.swift

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,28 @@ class ViewController: UIViewController, ImagePickerDelegate {
99
override func viewDidLoad() {
1010
super.viewDidLoad()
1111

12-
view.backgroundColor = UIColor.whiteColor()
12+
view.backgroundColor = UIColor.white
1313
view.addSubview(button)
1414
button.translatesAutoresizingMaskIntoConstraints = false
1515

16-
view.addConstraint(NSLayoutConstraint(item: button, attribute: .CenterX, relatedBy: .Equal, toItem: view, attribute: .CenterX, multiplier: 1, constant: 0))
17-
view.addConstraint(NSLayoutConstraint(item: button, attribute: .CenterY, relatedBy: .Equal, toItem: view, attribute: .CenterY, multiplier: 1, constant: 0))
16+
view.addConstraint(
17+
NSLayoutConstraint(item: button, attribute: .centerX,
18+
relatedBy: .equal, toItem: view,
19+
attribute: .centerX, multiplier: 1,
20+
constant: 0))
21+
22+
view.addConstraint(
23+
NSLayoutConstraint(item: button, attribute: .centerY,
24+
relatedBy: .equal, toItem: view,
25+
attribute: .centerY, multiplier: 1,
26+
constant: 0))
1827
}
1928

2029
func makeButton() -> UIButton {
2130
let button = UIButton()
22-
button.setTitle("Show ImagePicker", forState: .Normal)
23-
button.setTitleColor(UIColor.blackColor(), forState: .Normal)
24-
button.addTarget(self, action: #selector(buttonTouched(_:)), forControlEvents: .TouchUpInside)
31+
button.setTitle("Show ImagePicker", for: .normal)
32+
button.setTitleColor(UIColor.black, for: .normal)
33+
button.addTarget(self, action: #selector(buttonTouched(button:)), for: .touchUpInside)
2534

2635
return button
2736
}
@@ -30,27 +39,27 @@ class ViewController: UIViewController, ImagePickerDelegate {
3039
let imagePicker = ImagePickerController()
3140
imagePicker.delegate = self
3241

33-
presentViewController(imagePicker, animated: true, completion: nil)
42+
present(imagePicker, animated: true, completion: nil)
3443
}
3544

3645
// MARK: - ImagePickerDelegate
3746

38-
func cancelButtonDidPress(imagePicker: ImagePickerController) {
39-
imagePicker.dismissViewControllerAnimated(true, completion: nil)
47+
func cancelButtonDidPress(_ imagePicker: ImagePickerController) {
48+
imagePicker.dismiss(animated: true, completion: nil)
4049
}
4150

42-
func wrapperDidPress(imagePicker: ImagePickerController, images: [UIImage]) {
51+
func wrapperDidPress(_ imagePicker: ImagePickerController, images: [UIImage]) {
4352
guard images.count > 0 else { return }
4453

4554
let lightboxImages = images.map {
4655
return LightboxImage(image: $0)
4756
}
4857

4958
let lightbox = LightboxController(images: lightboxImages, startIndex: 0)
50-
imagePicker.presentViewController(lightbox, animated: true, completion: nil)
59+
imagePicker.present(lightbox, animated: true, completion: nil)
5160
}
5261

53-
func doneButtonDidPress(imagePicker: ImagePickerController, images: [UIImage]) {
54-
imagePicker.dismissViewControllerAnimated(true, completion: nil)
62+
func doneButtonDidPress(_ imagePicker: ImagePickerController, images: [UIImage]) {
63+
imagePicker.dismiss(animated: true, completion: nil)
5564
}
5665
}

Demo/ImagePickerDemo/ImagePickerDemoTests/ImagePickerDemoTests.swift

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

0 commit comments

Comments
 (0)