Skip to content

Commit 3df60a3

Browse files
committed
converts swift to latest version
1 parent 4f8db8a commit 3df60a3

File tree

8 files changed

+60
-49
lines changed

8 files changed

+60
-49
lines changed

.travis.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ branches:
33
- master
44
language: objective-c
55
os: osx
6-
osx_image: xcode7.3
6+
osx_image: xcode8.3
77
env:
88
global:
99
- LC_CTYPE=en_US.UTF-8
@@ -35,4 +35,4 @@ after_success:
3535
- |
3636
if [ "$TEST_TYPE" = iOS ] || [ "$TEST_TYPE" = macOS ]; then
3737
bash <(curl -s https://codecov.io/bash)
38-
fi
38+
fi

Parse.xcodeproj/project.pbxproj

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6877,6 +6877,9 @@
68776877
LastUpgradeCheck = 0730;
68786878
ORGANIZATIONNAME = "Parse Inc.";
68796879
TargetAttributes = {
6880+
816F441B1A8E8933009CDB32 = {
6881+
LastSwiftMigration = 0830;
6882+
};
68806883
81C3821B19CCA89E0066284A = {
68816884
CreatedOnToolsVersion = 6.0.1;
68826885
};
@@ -8639,13 +8642,15 @@
86398642
isa = XCBuildConfiguration;
86408643
baseConfigurationReference = F55ABB591B4F39DA00A0ECD5 /* ParseUnitTests-iOS.xcconfig */;
86418644
buildSettings = {
8645+
SWIFT_VERSION = 3.0;
86428646
};
86438647
name = Debug;
86448648
};
86458649
816F449A1A8E8933009CDB32 /* Release */ = {
86468650
isa = XCBuildConfiguration;
86478651
baseConfigurationReference = F55ABB591B4F39DA00A0ECD5 /* ParseUnitTests-iOS.xcconfig */;
86488652
buildSettings = {
8653+
SWIFT_VERSION = 3.0;
86498654
};
86508655
name = Release;
86518656
};

ParseStarterProject/OSX/ParseOSXStarterProject-Swift/ParseOSXStarterProject-Swift.xcodeproj/project.pbxproj

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,7 @@
159159
};
160160
81CC85B71A49F2E00076DE19 = {
161161
CreatedOnToolsVersion = 6.1.1;
162+
LastSwiftMigration = 0830;
162163
};
163164
};
164165
};
@@ -344,6 +345,7 @@
344345
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks";
345346
PRODUCT_BUNDLE_IDENTIFIER = "com.parse.$(PRODUCT_NAME:rfc1034identifier)";
346347
PRODUCT_NAME = "ParseOSXStarterProject-Swift";
348+
SWIFT_VERSION = 3.0;
347349
};
348350
name = Debug;
349351
};
@@ -360,6 +362,7 @@
360362
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks";
361363
PRODUCT_BUNDLE_IDENTIFIER = "com.parse.$(PRODUCT_NAME:rfc1034identifier)";
362364
PRODUCT_NAME = "ParseOSXStarterProject-Swift";
365+
SWIFT_VERSION = 3.0;
363366
};
364367
name = Release;
365368
};

