Skip to content
This repository has been archived by the owner on May 6, 2024. It is now read-only.

Commit

Permalink
feat: add support of Xcode 14.3.1 (#1770)
Browse files Browse the repository at this point in the history
  • Loading branch information
saeedbashir committed Jul 10, 2023
1 parent 762a7aa commit 8b2c815
Show file tree
Hide file tree
Showing 54 changed files with 159 additions and 132 deletions.
2 changes: 1 addition & 1 deletion Source/BlockCompletionApi.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public struct BlockCompletionApi {
"username": username,
"course_key": courseID,
"blocks" : [ blockID: 1.0]
]))
] as [String : Any]))

return NetworkRequest(
method: .POST,
Expand Down
2 changes: 1 addition & 1 deletion Source/CalendarSyncConfig.swift
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ struct CalendarSyncConfig {
Keys.disabledVersions.rawValue: disabledVersions,
Keys.selfPacedEnabled.rawValue: selfPacedEnabled,
Keys.instructorPacedEnabled.rawValue: instructorPacedEnabled,
]
] as [String : Any]
]
}
}
2 changes: 1 addition & 1 deletion Source/Core/Code/NSObject+OEXDeallocAction.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
// Copyright (c) 2015-2016 edX. All rights reserved.
//

@import Foundation;
#import <Foundation/Foundation.h>

NS_ASSUME_NONNULL_BEGIN

Expand Down
20 changes: 10 additions & 10 deletions Source/Core/Test/Code/NetworkManagerTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ class NetworkManagerTests: XCTestCase {
let sampleJSON = JSON([
"Some field" : true,
"Some other field" : ["a", "b"]
])
] as [String : Any])
let apiRequest = NetworkRequest(
method: HTTPMethod.POST,
path: "/something",
Expand Down Expand Up @@ -146,7 +146,7 @@ class NetworkManagerTests: XCTestCase {
expectation.fulfill()
}

waitForExpectations()
OEXWaitForExpectations()

XCTAssertEqual(manager.tokenStatus, AccessTokenStatus.expired)
}
Expand All @@ -172,7 +172,7 @@ class NetworkManagerTests: XCTestCase {
manager.responseCache.setCacheResponse(response, withData: originalData, forRequest: urlRequest as URLRequest, completion: {
cacheExpectation.fulfill()
})
waitForExpectations()
OEXWaitForExpectations()

// make a request
let networkData = "network".data(using: String.Encoding.utf8)!
Expand All @@ -196,7 +196,7 @@ class NetworkManagerTests: XCTestCase {
loadedExpectation.fulfill()
}
})
waitForExpectations()
OEXWaitForExpectations()
}

XCTAssertEqual(results.value, [originalData, networkData])
Expand All @@ -218,7 +218,7 @@ class NetworkManagerTests: XCTestCase {
stream.listen(owner) {_ in
loadedExpectation.fulfill()
}
waitForExpectations()
OEXWaitForExpectations()
}

