Skip to content
This repository was archived by the owner on Sep 15, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
64c8614
Merge branch 'develop' into issue/79-migrate-swift-5
mindgraffiti Mar 11, 2020
6697c8f
Update shared pod schemes to 11.3
mindgraffiti Mar 11, 2020
c932e37
`pod update` to get the latest acceptable changes for WP pods
mindgraffiti Mar 11, 2020
d1024a8
`pod update` to get latest internal pod updates
mindgraffiti Mar 11, 2020
8a39e55
Bump dependency pod versions in podspec
mindgraffiti Mar 11, 2020
06e28dc
Bump podspec version
mindgraffiti Mar 11, 2020
b668dfe
Update OHHTTPStubs pod to latest version (8.0 and 9.0 support Swift 5)
mindgraffiti Mar 11, 2020
b061d25
Update checksum for OHHTTPStubs
mindgraffiti Mar 11, 2020
78dc4c5
Remove `OH` prefix from OHHTTPStubs classes, per 9.0 update
mindgraffiti Mar 11, 2020
643e45a
Update unit tests framework to use Swift 5
mindgraffiti Mar 12, 2020
caadb96
Migrate main project to Swift 5
mindgraffiti Mar 12, 2020
3682253
Update code to Swift 5
mindgraffiti Mar 12, 2020
34c1a75
Enable base internationalization
mindgraffiti Mar 12, 2020
e70f44e
Update podspec swift version requirement to 5.0
mindgraffiti Mar 12, 2020
cd056a1
Bug fix #149 - do not output social login to logs
mindgraffiti Mar 12, 2020
ef969b0
Merge branch 'develop' into issue/79-migrate-swift-5
mindgraffiti Mar 12, 2020
1a219b3
Update podspec to 4.6.0-beta.6
mindgraffiti Mar 12, 2020
08ab35a
Delete code migration substitutions and use code that is easier to read
mindgraffiti Mar 13, 2020
b254c06
Delete generated code substitution and use easier to read code
mindgraffiti Mar 13, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ platform :ios, '11.0'
def wordpresskit_pods
pod 'Alamofire', '~> 4.8.0'
pod 'CocoaLumberjack', '3.4.2'
pod 'WordPressShared', '~> 1.8.13-beta'
pod 'WordPressShared', '~> 1.8.15-beta'
# pod 'WordPressShared', :git => 'https://github.com/wordpress-mobile/WordPress-iOS-Shared.git', :commit => 'efe5a065f3ace331353595ef85eef502baa23497'
pod 'NSObject-SafeExpectations', '~> 0.0.4'
pod 'wpxmlrpc', '0.8.5-beta.1'
Expand All @@ -28,7 +28,7 @@ target 'WordPressKitTests' do
project 'WordPressKit.xcodeproj'
wordpresskit_pods

pod 'OHHTTPStubs', '6.1.0'
pod 'OHHTTPStubs/Swift', '6.1.0'
pod 'OHHTTPStubs', '9.0'
pod 'OHHTTPStubs/Swift', '9.0'
pod 'OCMock', '~> 3.4.2'
end
30 changes: 15 additions & 15 deletions Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,23 @@ PODS:
- FormatterKit/Resources
- NSObject-SafeExpectations (0.0.4)
- OCMock (3.4.3)
- OHHTTPStubs (6.1.0):
- OHHTTPStubs/Default (= 6.1.0)
- OHHTTPStubs/Core (6.1.0)
- OHHTTPStubs/Default (6.1.0):
- OHHTTPStubs (9.0.0):
- OHHTTPStubs/Default (= 9.0.0)
- OHHTTPStubs/Core (9.0.0)
- OHHTTPStubs/Default (9.0.0):
- OHHTTPStubs/Core
- OHHTTPStubs/JSON
- OHHTTPStubs/NSURLSession
- OHHTTPStubs/OHPathHelpers
- OHHTTPStubs/JSON (6.1.0):
- OHHTTPStubs/JSON (9.0.0):
- OHHTTPStubs/Core
- OHHTTPStubs/NSURLSession (6.1.0):
- OHHTTPStubs/NSURLSession (9.0.0):
- OHHTTPStubs/Core
- OHHTTPStubs/OHPathHelpers (6.1.0)
- OHHTTPStubs/Swift (6.1.0):
- OHHTTPStubs/OHPathHelpers (9.0.0)
- OHHTTPStubs/Swift (9.0.0):
- OHHTTPStubs/Default
- UIDeviceIdentifier (1.4.0)
- WordPressShared (1.8.13-beta.3):
- WordPressShared (1.8.15):
- CocoaLumberjack (~> 3.4)
- FormatterKit/TimeIntervalFormatter (= 1.8.2)
- wpxmlrpc (0.8.5-beta.1)
Expand All @@ -37,10 +37,10 @@ DEPENDENCIES:
- CocoaLumberjack (= 3.4.2)
- NSObject-SafeExpectations (~> 0.0.4)
- OCMock (~> 3.4.2)
- OHHTTPStubs (= 6.1.0)
- OHHTTPStubs/Swift (= 6.1.0)
- OHHTTPStubs (= 9.0)
- OHHTTPStubs/Swift (= 9.0)
- UIDeviceIdentifier (~> 1)
- WordPressShared (~> 1.8.13-beta)
- WordPressShared (~> 1.8.15-beta)
- wpxmlrpc (= 0.8.5-beta.1)

