Skip to content
This repository was archived by the owner on Sep 15, 2025. It is now read-only.

Commit 9596519

Browse files
Merge pull request #105 from wordpress-mobile/issue/79-swift5-phase1
Apply some Swift 4 cleanup
2 parents 818ac9d + ccf4322 commit 9596519

19 files changed

+57
-67
lines changed

WordPressKit.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Pod::Spec.new do |s|
22
s.name = "WordPressKit"
3-
s.version = "2.1.0"
3+
s.version = "2.1.1-beta.1"
44
s.summary = "WordPressKit offers a clean and simple WordPress.com and WordPress.org API."
55

66
s.description = <<-DESC

WordPressKit.xcodeproj/project.pbxproj

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2663,7 +2663,6 @@
26632663
PRODUCT_NAME = "$(TARGET_NAME)";
26642664
SKIP_INSTALL = YES;
26652665
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
2666-
SWIFT_VERSION = 4.2;
26672666
};
26682667
name = Debug;
26692668
};
@@ -2689,7 +2688,6 @@
26892688
PRODUCT_BUNDLE_IDENTIFIER = com.automattic.WordPressKit;
26902689
PRODUCT_NAME = "$(TARGET_NAME)";
26912690
SKIP_INSTALL = YES;
2692-
SWIFT_VERSION = 4.2;
26932691
};
26942692
name = Release;
26952693
};
@@ -2710,7 +2708,6 @@
27102708
PRODUCT_NAME = "$(TARGET_NAME)";
27112709
SWIFT_OBJC_BRIDGING_HEADER = "WordPressKitTests/WordPressKitTests-Bridging-Header.h";
27122710
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
2713-
SWIFT_VERSION = 4.2;
27142711
};
27152712
name = Debug;
27162713
};
@@ -2730,7 +2727,6 @@
27302727
PRODUCT_BUNDLE_IDENTIFIER = com.automattic.WordPressKitTests;
27312728
PRODUCT_NAME = "$(TARGET_NAME)";
27322729
SWIFT_OBJC_BRIDGING_HEADER = "WordPressKitTests/WordPressKitTests-Bridging-Header.h";
2733-
SWIFT_VERSION = 4.2;
27342730
};
27352731
name = Release;
27362732
};
@@ -2812,7 +2808,6 @@
28122808
PRODUCT_BUNDLE_IDENTIFIER = com.automattic.WordPressKit;
28132809
PRODUCT_NAME = "$(TARGET_NAME)";
28142810
SKIP_INSTALL = YES;
2815-
SWIFT_VERSION = 4.2;
28162811
};
28172812
name = "Release-Internal";
28182813
};
@@ -2832,7 +2827,6 @@
28322827
PRODUCT_BUNDLE_IDENTIFIER = com.automattic.WordPressKitTests;
28332828
PRODUCT_NAME = "$(TARGET_NAME)";
28342829
SWIFT_OBJC_BRIDGING_HEADER = "WordPressKitTests/WordPressKitTests-Bridging-Header.h";
2835-
SWIFT_VERSION = 4.2;
28362830
};
28372831
name = "Release-Internal";
28382832
};
@@ -2914,7 +2908,6 @@
29142908
PRODUCT_BUNDLE_IDENTIFIER = com.automattic.WordPressKit;
29152909
PRODUCT_NAME = "$(TARGET_NAME)";
29162910
SKIP_INSTALL = YES;
2917-
SWIFT_VERSION = 4.2;
29182911
};
29192912
name = "Release-Alpha";
29202913
};
@@ -2934,7 +2927,6 @@
29342927
PRODUCT_BUNDLE_IDENTIFIER = com.automattic.WordPressKitTests;
29352928
PRODUCT_NAME = "$(TARGET_NAME)";
29362929
SWIFT_OBJC_BRIDGING_HEADER = "WordPressKitTests/WordPressKitTests-Bridging-Header.h";
2937-
SWIFT_VERSION = 4.2;
29382930
};
29392931
name = "Release-Alpha";
29402932
};

WordPressKit/AccountSettingsRemote.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ public class AccountSettingsRemote: ServiceRemoteWordPressComREST {
123123
})
124124
}
125125