XCTAssertTrue(cache.isEmpty, "Requests with no response shouldn't enter cache")
Expand All @@ -233,7 +233,7 @@ class NetworkManagerTests: XCTestCase {
expectation.fulfill()
}
}
waitForExpectations()
OEXWaitForExpectations()
XCTAssertFalse(stream.active)
XCTAssertNotNil(stream.error)
}
Expand All @@ -256,7 +256,7 @@ class NetworkManagerTests: XCTestCase {
stream.listenOnce(self) {_ in
loadedExpectation.fulfill()
}
waitForExpectations()
OEXWaitForExpectations()

let cacheExpectation = expectation(description: "Cache Load finished")
manager.responseCache.fetchCacheEntryWithRequest(urlRequest) {
Expand All @@ -265,7 +265,7 @@ class NetworkManagerTests: XCTestCase {
XCTAssertEqual($0!.headers, headers)
cacheExpectation.fulfill()
}
waitForExpectations()
OEXWaitForExpectations()
}

func testAuthenticationActionAuthenticateSuccess() {
Expand Down Expand Up @@ -309,7 +309,7 @@ class NetworkManagerTests: XCTestCase {
XCTAssertEqual(response.data?.rawString(), "{\n \"I Love\" : \"Cake\"\n}")
expectation.fulfill()
}
waitForExpectations()
OEXWaitForExpectations()
}

func testAuthenticationActionAuthenticateFailure() {
Expand Down Expand Up @@ -340,7 +340,7 @@ class NetworkManagerTests: XCTestCase {
XCTAssertEqual(response.data, nil)
expectation.fulfill()
}
waitForExpectations()
OEXWaitForExpectations()
}

func simpleStubResponseBuilder(_ statusCode: Int32, data: String) -> OHHTTPStubsResponse{
Expand Down
6 changes: 3 additions & 3 deletions Source/Core/Test/Code/PaginationInfoTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class PaginationInfoTests: XCTestCase {
"num_pages" : 3,
"previous" : "http://example.com/previous",
"next" : "http://example.com/next",
])
] as [String : Any])
let info = PaginationInfo(json: json)
XCTAssertEqual(info!.pageCount, 3)
XCTAssertEqual(info!.totalCount, 25)
Expand All @@ -31,7 +31,7 @@ class PaginationInfoTests: XCTestCase {
"count" : 25,
"previous" : "http://example.com/previous",
"next" : "http://example.com/next",
])
] as [String : Any])
let info = PaginationInfo(json: json)
XCTAssertNil(info)
}
Expand Down Expand Up @@ -76,7 +76,7 @@ class PaginationInfoTests: XCTestCase {
"num_pages" : 4
],
"results" : [1, 2, 3, 4]
]))
] as [String : Any]))
XCTAssertEqual(parse.value!.value, [1, 2, 3, 4])
XCTAssertEqual(parse.value!.pagination.pageCount, 4)
XCTAssertEqual(parse.value!.pagination.totalCount, 50)
Expand Down
20 changes: 10 additions & 10 deletions Source/Core/Test/Code/PersistentResponseCacheTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ class PersistentResponseCacheTests: XCTestCase {
cache.setCacheResponse(response, withData: data, forRequest: request) {
storeExpectation.fulfill()
}
waitForExpectations()
OEXWaitForExpectations()

let loadExpectation = expectation(description: "Cache loaded")
cache.fetchCacheEntryWithRequest(request) {entry in
Expand All @@ -72,7 +72,7 @@ class PersistentResponseCacheTests: XCTestCase {
XCTAssertEqual(entry!.statusCode, statusCode)
XCTAssertEqual(entry!.headers, headers)
}
waitForExpectations()
OEXWaitForExpectations()
}

func testDifferentMethods() {
Expand All @@ -87,7 +87,7 @@ class PersistentResponseCacheTests: XCTestCase {
cache.setCacheResponse(response, withData: getData, forRequest: getRequest) {
getStoreExpectation.fulfill()
}
waitForExpectations()
OEXWaitForExpectations()

let postStoreExpectation = expectation(description: "Cache stored POST")
let postData = "test data".data(using: String.Encoding.utf8)!
Expand All @@ -97,21 +97,21 @@ class PersistentResponseCacheTests: XCTestCase {
cache.setCacheResponse(response, withData: postData, forRequest: postRequest as URLRequest) {
postStoreExpectation.fulfill()
}
waitForExpectations()
OEXWaitForExpectations()

let getLoadExpectation = expectation(description: "Cache loaded GET")
cache.fetchCacheEntryWithRequest(getRequest) {
XCTAssertEqual($0!.data!, getData)
getLoadExpectation.fulfill()
}
waitForExpectations()
OEXWaitForExpectations()

let postLoadExpectation = expectation(description: "Cache loaded POST")
cache.fetchCacheEntryWithRequest(postRequest as URLRequest) {
XCTAssertEqual($0!.data!, postData)
postLoadExpectation.fulfill()
}
waitForExpectations()
OEXWaitForExpectations()
}

func testMiss() {
Expand All @@ -123,15 +123,15 @@ class PersistentResponseCacheTests: XCTestCase {
cache.setCacheResponse(response, withData: nil, forRequest: request) {
storeExpectation.fulfill()
}
waitForExpectations()
OEXWaitForExpectations()

let loadExpectation = expectation(description: "Cache loaded")
let otherRequest = URLRequest(url: URL(string : "http://edx.org")!)
cache.fetchCacheEntryWithRequest(otherRequest) {
XCTAssertNil($0)
loadExpectation.fulfill()
}
waitForExpectations()
OEXWaitForExpectations()
}


Expand Down Expand Up @@ -177,7 +177,7 @@ class PersistentResponseCacheTests: XCTestCase {
XCTAssertNil(entry)
expectation.fulfill()
}
waitForExpectations()
OEXWaitForExpectations()
}

// Since we use NSCoding to save cache entries, it's not super robust against
Expand Down Expand Up @@ -212,7 +212,7 @@ class PersistentResponseCacheTests: XCTestCase {
XCTAssertEqual(entry?.data, "test".data(using: String.Encoding.utf8))
expectation.fulfill()
}
waitForExpectations()
OEXWaitForExpectations()
}

}
2 changes: 1 addition & 1 deletion Source/CourseCatalogAPI.swift
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public struct CourseCatalogAPI {
"course_details" : [
"course_id": courseID,
"email_opt_in": emailOptIn
]
] as [String : Any]
])),
deserializer: .jsonResponse(enrollmentDeserializer)
)
Expand Down
4 changes: 2 additions & 2 deletions Source/CourseUpgradeAPI.swift
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public struct CourseUpgradeAPI {
body: .jsonBody(JSON([
"basket_id": basketID,
"payment_processor": PaymentProcessor
])),
] as [String : Any])),
deserializer: .jsonResponse(checkoutDeserializer)
)
}
Expand All @@ -68,7 +68,7 @@ public struct CourseUpgradeAPI {
"currency_code": currencyCode,
"purchaseToken": receipt,
"payment_processor": PaymentProcessor
])),
] as [String : Any])),
deserializer: .jsonResponse(executeDeserializer)
)
}
Expand Down
10 changes: 7 additions & 3 deletions Source/CourseUpgradeHelper.swift
Original file line number Diff line number Diff line change
Expand Up @@ -428,9 +428,9 @@ extension CourseUpgradeHelper {

private func savedIAPSKUsFromKeychain() -> [String : [InappPurchase]] {
guard let data = keychain.getData(IAPKeychainKey),
let purchases = try? NSKeyedUnarchiver.unarchiveTopLevelObjectWithData(data) as? [String : [InappPurchase]]
let purchases = try? NSKeyedUnarchiver.unarchivedObject(ofClasses: [InappPurchase.self, NSDictionary.self, NSString.self, NSArray.self], from: data) as? [String : [InappPurchase]] ?? [:]
else { return [:] }

return purchases
}

Expand All @@ -444,9 +444,13 @@ extension CourseUpgradeHelper {
}
}