ParseStarterProject/OSX/ParseOSXStarterProject-Swift/ParseOSXStarterProject/AppDelegate.swift

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class AppDelegate: NSObject, NSApplicationDelegate {
1616

1717
@IBOutlet weak var window: NSWindow?
1818

19-
func applicationDidFinishLaunching(aNotification: NSNotification) {
19+
func applicationDidFinishLaunching(_ aNotification: Notification) {
2020
// ****************************************************************************
2121
// Initialize Parse SDK
2222
// ****************************************************************************
@@ -32,17 +32,17 @@ class AppDelegate: NSObject, NSApplicationDelegate {
3232

3333
// Enable storing and querying data from Local Datastore.
3434
// Remove this line if you don't want to use Local Datastore features or want to use cachePolicy.
35-
$0.localDatastoreEnabled = true
35+
$0.isLocalDatastoreEnabled = true
3636
}
37-
Parse.initializeWithConfiguration(configuration)
37+
Parse.initialize(with: configuration)
3838

3939
PFUser.enableAutomaticUser()
4040

4141
let defaultACL: PFACL = PFACL()
4242
// If you would like all objects to be private by default, remove this line.
43-
defaultACL.publicReadAccess = true
43+
defaultACL.getPublicReadAccess = true
4444

45-
PFACL.setDefaultACL(defaultACL, withAccessForCurrentUser: true)
45+
PFACL.setDefault(defaultACL, withAccessForCurrentUser: true)
4646

4747
// ****************************************************************************
4848
// Uncomment these lines to register for Push Notifications.
@@ -52,24 +52,24 @@ class AppDelegate: NSObject, NSApplicationDelegate {
5252
//
5353
// ****************************************************************************
5454

55-
PFAnalytics.trackAppOpenedWithLaunchOptions(nil)
55+
PFAnalytics.trackAppOpened(launchOptions: nil)
5656
}
5757

58-
func application(application: NSApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: NSData) {
59-
let installation = PFInstallation.currentInstallation()
60-
installation?.setDeviceTokenFromData(deviceToken)
58+
func application(_ application: NSApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
59+
let installation = PFInstallation.current()
60+
installation?.setDeviceTokenFrom(deviceToken)
6161
installation?.saveInBackground()
6262

63-
PFPush.subscribeToChannelInBackground("") { (succeeded: Bool, error: NSError?) in
63+
PFPush.subscribeToChannel(inBackground: "") { (succeeded: Bool, error: Error?) in
6464
if succeeded {
6565
print("ParseStarterProject successfully subscribed to push notifications on the broadcast channel.\n")
66-
} else {
67-
print("ParseStarterProject failed to subscribe to push notifications on the broadcast channel with error = %@.\n", error)
66+
} else if let error = error {
67+
print("ParseStarterProject failed to subscribe to push notifications on the broadcast channel with error = %@.\n", (error as NSError))
6868
}
6969
}
7070
}
7171

72-
func application(application: NSApplication, didFailToRegisterForRemoteNotificationsWithError error: NSError) {
72+
func application(_ application: NSApplication, didFailToRegisterForRemoteNotificationsWithError error: Error) {
7373
print("application:didFailToRegisterForRemoteNotificationsWithError: %@\n", error)
7474
}
7575

ParseStarterProject/iOS/ParseStarterProject-Swift/ParseStarterProject-Swift.xcodeproj/project.pbxproj

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,7 @@
176176
};
177177
81BA81441A49DA1800E65899 = {
178178
CreatedOnToolsVersion = 6.1.1;
179+
LastSwiftMigration = 0830;
179180
};
180181
};
181182
};
@@ -367,6 +368,7 @@
367368
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
368369
PRODUCT_BUNDLE_IDENTIFIER = "com.parse.$(PRODUCT_NAME:rfc1034identifier)";
369370
PRODUCT_NAME = "ParseStarterProject-Swift";
371+
SWIFT_VERSION = 3.0;
370372
};
371373
name = Debug;
372374
};
@@ -383,6 +385,7 @@
383385
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
384386
PRODUCT_BUNDLE_IDENTIFIER = "com.parse.$(PRODUCT_NAME:rfc1034identifier)";
385387
PRODUCT_NAME = "ParseStarterProject-Swift";
388+
SWIFT_VERSION = 3.0;
386389
};
387390
name = Release;
388391
};

ParseStarterProject/iOS/ParseStarterProject-Swift/ParseStarterProject/AppDelegate.swift

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
2323
// MARK: - UIApplicationDelegate
2424
//--------------------------------------
2525

26-
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
26+
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
2727
// ****************************************************************************
2828
// Initialize Parse SDK
2929
// ****************************************************************************
@@ -39,9 +39,9 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
3939

4040
// Enable storing and querying data from Local Datastore.
4141
// Remove this line if you don't want to use Local Datastore features or want to use cachePolicy.
42-
$0.localDatastoreEnabled = true
42+
$0.isLocalDatastoreEnabled = true
4343
}
44-
Parse.initializeWithConfiguration(configuration)
44+
Parse.initialize(with: configuration)
4545

4646
// ****************************************************************************
4747
// If you are using Facebook, uncomment and add your FacebookAppID to your bundle's plist as
@@ -55,27 +55,27 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
5555
let defaultACL = PFACL()
5656

5757
// If you would like all objects to be private by default, remove this line.
58-
defaultACL.publicReadAccess = true
58+
defaultACL.getPublicReadAccess = true
5959

60-
PFACL.setDefaultACL(defaultACL, withAccessForCurrentUser: true)
60+
PFACL.setDefault(defaultACL, withAccessForCurrentUser: true)
6161