SPEC REPOS:
Expand All @@ -61,11 +61,11 @@ SPEC CHECKSUMS:
FormatterKit: 4b8f29acc9b872d5d12a63efb560661e8f2e1b98
NSObject-SafeExpectations: ab8fe623d36b25aa1f150affa324e40a2f3c0374
OCMock: 43565190abc78977ad44a61c0d20d7f0784d35ab
OHHTTPStubs: 1e21c7d2c084b8153fc53d48400d8919d2d432d0
OHHTTPStubs: cb29d2a9d09a828ecb93349a2b0c64f99e0db89f
UIDeviceIdentifier: 44f805037d21b94394821828f4fcaba34b38c2d0
WordPressShared: 98ebacf932b8f7b99a6ccb9f61b3fb1792f82d55
WordPressShared: 02e0947034648cbd7251ffcc10f64d512f93a53b
wpxmlrpc: d758b6ad17723d31d06493acc932f6d9b340de95

PODFILE CHECKSUM: fab42fa1edfada850c4e7c8cda4f3c8748eaa9ca
PODFILE CHECKSUM: f9aa630fd36cfb01c9eea628263740a2703d39e9

COCOAPODS: 1.8.4
6 changes: 3 additions & 3 deletions WordPressKit.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = "WordPressKit"
s.version = "4.6.0-beta.5"
s.version = "4.6.0-beta.6"
s.summary = "WordPressKit offers a clean and simple WordPress.com and WordPress.org API."

s.description = <<-DESC
Expand All @@ -12,7 +12,7 @@ Pod::Spec.new do |s|
s.license = "GPLv2"
s.author = { "WordPress" => "mobile@automattic.com" }
s.platform = :ios, "11.0"
s.swift_version = '4.2'
s.swift_version = '5.0'
s.source = { :git => "https://github.com/wordpress-mobile/WordPressKit-iOS.git", :tag => s.version.to_s }
s.source_files = 'WordPressKit/**/*.{h,m,swift}'
s.private_header_files = "WordPressKit/Private/*.h"
Expand All @@ -21,7 +21,7 @@ Pod::Spec.new do |s|