class InappPurchase: NSObject, NSCoding {
class InappPurchase: NSObject, NSCoding, NSSecureCoding {
var status: Bool = false
var identifier: String = ""

static var supportsSecureCoding: Bool {
return true
}

required init?(coder: NSCoder) {
identifier = coder.decodeObject(forKey: "identifier") as? String ?? ""
Expand Down
2 changes: 1 addition & 1 deletion Source/DiscussionAPI.swift
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ public class DiscussionAPI {
"title" : newThread.title,
"raw_body" : newThread.rawBody,
"following" : follow
])
] as [String : Any])
return NetworkRequest(
method : HTTPMethod.POST,
path : "/api/discussion/v1/threads/",
Expand Down
4 changes: 2 additions & 2 deletions Source/JSON+ReadFromFile.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public extension JSON {
let data = try? NSData(contentsOf: url, options: NSData.ReadingOptions.mappedIfSafe) else
{
assertionFailure("Couldn't load data from file")
self.init([:])
self.init([:] as [String : Any])
return
}
self.init(data:data as Data)
Expand All @@ -34,7 +34,7 @@ public extension JSON {
let data = NSDictionary(contentsOf: url) else
{
assertionFailure("Couldn't load data from file")
self.init([:])
self.init([:] as [String : Any])
return
}
self.init(data)
Expand Down
2 changes: 1 addition & 1 deletion Source/SegmentAnalyticsTracker.swift
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ class SegmentAnalyticsTracker : NSObject, OEXAnalyticsTracker {
}

func trackScreen(withName screenName: String, courseID: String?, value: String?, additionalInfo info: [String : String]?) {
var properties: [String:Any] = [
var properties: [String : Any] = [
key_context: [
key_app_name: value_app_name
]
Expand Down
2 changes: 1 addition & 1 deletion Test/APIURLDefaultVersionTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class APIURLDefaultVersionTests: XCTestCase {
}

func testEmptyAPIURLConfig() {
let config = OEXConfig(dictionary:["API_URL_VERSION":[:]])
let config = OEXConfig(dictionary:["API_URL_VERSION":[:] as [String : Any]])
XCTAssertEqual(config.apiUrlVersionConfig.blocks, APIURLDefaultVersion.blocks.rawValue)
}

Expand Down
6 changes: 3 additions & 3 deletions Test/CourseCatalogDetailViewControllerTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ class CourseCatalogDetailViewControllerTests: SnapshotTestCase {
XCTAssertTrue(controller.t_isShowingOverlayMessage)
expectations.fulfill()
})
waitForExpectations()
OEXWaitForExpectations()
}
}

Expand All @@ -147,7 +147,7 @@ class CourseCatalogDetailViewControllerTests: SnapshotTestCase {
XCTAssertTrue(controller.t_isShowingAlertView())
expectations.fulfill()
})
waitForExpectations()
OEXWaitForExpectations()
}
}