126-
fileprivate func settingsFromResponse(_ responseObject: AnyObject) throws -> AccountSettings {
126+
private func settingsFromResponse(_ responseObject: AnyObject) throws -> AccountSettings {
127127
guard let
128128
response = responseObject as? [String: AnyObject],
129129
let firstName = response["first_name"] as? String,
@@ -158,7 +158,7 @@ public class AccountSettingsRemote: ServiceRemoteWordPressComREST {
158158
tracksOptOut: tracksOptOut)
159159
}
160160

161-
fileprivate func fieldNameForChange(_ change: AccountSettingsChange) -> String {
161+
private func fieldNameForChange(_ change: AccountSettingsChange) -> String {
162162
switch change {
163163
case .firstName:
164164
return "first_name"

WordPressKit/GravatarServiceRemote.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ open class GravatarServiceRemote {
9393

9494
/// Returns a new (randomized) Boundary String
9595
///
96-
fileprivate func boundaryForRequest() -> String {
96+
private func boundaryForRequest() -> String {
9797
return "Boundary-" + UUID().uuidString
9898
}
9999

@@ -107,7 +107,7 @@ open class GravatarServiceRemote {
107107
///
108108
/// - Returns: A NSData instance, containing the Request's Payload.
109109
///
110-
fileprivate func bodyWithGravatarData(_ gravatarData: Data, account: String, boundary: String) -> Data {
110+
private func bodyWithGravatarData(_ gravatarData: Data, account: String, boundary: String) -> Data {
111111
let body = NSMutableData()
112112

113113
// Image Payload
@@ -131,7 +131,7 @@ open class GravatarServiceRemote {
131131

132132

133133
// MARK: - Private Structs
134-
fileprivate struct UploadParameters {
134+
private struct UploadParameters {
135135
static let endpointURL = "https://api.gravatar.com/v1/upload-image"
136136
static let HTTPMethod = "POST"
137137
static let contentType = "application/octet-stream"

WordPressKit/HTTPAuthenticationAlertController.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ open class HTTPAuthenticationAlertController {
77

88
public typealias AuthenticationHandler = (URLSession.AuthChallengeDisposition, URLCredential?) -> Void
99

10-
fileprivate static var onGoingChallenges = [URLProtectionSpace: [AuthenticationHandler]]()
10+
private static var onGoingChallenges = [URLProtectionSpace: [AuthenticationHandler]]()
1111

1212
static public func controller(for challenge: URLAuthenticationChallenge, handler: @escaping AuthenticationHandler) -> UIAlertController? {
1313
if var handlers = onGoingChallenges[challenge.protectionSpace] {
@@ -35,7 +35,7 @@ open class HTTPAuthenticationAlertController {
3535
onGoingChallenges.removeValue(forKey: challenge.protectionSpace)
3636
}
3737

38-
static fileprivate func controllerForServerTrustChallenge(_ challenge: URLAuthenticationChallenge) -> UIAlertController {
38+
private static func controllerForServerTrustChallenge(_ challenge: URLAuthenticationChallenge) -> UIAlertController {
3939
let title = NSLocalizedString("Certificate error", comment: "Popup title for wrong SSL certificate.")
4040
let message = String(format: NSLocalizedString("The certificate for this server is invalid. You might be connecting to a server that is pretending to be “%@” which could put your confidential information at risk.\n\nWould you like to trust the certificate anyway?", comment: ""), challenge.protectionSpace.host)
4141
let controller = UIAlertController(title: title, message: message, preferredStyle: .alert)
@@ -58,7 +58,7 @@ open class HTTPAuthenticationAlertController {
5858
return controller
5959
}
6060

61-
static fileprivate func controllerForUserAuthenticationChallenge(_ challenge: URLAuthenticationChallenge) -> UIAlertController {
61+
private static func controllerForUserAuthenticationChallenge(_ challenge: URLAuthenticationChallenge) -> UIAlertController {
6262
let title = String(format: NSLocalizedString("Authentication required for host: %@", comment: "Popup title to ask for user credentials."), challenge.protectionSpace.host)
6363
let message = NSLocalizedString("Please enter your credentials", comment: "Popup message to ask for user credentials (fields shown below).")
6464
let controller = UIAlertController(title: title,

WordPressKit/NotificationSyncServiceRemote.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import Foundation
55
public class NotificationSyncServiceRemote: ServiceRemoteWordPressComREST {
66
// MARK: - Constants
77
//
8-
fileprivate let defaultPageSize = 100
8+
private let defaultPageSize = 100
99

1010

1111
// MARK: - Errors

WordPressKit/PluginServiceRemote.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ public class PluginServiceRemote: ServiceRemoteWordPressComREST {
182182
}
183183
}
184184

185-
fileprivate extension PluginServiceRemote {
185+
private extension PluginServiceRemote {
186186
func encoded(pluginID: String) -> String? {
187187
let allowedCharacters = CharacterSet.urlPathAllowed.subtracting(CharacterSet(charactersIn: "/"))
188188
guard let escapedPluginID = pluginID.addingPercentEncoding(withAllowedCharacters: allowedCharacters) else {

WordPressKit/RemoteBlogSettings.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,6 @@ public class RemoteBlogSettings: NSObject {
209209

210210
// MARK: - Private
211211

212-
fileprivate static let AscendingStringValue = "asc"
213-
fileprivate static let DescendingStringValue = "desc"
212+
private static let AscendingStringValue = "asc"
213+
private static let DescendingStringValue = "desc"
214214
}

WordPressKit/RemoteNotificationSettings.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ open class RemoteNotificationSettings {
6767
///
6868
/// - Returns: A native Swift dictionary, containing only the Boolean entries
6969
///
70-
fileprivate func filterNonBooleanEntries(_ dictionary: NSDictionary?) -> [String : Bool] {
70+
private func filterNonBooleanEntries(_ dictionary: NSDictionary?) -> [String : Bool] {
7171
var filtered = [String: Bool]()
7272
if dictionary == nil {
7373
return filtered
@@ -114,7 +114,7 @@ open class RemoteNotificationSettings {
114114
/// - channel: The communications channel that uses the current settings
115115
/// - settings: Raw dictionary containing the remote settings response
116116
///
117-
fileprivate init(channel: Channel, settings: NSDictionary?) {
117+
private init(channel: Channel, settings: NSDictionary?) {
118118
self.channel = channel
119119
self.streams = Stream.fromDictionary(settings)
120120
}
@@ -124,7 +124,7 @@ open class RemoteNotificationSettings {
124124
///
125125
/// - Parameter wpcomSettings: Dictionary containing the collection of WordPress.com Settings
126126
///
127-
fileprivate init(wpcomSettings: NSDictionary?) {
127+
private init(wpcomSettings: NSDictionary?) {
128128
// WordPress.com is a special scenario: It contains just one (unspecified) stream: Email
129129
self.channel = Channel.wordPressCom
130130
self.streams = [ Stream(kind: .Email, preferences: wpcomSettings) ]
@@ -135,7 +135,7 @@ open class RemoteNotificationSettings {
135135
///
136136
/// - Parameter blogSettings: Dictionary containing the collection of settings for a single blog
137137
///
138-
fileprivate convenience init(blogSettings: NSDictionary?) {
138+
private convenience init(blogSettings: NSDictionary?) {
139139
let blogId = blogSettings?["blog_id"] as? Int ?? Int.max
140140
self.init(channel: Channel.blog(blogId: blogId), settings: blogSettings)
141141
}
@@ -145,7 +145,7 @@ open class RemoteNotificationSettings {
145145
///
146146
/// - Parameter otherSettings: Dictionary containing the collection of "Other Settings"
147147
///
148-
fileprivate convenience init(otherSettings: NSDictionary?) {
148+
private convenience init(otherSettings: NSDictionary?) {
149149
self.init(channel: Channel.other, settings: otherSettings)
150150
}
151151

WordPressKit/SharingServiceRemote.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ open class SharingServiceRemote: ServiceRemoteWordPressComREST {
154154
///
155155
/// - Returns: An array of KeyringConnectionExternalUser instances.
156156
///
157-
fileprivate func externalUsersForKeyringConnection(_ externalUsers: NSArray) -> [KeyringConnectionExternalUser] {
157+
private func externalUsersForKeyringConnection(_ externalUsers: NSArray) -> [KeyringConnectionExternalUser] {
158158
let arr: [KeyringConnectionExternalUser] = externalUsers.map { (dict) -> KeyringConnectionExternalUser in
159159
let externalUser = KeyringConnectionExternalUser()
160160
externalUser.externalID = (dict as AnyObject).string(forKey: ConnectionDictionaryKeys.externalID) ?? externalUser.externalID
@@ -364,7 +364,7 @@ open class SharingServiceRemote: ServiceRemoteWordPressComREST {
364364
///
365365
/// - Returns: A `RemotePublicizeConnection` object.
366366
///
367-
fileprivate func remotePublicizeConnectionFromDictionary(_ dict: NSDictionary) -> RemotePublicizeConnection? {
367+
private func remotePublicizeConnectionFromDictionary(_ dict: NSDictionary) -> RemotePublicizeConnection? {
368368
guard let connectionID = dict.number(forKey: ConnectionDictionaryKeys.ID) else {
369369
return nil
370370
}
@@ -486,7 +486,7 @@ open class SharingServiceRemote: ServiceRemoteWordPressComREST {
486486
///
487487
/// - Returns: An array of `RemoteSharingButton` objects.
488488
///
489-
fileprivate func remoteSharingButtonsFromDictionary(_ buttons: NSArray) -> [RemoteSharingButton] {
489+
private func remoteSharingButtonsFromDictionary(_ buttons: NSArray) -> [RemoteSharingButton] {
490490
var order = 0
491491
let sharingButtons: [RemoteSharingButton] = buttons.map { (dict) -> RemoteSharingButton in
492492
let btn = RemoteSharingButton()
@@ -510,7 +510,7 @@ open class SharingServiceRemote: ServiceRemoteWordPressComREST {
510510
}
511511

512512

513-
fileprivate func dictionariesFromRemoteSharingButtons(_ buttons: [RemoteSharingButton]) -> [NSDictionary] {
513+
private func dictionariesFromRemoteSharingButtons(_ buttons: [RemoteSharingButton]) -> [NSDictionary] {
514514
return buttons.map({ (btn) -> NSDictionary in
515515

516516
let dict = NSMutableDictionary()

0 commit comments

Comments
 (0)