s.dependency 'Alamofire', '~> 4.8.0'
s.dependency 'CocoaLumberjack', '~> 3.4'
s.dependency 'WordPressShared', '~> 1.8.13-beta'
s.dependency 'WordPressShared', '~> 1.8.15-beta'
s.dependency 'NSObject-SafeExpectations', '0.0.4'
s.dependency 'wpxmlrpc', '0.8.5-beta.1'
s.dependency 'UIDeviceIdentifier', '~> 1'
Expand Down
16 changes: 12 additions & 4 deletions WordPressKit.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -1915,23 +1915,23 @@
TargetAttributes = {
9368C77A1EC5EF1B0092CE8E = {
CreatedOnToolsVersion = 8.3.2;
LastSwiftMigration = 0910;
LastSwiftMigration = 1130;
ProvisioningStyle = Automatic;
};
9368C7831EC5EF1B0092CE8E = {
CreatedOnToolsVersion = 8.3.2;
LastSwiftMigration = 0910;
LastSwiftMigration = 1130;
ProvisioningStyle = Automatic;
};
};
};
buildConfigurationList = 9368C7751EC5EF1B0092CE8E /* Build configuration list for PBXProject "WordPressKit" */;
compatibilityVersion = "Xcode 3.2";
developmentRegion = English;
developmentRegion = en;
hasScannedForEncodings = 0;
knownRegions = (
English,
en,
Base,
);
mainGroup = 9368C7711EC5EF1B0092CE8E;
productRefGroup = 9368C77C1EC5EF1B0092CE8E /* Products */;
Expand Down Expand Up @@ -2610,6 +2610,7 @@
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 5.0;
};
name = Debug;
};
Expand All @@ -2635,6 +2636,7 @@
PRODUCT_BUNDLE_IDENTIFIER = com.automattic.WordPressKit;
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
SWIFT_VERSION = 5.0;
};
name = Release;
};
Expand All @@ -2655,6 +2657,7 @@
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OBJC_BRIDGING_HEADER = "WordPressKitTests/WordPressKitTests-Bridging-Header.h";
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 5.0;
};
name = Debug;
};
Expand All @@ -2674,6 +2677,7 @@
PRODUCT_BUNDLE_IDENTIFIER = com.automattic.WordPressKitTests;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OBJC_BRIDGING_HEADER = "WordPressKitTests/WordPressKitTests-Bridging-Header.h";
SWIFT_VERSION = 5.0;
};
name = Release;
};
Expand Down Expand Up @@ -2756,6 +2760,7 @@
PRODUCT_BUNDLE_IDENTIFIER = com.automattic.WordPressKit;
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
SWIFT_VERSION = 5.0;
};
name = "Release-Internal";
};
Expand All @@ -2775,6 +2780,7 @@
PRODUCT_BUNDLE_IDENTIFIER = com.automattic.WordPressKitTests;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OBJC_BRIDGING_HEADER = "WordPressKitTests/WordPressKitTests-Bridging-Header.h";
SWIFT_VERSION = 5.0;
};
name = "Release-Internal";
};
Expand Down Expand Up @@ -2857,6 +2863,7 @@
PRODUCT_BUNDLE_IDENTIFIER = com.automattic.WordPressKit;
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
SWIFT_VERSION = 5.0;
};
name = "Release-Alpha";
};
Expand All @@ -2876,6 +2883,7 @@
PRODUCT_BUNDLE_IDENTIFIER = com.automattic.WordPressKitTests;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OBJC_BRIDGING_HEADER = "WordPressKitTests/WordPressKitTests-Bridging-Header.h";
SWIFT_VERSION = 5.0;
};
name = "Release-Alpha";
};
Expand Down
24 changes: 10 additions & 14 deletions WordPressKit.xcodeproj/xcshareddata/xcschemes/WordPressKit.xcscheme
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1020"
LastUpgradeVersion = "1130"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand All @@ -27,6 +27,15 @@
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "9368C77A1EC5EF1B0092CE8E"
BuildableName = "WordPressKit.framework"
BlueprintName = "WordPressKit"
ReferencedContainer = "container:WordPressKit.xcodeproj">
</BuildableReference>
</MacroExpansion>
<Testables>
<TestableReference
skipped = "NO">
Expand All @@ -44,17 +53,6 @@
</SkippedTests>
</TestableReference>
</Testables>
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "9368C77A1EC5EF1B0092CE8E"
BuildableName = "WordPressKit.framework"
BlueprintName = "WordPressKit"
ReferencedContainer = "container:WordPressKit.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
Expand All @@ -75,8 +73,6 @@
ReferencedContainer = "container:WordPressKit.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1020"
LastUpgradeVersion = "1130"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand All @@ -23,8 +23,6 @@
</BuildableReference>
</TestableReference>
</Testables>
<AdditionalOptions>
</AdditionalOptions>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
Expand All @@ -36,8 +34,6 @@
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
Expand Down
10 changes: 5 additions & 5 deletions WordPressKit/CocoaLumberjack.swift
Original file line number Diff line number Diff line change
Expand Up @@ -68,23 +68,23 @@ public func _DDLogMessage(_ message: @autoclosure () -> String, level: DDLogLeve
}