Expand All @@ -173,7 +173,7 @@ class CourseCatalogDetailViewControllerTests: SnapshotTestCase {
controller.t_enrollInCourse {
completionCalled = true
}
waitForExpectations()
OEXWaitForExpectations()
XCTAssertTrue(completionCalled)
}
return environment
Expand Down
2 changes: 1 addition & 1 deletion Test/CourseContentPageViewControllerTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class CourseContentPageViewControllerTests: SnapshotTestCase {
}
}
}
self.waitForExpectations()
self.OEXWaitForExpectations()
}
return controller
}
Expand Down
4 changes: 2 additions & 2 deletions Test/CourseDashboardViewControllerTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ class CourseDashboardViewControllerTests: SnapshotTestCase {
expectations.fulfill()
}

waitForExpectations()
OEXWaitForExpectations()

inScreenNavigationContext(controller, action: { () -> () in
assertSnapshotValidWithContent(controller.navigationController!)
Expand Down Expand Up @@ -146,7 +146,7 @@ class CourseDashboardViewControllerTests: SnapshotTestCase {
expectations.fulfill()
}

waitForExpectations()
OEXWaitForExpectations()


inScreenNavigationContext(controller, action: { () -> () in
Expand Down
2 changes: 1 addition & 1 deletion Test/CourseDataManagerTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class CourseDataManagerTests: XCTestCase {
XCTAssertEqual(rootBlock.value!.blockID, rootID, file : file, line : line)
expectation.fulfill()
}
waitForExpectations()
OEXWaitForExpectations()
}

func addInterceptorForOutline(_ networkManager: MockNetworkManager, outline : CourseOutline) {
Expand Down
Loading

0 comments on commit 8b2c815

Please sign in to comment.