From 46e9d56c6e1ec0233d63d054ea82c82a4b0c73d7 Mon Sep 17 00:00:00 2001 From: Rodrigo Lopez-Romero Date: Wed, 3 May 2017 13:00:52 +0200 Subject: [PATCH 01/27] Changes in order to support Swift 3 --- .../AppIcon.appiconset/Contents.json | 10 ++++ LaunchGate.xcodeproj/project.pbxproj | 13 ++--- Podfile.lock | 2 +- Source/DefaultParser.swift | 40 +++++++------- Source/DialogManager.swift | 52 +++++++++---------- Source/LaunchGate.swift | 34 ++++++------ Source/LaunchGateParser.swift | 2 +- Source/Memory.swift | 16 +++--- Source/RemoteFileManager.swift | 16 +++--- Tests/DialogManagerSpec.swift | 8 +-- Tests/LaunchGateSpec.swift | 14 ++--- Tests/RemoteFileManagerSpec.swift | 6 +-- Tests/SpecHelper.swift | 16 +++--- 13 files changed, 120 insertions(+), 109 deletions(-) diff --git a/Example/Example/Assets.xcassets/AppIcon.appiconset/Contents.json b/Example/Example/Assets.xcassets/AppIcon.appiconset/Contents.json index 118c98f..b8236c6 100644 --- a/Example/Example/Assets.xcassets/AppIcon.appiconset/Contents.json +++ b/Example/Example/Assets.xcassets/AppIcon.appiconset/Contents.json @@ -1,5 +1,15 @@ { "images" : [ + { + "idiom" : "iphone", + "size" : "20x20", + "scale" : "2x" + }, + { + "idiom" : "iphone", + "size" : "20x20", + "scale" : "3x" + }, { "idiom" : "iphone", "size" : "29x29", diff --git a/LaunchGate.xcodeproj/project.pbxproj b/LaunchGate.xcodeproj/project.pbxproj index c18961c..25a3bd7 100644 --- a/LaunchGate.xcodeproj/project.pbxproj +++ b/LaunchGate.xcodeproj/project.pbxproj @@ -278,10 +278,11 @@ TargetAttributes = { C5C04BC51C696767007397D0 = { CreatedOnToolsVersion = 7.2; + LastSwiftMigration = 0830; }; C5C04BCF1C696767007397D0 = { CreatedOnToolsVersion = 7.2; - LastSwiftMigration = 0810; + LastSwiftMigration = 0830; }; }; }; @@ -371,7 +372,7 @@ ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n"; + shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n"; showEnvVarsInLog = 0; }; FC8B5F2AC9518D4264A0CAB5 /* [CP] Copy Pods Resources */ = { @@ -538,7 +539,7 @@ PRODUCT_NAME = "$(TARGET_NAME)"; SKIP_INSTALL = YES; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; - SWIFT_VERSION = 2.3; + SWIFT_VERSION = 3.0; }; name = Debug; }; @@ -556,7 +557,7 @@ PRODUCT_BUNDLE_IDENTIFIER = com.dtrenz.LaunchGate; PRODUCT_NAME = "$(TARGET_NAME)"; SKIP_INSTALL = YES; - SWIFT_VERSION = 2.3; + SWIFT_VERSION = 3.0; }; name = Release; }; @@ -568,7 +569,7 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = com.dtrenz.LaunchGateTests; PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_VERSION = 2.3; + SWIFT_VERSION = 3.0; }; name = Debug; }; @@ -580,7 +581,7 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = com.dtrenz.LaunchGateTests; PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_VERSION = 2.3; + SWIFT_VERSION = 3.0; }; name = Release; }; diff --git a/Podfile.lock b/Podfile.lock index 67f066f..60de23b 100644 --- a/Podfile.lock +++ b/Podfile.lock @@ -12,4 +12,4 @@ SPEC CHECKSUMS: PODFILE CHECKSUM: 7bd4003f06bc200862f8d9bac0d09aeefb6a06c4 -COCOAPODS: 1.2.0 +COCOAPODS: 1.2.1 diff --git a/Source/DefaultParser.swift b/Source/DefaultParser.swift index fbff410..d80ca15 100644 --- a/Source/DefaultParser.swift +++ b/Source/DefaultParser.swift @@ -13,30 +13,30 @@ class DefaultParser: LaunchGateParser { typealias JSON = [String: AnyObject] enum Error: LaunchGateError { - case UnableToParseConfigurationObject - case UnableToParseAlert - case UnableToParseOptionalUpdate - case UnableToParseRequiredUpdate + case unableToParseConfigurationObject + case unableToParseAlert + case unableToParseOptionalUpdate + case unableToParseRequiredUpdate var description: String { switch self { - case UnableToParseConfigurationObject: + case .unableToParseConfigurationObject: return "Unable to parse the configuration object (\"ios\") from JSON file." - case UnableToParseAlert: + case .unableToParseAlert: return "Unable to parse the alert configuration from JSON file." - case UnableToParseOptionalUpdate: + case .unableToParseOptionalUpdate: return "Unable to parse the optional update configuration from JSON file." - case UnableToParseRequiredUpdate: + case .unableToParseRequiredUpdate: return "Unable to parse the required update configuration from JSON file." } } } - func parse(jsonData: NSData) -> LaunchGateConfiguration? { + func parse(_ jsonData: Data) -> LaunchGateConfiguration? { do { - let json = try NSJSONSerialization.JSONObjectWithData(jsonData, options: []) + let json = try JSONSerialization.jsonObject(with: jsonData, options: []) as! JSON - guard let config = json["ios"] as? JSON else { throw Error.UnableToParseConfigurationObject } + guard let config = json["ios"] else { throw Error.unableToParseConfigurationObject } var alert: AlertConfiguration? var optionalUpdate: UpdateConfiguration? @@ -68,23 +68,23 @@ class DefaultParser: LaunchGateParser { return nil } - private static func parseAlert(json: JSON) throws -> AlertConfiguration? { - guard let message = json["message"] as? String else { throw Error.UnableToParseAlert } - guard let blocking = json["blocking"] as? Bool else { throw Error.UnableToParseAlert } + fileprivate static func parseAlert(_ json: JSON) throws -> AlertConfiguration? { + guard let message = json["message"] as? String else { throw Error.unableToParseAlert } + guard let blocking = json["blocking"] as? Bool else { throw Error.unableToParseAlert } return AlertConfiguration(message: message, blocking: blocking) } - private static func parseOptionalUpdate(json: JSON) throws -> UpdateConfiguration? { - guard let version = json["optionalVersion"] as? String else { throw Error.UnableToParseOptionalUpdate } - guard let message = json["message"] as? String else { throw Error.UnableToParseOptionalUpdate } + fileprivate static func parseOptionalUpdate(_ json: JSON) throws -> UpdateConfiguration? { + guard let version = json["optionalVersion"] as? String else { throw Error.unableToParseOptionalUpdate } + guard let message = json["message"] as? String else { throw Error.unableToParseOptionalUpdate } return UpdateConfiguration(version: version, message: message) } - private static func parseRequiredUpdate(json: JSON) throws -> UpdateConfiguration? { - guard let version = json["minimumVersion"] as? String else { throw Error.UnableToParseRequiredUpdate } - guard let message = json["message"] as? String else { throw Error.UnableToParseRequiredUpdate } + fileprivate static func parseRequiredUpdate(_ json: JSON) throws -> UpdateConfiguration? { + guard let version = json["minimumVersion"] as? String else { throw Error.unableToParseRequiredUpdate } + guard let message = json["message"] as? String else { throw Error.unableToParseRequiredUpdate } return UpdateConfiguration(version: version, message: message) } diff --git a/Source/DialogManager.swift b/Source/DialogManager.swift index 5cbdf11..d0e9466 100644 --- a/Source/DialogManager.swift +++ b/Source/DialogManager.swift @@ -15,16 +15,16 @@ protocol Dialogable { class DialogManager { - typealias RememberableDialogSubject = protocol + typealias RememberableDialogSubject = Dialogable & Rememberable enum DialogType { - case Alert(blocking: Bool) - case OptionalUpdate(updateURL: NSURL) - case RequiredUpdate(updateURL: NSURL) + case alert(blocking: Bool) + case optionalUpdate(updateURL: URL) + case requiredUpdate(updateURL: URL) } - func displayAlertDialog(alertConfig: RememberableDialogSubject, blocking: Bool) { - let dialog = createAlertController(.Alert(blocking: blocking), message: alertConfig.message) + func displayAlertDialog(_ alertConfig: RememberableDialogSubject, blocking: Bool) { + let dialog = createAlertController(.alert(blocking: blocking), message: alertConfig.message) displayAlertController(dialog) { () -> Void in if !blocking { @@ -33,14 +33,14 @@ class DialogManager { } } - func displayRequiredUpdateDialog(updateConfig: Dialogable, updateURL: NSURL) { - let dialog = createAlertController(.RequiredUpdate(updateURL: updateURL), message: updateConfig.message) + func displayRequiredUpdateDialog(_ updateConfig: Dialogable, updateURL: URL) { + let dialog = createAlertController(.requiredUpdate(updateURL: updateURL), message: updateConfig.message) displayAlertController(dialog, completion: nil) } - func displayOptionalUpdateDialog(updateConfig: RememberableDialogSubject, updateURL: NSURL) { - let dialog = createAlertController(.OptionalUpdate(updateURL: updateURL), message: updateConfig.message) + func displayOptionalUpdateDialog(_ updateConfig: RememberableDialogSubject, updateURL: URL) { + let dialog = createAlertController(.optionalUpdate(updateURL: updateURL), message: updateConfig.message) displayAlertController(dialog) { () -> Void in Memory.remember(updateConfig) @@ -49,30 +49,30 @@ class DialogManager { // MARK: Custom Alert Controllers - func createAlertController(type: DialogType, message: String) -> UIAlertController { - let alertController = UIAlertController(title: nil, message: message, preferredStyle: .Alert) + func createAlertController(_ type: DialogType, message: String) -> UIAlertController { + let alertController = UIAlertController(title: nil, message: message, preferredStyle: .alert) switch type { - case let .Alert(blocking): + case let .alert(blocking): if !blocking { alertController.addAction(dismissActon()) } - case let .OptionalUpdate(updateURL): + case let .optionalUpdate(updateURL): alertController.addAction(dismissActon()) alertController.addAction(updateAction(updateURL)) - case let .RequiredUpdate(updateURL): + case let .requiredUpdate(updateURL): alertController.addAction(updateAction(updateURL)) } return alertController } - func displayAlertController(alert: UIAlertController, completion: (() -> Void)?) { - dispatch_async(dispatch_get_main_queue()) { [] in + func displayAlertController(_ alert: UIAlertController, completion: (() -> Void)?) { + DispatchQueue.main.async { [] in if let topViewController = self.topViewController() { - topViewController.presentViewController(alert, animated: true) { + topViewController.present(alert, animated: true) { if let completion = completion { completion() } @@ -82,24 +82,24 @@ class DialogManager { } func topViewController() -> UIViewController? { - return UIApplication.sharedApplication().keyWindow?.rootViewController + return UIApplication.shared.keyWindow?.rootViewController } // MARK: Custom Alert Actions - private func dismissActon() -> UIAlertAction { + fileprivate func dismissActon() -> UIAlertAction { return UIAlertAction( title: NSLocalizedString("Dismiss", comment: "Button title for dismissing the update AlertView"), - style: .Default) { _ in } + style: .default) { _ in } } - private func updateAction(updateURL: NSURL) -> UIAlertAction { + fileprivate func updateAction(_ updateURL: URL) -> UIAlertAction { return UIAlertAction( title: NSLocalizedString("Update", comment: "Button title for accepting the update AlertView"), - style: .Default) { (action) -> Void in - if UIApplication.sharedApplication().canOpenURL(updateURL) { - dispatch_async(dispatch_get_main_queue()) { [] in - UIApplication.sharedApplication().openURL(updateURL) + style: .default) { (action) -> Void in + if UIApplication.shared.canOpenURL(updateURL) { + DispatchQueue.main.async { [] in + UIApplication.shared.openURL(updateURL) } } } diff --git a/Source/LaunchGate.swift b/Source/LaunchGate.swift index 4e118ab..8c11859 100644 --- a/Source/LaunchGate.swift +++ b/Source/LaunchGate.swift @@ -9,19 +9,19 @@ import Foundation /// Custom internal error type -typealias LaunchGateError = protocol +typealias LaunchGateError = Error & CustomStringConvertible -public class LaunchGate { +open class LaunchGate { /// Parser to use when parsing the configuration file - public var parser: LaunchGateParser! + open var parser: LaunchGateParser! /// URI for the configuration file - var configurationFileURL: NSURL! + var configurationFileURL: URL! /// App Store URI ("itms-apps://itunes.apple.com/...") for the current app - var updateURL: NSURL! + var updateURL: URL! /// Manager object for the various alert dialogs var dialogManager: DialogManager! @@ -40,8 +40,8 @@ public class LaunchGate { - Returns: A `LaunchGate` instance or `nil` */ public init?(configURI: String, appStoreURI: String) { - guard let configURL = NSURL(string: configURI) else { return nil } - guard let appStoreURL = NSURL(string: appStoreURI) else { return nil } + guard let configURL = URL(string: configURI) else { return nil } + guard let appStoreURL = URL(string: appStoreURI) else { return nil } configurationFileURL = configURL updateURL = appStoreURL @@ -50,8 +50,8 @@ public class LaunchGate { } /// Check the configuration file and perform any appropriate action. - public func check() { - performCheck(RemoteFileManager(remoteFileURL: configurationFileURL)) + open func check() { + performCheck(RemoteFileManager(remoteFileURL: (configurationFileURL as URL))) } // MARK: - Internal API @@ -62,7 +62,7 @@ public class LaunchGate { - Parameter remoteFileManager: The `RemoteFileManager` to use to fetch the configuration file. */ - func performCheck(remoteFileManager: RemoteFileManager) { + func performCheck(_ remoteFileManager: RemoteFileManager) { remoteFileManager.fetchRemoteFile { (jsonData) -> Void in if let config = self.parser.parse(jsonData) { self.displayDialogIfNecessary(config, dialogManager: self.dialogManager) @@ -77,12 +77,12 @@ public class LaunchGate { - config: Configuration parsed from remote configuration file. - dialogManager: Manager object for the various alert dialogs */ - func displayDialogIfNecessary(config: LaunchGateConfiguration, dialogManager: DialogManager) { - if let reqUpdate = config.requiredUpdate, appVersion = currentAppVersion() { + func displayDialogIfNecessary(_ config: LaunchGateConfiguration, dialogManager: DialogManager) { + if let reqUpdate = config.requiredUpdate, let appVersion = currentAppVersion() { if shouldShowRequiredUpdateDialog(reqUpdate, appVersion: appVersion) { dialogManager.displayRequiredUpdateDialog(reqUpdate, updateURL: updateURL) } - } else if let optUpdate = config.optionalUpdate, appVersion = currentAppVersion() { + } else if let optUpdate = config.optionalUpdate, let appVersion = currentAppVersion() { if shouldShowOptionalUpdateDialog(optUpdate, appVersion: appVersion) { dialogManager.displayOptionalUpdateDialog(optUpdate, updateURL: updateURL) } @@ -100,7 +100,7 @@ public class LaunchGate { - Returns: `true`, if an alert dialog should be displayed; `false`, if not. */ - func shouldShowAlertDialog(alertConfig: AlertConfiguration) -> Bool { + func shouldShowAlertDialog(_ alertConfig: AlertConfiguration) -> Bool { return alertConfig.blocking || alertConfig.isNotRemembered() } @@ -111,7 +111,7 @@ public class LaunchGate { - Returns: `true`, if an optional update should be displayed; `false`, if not. */ - func shouldShowOptionalUpdateDialog(updateConfig: UpdateConfiguration, appVersion: String) -> Bool { + func shouldShowOptionalUpdateDialog(_ updateConfig: UpdateConfiguration, appVersion: String) -> Bool { guard updateConfig.isNotRemembered() else { return false } return appVersion < updateConfig.version @@ -124,12 +124,12 @@ public class LaunchGate { - Returns: `true`, if a required update dialog should be displayed; `false`, if not. */ - func shouldShowRequiredUpdateDialog(updateConfig: UpdateConfiguration, appVersion: String) -> Bool { + func shouldShowRequiredUpdateDialog(_ updateConfig: UpdateConfiguration, appVersion: String) -> Bool { return appVersion < updateConfig.version } func currentAppVersion() -> String? { - return NSBundle.mainBundle().infoDictionary?["CFBundleShortVersionString"] as? String + return Bundle.main.infoDictionary?["CFBundleShortVersionString"] as? String } } diff --git a/Source/LaunchGateParser.swift b/Source/LaunchGateParser.swift index 665c14b..e70a614 100644 --- a/Source/LaunchGateParser.swift +++ b/Source/LaunchGateParser.swift @@ -20,6 +20,6 @@ public protocol LaunchGateParser { - Returns: The resulting `LaunchGateRemoteConfiguration` object, or `nil` if parsing fails for any reason (i.e. malformed JSON response). */ - func parse(jsonData: NSData) -> LaunchGateConfiguration? + func parse(_ jsonData: Data) -> LaunchGateConfiguration? } diff --git a/Source/Memory.swift b/Source/Memory.swift index 9148716..3fd02b2 100644 --- a/Source/Memory.swift +++ b/Source/Memory.swift @@ -11,20 +11,20 @@ import Foundation struct Memory { - static var userPrefs: NSUserDefaults { - return NSUserDefaults.standardUserDefaults() + static var userPrefs: UserDefaults { + return UserDefaults.standard } - static func remember(item: Rememberable) { - userPrefs.setObject(item.rememberString(), forKey: item.rememberKey()) + static func remember(_ item: Rememberable) { + userPrefs.set(item.rememberString(), forKey: item.rememberKey()) } - static func forget(item: Rememberable) { - userPrefs.removeObjectForKey(item.rememberKey()) + static func forget(_ item: Rememberable) { + userPrefs.removeObject(forKey: item.rememberKey()) } - static func contains(item: Rememberable) -> Bool { - if let storedString = userPrefs.stringForKey(item.rememberKey()) where storedString == item.rememberString() { + static func contains(_ item: Rememberable) -> Bool { + if let storedString = userPrefs.string(forKey: item.rememberKey()), storedString == item.rememberString() { return true } diff --git a/Source/RemoteFileManager.swift b/Source/RemoteFileManager.swift index 5bb28b5..8f8cfcc 100644 --- a/Source/RemoteFileManager.swift +++ b/Source/RemoteFileManager.swift @@ -11,18 +11,18 @@ import Foundation class RemoteFileManager { - let remoteFileURL: NSURL + let remoteFileURL: URL - init(remoteFileURL: NSURL) { + init(remoteFileURL: URL) { self.remoteFileURL = remoteFileURL } - func fetchRemoteFile(callback: (NSData) -> Void) { - performRemoteFileRequest(NSURLSession.sharedSession(), url: remoteFileURL, responseHandler: callback) + func fetchRemoteFile(_ callback: @escaping (Data) -> Void) { + performRemoteFileRequest(URLSession.shared, url: remoteFileURL, responseHandler: callback) } - func performRemoteFileRequest(session: NSURLSession, url: NSURL, responseHandler: (data: NSData) -> Void) { - let task = session.dataTaskWithURL(url) { (data, response, error) -> Void in + func performRemoteFileRequest(_ session: URLSession, url: URL, responseHandler: @escaping (_ data: Data) -> Void) { + let task = session.dataTask(with: url, completionHandler: { (data, response, error) -> Void in if let error = error { print("LaunchGate — Error: \(error.localizedDescription)") } @@ -32,8 +32,8 @@ class RemoteFileManager { return } - responseHandler(data: data) - } + responseHandler(data) + }) task.resume() } diff --git a/Tests/DialogManagerSpec.swift b/Tests/DialogManagerSpec.swift index 17783f4..8a6d28a 100644 --- a/Tests/DialogManagerSpec.swift +++ b/Tests/DialogManagerSpec.swift @@ -14,15 +14,15 @@ class DialogManagerSpec: QuickSpec { var testAlert: AlertConfiguration! var createAlertControllerWasCalledWithAlert = false - override func createAlertController(type: DialogManager.DialogType, message: String) -> UIAlertController { - if case let .Alert(blocking) = type where blocking == testAlert.blocking && message == testAlert.message { + override func createAlertController(_ type: DialogManager.DialogType, message: String) -> UIAlertController { + if case let .Alert(blocking) = type, blocking == testAlert.blocking && message == testAlert.message { createAlertControllerWasCalledWithAlert = true } return UIAlertController() } - override func displayAlertController(alert: UIAlertController, completion: (() -> Void)?) {} // stub + override func displayAlertController(_ alert: UIAlertController, completion: (() -> Void)?) {} // stub } let alert = AlertConfiguration(message: "Hello World", blocking: true)! @@ -39,7 +39,7 @@ class DialogManagerSpec: QuickSpec { describe("dialog memory logic ") { class MockViewController: UIViewController { - override func presentViewController(viewControllerToPresent: UIViewController, animated flag: Bool, completion: (() -> Void)?) { + override func presentViewController(_ viewControllerToPresent: UIViewController, animated flag: Bool, completion: (() -> Void)?) { completion!() } } diff --git a/Tests/LaunchGateSpec.swift b/Tests/LaunchGateSpec.swift index 6edacad..6d6cf6c 100644 --- a/Tests/LaunchGateSpec.swift +++ b/Tests/LaunchGateSpec.swift @@ -44,7 +44,7 @@ class LaunchGateSpec: QuickSpec { class MockLaunchGate: LaunchGate { var performCheckWasCalledWithRemoteFileManager = false - override func performCheck(remoteFileManager: RemoteFileManager) { + override func performCheck(_ remoteFileManager: RemoteFileManager) { if remoteFileManager.remoteFileURL.absoluteString == "https://www.example.com/example.json" { performCheckWasCalledWithRemoteFileManager = true } @@ -69,7 +69,7 @@ class LaunchGateSpec: QuickSpec { var fetchRemoteFileWasCalled = false - override func fetchRemoteFile(callback: (NSData) -> Void) { + override func fetchRemoteFile(_ callback: (NSData) -> Void) { fetchRemoteFileWasCalled = true callback(testData) @@ -97,7 +97,7 @@ class LaunchGateSpec: QuickSpec { var testData: NSData! var parseWasCalledWithJSON = false - func parse(jsonData: NSData) -> LaunchGateConfiguration? { + func parse(_ jsonData: NSData) -> LaunchGateConfiguration? { if jsonData == testData { parseWasCalledWithJSON = true } @@ -128,7 +128,7 @@ class LaunchGateSpec: QuickSpec { var displayDialogWasCalled = false - override func displayDialogIfNecessary(config: LaunchGateConfiguration, dialogManager: DialogManager) { + override func displayDialogIfNecessary(_ config: LaunchGateConfiguration, dialogManager: DialogManager) { displayDialogWasCalled = true } } @@ -156,9 +156,9 @@ class LaunchGateSpec: QuickSpec { var displayRequiredUpdateDialogWasCalled = false var displayOptionalUpdateDialogWasCalled = false - override func displayAlertDialog(configObject: DialogManager.RememberableDialogSubject, blocking: Bool) { displayAlertDialogWasCalled = true } - override func displayOptionalUpdateDialog(updateConfig: RememberableDialogSubject, updateURL: NSURL) { displayOptionalUpdateDialogWasCalled = true } - override func displayRequiredUpdateDialog(updateConfig: Dialogable, updateURL: NSURL) { displayRequiredUpdateDialogWasCalled = true } + override func displayAlertDialog(_ configObject: DialogManager.RememberableDialogSubject, blocking: Bool) { displayAlertDialogWasCalled = true } + override func displayOptionalUpdateDialog(_ updateConfig: RememberableDialogSubject, updateURL: NSURL) { displayOptionalUpdateDialogWasCalled = true } + override func displayRequiredUpdateDialog(_ updateConfig: Dialogable, updateURL: NSURL) { displayRequiredUpdateDialogWasCalled = true } } var launchGate: MockLaunchGate! diff --git a/Tests/RemoteFileManagerSpec.swift b/Tests/RemoteFileManagerSpec.swift index 14b6cce..0b788c2 100644 --- a/Tests/RemoteFileManagerSpec.swift +++ b/Tests/RemoteFileManagerSpec.swift @@ -6,7 +6,7 @@ import Nimble class RemoteFileManagerSpec: QuickSpec { override func spec() { - let exampleURL = NSURL(string: "https://www.launchgate.com/update.json")! + let exampleURL = URL(string: "https://www.launchgate.com/update.json")! describe("#init") { @@ -24,7 +24,7 @@ class RemoteFileManagerSpec: QuickSpec { var performRemoteFileRequestWasCalled = false var performRemoteFileRequestWasCalledWithRemoteFileURI = false - override func performRemoteFileRequest(session: NSURLSession, url: NSURL, responseHandler: (data: NSData) -> Void) { + override func performRemoteFileRequest(_ session: NSURLSession, url: NSURL, responseHandler: (_ data: NSData) -> Void) { if url.absoluteString == "https://www.launchgate.com/update.json" { performRemoteFileRequestWasCalledWithRemoteFileURI = true } @@ -57,7 +57,7 @@ class RemoteFileManagerSpec: QuickSpec { let testData = MockData() - override func dataTaskWithURL(url: NSURL, completionHandler: (NSData?, NSURLResponse?, NSError?) -> Void) -> NSURLSessionDataTask { + override func dataTaskWithURL(_ url: NSURL, completionHandler: (NSData?, NSURLResponse?, NSError?) -> Void) -> NSURLSessionDataTask { dataTaskWithURLWasCalled = true completionHandler(testData, nil, nil) diff --git a/Tests/SpecHelper.swift b/Tests/SpecHelper.swift index b7b471b..0ab8382 100644 --- a/Tests/SpecHelper.swift +++ b/Tests/SpecHelper.swift @@ -7,19 +7,19 @@ import Foundation class SpecHelper { - enum Error: ErrorType { - case BundleNotFound - case FileNotFound + enum Error: Error { + case bundleNotFound + case fileNotFound } - static func loadFixture(name: String) throws -> NSData { - let bundle = NSBundle(forClass: SpecHelper.self) + static func loadFixture(_ name: String) throws -> Data { + let bundle = Bundle(for: SpecHelper.self) - guard let path = bundle.pathForResource(name, ofType: nil) else { - throw Error.FileNotFound + guard let path = bundle.path(forResource: name, ofType: nil) else { + throw Error.fileNotFound } - let data = try NSData(contentsOfFile: path, options: NSDataReadingOptions.DataReadingMappedIfSafe) + let data = try Data(contentsOf: URL(fileURLWithPath: path), options: NSData.ReadingOptions.mappedIfSafe) return data } From 38f73d78a1b220e6a6615d4821a598464ab451ca Mon Sep 17 00:00:00 2001 From: Rodrigo Lopez-Romero Date: Wed, 3 May 2017 16:26:08 +0200 Subject: [PATCH 02/27] Correcting SwiftLint errors. --- Example/Example.xcodeproj/project.pbxproj | 5 +- .../xcshareddata/xcschemes/Example.xcscheme | 2 +- Example/Example/AppDelegate.swift | 2 +- Example/Example/Info.plist | 2 +- LaunchGate.xcodeproj/project.pbxproj | 53 ++++++++++++++++++- .../xcschemes/LaunchGate.xcscheme | 2 +- Podfile | 8 +++ Podfile.lock | 5 +- Source/DefaultParser.swift | 4 +- Source/DialogManager.swift | 2 +- Source/RemoteFileManager.swift | 9 +++- 11 files changed, 80 insertions(+), 14 deletions(-) diff --git a/Example/Example.xcodeproj/project.pbxproj b/Example/Example.xcodeproj/project.pbxproj index 0829e2f..2153b31 100644 --- a/Example/Example.xcodeproj/project.pbxproj +++ b/Example/Example.xcodeproj/project.pbxproj @@ -139,6 +139,7 @@ TargetAttributes = { C5A878881C6A7A95004599C2 = { CreatedOnToolsVersion = 7.2; + LastSwiftMigration = 0830; }; }; }; @@ -317,7 +318,7 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = com.dtrenz.Example; PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_VERSION = 2.3; + SWIFT_VERSION = 3.0; }; name = Debug; }; @@ -329,7 +330,7 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = com.dtrenz.Example; PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_VERSION = 2.3; + SWIFT_VERSION = 3.0; }; name = Release; }; diff --git a/Example/Example.xcodeproj/xcshareddata/xcschemes/Example.xcscheme b/Example/Example.xcodeproj/xcshareddata/xcschemes/Example.xcscheme index b87fc46..f493dff 100644 --- a/Example/Example.xcodeproj/xcshareddata/xcschemes/Example.xcscheme +++ b/Example/Example.xcodeproj/xcshareddata/xcschemes/Example.xcscheme @@ -1,6 +1,6 @@ CFBundlePackageType APPL CFBundleShortVersionString - 1.0 + 0.1 CFBundleSignature ???? CFBundleVersion diff --git a/LaunchGate.xcodeproj/project.pbxproj b/LaunchGate.xcodeproj/project.pbxproj index 25a3bd7..f86a748 100644 --- a/LaunchGate.xcodeproj/project.pbxproj +++ b/LaunchGate.xcodeproj/project.pbxproj @@ -7,6 +7,7 @@ objects = { /* Begin PBXBuildFile section */ + 7275123AB954D288769E990A /* Pods_LaunchGate.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DBE8225ED27D646C8CFB8C5E /* Pods_LaunchGate.framework */; }; C5478DD31C6968C800843BA3 /* AlertConfiguration.swift in Sources */ = {isa = PBXBuildFile; fileRef = C5478DC81C6968C800843BA3 /* AlertConfiguration.swift */; }; C5478DD41C6968C800843BA3 /* DialogManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = C5478DC91C6968C800843BA3 /* DialogManager.swift */; }; C5478DD51C6968C800843BA3 /* LaunchGate.swift in Sources */ = {isa = PBXBuildFile; fileRef = C5478DCA1C6968C800843BA3 /* LaunchGate.swift */; }; @@ -50,8 +51,10 @@ /* Begin PBXFileReference section */ 09553AF46AB4FDB398881D98 /* Pods_LaunchGateTests.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_LaunchGateTests.framework; sourceTree = BUILT_PRODUCTS_DIR; }; + 293D3BC7DDE54B109DD218FD /* Pods-LaunchGate.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-LaunchGate.debug.xcconfig"; path = "Pods/Target Support Files/Pods-LaunchGate/Pods-LaunchGate.debug.xcconfig"; sourceTree = ""; }; 5AB7C55DD8BF85EC8936F7D7 /* Pods-LaunchGateTests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-LaunchGateTests.release.xcconfig"; path = "Pods/Target Support Files/Pods-LaunchGateTests/Pods-LaunchGateTests.release.xcconfig"; sourceTree = ""; }; 9EE87D27A2BAEF9BC5A90AF1 /* Pods-LaunchGateTests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-LaunchGateTests.debug.xcconfig"; path = "Pods/Target Support Files/Pods-LaunchGateTests/Pods-LaunchGateTests.debug.xcconfig"; sourceTree = ""; }; + A881ED02961A5E6352EEBF2E /* Pods-LaunchGate.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-LaunchGate.release.xcconfig"; path = "Pods/Target Support Files/Pods-LaunchGate/Pods-LaunchGate.release.xcconfig"; sourceTree = ""; }; C547584C1C73CBF8000A6EFA /* config-optional.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = "config-optional.json"; sourceTree = ""; }; C547584E1C73CC17000A6EFA /* config-required.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = "config-required.json"; sourceTree = ""; }; C54758521C73D692000A6EFA /* config-alert.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = "config-alert.json"; sourceTree = ""; }; @@ -83,6 +86,7 @@ C5ACF5331C74EF72009C1729 /* DialogManagerSpec.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = DialogManagerSpec.swift; path = Tests/DialogManagerSpec.swift; sourceTree = SOURCE_ROOT; }; C5C04BC61C696767007397D0 /* LaunchGate.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = LaunchGate.framework; sourceTree = BUILT_PRODUCTS_DIR; }; C5C04BD01C696767007397D0 /* LaunchGateTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = LaunchGateTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; + DBE8225ED27D646C8CFB8C5E /* Pods_LaunchGate.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_LaunchGate.framework; sourceTree = BUILT_PRODUCTS_DIR; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -90,6 +94,7 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( + 7275123AB954D288769E990A /* Pods_LaunchGate.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -110,6 +115,8 @@ children = ( 9EE87D27A2BAEF9BC5A90AF1 /* Pods-LaunchGateTests.debug.xcconfig */, 5AB7C55DD8BF85EC8936F7D7 /* Pods-LaunchGateTests.release.xcconfig */, + 293D3BC7DDE54B109DD218FD /* Pods-LaunchGate.debug.xcconfig */, + A881ED02961A5E6352EEBF2E /* Pods-LaunchGate.release.xcconfig */, ); name = Pods; sourceTree = ""; @@ -118,6 +125,7 @@ isa = PBXGroup; children = ( 09553AF46AB4FDB398881D98 /* Pods_LaunchGateTests.framework */, + DBE8225ED27D646C8CFB8C5E /* Pods_LaunchGate.framework */, ); name = Frameworks; sourceTree = ""; @@ -230,11 +238,13 @@ isa = PBXNativeTarget; buildConfigurationList = C5C04BDA1C696767007397D0 /* Build configuration list for PBXNativeTarget "LaunchGate" */; buildPhases = ( + 9DC7CFBAF84F9C5EF0293E5A /* [CP] Check Pods Manifest.lock */, C5B85B4E1C6A862E00B007CD /* Swiftlint */, C5C04BC11C696767007397D0 /* Sources */, C5C04BC21C696767007397D0 /* Frameworks */, C5C04BC31C696767007397D0 /* Headers */, C5C04BC41C696767007397D0 /* Resources */, + DBC12B8317623B5CF98B6810 /* [CP] Copy Pods Resources */, ); buildRules = ( ); @@ -273,7 +283,7 @@ isa = PBXProject; attributes = { LastSwiftUpdateCheck = 0720; - LastUpgradeCheck = 0720; + LastUpgradeCheck = 0830; ORGANIZATIONNAME = "Dan Trenz"; TargetAttributes = { C5C04BC51C696767007397D0 = { @@ -331,6 +341,21 @@ /* End PBXResourcesBuildPhase section */ /* Begin PBXShellScriptBuildPhase section */ + 9DC7CFBAF84F9C5EF0293E5A /* [CP] Check Pods Manifest.lock */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + ); + name = "[CP] Check Pods Manifest.lock"; + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n"; + showEnvVarsInLog = 0; + }; 9F31E47EBB50721D2046C6CC /* [CP] Embed Pods Frameworks */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; @@ -358,7 +383,7 @@ ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "if which swiftlint >/dev/null; then\n swiftlint\nelse\n echo \"warning: SwiftLint not installed, download from https://github.com/realm/SwiftLint\"\nfi"; + shellScript = "\"${PODS_ROOT}/SwiftLint/swiftlint\""; }; C76D564ED9E289949248D7A9 /* [CP] Check Pods Manifest.lock */ = { isa = PBXShellScriptBuildPhase; @@ -375,6 +400,21 @@ shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n"; showEnvVarsInLog = 0; }; + DBC12B8317623B5CF98B6810 /* [CP] Copy Pods Resources */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + ); + name = "[CP] Copy Pods Resources"; + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-LaunchGate/Pods-LaunchGate-resources.sh\"\n"; + showEnvVarsInLog = 0; + }; FC8B5F2AC9518D4264A0CAB5 /* [CP] Copy Pods Resources */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; @@ -448,8 +488,10 @@ CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; CLANG_WARN_EMPTY_BODY = YES; CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; CLANG_WARN_INT_CONVERSION = YES; CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_SUSPICIOUS_MOVE = YES; CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; @@ -496,8 +538,10 @@ CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; CLANG_WARN_EMPTY_BODY = YES; CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; CLANG_WARN_INT_CONVERSION = YES; CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_SUSPICIOUS_MOVE = YES; CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; @@ -517,6 +561,7 @@ IPHONEOS_DEPLOYMENT_TARGET = 9.2; MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = iphoneos; + SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; TARGETED_DEVICE_FAMILY = "1,2"; VALIDATE_PRODUCT = YES; VERSIONING_SYSTEM = "apple-generic"; @@ -526,8 +571,10 @@ }; C5C04BDB1C696767007397D0 /* Debug */ = { isa = XCBuildConfiguration; + baseConfigurationReference = 293D3BC7DDE54B109DD218FD /* Pods-LaunchGate.debug.xcconfig */; buildSettings = { CLANG_ENABLE_MODULES = YES; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = ""; DEFINES_MODULE = YES; DYLIB_COMPATIBILITY_VERSION = 1; DYLIB_CURRENT_VERSION = 1; @@ -545,8 +592,10 @@ }; C5C04BDC1C696767007397D0 /* Release */ = { isa = XCBuildConfiguration; + baseConfigurationReference = A881ED02961A5E6352EEBF2E /* Pods-LaunchGate.release.xcconfig */; buildSettings = { CLANG_ENABLE_MODULES = YES; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = ""; DEFINES_MODULE = YES; DYLIB_COMPATIBILITY_VERSION = 1; DYLIB_CURRENT_VERSION = 1; diff --git a/LaunchGate.xcodeproj/xcshareddata/xcschemes/LaunchGate.xcscheme b/LaunchGate.xcodeproj/xcshareddata/xcschemes/LaunchGate.xcscheme index a8f4b33..9db4ff4 100644 --- a/LaunchGate.xcodeproj/xcshareddata/xcschemes/LaunchGate.xcscheme +++ b/LaunchGate.xcodeproj/xcshareddata/xcschemes/LaunchGate.xcscheme @@ -1,6 +1,6 @@ 0.9.3' pod 'Nimble', '4.1.0' + pod 'SwiftLint' +end + +target 'LaunchGate' do + inherit! :search_paths + pod 'SwiftLint' end diff --git a/Podfile.lock b/Podfile.lock index 60de23b..dc4c6aa 100644 --- a/Podfile.lock +++ b/Podfile.lock @@ -1,15 +1,18 @@ PODS: - Nimble (4.1.0) - Quick (0.9.3) + - SwiftLint (0.18.1) DEPENDENCIES: - Nimble (= 4.1.0) - Quick (~> 0.9.3) + - SwiftLint SPEC CHECKSUMS: Nimble: 97a0a4cae5124c117115634b2d055d8c97d0af19 Quick: 13a2a2b19a5d8e3ed4fd0c36ee46597fd77ebf71 + SwiftLint: b467d08f5b25dc3b3cfed243d8e1b74b91714c67 -PODFILE CHECKSUM: 7bd4003f06bc200862f8d9bac0d09aeefb6a06c4 +PODFILE CHECKSUM: 6cdc90a4dc4cd9d492a9db40dfecc725619fed19 COCOAPODS: 1.2.1 diff --git a/Source/DefaultParser.swift b/Source/DefaultParser.swift index d80ca15..313f8e7 100644 --- a/Source/DefaultParser.swift +++ b/Source/DefaultParser.swift @@ -34,8 +34,8 @@ class DefaultParser: LaunchGateParser { func parse(_ jsonData: Data) -> LaunchGateConfiguration? { do { - let json = try JSONSerialization.jsonObject(with: jsonData, options: []) as! JSON - + let jsonData = try JSONSerialization.jsonObject(with: jsonData, options: []) + guard let json = jsonData as? JSON else { throw Error.unableToParseConfigurationObject } guard let config = json["ios"] else { throw Error.unableToParseConfigurationObject } var alert: AlertConfiguration? diff --git a/Source/DialogManager.swift b/Source/DialogManager.swift index d0e9466..ba1f4c1 100644 --- a/Source/DialogManager.swift +++ b/Source/DialogManager.swift @@ -96,7 +96,7 @@ class DialogManager { fileprivate func updateAction(_ updateURL: URL) -> UIAlertAction { return UIAlertAction( title: NSLocalizedString("Update", comment: "Button title for accepting the update AlertView"), - style: .default) { (action) -> Void in + style: .default) { (_) -> Void in if UIApplication.shared.canOpenURL(updateURL) { DispatchQueue.main.async { [] in UIApplication.shared.openURL(updateURL) diff --git a/Source/RemoteFileManager.swift b/Source/RemoteFileManager.swift index 8f8cfcc..b1ab59a 100644 --- a/Source/RemoteFileManager.swift +++ b/Source/RemoteFileManager.swift @@ -26,14 +26,19 @@ class RemoteFileManager { if let error = error { print("LaunchGate — Error: \(error.localizedDescription)") } - + + guard let statusCode = (response as? HTTPURLResponse)?.statusCode, statusCode >= 200 && statusCode <= 299 else { + print("LaunchGate - Request returned a status code other than 2xx.") + return + } + guard let data = data else { print("LaunchGate — Error: Remote configuration file response was empty.") return } responseHandler(data) - }) + }) task.resume() } From a8da17a60438229642a99702171186de63887f8b Mon Sep 17 00:00:00 2001 From: Rodrigo Lopez-Romero Date: Wed, 3 May 2017 16:28:36 +0200 Subject: [PATCH 03/27] Correcting trailing Whitespace Violation: Lines should not have trailing whitespace. --- Source/RemoteFileManager.swift | 2 -- 1 file changed, 2 deletions(-) diff --git a/Source/RemoteFileManager.swift b/Source/RemoteFileManager.swift index b1ab59a..3f50f6f 100644 --- a/Source/RemoteFileManager.swift +++ b/Source/RemoteFileManager.swift @@ -26,12 +26,10 @@ class RemoteFileManager { if let error = error { print("LaunchGate — Error: \(error.localizedDescription)") } - guard let statusCode = (response as? HTTPURLResponse)?.statusCode, statusCode >= 200 && statusCode <= 299 else { print("LaunchGate - Request returned a status code other than 2xx.") return } - guard let data = data else { print("LaunchGate — Error: Remote configuration file response was empty.") return From 79b98f463687b1cfa8254be7d7248a0a0aa9aed2 Mon Sep 17 00:00:00 2001 From: Rodrigo Lopez-Romero Date: Wed, 3 May 2017 16:58:56 +0200 Subject: [PATCH 04/27] Updating Gemfile and Gemfile.lock to support the new version of cocoa pods. --- Gemfile | 2 +- Gemfile.lock | 31 +++++++++++++++---------------- 2 files changed, 16 insertions(+), 17 deletions(-) diff --git a/Gemfile b/Gemfile index 5a5286f..b65f874 100644 --- a/Gemfile +++ b/Gemfile @@ -1,2 +1,2 @@ source 'https://rubygems.org' -gem 'cocoapods', '~> 1.2.0' +gem 'cocoapods', '~> 1.2.1' \ No newline at end of file diff --git a/Gemfile.lock b/Gemfile.lock index e736a4d..c19d755 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -8,26 +8,26 @@ GEM thread_safe (~> 0.3, >= 0.3.4) tzinfo (~> 1.1) claide (1.0.1) - cocoapods (1.2.0) + cocoapods (1.2.1) activesupport (>= 4.0.2, < 5) claide (>= 1.0.1, < 2.0) - cocoapods-core (= 1.2.0) + cocoapods-core (= 1.2.1) cocoapods-deintegrate (>= 1.0.1, < 2.0) cocoapods-downloader (>= 1.1.3, < 2.0) cocoapods-plugins (>= 1.0.0, < 2.0) cocoapods-search (>= 1.0.0, < 2.0) cocoapods-stats (>= 1.0.0, < 2.0) - cocoapods-trunk (>= 1.1.2, < 2.0) + cocoapods-trunk (>= 1.2.0, < 2.0) cocoapods-try (>= 1.1.0, < 2.0) - colored (~> 1.2) + colored2 (~> 3.1) escape (~> 0.0.4) fourflusher (~> 2.0.1) gh_inspector (~> 1.0) - molinillo (~> 0.5.5) + molinillo (~> 0.5.7) nap (~> 1.0) - ruby-macho (~> 0.2.5) - xcodeproj (>= 1.4.1, < 2.0) - cocoapods-core (1.2.0) + ruby-macho (~> 1.1) + xcodeproj (>= 1.4.4, < 2.0) + cocoapods-core (1.2.1) activesupport (>= 4.0.2, < 5) fuzzy_match (~> 2.0.4) nap (~> 1.0) @@ -37,11 +37,11 @@ GEM nap cocoapods-search (1.0.0) cocoapods-stats (1.0.0) - cocoapods-trunk (1.1.2) + cocoapods-trunk (1.2.0) nap (>= 0.8, < 2.0) netrc (= 0.7.8) cocoapods-try (1.1.0) - colored (1.2) + colored2 (3.1.2) escape (0.0.4) fourflusher (2.0.1) fuzzy_match (2.0.4) @@ -52,22 +52,21 @@ GEM nanaimo (0.2.3) nap (1.1.0) netrc (0.7.8) - ruby-macho (0.2.6) + ruby-macho (1.1.0) thread_safe (0.3.6) - tzinfo (1.2.2) + tzinfo (1.2.3) thread_safe (~> 0.1) - xcodeproj (1.4.2) + xcodeproj (1.4.4) CFPropertyList (~> 2.3.3) - activesupport (>= 3) claide (>= 1.0.1, < 2.0) - colored (~> 1.2) + colored2 (~> 3.1) nanaimo (~> 0.2.3) PLATFORMS ruby DEPENDENCIES - cocoapods (~> 1.2.0) + cocoapods (~> 1.2.1) BUNDLED WITH 1.14.6 From 80ac9d0192ce0aaad73b7fc1668f3aac861c7615 Mon Sep 17 00:00:00 2001 From: Rodrigo Lopez-Romero Date: Wed, 3 May 2017 17:44:49 +0200 Subject: [PATCH 05/27] Returning to the CocoaPods version 1.2.0. Solving issues with Travis CI --- Gemfile | 2 +- Gemfile.lock | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Gemfile b/Gemfile index b65f874..146ac62 100644 --- a/Gemfile +++ b/Gemfile @@ -1,2 +1,2 @@ source 'https://rubygems.org' -gem 'cocoapods', '~> 1.2.1' \ No newline at end of file +gem 'cocoapods', '~> 1.2.0' \ No newline at end of file diff --git a/Gemfile.lock b/Gemfile.lock index c19d755..5aeffac 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -66,7 +66,7 @@ PLATFORMS ruby DEPENDENCIES - cocoapods (~> 1.2.1) + cocoapods (~> 1.2.0) BUNDLED WITH - 1.14.6 + 1.13.6 From 375ad15cc51bea028ac9bbb7668603cdaf66a326 Mon Sep 17 00:00:00 2001 From: RLRG Date: Wed, 3 May 2017 17:52:10 +0200 Subject: [PATCH 06/27] Update .travis.yml --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 3bc7d88..a13e621 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,7 @@ branches: only: - develop + - travisCIProblemBranch - master language: objective-c osx_image: xcode7.2 From b3400eab3e96d44995f2c6a8abd83ef6ad8e6c7b Mon Sep 17 00:00:00 2001 From: Rodrigo Lopez-Romero Date: Thu, 4 May 2017 11:11:32 +0200 Subject: [PATCH 07/27] Updating the version of the gems bundler. --- Gemfile.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile.lock b/Gemfile.lock index 5aeffac..707aea4 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -69,4 +69,4 @@ DEPENDENCIES cocoapods (~> 1.2.0) BUNDLED WITH - 1.13.6 + 1.14.6 From 259ea0e8b64d799f5ed5054c4bbf9d0bbad328a7 Mon Sep 17 00:00:00 2001 From: Rodrigo Lopez-Romero Date: Thu, 4 May 2017 11:36:38 +0200 Subject: [PATCH 08/27] Trying to fix the Travis CI compilation updating the cocoa pods version. --- Gemfile | 2 +- Gemfile.lock | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Gemfile b/Gemfile index 146ac62..b65f874 100644 --- a/Gemfile +++ b/Gemfile @@ -1,2 +1,2 @@ source 'https://rubygems.org' -gem 'cocoapods', '~> 1.2.0' \ No newline at end of file +gem 'cocoapods', '~> 1.2.1' \ No newline at end of file diff --git a/Gemfile.lock b/Gemfile.lock index 707aea4..c19d755 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -66,7 +66,7 @@ PLATFORMS ruby DEPENDENCIES - cocoapods (~> 1.2.0) + cocoapods (~> 1.2.1) BUNDLED WITH 1.14.6 From d6a3dcfb1fe0d5409664a55772d6cd767386e9bb Mon Sep 17 00:00:00 2001 From: RLRG Date: Thu, 4 May 2017 11:44:01 +0200 Subject: [PATCH 09/27] Updating travis file This way, we will be able to use the lastest version of the bundler --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index a13e621..a1d858d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -15,6 +15,7 @@ notifications: on_success: change before_install: - rvm use $RVM_RUBY_VERSION + - gem install bundler - gem install cocoapods - gem install slather - pod install From fdd5d44a19a8a24ddba06bd75093698f003a3a3d Mon Sep 17 00:00:00 2001 From: RLRG Date: Thu, 4 May 2017 11:48:42 +0200 Subject: [PATCH 10/27] Updating travis file again Reverting file to look for another solution --- .travis.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index a1d858d..a13e621 100644 --- a/.travis.yml +++ b/.travis.yml @@ -15,7 +15,6 @@ notifications: on_success: change before_install: - rvm use $RVM_RUBY_VERSION - - gem install bundler - gem install cocoapods - gem install slather - pod install From 7d94b7176cb285b1862f3bc2643c8d946e563e6a Mon Sep 17 00:00:00 2001 From: Rodrigo Lopez-Romero Date: Thu, 4 May 2017 11:57:38 +0200 Subject: [PATCH 11/27] Downgrading the bundler version to see if Travis CI compiles. --- Gemfile.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile.lock b/Gemfile.lock index c19d755..8aa8348 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -69,4 +69,4 @@ DEPENDENCIES cocoapods (~> 1.2.1) BUNDLED WITH - 1.14.6 + 1.13.2 From 7425287206b6e2764e8f7ae7c7fc256d19db73bf Mon Sep 17 00:00:00 2001 From: Rodrigo Lopez-Romero Date: Thu, 4 May 2017 12:04:17 +0200 Subject: [PATCH 12/27] Updating gem file --- Gemfile | 2 +- Gemfile.lock | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Gemfile b/Gemfile index b65f874..146ac62 100644 --- a/Gemfile +++ b/Gemfile @@ -1,2 +1,2 @@ source 'https://rubygems.org' -gem 'cocoapods', '~> 1.2.1' \ No newline at end of file +gem 'cocoapods', '~> 1.2.0' \ No newline at end of file diff --git a/Gemfile.lock b/Gemfile.lock index 8aa8348..999cd8c 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -66,7 +66,7 @@ PLATFORMS ruby DEPENDENCIES - cocoapods (~> 1.2.1) + cocoapods (~> 1.2.0) BUNDLED WITH 1.13.2 From 228c1d4da30e9f1af4311002ba7fba54f58db3c4 Mon Sep 17 00:00:00 2001 From: RLRG Date: Thu, 4 May 2017 12:16:07 +0200 Subject: [PATCH 13/27] Updating travis file Updating the XCode image in order to support Swift 3 (+1 squashed commit) Squashed commits: [c8863fd] Updating travis file Adding pod repo update to fix the pod install problem --- .travis.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index a13e621..a9e6b40 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,7 +4,7 @@ branches: - travisCIProblemBranch - master language: objective-c -osx_image: xcode7.2 +osx_image: xcode8 notifications: slack: rooms: @@ -17,6 +17,7 @@ before_install: - rvm use $RVM_RUBY_VERSION - gem install cocoapods - gem install slather + - pod repo update - pod install after_success: - slather From bbe7dca826cb0e0123face393fb2fa8b52157e1c Mon Sep 17 00:00:00 2001 From: Rodrigo Lopez-Romero Date: Thu, 4 May 2017 12:52:50 +0200 Subject: [PATCH 14/27] Updating pods to the latest versions to check if it compiles successfully. --- Podfile | 4 ++-- Podfile.lock | 14 +++++++------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/Podfile b/Podfile index 7051fbf..8cce51e 100644 --- a/Podfile +++ b/Podfile @@ -5,8 +5,8 @@ pod 'SwiftLint' target 'LaunchGateTests' do inherit! :search_paths - pod 'Quick', '~> 0.9.3' - pod 'Nimble', '4.1.0' + pod 'Quick' + pod 'Nimble' pod 'SwiftLint' end diff --git a/Podfile.lock b/Podfile.lock index dc4c6aa..91db8e1 100644 --- a/Podfile.lock +++ b/Podfile.lock @@ -1,18 +1,18 @@ PODS: - - Nimble (4.1.0) - - Quick (0.9.3) + - Nimble (7.0.0) + - Quick (1.1.0) - SwiftLint (0.18.1) DEPENDENCIES: - - Nimble (= 4.1.0) - - Quick (~> 0.9.3) + - Nimble + - Quick - SwiftLint SPEC CHECKSUMS: - Nimble: 97a0a4cae5124c117115634b2d055d8c97d0af19 - Quick: 13a2a2b19a5d8e3ed4fd0c36ee46597fd77ebf71 + Nimble: 874982b605d4d752fcac6be695d13c502de84b1b + Quick: dafc587e21eed9f4cab3249b9f9015b0b7a7f71d SwiftLint: b467d08f5b25dc3b3cfed243d8e1b74b91714c67 -PODFILE CHECKSUM: 6cdc90a4dc4cd9d492a9db40dfecc725619fed19 +PODFILE CHECKSUM: 135b4044b18ac1fb3ddfae8b0438dd0e41c6b159 COCOAPODS: 1.2.1 From feb0524eeee6bddcae6e976aa1179fae7a26f713 Mon Sep 17 00:00:00 2001 From: Rodrigo Lopez-Romero Date: Thu, 4 May 2017 14:00:57 +0200 Subject: [PATCH 15/27] Converting the code of the Tests to support Swift 3 --- Source/LaunchGate.swift | 2 +- Source/LaunchGateParser.swift | 2 +- Tests/DefaultParserSpec.swift | 4 ++-- Tests/DialogManagerSpec.swift | 8 ++++---- Tests/LaunchGateSpec.swift | 18 +++++++++--------- Tests/MemorySpec.swift | 4 ++-- Tests/RemoteFileManagerSpec.swift | 12 ++++++------ Tests/SpecHelper.swift | 6 +++--- 8 files changed, 28 insertions(+), 28 deletions(-) diff --git a/Source/LaunchGate.swift b/Source/LaunchGate.swift index 8c11859..2ec0215 100644 --- a/Source/LaunchGate.swift +++ b/Source/LaunchGate.swift @@ -30,7 +30,7 @@ open class LaunchGate { /** Failable initializer. If either the `configURI` or `appStoreURI` are unable to be - converted into an `NSURL` (i.e. containing illegal URL characters) this initializer + converted into an `URL` (i.e. containing illegal URL characters) this initializer will return `nil`. - Parameters: diff --git a/Source/LaunchGateParser.swift b/Source/LaunchGateParser.swift index e70a614..69e7e30 100644 --- a/Source/LaunchGateParser.swift +++ b/Source/LaunchGateParser.swift @@ -15,7 +15,7 @@ public protocol LaunchGateParser { /** Parse the configuration file into a `LaunchGateRemoteConfiguration` object. - - Parameter jsonData: The configuration file JSON as NSData. + - Parameter jsonData: The configuration file JSON as Data. - Returns: The resulting `LaunchGateRemoteConfiguration` object, or `nil` if parsing fails for any reason (i.e. malformed JSON response). diff --git a/Tests/DefaultParserSpec.swift b/Tests/DefaultParserSpec.swift index d246d9e..226464e 100644 --- a/Tests/DefaultParserSpec.swift +++ b/Tests/DefaultParserSpec.swift @@ -8,7 +8,7 @@ class DefaultParserSpec: QuickSpec { describe("#parse") { - var jsonData: NSData! + var jsonData: Data! var parser: LaunchGateParser! beforeEach { @@ -197,4 +197,4 @@ class DefaultParserSpec: QuickSpec { } } -} \ No newline at end of file +} diff --git a/Tests/DialogManagerSpec.swift b/Tests/DialogManagerSpec.swift index 8a6d28a..49a43e6 100644 --- a/Tests/DialogManagerSpec.swift +++ b/Tests/DialogManagerSpec.swift @@ -15,7 +15,7 @@ class DialogManagerSpec: QuickSpec { var createAlertControllerWasCalledWithAlert = false override func createAlertController(_ type: DialogManager.DialogType, message: String) -> UIAlertController { - if case let .Alert(blocking) = type, blocking == testAlert.blocking && message == testAlert.message { + if case let .alert(blocking) = type, blocking == testAlert.blocking && message == testAlert.message { createAlertControllerWasCalledWithAlert = true } @@ -39,7 +39,7 @@ class DialogManagerSpec: QuickSpec { describe("dialog memory logic ") { class MockViewController: UIViewController { - override func presentViewController(_ viewControllerToPresent: UIViewController, animated flag: Bool, completion: (() -> Void)?) { + override func present(_ viewControllerToPresent: UIViewController, animated flag: Bool, completion: (() -> Void)?) { completion!() } } @@ -82,7 +82,7 @@ class DialogManagerSpec: QuickSpec { Memory.forget(update) - dialogManager.displayOptionalUpdateDialog(update, updateURL: NSURL()) + dialogManager.displayOptionalUpdateDialog(update, updateURL: URL(string: "")!) expect(Memory.contains(update)).toEventually(beTrue()) } @@ -94,7 +94,7 @@ class DialogManagerSpec: QuickSpec { Memory.forget(update) - dialogManager.displayRequiredUpdateDialog(update, updateURL: NSURL()) + dialogManager.displayRequiredUpdateDialog(update, updateURL: URL(string: "")!) expect(Memory.contains(update)).toEventually(beFalse()) } diff --git a/Tests/LaunchGateSpec.swift b/Tests/LaunchGateSpec.swift index 6d6cf6c..c71ec4d 100644 --- a/Tests/LaunchGateSpec.swift +++ b/Tests/LaunchGateSpec.swift @@ -25,13 +25,13 @@ class LaunchGateSpec: QuickSpec { expect(launchGate).to(beNil()) } - it("creates a NSURL from the configURI") { + it("creates a URL from the configURI") { let launchGate = LaunchGate(configURI: configURI, appStoreURI: appStoreURI) expect(launchGate!.configurationFileURL.absoluteString) == configURI } - it("creates a NSURL from the appStoreURI") { + it("creates a URL from the appStoreURI") { let launchGate = LaunchGate(configURI: configURI, appStoreURI: appStoreURI) expect(launchGate!.updateURL.absoluteString) == appStoreURI @@ -65,11 +65,11 @@ class LaunchGateSpec: QuickSpec { let jsonData = try! SpecHelper.loadFixture("config.json") class MockRemoteFileManager: RemoteFileManager { - var testData: NSData! + var testData: Data! var fetchRemoteFileWasCalled = false - override func fetchRemoteFile(_ callback: (NSData) -> Void) { + override func fetchRemoteFile(_ callback: @escaping (Data) -> Void) { fetchRemoteFileWasCalled = true callback(testData) @@ -79,7 +79,7 @@ class LaunchGateSpec: QuickSpec { var mockRemoteFileManager: MockRemoteFileManager! beforeEach { - mockRemoteFileManager = MockRemoteFileManager(remoteFileURL: NSURL()) + mockRemoteFileManager = MockRemoteFileManager(remoteFileURL: URL(string: "")!) mockRemoteFileManager.testData = jsonData } @@ -94,10 +94,10 @@ class LaunchGateSpec: QuickSpec { context("when the configuration JSON is downloaded") { class MockParser: LaunchGateParser { - var testData: NSData! + var testData: Data! var parseWasCalledWithJSON = false - func parse(_ jsonData: NSData) -> LaunchGateConfiguration? { + func parse(_ jsonData: Data) -> LaunchGateConfiguration? { if jsonData == testData { parseWasCalledWithJSON = true } @@ -157,8 +157,8 @@ class LaunchGateSpec: QuickSpec { var displayOptionalUpdateDialogWasCalled = false override func displayAlertDialog(_ configObject: DialogManager.RememberableDialogSubject, blocking: Bool) { displayAlertDialogWasCalled = true } - override func displayOptionalUpdateDialog(_ updateConfig: RememberableDialogSubject, updateURL: NSURL) { displayOptionalUpdateDialogWasCalled = true } - override func displayRequiredUpdateDialog(_ updateConfig: Dialogable, updateURL: NSURL) { displayRequiredUpdateDialogWasCalled = true } + override func displayOptionalUpdateDialog(_ updateConfig: RememberableDialogSubject, updateURL: URL) { displayOptionalUpdateDialogWasCalled = true } + override func displayRequiredUpdateDialog(_ updateConfig: Dialogable, updateURL: URL) { displayRequiredUpdateDialogWasCalled = true } } var launchGate: MockLaunchGate! diff --git a/Tests/MemorySpec.swift b/Tests/MemorySpec.swift index baf896f..cff1486 100644 --- a/Tests/MemorySpec.swift +++ b/Tests/MemorySpec.swift @@ -18,7 +18,7 @@ class MemorySpec: QuickSpec { Memory.remember(item) - expect(NSUserDefaults.standardUserDefaults().stringForKey(item.rememberKey())) == item.rememberString() + expect(UserDefaults.standard.string(forKey: item.rememberKey())) == item.rememberString() } } @@ -29,7 +29,7 @@ class MemorySpec: QuickSpec { Memory.forget(item) - expect(NSUserDefaults.standardUserDefaults().stringForKey(item.rememberKey())).to(beNil()) + expect(UserDefaults.standard.string(forKey: item.rememberKey())).to(beNil()) } } diff --git a/Tests/RemoteFileManagerSpec.swift b/Tests/RemoteFileManagerSpec.swift index 0b788c2..4c03024 100644 --- a/Tests/RemoteFileManagerSpec.swift +++ b/Tests/RemoteFileManagerSpec.swift @@ -24,7 +24,7 @@ class RemoteFileManagerSpec: QuickSpec { var performRemoteFileRequestWasCalled = false var performRemoteFileRequestWasCalledWithRemoteFileURI = false - override func performRemoteFileRequest(_ session: NSURLSession, url: NSURL, responseHandler: (_ data: NSData) -> Void) { + override func performRemoteFileRequest(_ session: URLSession, url: URL, responseHandler: @escaping (_ data: Data) -> Void) { if url.absoluteString == "https://www.launchgate.com/update.json" { performRemoteFileRequestWasCalledWithRemoteFileURI = true } @@ -48,19 +48,19 @@ class RemoteFileManagerSpec: QuickSpec { // only mocking this class for verification in the callbackWasCalledWithData check below. class MockData: NSData {} - class MockURLSessionDataTask: NSURLSessionDataTask { + class MockURLSessionDataTask: URLSessionDataTask { override func resume() {} // stub } - class MockURLSession: NSURLSession { + class MockURLSession: URLSession { var dataTaskWithURLWasCalled = false let testData = MockData() - override func dataTaskWithURL(_ url: NSURL, completionHandler: (NSData?, NSURLResponse?, NSError?) -> Void) -> NSURLSessionDataTask { + override func dataTask(with url: URL, completionHandler: @escaping (Data?, URLResponse?, Error?) -> Void) -> URLSessionDataTask { dataTaskWithURLWasCalled = true - completionHandler(testData, nil, nil) + completionHandler(testData as Data, nil, nil) return MockURLSessionDataTask() } @@ -82,7 +82,7 @@ class RemoteFileManagerSpec: QuickSpec { var callbackWasCalledWithData = false remoteFileManager.performRemoteFileRequest(session, url: exampleURL) { (data) in - if data === session.testData { + if data == session.testData as Data { callbackWasCalledWithData = true } } diff --git a/Tests/SpecHelper.swift b/Tests/SpecHelper.swift index 0ab8382..df2db3b 100644 --- a/Tests/SpecHelper.swift +++ b/Tests/SpecHelper.swift @@ -7,7 +7,7 @@ import Foundation class SpecHelper { - enum Error: Error { + enum SpecHelperError: Error { case bundleNotFound case fileNotFound } @@ -16,10 +16,10 @@ class SpecHelper { let bundle = Bundle(for: SpecHelper.self) guard let path = bundle.path(forResource: name, ofType: nil) else { - throw Error.fileNotFound + throw SpecHelperError.fileNotFound } - let data = try Data(contentsOf: URL(fileURLWithPath: path), options: NSData.ReadingOptions.mappedIfSafe) + let data = try Data(contentsOf: URL(fileURLWithPath: path), options: Data.ReadingOptions.mappedIfSafe) return data } From c1b635bab132658fdd7a821782155ebef87edbec Mon Sep 17 00:00:00 2001 From: Rodrigo Lopez-Romero Date: Thu, 4 May 2017 16:57:05 +0200 Subject: [PATCH 16/27] Changes to fix some unitary tests of the project --- Source/RemoteFileManager.swift | 5 ++--- Tests/DialogManagerSpec.swift | 4 ++-- Tests/LaunchGateSpec.swift | 31 +++++++++++++++++++------------ Tests/RemoteFileManagerSpec.swift | 6 +++--- 4 files changed, 26 insertions(+), 20 deletions(-) diff --git a/Source/RemoteFileManager.swift b/Source/RemoteFileManager.swift index 3f50f6f..a12420b 100644 --- a/Source/RemoteFileManager.swift +++ b/Source/RemoteFileManager.swift @@ -26,9 +26,8 @@ class RemoteFileManager { if let error = error { print("LaunchGate — Error: \(error.localizedDescription)") } - guard let statusCode = (response as? HTTPURLResponse)?.statusCode, statusCode >= 200 && statusCode <= 299 else { - print("LaunchGate - Request returned a status code other than 2xx.") - return + if let response = response { + print("LaunchGate - Error because there is no response \(response.debugDescription)") } guard let data = data else { print("LaunchGate — Error: Remote configuration file response was empty.") diff --git a/Tests/DialogManagerSpec.swift b/Tests/DialogManagerSpec.swift index 49a43e6..a203baa 100644 --- a/Tests/DialogManagerSpec.swift +++ b/Tests/DialogManagerSpec.swift @@ -82,7 +82,7 @@ class DialogManagerSpec: QuickSpec { Memory.forget(update) - dialogManager.displayOptionalUpdateDialog(update, updateURL: URL(string: "")!) + dialogManager.displayOptionalUpdateDialog(update, updateURL: URL(string: "https://raw.githubusercontent.com/dtrenz/LaunchGate/develop/Example/Example/example.json")!) expect(Memory.contains(update)).toEventually(beTrue()) } @@ -94,7 +94,7 @@ class DialogManagerSpec: QuickSpec { Memory.forget(update) - dialogManager.displayRequiredUpdateDialog(update, updateURL: URL(string: "")!) + dialogManager.displayRequiredUpdateDialog(update, updateURL: URL(string: "https://raw.githubusercontent.com/dtrenz/LaunchGate/develop/Example/Example/example.json")!) expect(Memory.contains(update)).toEventually(beFalse()) } diff --git a/Tests/LaunchGateSpec.swift b/Tests/LaunchGateSpec.swift index c71ec4d..4eb40e4 100644 --- a/Tests/LaunchGateSpec.swift +++ b/Tests/LaunchGateSpec.swift @@ -79,7 +79,7 @@ class LaunchGateSpec: QuickSpec { var mockRemoteFileManager: MockRemoteFileManager! beforeEach { - mockRemoteFileManager = MockRemoteFileManager(remoteFileURL: URL(string: "")!) + mockRemoteFileManager = MockRemoteFileManager(remoteFileURL: URL(string: "https://raw.githubusercontent.com/dtrenz/LaunchGate/master/example.json")!) mockRemoteFileManager.testData = jsonData } @@ -182,25 +182,31 @@ class LaunchGateSpec: QuickSpec { } } - - context("when the app is elligible for an optional update") { + context("when the app is elligible for an optional update") { + it("displays an optional update dialog") { - let optionalUpdate = UpdateConfiguration(version: "1.2", message: "Optional update availabe.") - config.optionalUpdate = optionalUpdate - Memory.forget(optionalUpdate!) - - launchGate.displayDialogIfNecessary(config, dialogManager: dialogManager) - + let optionalUpdate = UpdateConfiguration(version: "1.2", message: "Optional update availabe.") + config.optionalUpdate = optionalUpdate + Memory.forget(optionalUpdate!) + + launchGate.displayDialogIfNecessary(config, dialogManager: dialogManager) + + // while(Memory.contains(optionalUpdate!)){ + // Memory.forget(optionalUpdate!) + // if (!Memory.contains(optionalUpdate!)){ + // + // } + // } + expect(dialogManager.displayOptionalUpdateDialogWasCalled) == true } - } context("when an alert should be displayed") { it("displays an alert dialog") { - let alert = AlertConfiguration(message: "Hello world", blocking: false) + let alert = AlertConfiguration(message: "Hello world", blocking: true) config.alert = alert Memory.forget(alert!) @@ -270,9 +276,10 @@ class LaunchGateSpec: QuickSpec { } context("when the app version is LESS THAN the update version") { - let appVersion = "1.1" + let appVersion = "1.0" it("returns true") { + Memory.forget(updateConfig) let result = launchGate.shouldShowOptionalUpdateDialog(updateConfig, appVersion: appVersion) expect(result) == true diff --git a/Tests/RemoteFileManagerSpec.swift b/Tests/RemoteFileManagerSpec.swift index 4c03024..7c68dd1 100644 --- a/Tests/RemoteFileManagerSpec.swift +++ b/Tests/RemoteFileManagerSpec.swift @@ -55,12 +55,12 @@ class RemoteFileManagerSpec: QuickSpec { class MockURLSession: URLSession { var dataTaskWithURLWasCalled = false - let testData = MockData() + let testData = Data() override func dataTask(with url: URL, completionHandler: @escaping (Data?, URLResponse?, Error?) -> Void) -> URLSessionDataTask { dataTaskWithURLWasCalled = true - completionHandler(testData as Data, nil, nil) + completionHandler(testData, nil, nil) return MockURLSessionDataTask() } @@ -82,7 +82,7 @@ class RemoteFileManagerSpec: QuickSpec { var callbackWasCalledWithData = false remoteFileManager.performRemoteFileRequest(session, url: exampleURL) { (data) in - if data == session.testData as Data { + if data == session.testData { callbackWasCalledWithData = true } } From 6f3c792a3f1f10bd9eab482c4c315f5edec7e651 Mon Sep 17 00:00:00 2001 From: Dan Trenz Date: Thu, 4 May 2017 10:32:24 -0400 Subject: [PATCH 17/27] Updating Travis CI config to keep CI jobs working --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index a9e6b40..903ce6e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -15,7 +15,7 @@ notifications: on_success: change before_install: - rvm use $RVM_RUBY_VERSION - - gem install cocoapods + - bundle - gem install slather - pod repo update - pod install From 304a7cb1ccc1fb522e35f50d51b8a4806ecc48b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rodrigo=20Lo=CC=81pez-Romero=20Guijarro?= Date: Thu, 4 May 2017 18:34:43 +0200 Subject: [PATCH 18/27] Removing comment in tests code. --- Tests/LaunchGateSpec.swift | 7 ------- 1 file changed, 7 deletions(-) diff --git a/Tests/LaunchGateSpec.swift b/Tests/LaunchGateSpec.swift index 4eb40e4..b93256f 100644 --- a/Tests/LaunchGateSpec.swift +++ b/Tests/LaunchGateSpec.swift @@ -192,13 +192,6 @@ class LaunchGateSpec: QuickSpec { launchGate.displayDialogIfNecessary(config, dialogManager: dialogManager) - // while(Memory.contains(optionalUpdate!)){ - // Memory.forget(optionalUpdate!) - // if (!Memory.contains(optionalUpdate!)){ - // - // } - // } - expect(dialogManager.displayOptionalUpdateDialogWasCalled) == true } } From 8b2b92813a30b11ed313aad18ca6343d1b06bcc9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rodrigo=20Lo=CC=81pez-Romero=20Guijarro?= Date: Fri, 5 May 2017 11:13:00 +0200 Subject: [PATCH 19/27] Fixing networking response request condition --- Source/RemoteFileManager.swift | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Source/RemoteFileManager.swift b/Source/RemoteFileManager.swift index a12420b..ad6a660 100644 --- a/Source/RemoteFileManager.swift +++ b/Source/RemoteFileManager.swift @@ -26,8 +26,9 @@ class RemoteFileManager { if let error = error { print("LaunchGate — Error: \(error.localizedDescription)") } - if let response = response { - print("LaunchGate - Error because there is no response \(response.debugDescription)") + guard response != nil else { + print("LaunchGate - Error because there is no response") + return } guard let data = data else { print("LaunchGate — Error: Remote configuration file response was empty.") From 8d0c3c91bba764a413bbf2da5da6fbc0360726a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rodrigo=20Lo=CC=81pez-Romero=20Guijarro?= Date: Wed, 27 Sep 2017 10:39:57 +0200 Subject: [PATCH 20/27] chore: change file permissions This change is caused by the update of Xcode 9. --- .gitignore | 0 .hound.yml | 0 .slather.yml | 0 .swiftlint.yml | 0 .travis.yml | 0 CHANGELOG.md | 0 Example/Example.xcodeproj/project.pbxproj | 0 .../xcshareddata/xcschemes/Example.xcscheme | 0 .../AppIcon.appiconset/Contents.json | 0 Example/Example/Base.lproj/LaunchScreen.storyboard | 0 Example/Example/Base.lproj/Main.storyboard | 0 Example/Example/Info.plist | 0 Example/Example/example.json | 0 Gemfile | 0 Gemfile.lock | 0 LICENSE | 0 LaunchGate.podspec | 0 LaunchGate.xcodeproj/project.pbxproj | 0 .../project.xcworkspace/contents.xcworkspacedata | 0 .../xcshareddata/xcschemes/LaunchGate.xcscheme | 0 LaunchGate.xcworkspace/contents.xcworkspacedata | 0 Podfile | 0 Podfile.lock | 0 README.md | 0 Screenshots/alert-blocking.png | Bin Screenshots/alert-nonblocking.png | Bin Screenshots/optional-update.png | Bin Screenshots/required-update.png | Bin Source/AlertConfiguration.swift | 0 Source/DefaultParser.swift | 0 Source/DialogManager.swift | 0 Source/Info.plist | 0 Source/LaunchGate.h | 0 Source/LaunchGate.swift | 0 Source/LaunchGateConfiguration.swift | 0 Source/LaunchGateParser.swift | 0 Source/Memory.swift | 0 Source/Rememberable.swift | 0 Source/RemoteFileManager.swift | 0 Source/UpdateConfiguration.swift | 0 Tests/ConfigurationSpec.swift | 0 Tests/DefaultParserSpec.swift | 0 Tests/DialogManagerSpec.swift | 0 Tests/Fixtures/config-alert.json | 0 Tests/Fixtures/config-malformed-alert.json | 0 Tests/Fixtures/config-malformed-empty.json | 0 Tests/Fixtures/config-malformed-ios.json | 0 Tests/Fixtures/config-malformed-optional.json | 0 Tests/Fixtures/config-malformed-required.json | 0 Tests/Fixtures/config-optional.json | 0 Tests/Fixtures/config-required.json | 0 Tests/Fixtures/config.json | 0 Tests/Info.plist | 0 Tests/LaunchGateSpec.swift | 0 Tests/MemorySpec.swift | 0 Tests/RemoteFileManagerSpec.swift | 0 Tests/SpecHelper.swift | 0 57 files changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 .gitignore mode change 100644 => 100755 .hound.yml mode change 100644 => 100755 .slather.yml mode change 100644 => 100755 .swiftlint.yml mode change 100644 => 100755 .travis.yml mode change 100644 => 100755 CHANGELOG.md mode change 100644 => 100755 Example/Example.xcodeproj/project.pbxproj mode change 100644 => 100755 Example/Example.xcodeproj/xcshareddata/xcschemes/Example.xcscheme mode change 100644 => 100755 Example/Example/Assets.xcassets/AppIcon.appiconset/Contents.json mode change 100644 => 100755 Example/Example/Base.lproj/LaunchScreen.storyboard mode change 100644 => 100755 Example/Example/Base.lproj/Main.storyboard mode change 100644 => 100755 Example/Example/Info.plist mode change 100644 => 100755 Example/Example/example.json mode change 100644 => 100755 Gemfile mode change 100644 => 100755 Gemfile.lock mode change 100644 => 100755 LICENSE mode change 100644 => 100755 LaunchGate.podspec mode change 100644 => 100755 LaunchGate.xcodeproj/project.pbxproj mode change 100644 => 100755 LaunchGate.xcodeproj/project.xcworkspace/contents.xcworkspacedata mode change 100644 => 100755 LaunchGate.xcodeproj/xcshareddata/xcschemes/LaunchGate.xcscheme mode change 100644 => 100755 LaunchGate.xcworkspace/contents.xcworkspacedata mode change 100644 => 100755 Podfile mode change 100644 => 100755 Podfile.lock mode change 100644 => 100755 README.md mode change 100644 => 100755 Screenshots/alert-blocking.png mode change 100644 => 100755 Screenshots/alert-nonblocking.png mode change 100644 => 100755 Screenshots/optional-update.png mode change 100644 => 100755 Screenshots/required-update.png mode change 100644 => 100755 Source/AlertConfiguration.swift mode change 100644 => 100755 Source/DefaultParser.swift mode change 100644 => 100755 Source/DialogManager.swift mode change 100644 => 100755 Source/Info.plist mode change 100644 => 100755 Source/LaunchGate.h mode change 100644 => 100755 Source/LaunchGate.swift mode change 100644 => 100755 Source/LaunchGateConfiguration.swift mode change 100644 => 100755 Source/LaunchGateParser.swift mode change 100644 => 100755 Source/Memory.swift mode change 100644 => 100755 Source/Rememberable.swift mode change 100644 => 100755 Source/RemoteFileManager.swift mode change 100644 => 100755 Source/UpdateConfiguration.swift mode change 100644 => 100755 Tests/ConfigurationSpec.swift mode change 100644 => 100755 Tests/DefaultParserSpec.swift mode change 100644 => 100755 Tests/DialogManagerSpec.swift mode change 100644 => 100755 Tests/Fixtures/config-alert.json mode change 100644 => 100755 Tests/Fixtures/config-malformed-alert.json mode change 100644 => 100755 Tests/Fixtures/config-malformed-empty.json mode change 100644 => 100755 Tests/Fixtures/config-malformed-ios.json mode change 100644 => 100755 Tests/Fixtures/config-malformed-optional.json mode change 100644 => 100755 Tests/Fixtures/config-malformed-required.json mode change 100644 => 100755 Tests/Fixtures/config-optional.json mode change 100644 => 100755 Tests/Fixtures/config-required.json mode change 100644 => 100755 Tests/Fixtures/config.json mode change 100644 => 100755 Tests/Info.plist mode change 100644 => 100755 Tests/LaunchGateSpec.swift mode change 100644 => 100755 Tests/MemorySpec.swift mode change 100644 => 100755 Tests/RemoteFileManagerSpec.swift mode change 100644 => 100755 Tests/SpecHelper.swift diff --git a/.gitignore b/.gitignore old mode 100644 new mode 100755 diff --git a/.hound.yml b/.hound.yml old mode 100644 new mode 100755 diff --git a/.slather.yml b/.slather.yml old mode 100644 new mode 100755 diff --git a/.swiftlint.yml b/.swiftlint.yml old mode 100644 new mode 100755 diff --git a/.travis.yml b/.travis.yml old mode 100644 new mode 100755 diff --git a/CHANGELOG.md b/CHANGELOG.md old mode 100644 new mode 100755 diff --git a/Example/Example.xcodeproj/project.pbxproj b/Example/Example.xcodeproj/project.pbxproj old mode 100644 new mode 100755 diff --git a/Example/Example.xcodeproj/xcshareddata/xcschemes/Example.xcscheme b/Example/Example.xcodeproj/xcshareddata/xcschemes/Example.xcscheme old mode 100644 new mode 100755 diff --git a/Example/Example/Assets.xcassets/AppIcon.appiconset/Contents.json b/Example/Example/Assets.xcassets/AppIcon.appiconset/Contents.json old mode 100644 new mode 100755 diff --git a/Example/Example/Base.lproj/LaunchScreen.storyboard b/Example/Example/Base.lproj/LaunchScreen.storyboard old mode 100644 new mode 100755 diff --git a/Example/Example/Base.lproj/Main.storyboard b/Example/Example/Base.lproj/Main.storyboard old mode 100644 new mode 100755 diff --git a/Example/Example/Info.plist b/Example/Example/Info.plist old mode 100644 new mode 100755 diff --git a/Example/Example/example.json b/Example/Example/example.json old mode 100644 new mode 100755 diff --git a/Gemfile b/Gemfile old mode 100644 new mode 100755 diff --git a/Gemfile.lock b/Gemfile.lock old mode 100644 new mode 100755 diff --git a/LICENSE b/LICENSE old mode 100644 new mode 100755 diff --git a/LaunchGate.podspec b/LaunchGate.podspec old mode 100644 new mode 100755 diff --git a/LaunchGate.xcodeproj/project.pbxproj b/LaunchGate.xcodeproj/project.pbxproj old mode 100644 new mode 100755 diff --git a/LaunchGate.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/LaunchGate.xcodeproj/project.xcworkspace/contents.xcworkspacedata old mode 100644 new mode 100755 diff --git a/LaunchGate.xcodeproj/xcshareddata/xcschemes/LaunchGate.xcscheme b/LaunchGate.xcodeproj/xcshareddata/xcschemes/LaunchGate.xcscheme old mode 100644 new mode 100755 diff --git a/LaunchGate.xcworkspace/contents.xcworkspacedata b/LaunchGate.xcworkspace/contents.xcworkspacedata old mode 100644 new mode 100755 diff --git a/Podfile b/Podfile old mode 100644 new mode 100755 diff --git a/Podfile.lock b/Podfile.lock old mode 100644 new mode 100755 diff --git a/README.md b/README.md old mode 100644 new mode 100755 diff --git a/Screenshots/alert-blocking.png b/Screenshots/alert-blocking.png old mode 100644 new mode 100755 diff --git a/Screenshots/alert-nonblocking.png b/Screenshots/alert-nonblocking.png old mode 100644 new mode 100755 diff --git a/Screenshots/optional-update.png b/Screenshots/optional-update.png old mode 100644 new mode 100755 diff --git a/Screenshots/required-update.png b/Screenshots/required-update.png old mode 100644 new mode 100755 diff --git a/Source/AlertConfiguration.swift b/Source/AlertConfiguration.swift old mode 100644 new mode 100755 diff --git a/Source/DefaultParser.swift b/Source/DefaultParser.swift old mode 100644 new mode 100755 diff --git a/Source/DialogManager.swift b/Source/DialogManager.swift old mode 100644 new mode 100755 diff --git a/Source/Info.plist b/Source/Info.plist old mode 100644 new mode 100755 diff --git a/Source/LaunchGate.h b/Source/LaunchGate.h old mode 100644 new mode 100755 diff --git a/Source/LaunchGate.swift b/Source/LaunchGate.swift old mode 100644 new mode 100755 diff --git a/Source/LaunchGateConfiguration.swift b/Source/LaunchGateConfiguration.swift old mode 100644 new mode 100755 diff --git a/Source/LaunchGateParser.swift b/Source/LaunchGateParser.swift old mode 100644 new mode 100755 diff --git a/Source/Memory.swift b/Source/Memory.swift old mode 100644 new mode 100755 diff --git a/Source/Rememberable.swift b/Source/Rememberable.swift old mode 100644 new mode 100755 diff --git a/Source/RemoteFileManager.swift b/Source/RemoteFileManager.swift old mode 100644 new mode 100755 diff --git a/Source/UpdateConfiguration.swift b/Source/UpdateConfiguration.swift old mode 100644 new mode 100755 diff --git a/Tests/ConfigurationSpec.swift b/Tests/ConfigurationSpec.swift old mode 100644 new mode 100755 diff --git a/Tests/DefaultParserSpec.swift b/Tests/DefaultParserSpec.swift old mode 100644 new mode 100755 diff --git a/Tests/DialogManagerSpec.swift b/Tests/DialogManagerSpec.swift old mode 100644 new mode 100755 diff --git a/Tests/Fixtures/config-alert.json b/Tests/Fixtures/config-alert.json old mode 100644 new mode 100755 diff --git a/Tests/Fixtures/config-malformed-alert.json b/Tests/Fixtures/config-malformed-alert.json old mode 100644 new mode 100755 diff --git a/Tests/Fixtures/config-malformed-empty.json b/Tests/Fixtures/config-malformed-empty.json old mode 100644 new mode 100755 diff --git a/Tests/Fixtures/config-malformed-ios.json b/Tests/Fixtures/config-malformed-ios.json old mode 100644 new mode 100755 diff --git a/Tests/Fixtures/config-malformed-optional.json b/Tests/Fixtures/config-malformed-optional.json old mode 100644 new mode 100755 diff --git a/Tests/Fixtures/config-malformed-required.json b/Tests/Fixtures/config-malformed-required.json old mode 100644 new mode 100755 diff --git a/Tests/Fixtures/config-optional.json b/Tests/Fixtures/config-optional.json old mode 100644 new mode 100755 diff --git a/Tests/Fixtures/config-required.json b/Tests/Fixtures/config-required.json old mode 100644 new mode 100755 diff --git a/Tests/Fixtures/config.json b/Tests/Fixtures/config.json old mode 100644 new mode 100755 diff --git a/Tests/Info.plist b/Tests/Info.plist old mode 100644 new mode 100755 diff --git a/Tests/LaunchGateSpec.swift b/Tests/LaunchGateSpec.swift old mode 100644 new mode 100755 diff --git a/Tests/MemorySpec.swift b/Tests/MemorySpec.swift old mode 100644 new mode 100755 diff --git a/Tests/RemoteFileManagerSpec.swift b/Tests/RemoteFileManagerSpec.swift old mode 100644 new mode 100755 diff --git a/Tests/SpecHelper.swift b/Tests/SpecHelper.swift old mode 100644 new mode 100755 From 2c59bf6de705e2a9fc216bd89812634dba93f1d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rodrigo=20Lo=CC=81pez-Romero=20Guijarro?= Date: Wed, 27 Sep 2017 10:51:27 +0200 Subject: [PATCH 21/27] chore: Update travis and gem files --- .travis.yml | 6 +++--- Gemfile | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index 903ce6e..dfecad9 100755 --- a/.travis.yml +++ b/.travis.yml @@ -4,7 +4,7 @@ branches: - travisCIProblemBranch - master language: objective-c -osx_image: xcode8 +osx_image: xcode9 notifications: slack: rooms: @@ -15,9 +15,9 @@ notifications: on_success: change before_install: - rvm use $RVM_RUBY_VERSION - - bundle + - bundle install - gem install slather - - pod repo update + - pod repo update --verbose - pod install after_success: - slather diff --git a/Gemfile b/Gemfile index 146ac62..8308684 100755 --- a/Gemfile +++ b/Gemfile @@ -1,2 +1,2 @@ source 'https://rubygems.org' -gem 'cocoapods', '~> 1.2.0' \ No newline at end of file +gem 'cocoapods' From 7a6b491ee913503aebbf3013e02e843c26c52d89 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rodrigo=20Lo=CC=81pez-Romero=20Guijarro?= Date: Wed, 27 Sep 2017 11:27:46 +0200 Subject: [PATCH 22/27] chore: update travis CI file --- .travis.yml | 14 +++++++++----- Gemfile.lock | 4 ++-- LaunchGate.xcodeproj/project.pbxproj | 6 ++---- 3 files changed, 13 insertions(+), 11 deletions(-) diff --git a/.travis.yml b/.travis.yml index dfecad9..2d192fb 100755 --- a/.travis.yml +++ b/.travis.yml @@ -3,7 +3,7 @@ branches: - develop - travisCIProblemBranch - master -language: objective-c +language: swift osx_image: xcode9 notifications: slack: @@ -15,13 +15,17 @@ notifications: on_success: change before_install: - rvm use $RVM_RUBY_VERSION - - bundle install + - gem install cocoapods + - gem install xcpretty -N - gem install slather - - pod repo update --verbose + - brew update + - brew install swiftlint || true + - pod repo update - pod install after_success: - slather - bash <(curl -s https://codecov.io/bash) -f cobertura.xml script: - - set -o pipefail && xcodebuild clean test -workspace LaunchGate.xcworkspace -scheme LaunchGate -destination 'platform=iOS Simulator,name=iPhone 6s' ONLY_ACTIVE_ARCH=YES | xcpretty - - pod lib lint + - set -o pipefail + - xcodebuild clean test -workspace LaunchGate.xcworkspace -scheme LaunchGate -destination 'platform=iOS Simulator,name=iPhone 6s' ONLY_ACTIVE_ARCH=YES | xcpretty + - swiftlint diff --git a/Gemfile.lock b/Gemfile.lock index 999cd8c..3c9f0c2 100755 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -66,7 +66,7 @@ PLATFORMS ruby DEPENDENCIES - cocoapods (~> 1.2.0) + cocoapods BUNDLED WITH - 1.13.2 + 1.15.4 diff --git a/LaunchGate.xcodeproj/project.pbxproj b/LaunchGate.xcodeproj/project.pbxproj index f86a748..6300260 100755 --- a/LaunchGate.xcodeproj/project.pbxproj +++ b/LaunchGate.xcodeproj/project.pbxproj @@ -199,8 +199,7 @@ C5478DD01C6968C800843BA3 /* UpdateConfiguration.swift */, C5A878AA1C6A7E36004599C2 /* Supporting Files */, ); - name = Source; - path = LaunchGate; + path = Source; sourceTree = ""; }; C5C04BD41C696767007397D0 /* Tests */ = { @@ -216,8 +215,7 @@ C5A8786D1C6A74B9004599C2 /* Fixtures */, C5A878AB1C6A7E3F004599C2 /* Supporting Files */, ); - name = Tests; - path = LaunchGateTests; + path = Tests; sourceTree = ""; }; /* End PBXGroup section */ From 33640eefa9d95d1b8b84e2f018e69ced39d49cb1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rodrigo=20Lo=CC=81pez-Romero=20Guijarro?= Date: Wed, 27 Sep 2017 11:44:33 +0200 Subject: [PATCH 23/27] chore: Update pods --- Podfile.lock | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Podfile.lock b/Podfile.lock index 91db8e1..f796125 100755 --- a/Podfile.lock +++ b/Podfile.lock @@ -1,7 +1,7 @@ PODS: - - Nimble (7.0.0) + - Nimble (7.0.2) - Quick (1.1.0) - - SwiftLint (0.18.1) + - SwiftLint (0.22.0) DEPENDENCIES: - Nimble @@ -9,9 +9,9 @@ DEPENDENCIES: - SwiftLint SPEC CHECKSUMS: - Nimble: 874982b605d4d752fcac6be695d13c502de84b1b + Nimble: bfe1f814edabba69ff145cb1283e04ed636a67f2 Quick: dafc587e21eed9f4cab3249b9f9015b0b7a7f71d - SwiftLint: b467d08f5b25dc3b3cfed243d8e1b74b91714c67 + SwiftLint: 1134786caedd2caab0560d2f36b76414a5a56808 PODFILE CHECKSUM: 135b4044b18ac1fb3ddfae8b0438dd0e41c6b159 From 30fea184d191b57ce8f52cbc91fee8547eb056b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rodrigo=20Lo=CC=81pez-Romero=20Guijarro?= Date: Wed, 27 Sep 2017 12:04:39 +0200 Subject: [PATCH 24/27] chore: Install cocoapods using bundler --- .travis.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 2d192fb..afc809c 100755 --- a/.travis.yml +++ b/.travis.yml @@ -15,9 +15,10 @@ notifications: on_success: change before_install: - rvm use $RVM_RUBY_VERSION - - gem install cocoapods + - bundle install - gem install xcpretty -N - gem install slather + - bundle update - brew update - brew install swiftlint || true - pod repo update From acd04c61fded3a01b4f893449276ff5ae20b66fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rodrigo=20Lo=CC=81pez-Romero=20Guijarro?= Date: Wed, 27 Sep 2017 12:42:05 +0200 Subject: [PATCH 25/27] test: Fix performRemoteFileRequest unit test --- Tests/RemoteFileManagerSpec.swift | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Tests/RemoteFileManagerSpec.swift b/Tests/RemoteFileManagerSpec.swift index 7c68dd1..518539b 100755 --- a/Tests/RemoteFileManagerSpec.swift +++ b/Tests/RemoteFileManagerSpec.swift @@ -59,8 +59,9 @@ class RemoteFileManagerSpec: QuickSpec { override func dataTask(with url: URL, completionHandler: @escaping (Data?, URLResponse?, Error?) -> Void) -> URLSessionDataTask { dataTaskWithURLWasCalled = true - - completionHandler(testData, nil, nil) + + let urlResponse = HTTPURLResponse(url: URL(string: "https://www.google.es/")!, statusCode: 200, httpVersion: nil, headerFields: nil) + completionHandler(testData, urlResponse, nil) return MockURLSessionDataTask() } From a592e20e4169f181cc82df1da3aca6a8719a6761 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rodrigo=20Lo=CC=81pez-Romero=20Guijarro?= Date: Wed, 27 Sep 2017 13:19:33 +0200 Subject: [PATCH 26/27] fix: correct example.json URL --- Example/Example/AppDelegate.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Example/Example/AppDelegate.swift b/Example/Example/AppDelegate.swift index 4377422..6beb3da 100644 --- a/Example/Example/AppDelegate.swift +++ b/Example/Example/AppDelegate.swift @@ -17,7 +17,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate { lazy var launchGate: LaunchGate? = { let launchGate = LaunchGate( - configURI: "https://raw.githubusercontent.com/dtrenz/LaunchGate/master/example.json", + configURI: "https://raw.githubusercontent.com/dtrenz/LaunchGate/master/Example/Example/example.json", appStoreURI: "itms-apps://itunes.apple.com/us/app/wikipedia-mobile/id324715238" ) From 2354553ac34815b0e1a5b784a6ee04bdc503aaf7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rodrigo=20Lo=CC=81pez-Romero=20Guijarro?= Date: Wed, 27 Sep 2017 16:30:40 +0200 Subject: [PATCH 27/27] fix: logic difference with Android There is a slight difference in the operation comparing to Gandalf: the alert has more priority over the optionalUpdate in Gandalf and in the LaunchGate it is just the opposite. Fixes #35 Android-iOS logic difference --- Source/LaunchGate.swift | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/Source/LaunchGate.swift b/Source/LaunchGate.swift index 2ec0215..75fcd15 100755 --- a/Source/LaunchGate.swift +++ b/Source/LaunchGate.swift @@ -78,18 +78,19 @@ open class LaunchGate { - dialogManager: Manager object for the various alert dialogs */ func displayDialogIfNecessary(_ config: LaunchGateConfiguration, dialogManager: DialogManager) { - if let reqUpdate = config.requiredUpdate, let appVersion = currentAppVersion() { - if shouldShowRequiredUpdateDialog(reqUpdate, appVersion: appVersion) { - dialogManager.displayRequiredUpdateDialog(reqUpdate, updateURL: updateURL) - } - } else if let optUpdate = config.optionalUpdate, let appVersion = currentAppVersion() { - if shouldShowOptionalUpdateDialog(optUpdate, appVersion: appVersion) { - dialogManager.displayOptionalUpdateDialog(optUpdate, updateURL: updateURL) - } - } else if let alert = config.alert { - if shouldShowAlertDialog(alert) { - dialogManager.displayAlertDialog(alert, blocking: alert.blocking) - } + if let reqUpdate = config.requiredUpdate, + let appVersion = currentAppVersion(), + shouldShowRequiredUpdateDialog(reqUpdate, appVersion: appVersion) { + dialogManager.displayRequiredUpdateDialog(reqUpdate, updateURL: updateURL) + } else if let alert = config.alert, + shouldShowAlertDialog(alert) { + dialogManager.displayAlertDialog(alert, blocking: alert.blocking) + } else if let optUpdate = config.optionalUpdate, + let appVersion = currentAppVersion(), + shouldShowOptionalUpdateDialog(optUpdate, appVersion: appVersion) { + dialogManager.displayOptionalUpdateDialog(optUpdate, updateURL: updateURL) + } else { + print("LaunchGate - No action is required") } }