62-
if application.applicationState != UIApplicationState.Background {
62+
if application.applicationState != UIApplicationState.background {
6363
// Track an app open here if we launch with a push, unless
6464
// "content_available" was used to trigger a background push (introduced in iOS 7).
6565
// In that case, we skip tracking here to avoid double counting the app-open.
6666

67-
let oldPushHandlerOnly = !respondsToSelector(#selector(UIApplicationDelegate.application(_:didReceiveRemoteNotification:fetchCompletionHandler:)))
67+
let oldPushHandlerOnly = !responds(to: #selector(UIApplicationDelegate.application(_:didReceiveRemoteNotification:fetchCompletionHandler:)))
6868
var noPushPayload = false
6969
if let options = launchOptions {
70-
noPushPayload = options[UIApplicationLaunchOptionsRemoteNotificationKey] == nil
70+
noPushPayload = options[UIApplicationLaunchOptionsKey.remoteNotification] == nil
7171
}
7272
if oldPushHandlerOnly || noPushPayload {
73-
PFAnalytics.trackAppOpenedWithLaunchOptions(launchOptions)
73+
PFAnalytics.trackAppOpened(launchOptions: launchOptions)
7474
}
7575
}
7676

77-
let types: UIUserNotificationType = [.Alert, .Badge, .Sound]
78-
let settings = UIUserNotificationSettings(forTypes: types, categories: nil)
77+
let types: UIUserNotificationType = [.alert, .badge, .sound]
78+
let settings = UIUserNotificationSettings(types: types, categories: nil)
7979
application.registerUserNotificationSettings(settings)
8080
application.registerForRemoteNotifications()
8181

@@ -86,32 +86,32 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
8686
// MARK: Push Notifications
8787
//--------------------------------------
8888

89-
func application(application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: NSData) {
90-
let installation = PFInstallation.currentInstallation()
91-
installation?.setDeviceTokenFromData(deviceToken)
89+
func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
90+
let installation = PFInstallation.current()
91+
installation?.setDeviceTokenFrom(deviceToken)
9292
installation?.saveInBackground()
9393

94-
PFPush.subscribeToChannelInBackground("") { (succeeded: Bool, error: NSError?) in
94+
PFPush.subscribeToChannel(inBackground: "") { (succeeded: Bool, error: Error?) in
9595
if succeeded {
9696
print("ParseStarterProject successfully subscribed to push notifications on the broadcast channel.\n")
97-
} else {
98-
print("ParseStarterProject failed to subscribe to push notifications on the broadcast channel with error = %@.\n", error)
97+
} else if let error = error {
98+
print("ParseStarterProject failed to subscribe to push notifications on the broadcast channel with error = %@.\n", (error as NSError))
9999
}
100100
}
101101
}
102102

103-
func application(application: UIApplication, didFailToRegisterForRemoteNotificationsWithError error: NSError) {
104-
if error.code == 3010 {
103+
func application(_ application: UIApplication, didFailToRegisterForRemoteNotificationsWithError error: Error) {
104+
if (error as NSError).code == 3010 {
105105
print("Push notifications are not supported in the iOS Simulator.\n")
106106
} else {
107107
print("application:didFailToRegisterForRemoteNotificationsWithError: %@\n", error)
108108
}
109109
}
110110

111-
func application(application: UIApplication, didReceiveRemoteNotification userInfo: [NSObject : AnyObject]) {
112-
PFPush.handlePush(userInfo)
113-
if application.applicationState == UIApplicationState.Inactive {
114-
PFAnalytics.trackAppOpenedWithRemoteNotificationPayload(userInfo)
111+
func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable: Any]) {
112+
PFPush.handle(userInfo)
113+
if application.applicationState == UIApplicationState.inactive {
114+
PFAnalytics.trackAppOpened(withRemoteNotificationPayload: userInfo)
115115
}
116116
}
117117

ParseStarterProject/watchOS/ParseStarterProject-Swift/ParseStarterProject/AppDelegate.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -89,17 +89,17 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
8989
installation?.setDeviceTokenFromData(deviceToken)
9090
installation?.saveInBackground()
9191

92-
PFPush.subscribeToChannelInBackground("") { (succeeded: Bool, error: NSError?) in
92+
PFPush.subscribeToChannelInBackground("") { (succeeded: Bool, error: Error?) in
9393
if succeeded {
9494
print("ParseStarterProject successfully subscribed to push notifications on the broadcast channel.\n")
95-
} else {
96-
print("ParseStarterProject failed to subscribe to push notifications on the broadcast channel with error = %@.\n", error)
95+
} else if let error = error {
96+
print("ParseStarterProject failed to subscribe to push notifications on the broadcast channel with error = %@.\n", (error as NSError))
9797
}
9898
}
9999
}
100100

101-
func application(application: UIApplication, didFailToRegisterForRemoteNotificationsWithError error: NSError) {
102-
if error.code == 3010 {
101+
func application(application: UIApplication, didFailToRegisterForRemoteNotificationsWithError error: Error) {
102+
if (error as NSError).code == 3010 {
103103
print("Push notifications are not supported in the iOS Simulator.\n")
104104
} else {
105105
print("application:didFailToRegisterForRemoteNotificationsWithError: %@\n", error)

Tests/Other/Swift/SwiftSubclass.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,14 @@ import Foundation
1212
import Parse
1313

1414
@objc
15-
public class SwiftSubclass: PFObject, PFSubclassing {
16-
@NSManaged public var primitiveProperty: Int
17-
@NSManaged public var objectProperty: AnyObject?
15+
open class SwiftSubclass: PFObject, PFSubclassing {
16+
@NSManaged open var primitiveProperty: Int
17+
@NSManaged open var objectProperty: AnyObject?
1818

19-
@NSManaged public var relationProperty: PFRelation?
20-
@NSManaged public var badProperty: CGPoint
19+
@NSManaged open var relationProperty: PFRelation?
20+
@NSManaged open var badProperty: CGPoint
2121

22-
public static func parseClassName() -> String {
22+
open static func parseClassName() -> String {
2323
return "SwiftSubclass"
2424
}
2525

0 commit comments

Comments
 (0)