Skip to content
This repository has been archived by the owner on Dec 14, 2021. It is now read-only.

migrate to Swift 5 #1037

Merged
merged 3 commits into from Jun 3, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 4 additions & 4 deletions Cartfile
@@ -1,12 +1,12 @@
github "Quick/Quick"
github "Quick/Nimble"
github "ReactiveX/RxSwift" ~> 4.4.0
github "ReactiveX/RxSwift"
github "RxSwiftCommunity/RxDataSources" "81b709c28b8ceb5cddc8c2262d009ea8735f0893"
github "RxSwiftCommunity/RxOptional" ~> 3.1.3
github "mozilla-mobile/telemetry-ios"
github "jrendel/SwiftKeychainWrapper" ~> 3.0
github "jrendel/SwiftKeychainWrapper"
github "mozilla-mobile/MappaMundi" "master"
github "mozilla/application-services" "v0.29.0"
github "adjust/ios_sdk" ~> 4.14.1
github "getsentry/sentry-cocoa" "4.1.0"
github "adjust/ios_sdk"
github "getsentry/sentry-cocoa"
github "ashleymills/Reachability.swift" "v4.3.0"
8 changes: 4 additions & 4 deletions Cartfile.resolved
@@ -1,13 +1,13 @@
github "Quick/Nimble" "v8.0.1"
github "Quick/Quick" "v2.1.0"
github "ReactiveX/RxSwift" "4.5.0"
github "ReactiveX/RxSwift" "5.0.1"
github "RxSwiftCommunity/RxDataSources" "81b709c28b8ceb5cddc8c2262d009ea8735f0893"
github "RxSwiftCommunity/RxOptional" "3.7.0"
github "adjust/ios_sdk" "v4.17.2"
github "adjust/ios_sdk" "v4.17.3"
github "apple/swift-protobuf" "1.5.0"
github "ashleymills/Reachability.swift" "v4.3.0"
github "getsentry/sentry-cocoa" "4.1.0"
github "getsentry/sentry-cocoa" "4.3.4"
github "jrendel/SwiftKeychainWrapper" "3.3.0"
github "mozilla-mobile/MappaMundi" "4341a2cf9f46b62857df0933cfa4405050b6a77b"
github "mozilla-mobile/MappaMundi" "02b6f0b404d0a7178c47c073550936016f42981e"
github "mozilla-mobile/telemetry-ios" "1.1.1"
github "mozilla/application-services" "v0.29.0"
31 changes: 20 additions & 11 deletions Lockbox.xcodeproj/project.pbxproj
Expand Up @@ -237,6 +237,8 @@
7DDEAA6C2124B7A700A7D521 /* AuthenticationServices.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 7D80F3072118DCC700DA191B /* AuthenticationServices.framework */; };
7DDEAA712124CEB100A7D521 /* DataStore.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7DDEAA702124CEB100A7D521 /* DataStore.swift */; };
7DE5896E2125D20C005CFF47 /* CredentialAccountStore.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7DE5896D2125D20C005CFF47 /* CredentialAccountStore.swift */; };
7DF455DC22A1D3D200207285 /* RxRelay.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 7DF455DB22A1D3D200207285 /* RxRelay.framework */; };
7DF455DD22A1D3F700207285 /* RxRelay.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 7DF455DB22A1D3D200207285 /* RxRelay.framework */; };
7DF469CA1F9F8FDA00375C74 /* RxTest.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 7DF469C91F9F8FDA00375C74 /* RxTest.framework */; };
7DF469CB1F9F8FE400375C74 /* RxTest.framework in CopyFiles */ = {isa = PBXBuildFile; fileRef = 7DF469C91F9F8FDA00375C74 /* RxTest.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
7DFF2EEB21382D5C00F001ED /* SharedAssets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 7DFF2EEA21382D5C00F001ED /* SharedAssets.xcassets */; };
Expand Down Expand Up @@ -556,6 +558,7 @@
7DDEAA702124CEB100A7D521 /* DataStore.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DataStore.swift; sourceTree = "<group>"; };
7DE5896D2125D20C005CFF47 /* CredentialAccountStore.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CredentialAccountStore.swift; sourceTree = "<group>"; };
7DEA1C4120362E09008AD7C4 /* Differentiator.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Differentiator.framework; path = Carthage/Build/iOS/Differentiator.framework; sourceTree = "<group>"; };
7DF455DB22A1D3D200207285 /* RxRelay.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = RxRelay.framework; path = Carthage/Build/iOS/RxRelay.framework; sourceTree = "<group>"; };
7DF469C31F9F8F8000375C74 /* RxSwift.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = RxSwift.framework; path = Carthage/Build/iOS/RxSwift.framework; sourceTree = "<group>"; };
7DF469C71F9F8FD500375C74 /* RxBlocking.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = RxBlocking.framework; path = Carthage/Build/iOS/RxBlocking.framework; sourceTree = "<group>"; };
7DF469C91F9F8FDA00375C74 /* RxTest.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = RxTest.framework; path = Carthage/Build/iOS/RxTest.framework; sourceTree = "<group>"; };
Expand Down Expand Up @@ -716,6 +719,7 @@
391233752090E56F00CB0233 /* SwiftKeychainWrapper.framework in Frameworks */,
7D5F1D7B20866A9400688DEA /* RxDataSources.framework in Frameworks */,
7D5F1D7E20866A9400688DEA /* Telemetry.framework in Frameworks */,
7DF455DC22A1D3D200207285 /* RxRelay.framework in Frameworks */,
7D5F1D7C20866A9400688DEA /* RxOptional.framework in Frameworks */,
7D5F1D7D20866A9400688DEA /* RxSwift.framework in Frameworks */,
7D1E758D224A7B3F00C06B4C /* SwiftProtobuf.framework in Frameworks */,
Expand All @@ -731,6 +735,7 @@
buildActionMask = 2147483647;
files = (
7DDEAA652124B27600A7D521 /* RxCocoa.framework in Frameworks */,
7DF455DD22A1D3F700207285 /* RxRelay.framework in Frameworks */,
7D11623D225FB839009097C7 /* MozillaAppServices.framework in Frameworks */,
7DDEAA662124B27900A7D521 /* RxDataSources.framework in Frameworks */,
7DDEAA672124B27F00A7D521 /* RxSwift.framework in Frameworks */,
Expand Down Expand Up @@ -1042,6 +1047,7 @@
7D1B1A8A1F98F86400C1F5FF /* Frameworks */ = {
isa = PBXGroup;
children = (
7DF455DB22A1D3D200207285 /* RxRelay.framework */,
7D897EAC2260FFA800257946 /* Reachability.framework */,
7D11623E225FDD27009097C7 /* SystemConfiguration.framework */,
7D07FE91225E2DB60000B030 /* Network.framework */,
Expand Down Expand Up @@ -1385,13 +1391,13 @@
};
7D1B1AC31F99028D00C1F5FF = {
CreatedOnToolsVersion = 9.0;
LastSwiftMigration = 0900;
LastSwiftMigration = 1020;
ProvisioningStyle = Automatic;
TestTargetID = 7D5DF8721F87F2600039B23E;
};
7D5DF8721F87F2600039B23E = {
CreatedOnToolsVersion = 9.0;
LastSwiftMigration = 1000;
LastSwiftMigration = 1020;
ProvisioningStyle = Automatic;
SystemCapabilities = {
com.apple.ApplicationGroups.iOS = {
Expand All @@ -1404,6 +1410,7 @@
};
7D80F3052118DCC700DA191B = {
CreatedOnToolsVersion = 10.0;
LastSwiftMigration = 1020;
ProvisioningStyle = Automatic;
SystemCapabilities = {
com.apple.ApplicationGroups.iOS = {
Expand Down Expand Up @@ -1528,6 +1535,7 @@
"$(SRCROOT)/Carthage/Build/iOS/Sentry.framework",
"$(SRCROOT)/Carthage/Build/iOS/SwiftProtobuf.framework",
"$(SRCROOT)/Carthage/Build/iOS/Reachability.framework",
"$(SRCROOT)/Carthage/Build/iOS/RxRelay.framework",
);
name = "Run Script";
outputPaths = (
Expand All @@ -1542,6 +1550,7 @@
"$(BUILT_PRODUCTS_DIR)/$(FRAMEWORKS_FOLDER_PATH)/AdjustSdk.framework",
"$(BUILT_PRODUCTS_DIR)/$(FRAMEWORKS_FOLDER_PATH)/Sentry.framework",
"$(BUILT_PRODUCTS_DIR)/$(FRAMEWORKS_FOLDER_PATH)/Reachability.framework",
"$(BUILT_PRODUCTS_DIR)/$(FRAMEWORKS_FOLDER_PATH)/RxRelay.framework",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
Expand Down Expand Up @@ -2138,7 +2147,7 @@
SWIFT_OBJC_BRIDGING_HEADER = "lockbox-ios/Common/Resources/lockbox-ios-Bridging-Header.h";
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_PRECOMPILE_BRIDGING_HEADER = NO;
SWIFT_VERSION = 4.2;
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Firefox Lockbox.app/Firefox Lockbox";
};
Expand All @@ -2163,7 +2172,7 @@
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OBJC_BRIDGING_HEADER = "lockbox-ios/Common/Resources/lockbox-ios-Bridging-Header.h";
SWIFT_PRECOMPILE_BRIDGING_HEADER = NO;
SWIFT_VERSION = 4.2;
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Firefox Lockbox.app/Firefox Lockbox";
};
Expand Down Expand Up @@ -2324,7 +2333,7 @@
SWIFT_OBJC_BRIDGING_HEADER = "lockbox-ios/Common/Resources/lockbox-ios-Bridging-Header.h";
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_PRECOMPILE_BRIDGING_HEADER = NO;
SWIFT_VERSION = 4.2;
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Debug;
Expand Down Expand Up @@ -2362,7 +2371,7 @@
SWIFT_INCLUDE_PATHS = "${PROJECT_DIR}/lockbox-ios/CommonCrypto/**";
SWIFT_OBJC_BRIDGING_HEADER = "lockbox-ios/Common/Resources/lockbox-ios-Bridging-Header.h";
SWIFT_PRECOMPILE_BRIDGING_HEADER = NO;
SWIFT_VERSION = 4.2;
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Release;
Expand All @@ -2389,7 +2398,7 @@
PRODUCT_BUNDLE_IDENTIFIER = org.mozilla.ios.Lockbox.CredentialProvider;
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
SWIFT_VERSION = 4.2;
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Debug;
Expand All @@ -2415,7 +2424,7 @@
PRODUCT_BUNDLE_IDENTIFIER = org.mozilla.ios.Lockbox.adhoc.CredentialProvider;
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
SWIFT_VERSION = 4.2;
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Branch;
Expand All @@ -2441,7 +2450,7 @@
PRODUCT_BUNDLE_IDENTIFIER = org.mozilla.ios.Lockbox.CredentialProvider;
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
SWIFT_VERSION = 4.2;
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Release;
Expand Down Expand Up @@ -2544,7 +2553,7 @@
SWIFT_OBJC_BRIDGING_HEADER = "lockbox-ios/Common/Resources/lockbox-ios-Bridging-Header.h";
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_PRECOMPILE_BRIDGING_HEADER = NO;
SWIFT_VERSION = 4.2;
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Branch;
Expand Down Expand Up @@ -2573,7 +2582,7 @@
SWIFT_OBJC_BRIDGING_HEADER = "lockbox-ios/Common/Resources/lockbox-ios-Bridging-Header.h";
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_PRECOMPILE_BRIDGING_HEADER = NO;
SWIFT_VERSION = 4.2;
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Lockbox-Branch.app/Lockbox-Branch";
};
Expand Down
5 changes: 4 additions & 1 deletion Shared/Common/Helpers/Bytes.swift
Expand Up @@ -11,7 +11,10 @@ open class Bytes {
open class func generateRandomBytes(_ len: UInt) -> Data {
let len = Int(len)
var data = Data(count: len)
data.withUnsafeMutableBytes { (p: UnsafeMutablePointer<UInt8>) in
data.withUnsafeMutableBytes { (p: UnsafeMutableRawBufferPointer) in
guard let p = p.bindMemory(to: UInt8.self).baseAddress else {
fatalError("Random byte generation failed.")
}
if (SecRandomCopyBytes(kSecRandomDefault, len, p) != errSecSuccess) {
fatalError("Random byte generation failed.")
}
Expand Down
12 changes: 9 additions & 3 deletions Shared/Store/BaseAccountStore.swift
Expand Up @@ -82,15 +82,21 @@ class BaseAccountStore {

guard let key = accessToken?.key,
let token = accessToken?.token
else { return }
else {
self?._syncCredentials.onNext(nil)
return
}

guard let tokenURL = try? self?.fxa?.getTokenServerEndpointURL() else { return }
guard let tokenURL = try? self?.fxa?.getTokenServerEndpointURL() else {
self?._syncCredentials.onNext(nil)
return
}

let syncInfo = SyncUnlockInfo(
kid: key.kid,
fxaAccessToken: token,
syncKey: key.k,
tokenserverURL: tokenURL!.absoluteString
tokenserverURL: tokenURL.absoluteString
)

self?._syncCredentials.onNext(
Expand Down
2 changes: 1 addition & 1 deletion Shared/Store/BaseDataStore.swift
Expand Up @@ -5,7 +5,7 @@
import Foundation
import MozillaAppServices
import RxSwift
import RxCocoa
import RxRelay
import RxOptional
import SwiftKeychainWrapper

Expand Down
2 changes: 1 addition & 1 deletion Shared/Store/BaseItemDetailStore.swift
Expand Up @@ -4,7 +4,7 @@

import Foundation
import RxSwift
import RxCocoa
import RxRelay

class BaseItemDetailStore {
internal var dispatcher: Dispatcher
Expand Down
4 changes: 2 additions & 2 deletions Shared/Store/NetworkStore.swift
Expand Up @@ -4,7 +4,7 @@

import Foundation
import RxSwift
import RxCocoa
import RxRelay
import Reachability

open class NetworkStore {
Expand Down Expand Up @@ -39,7 +39,7 @@ open class NetworkStore {
}

if !isRunningTest {
try? self.reachability?.startNotifier()
((try? self.reachability?.startNotifier()) as ()??)
}
}
}
2 changes: 1 addition & 1 deletion docs/install.md
@@ -1,4 +1,4 @@
1. Install Xcode version 10.2.1
1. Install Xcode version 10.2.1 + Swift 5.0.1.

2. Install the latest [Xcode developer tools](https://developer.apple.com/xcode/downloads/) from Apple

Expand Down
2 changes: 1 addition & 1 deletion docs/updating_libraries.md
@@ -1,6 +1,6 @@
# External Dependencies

You will need to use **Xcode 10.2.1** and **Swift 4.2.1** (`swiftlang-1000.0.36 clang-1000.10.44`) to work on Lockwise.
You will need to use **Xcode 10.2.1** and **Swift 5.0.1** (`swiftlang-1001.0.82.4 clang-1001.0.46.5`) to work on Lockwise.

## Swift frameworks

Expand Down
2 changes: 1 addition & 1 deletion lockbox-ios/Store/AccountStore.swift
Expand Up @@ -4,7 +4,7 @@

import Foundation
import RxSwift
import RxCocoa
import RxRelay
import MozillaAppServices
import SwiftKeychainWrapper
import WebKit
Expand Down
1 change: 1 addition & 0 deletions lockbox-ios/Store/ItemDetailStore.swift
Expand Up @@ -4,6 +4,7 @@

import Foundation
import RxSwift
import RxRelay
import RxCocoa
import MozillaAppServices

Expand Down
2 changes: 1 addition & 1 deletion lockbox-ios/Store/RouteStore.swift
Expand Up @@ -4,7 +4,7 @@

import Foundation
import RxSwift
import RxCocoa
import RxRelay

class RouteStore {
public static let shared = RouteStore()
Expand Down
2 changes: 1 addition & 1 deletion lockbox-ios/View/ItemListView.swift
Expand Up @@ -63,7 +63,7 @@ extension ItemListView: ItemListViewProtocol {
}

func bind(scrollAction: Driver<ScrollAction>) {
scrollAction.delay(RxTimeInterval(0.1))
scrollAction.delay(.milliseconds(100))
.drive(onNext: { action in
guard self.tableView.dataSource?.tableView(self.tableView, numberOfRowsInSection: 0) ?? 0 > 0 else { return }
switch action {
Expand Down
2 changes: 1 addition & 1 deletion lockbox-iosTests/BaseDataStoreSpec.swift
Expand Up @@ -341,7 +341,7 @@ class BaseDataStoreSpec: QuickSpec {
it("backdates the next lock time and locks the db") {
expect(self.autoLockSupport.backdateCalled).to(beTrue())
_ = try! self.subject.storageState.toBlocking().first()
let state = try! self.subject.storageState.toBlocking().first()
_ = try! self.subject.storageState.toBlocking().first()
expect(self.loginsStorage.ensureLockedCalled).to(beTrue())
}
}
Expand Down