public func DDLogDebug(_ message: @autoclosure () -> String, level: DDLogLevel = defaultDebugLevel, context: Int = 0, file: StaticString = #file, function: StaticString = #function, line: UInt = #line, tag: Any? = nil, asynchronous async: Bool = true, ddlog: DDLog = DDLog.sharedInstance) {
_DDLogMessage(message, level: level, flag: .debug, context: context, file: file, function: function, line: line, tag: tag, asynchronous: async, ddlog: ddlog)
_DDLogMessage(message(), level: level, flag: .debug, context: context, file: file, function: function, line: line, tag: tag, asynchronous: async, ddlog: ddlog)
}

public func DDLogInfo(_ message: @autoclosure () -> String, level: DDLogLevel = defaultDebugLevel, context: Int = 0, file: StaticString = #file, function: StaticString = #function, line: UInt = #line, tag: Any? = nil, asynchronous async: Bool = true, ddlog: DDLog = DDLog.sharedInstance) {
_DDLogMessage(message, level: level, flag: .info, context: context, file: file, function: function, line: line, tag: tag, asynchronous: async, ddlog: ddlog)
_DDLogMessage(message(), level: level, flag: .info, context: context, file: file, function: function, line: line, tag: tag, asynchronous: async, ddlog: ddlog)
}

public func DDLogWarn(_ message: @autoclosure () -> String, level: DDLogLevel = defaultDebugLevel, context: Int = 0, file: StaticString = #file, function: StaticString = #function, line: UInt = #line, tag: Any? = nil, asynchronous async: Bool = true, ddlog: DDLog = DDLog.sharedInstance) {
_DDLogMessage(message, level: level, flag: .warning, context: context, file: file, function: function, line: line, tag: tag, asynchronous: async, ddlog: ddlog)
_DDLogMessage(message(), level: level, flag: .warning, context: context, file: file, function: function, line: line, tag: tag, asynchronous: async, ddlog: ddlog)
}

public func DDLogVerbose(_ message: @autoclosure () -> String, level: DDLogLevel = defaultDebugLevel, context: Int = 0, file: StaticString = #file, function: StaticString = #function, line: UInt = #line, tag: Any? = nil, asynchronous async: Bool = true, ddlog: DDLog = DDLog.sharedInstance) {
_DDLogMessage(message, level: level, flag: .verbose, context: context, file: file, function: function, line: line, tag: tag, asynchronous: async, ddlog: ddlog)
_DDLogMessage(message(), level: level, flag: .verbose, context: context, file: file, function: function, line: line, tag: tag, asynchronous: async, ddlog: ddlog)
}

public func DDLogError(_ message: @autoclosure () -> String, level: DDLogLevel = defaultDebugLevel, context: Int = 0, file: StaticString = #file, function: StaticString = #function, line: UInt = #line, tag: Any? = nil, asynchronous async: Bool = false, ddlog: DDLog = DDLog.sharedInstance) {
_DDLogMessage(message, level: level, flag: .error, context: context, file: file, function: function, line: line, tag: tag, asynchronous: async, ddlog: ddlog)
_DDLogMessage(message(), level: level, flag: .error, context: context, file: file, function: function, line: line, tag: tag, asynchronous: async, ddlog: ddlog)
}

/// Returns a String of the current filename, without full path or extension.
Expand Down
8 changes: 5 additions & 3 deletions WordPressKit/PluginDirectoryEntry.swift
Original file line number Diff line number Diff line change
Expand Up @@ -84,16 +84,18 @@ extension PluginDirectoryEntry: Codable {
rating = try container.decode(Int.self, forKey: .rating)

let icons = try? container.decodeIfPresent([String: String].self, forKey: .icons)
icon = icons??["2x"].flatMap(URL.init(string:))
icon = icons?["2x"].flatMap({ (s) -> URL? in
URL(string: s)
})

// If there's no hi-res version of the banner, the API returns `high: false`, instead of something more logical,
// like an empty string or `null`, hence the dance below.
let banners = try? container.nestedContainer(keyedBy: BannersKeys.self, forKey: .banners)

if let highRes = try? banners?.decodeIfPresent(String.self, forKey: .high) {
banner = highRes.flatMap(URL.init(string:))
banner = URL(string: highRes)
} else if let lowRes = try? banners?.decodeIfPresent(String.self, forKey: .low) {
banner = lowRes.flatMap(URL.init(string:))
banner = URL(string: lowRes)
} else {
banner = nil
}
Expand Down
2 changes: 1 addition & 1 deletion WordPressKit/WordPressComOAuthClient.swift
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ public final class WordPressComOAuthClient: NSObject {
.responseJSON(completionHandler: { response in
switch response.result {
case .success(let responseObject):
DDLogVerbose("Received Social Login Oauth response: \(self.cleanedUpResponseForLogging(responseObject as AnyObject? ?? "nil" as AnyObject))")
Comment thread
diegoreymendez marked this conversation as resolved.
DDLogVerbose("Received Social Login Oauth response.")

let defaultError = NSError(domain: WordPressComOAuthClient.WordPressComOAuthErrorDomain,
code: WordPressComOAuthError.unknown.rawValue,
Expand Down
3 changes: 1 addition & 2 deletions WordPressKit/WordPressOrgXMLRPCValidator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -325,8 +325,7 @@ open class WordPressOrgXMLRPCValidator: NSObject {
guard let data = data,
let responseString = String(data: data, encoding: String.Encoding.utf8),
let parser = WordPressRSDParser(xmlString: responseString),
let endpoint = (try? parser.parsedEndpoint()),
let xmlrpc = endpoint,
let xmlrpc = try? parser.parsedEndpoint(),
let xmlrpcURL = URL(string: xmlrpc)
else {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe the whole guard statement can be simplified like so?

guard let data = data,
let responseString = String(data: data, encoding: String.Encoding.utf8),
let parser = WordPressRSDParser(xmlString: responseString),
let xmlrpc = try? parser.parsedEndpoint(),
let xmlrpcURL = URL(string: xmlrpc)
else {
failure(WordPressOrgXMLRPCValidatorError.invalid as NSError)
return
}

failure(WordPressOrgXMLRPCValidatorError.invalid as NSError)
Expand Down
8 changes: 4 additions & 4 deletions WordPressKitTests/BlogServiceRemoteRESTTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ @implementation BlogServiceRemoteRESTTests
- (void)tearDown
{
[super tearDown];
[OHHTTPStubs removeAllStubs];
[HTTPStubs removeAllStubs];
}


Expand Down Expand Up @@ -136,10 +136,10 @@ - (void)testSyncBlogSettingsParsesCorrectlyEveryField
BlogServiceRemoteREST *service = [[BlogServiceRemoteREST alloc] initWithWordPressComRestApi:api siteID:blogID];
XCTAssertNotNil(service, @"Error while creating the new service");

[OHHTTPStubs stubRequestsPassingTest:^BOOL(NSURLRequest *request) {
[HTTPStubs stubRequestsPassingTest:^BOOL(NSURLRequest *request) {
return [[request.URL absoluteString] containsString:endpoint];
} withStubResponse:^OHHTTPStubsResponse *(NSURLRequest *request) {
return [OHHTTPStubsResponse responseWithFileAtPath:responsePath
} withStubResponse:^HTTPStubsResponse *(NSURLRequest *request) {
return [HTTPStubsResponse responseWithFileAtPath:responsePath
statusCode:200
headers:@{@"Content-Type":@"application/json"}];
}];
Expand Down
2 changes: 1 addition & 1 deletion WordPressKitTests/ReaderSiteServiceRemoteTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ class ReaderSiteServiceRemoteTests: XCTestCase {
let testURLString = "http://www.wordpress.com"
let testURL = URL(string: testURLString)!
stub(condition:{request in request.url?.absoluteString == testURLString}) { request in
return OHHTTPStubsResponse(error: NSError(domain: NSURLErrorDomain, code: NSURLErrorUnknown, userInfo: nil))
return HTTPStubsResponse(error: NSError(domain: NSURLErrorDomain, code: NSURLErrorUnknown, userInfo: nil))
}

let expect = self.expectation(description: "One callback should be invoked")
Expand Down
Loading