diff --git a/Source/UsergridAsset.swift b/Source/UsergridAsset.swift index 93c88c7..87af86c 100644 --- a/Source/UsergridAsset.swift +++ b/Source/UsergridAsset.swift @@ -47,7 +47,7 @@ Unless defined, whenever possible, the content-type will be inferred from the da */ public class UsergridAsset: NSObject, NSCoding { - internal static let DEFAULT_FILE_NAME = "file" + public static let DEFAULT_FILE_NAME = "file" // MARK: - Instance Properties - diff --git a/Source/UsergridEntity.swift b/Source/UsergridEntity.swift index 7babee4..77dce16 100644 --- a/Source/UsergridEntity.swift +++ b/Source/UsergridEntity.swift @@ -89,7 +89,7 @@ open class UsergridEntity: NSObject, NSCoding { public var jsonObjectValue : [String:Any] { return self.properties } /// The string value. - public var stringValue : String { return NSString(data: try! JSONSerialization.data(withJSONObject: self.jsonObjectValue, options: .prettyPrinted), encoding: String.Encoding.utf8.rawValue) as! String } + public var stringValue : String { return NSString(data: try! JSONSerialization.data(withJSONObject: self.jsonObjectValue, options: .prettyPrinted), encoding: String.Encoding.utf8.rawValue)! as String } /// The description. open override var description : String { diff --git a/Source/UsergridRequestManager.swift b/Source/UsergridRequestManager.swift index a876f81..232d3ba 100644 --- a/Source/UsergridRequestManager.swift +++ b/Source/UsergridRequestManager.swift @@ -106,10 +106,10 @@ extension UsergridRequestManager { } } if createdUser == nil { - responseError = UsergridResponseError(jsonDictionary: jsonDict) ?? UsergridResponseError(errorName: "Auth Failed.", errorDescription: "Error Description: \(error?.localizedDescription).") + responseError = UsergridResponseError(jsonDictionary: jsonDict) ?? UsergridResponseError(errorName: "Auth Failed.", errorDescription: "Error Description: \(error?.localizedDescription ?? "").") } } else { - responseError = UsergridResponseError(errorName: "Auth Failed.", errorDescription: "Error Description: \(error?.localizedDescription).") + responseError = UsergridResponseError(errorName: "Auth Failed.", errorDescription: "Error Description: \(error?.localizedDescription ?? "").") } DispatchQueue.main.async { @@ -129,7 +129,7 @@ extension UsergridRequestManager { appAuth.accessToken = tokenAndExpiry.token appAuth.expiry = tokenAndExpiry.expiry } else { - responseError = UsergridResponseError(errorName: "Auth Failed.", errorDescription: "Error Description: \(error?.localizedDescription).") + responseError = UsergridResponseError(errorName: "Auth Failed.", errorDescription: "Error Description: \(error?.localizedDescription ?? "").") } DispatchQueue.main.async { diff --git a/Source/UsergridResponse.swift b/Source/UsergridResponse.swift index aa3f544..9a911cb 100644 --- a/Source/UsergridResponse.swift +++ b/Source/UsergridResponse.swift @@ -96,8 +96,8 @@ public class UsergridResponse: NSObject { /// The string value. public var stringValue : String { - if let responseJSON = self.responseJSON { - return NSString(data: try! JSONSerialization.data(withJSONObject: responseJSON, options: .prettyPrinted), encoding: String.Encoding.utf8.rawValue) as? String ?? "" + if let responseJSON = self.responseJSON, let string = NSString(data: try! JSONSerialization.data(withJSONObject: responseJSON, options: .prettyPrinted), encoding: String.Encoding.utf8.rawValue) as String? { + return string } else { return error?.description ?? "" } diff --git a/Source/UsergridResponseError.swift b/Source/UsergridResponseError.swift index f4dbc4a..4b381a3 100644 --- a/Source/UsergridResponseError.swift +++ b/Source/UsergridResponseError.swift @@ -42,12 +42,12 @@ public class UsergridResponseError: NSObject { /// The description. public override var description : String { - return "Error Name: \(errorName). Error Description: \(errorDescription). Exception: \(exception)." + return "Error Name: \(errorName). Error Description: \(errorDescription). Exception: \(exception ?? "")." } /// The debug description. public override var debugDescription : String { - return "Error Name: \(errorName). Error Description: \(errorDescription). Exception: \(exception)." + return "Error Name: \(errorName). Error Description: \(errorDescription). Exception: \(exception ?? "")." } // MARK: - Initialization - diff --git a/Source/UsergridSessionDelegate.swift b/Source/UsergridSessionDelegate.swift index 7866c26..1b8c206 100644 --- a/Source/UsergridSessionDelegate.swift +++ b/Source/UsergridSessionDelegate.swift @@ -49,7 +49,7 @@ extension UsergridSessionDelegate : URLSessionTaskDelegate { func urlSession(_ session: URLSession, task: URLSessionTask, didCompleteWithError error: Error?) { if let requestWrapper = requestDelegates[task.taskIdentifier] { - requestWrapper.error = error as? NSError // WTF + requestWrapper.error = error as NSError? // WTF requestWrapper.completion(requestWrapper) } self.removeRequestDelegate(task) diff --git a/Tests/ASSET_Tests.swift b/Tests/ASSET_Tests.swift index 0bbeb92..2ef5363 100644 --- a/Tests/ASSET_Tests.swift +++ b/Tests/ASSET_Tests.swift @@ -48,7 +48,7 @@ class ASSET_Tests: XCTestCase { } func getFullPathOfFile(_ fileLocation:String) -> String { - return (Bundle(for: object_getClass(self)).resourcePath!) + "/\(fileLocation)" + return (Bundle(for: object_getClass(self)!).resourcePath!) + "/\(fileLocation)" } func test_ASSET_INIT() { @@ -143,7 +143,7 @@ class ASSET_Tests: XCTestCase { XCTAssertTrue(removeResponse.ok) XCTAssertNotNil(removeResponse.user) XCTAssertNotNil(removeResponse.users) - print(removeResponse.error) + print(removeResponse.error ?? "No error.") expectation.fulfill() } } diff --git a/Tests/User_Tests.swift b/Tests/User_Tests.swift index aeea8c3..4af5c50 100644 --- a/Tests/User_Tests.swift +++ b/Tests/User_Tests.swift @@ -163,7 +163,7 @@ class User_Tests: XCTestCase { XCTAssertTrue(removeResponse.ok) XCTAssertNotNil(removeResponse.user) XCTAssertNotNil(removeResponse.users) - print(removeResponse.error) + print(removeResponse.error ?? "No error.") expectation.fulfill() } } diff --git a/UsergridSDK.xcodeproj/project.pbxproj b/UsergridSDK.xcodeproj/project.pbxproj index af92c89..e29d3a7 100644 --- a/UsergridSDK.xcodeproj/project.pbxproj +++ b/UsergridSDK.xcodeproj/project.pbxproj @@ -498,7 +498,7 @@ isa = PBXProject; attributes = { LastSwiftUpdateCheck = 0720; - LastUpgradeCheck = 0800; + LastUpgradeCheck = 0920; ORGANIZATIONNAME = "Apigee Inc."; TargetAttributes = { 630A219E1C49BFFC008BE87F = { @@ -507,7 +507,7 @@ }; 630A21B71C49C473008BE87F = { CreatedOnToolsVersion = 7.2; - LastSwiftMigration = 0800; + LastSwiftMigration = 0920; }; 6319202A1C48436500F99E86 = { LastSwiftMigration = 0800; @@ -522,7 +522,7 @@ }; 63AF0E871BBC38FB009D4196 = { CreatedOnToolsVersion = 7.0.1; - LastSwiftMigration = 0800; + LastSwiftMigration = 0920; }; 63EE60F11C406E1600AFC2CF = { LastSwiftMigration = 0800; @@ -788,7 +788,6 @@ PRODUCT_BUNDLE_IDENTIFIER = "org.apache.usergrid.swift-OSX-Tests"; PRODUCT_NAME = "$(TARGET_NAME)"; SDKROOT = macosx; - SWIFT_VERSION = 3.0; }; name = Debug; }; @@ -804,7 +803,6 @@ PRODUCT_NAME = "$(TARGET_NAME)"; SDKROOT = macosx; SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; - SWIFT_VERSION = 3.0; }; name = Release; }; @@ -816,7 +814,6 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = "org.apache.usergrid.swift-iOS-Tests"; PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_VERSION = 3.0; }; name = Debug; }; @@ -829,7 +826,6 @@ PRODUCT_BUNDLE_IDENTIFIER = "org.apache.usergrid.swift-iOS-Tests"; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; - SWIFT_VERSION = 3.0; }; name = Release; }; @@ -854,7 +850,6 @@ SDKROOT = macosx; SKIP_INSTALL = YES; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; - SWIFT_VERSION = 3.0; }; name = Debug; }; @@ -879,7 +874,6 @@ SDKROOT = macosx; SKIP_INSTALL = YES; SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; - SWIFT_VERSION = 3.0; }; name = Release; }; @@ -891,7 +885,6 @@ PRODUCT_BUNDLE_IDENTIFIER = "org.apache.usergrid.swift-TVOS-Tests"; PRODUCT_NAME = "$(TARGET_NAME)"; SDKROOT = appletvos; - SWIFT_VERSION = 3.0; TARGETED_DEVICE_FAMILY = 3; TVOS_DEPLOYMENT_TARGET = 10.0; }; @@ -906,7 +899,6 @@ PRODUCT_NAME = "$(TARGET_NAME)"; SDKROOT = appletvos; SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; - SWIFT_VERSION = 3.0; TARGETED_DEVICE_FAMILY = 3; TVOS_DEPLOYMENT_TARGET = 10.0; }; @@ -916,6 +908,7 @@ isa = XCBuildConfiguration; buildSettings = { APPLICATION_EXTENSION_API_ONLY = YES; + "CODE_SIGN_IDENTITY[sdk=watchos*]" = ""; DEFINES_MODULE = YES; DYLIB_COMPATIBILITY_VERSION = 1; DYLIB_CURRENT_VERSION = 1; @@ -927,7 +920,6 @@ PRODUCT_NAME = UsergridSDK; SDKROOT = watchos; SKIP_INSTALL = YES; - SWIFT_VERSION = 3.0; TARGETED_DEVICE_FAMILY = 4; WATCHOS_DEPLOYMENT_TARGET = 2.1; }; @@ -937,6 +929,7 @@ isa = XCBuildConfiguration; buildSettings = { APPLICATION_EXTENSION_API_ONLY = YES; + "CODE_SIGN_IDENTITY[sdk=watchos*]" = ""; DEFINES_MODULE = YES; DYLIB_COMPATIBILITY_VERSION = 1; DYLIB_CURRENT_VERSION = 1; @@ -949,7 +942,6 @@ SDKROOT = watchos; SKIP_INSTALL = YES; SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; - SWIFT_VERSION = 3.0; TARGETED_DEVICE_FAMILY = 4; WATCHOS_DEPLOYMENT_TARGET = 2.1; }; @@ -998,6 +990,8 @@ ONLY_ACTIVE_ARCH = YES; SDKROOT = iphoneos; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + SWIFT_SWIFT3_OBJC_INFERENCE = Off; + SWIFT_VERSION = 4.0; TARGETED_DEVICE_FAMILY = "1,2"; VERSIONING_SYSTEM = "apple-generic"; VERSION_INFO_PREFIX = ""; @@ -1039,6 +1033,8 @@ IPHONEOS_DEPLOYMENT_TARGET = 9.0; MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = iphoneos; + SWIFT_SWIFT3_OBJC_INFERENCE = Off; + SWIFT_VERSION = 4.0; TARGETED_DEVICE_FAMILY = "1,2"; VALIDATE_PRODUCT = YES; VERSIONING_SYSTEM = "apple-generic"; @@ -1051,6 +1047,7 @@ buildSettings = { CLANG_ENABLE_MODULES = YES; CODE_SIGN_IDENTITY = "iPhone Developer"; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = ""; DEFINES_MODULE = YES; DYLIB_COMPATIBILITY_VERSION = 1; DYLIB_CURRENT_VERSION = 1; @@ -1063,7 +1060,6 @@ PRODUCT_NAME = UsergridSDK; SKIP_INSTALL = YES; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; - SWIFT_VERSION = 3.0; }; name = Debug; }; @@ -1072,6 +1068,7 @@ buildSettings = { CLANG_ENABLE_MODULES = YES; CODE_SIGN_IDENTITY = "iPhone Developer"; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = ""; DEFINES_MODULE = YES; DYLIB_COMPATIBILITY_VERSION = 1; DYLIB_CURRENT_VERSION = 1; @@ -1084,7 +1081,6 @@ PRODUCT_NAME = UsergridSDK; SKIP_INSTALL = YES; SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; - SWIFT_VERSION = 3.0; }; name = Release; }; @@ -1092,6 +1088,7 @@ isa = XCBuildConfiguration; buildSettings = { CLANG_ENABLE_MODULES = YES; + "CODE_SIGN_IDENTITY[sdk=appletvos*]" = ""; DEFINES_MODULE = YES; DYLIB_COMPATIBILITY_VERSION = 1; DYLIB_CURRENT_VERSION = 1; @@ -1105,7 +1102,6 @@ SDKROOT = appletvos; SKIP_INSTALL = YES; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; - SWIFT_VERSION = 3.0; TARGETED_DEVICE_FAMILY = 3; }; name = Debug; @@ -1114,6 +1110,7 @@ isa = XCBuildConfiguration; buildSettings = { CLANG_ENABLE_MODULES = YES; + "CODE_SIGN_IDENTITY[sdk=appletvos*]" = ""; DEFINES_MODULE = YES; DYLIB_COMPATIBILITY_VERSION = 1; DYLIB_CURRENT_VERSION = 1; @@ -1127,7 +1124,6 @@ SDKROOT = appletvos; SKIP_INSTALL = YES; SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; - SWIFT_VERSION = 3.0; TARGETED_DEVICE_FAMILY = 3; }; name = Release; diff --git a/UsergridSDK.xcodeproj/xcshareddata/xcschemes/UsergridSDK OSX.xcscheme b/UsergridSDK.xcodeproj/xcshareddata/xcschemes/UsergridSDK OSX.xcscheme index 7cb7a01..ae0727e 100644 --- a/UsergridSDK.xcodeproj/xcshareddata/xcschemes/UsergridSDK OSX.xcscheme +++ b/UsergridSDK.xcodeproj/xcshareddata/xcschemes/UsergridSDK OSX.xcscheme @@ -1,6 +1,6 @@ @@ -56,6 +57,7 @@ buildConfiguration = "Debug" selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" + language = "" launchStyle = "0" useCustomWorkingDirectory = "NO" ignoresPersistentStateOnLaunch = "NO" diff --git a/UsergridSDK.xcodeproj/xcshareddata/xcschemes/UsergridSDK iOS.xcscheme b/UsergridSDK.xcodeproj/xcshareddata/xcschemes/UsergridSDK iOS.xcscheme index 87f3d97..030de55 100644 --- a/UsergridSDK.xcodeproj/xcshareddata/xcschemes/UsergridSDK iOS.xcscheme +++ b/UsergridSDK.xcodeproj/xcshareddata/xcschemes/UsergridSDK iOS.xcscheme @@ -1,6 +1,6 @@ @@ -56,6 +57,7 @@ buildConfiguration = "Debug" selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" + language = "" launchStyle = "0" useCustomWorkingDirectory = "NO" ignoresPersistentStateOnLaunch = "NO" diff --git a/UsergridSDK.xcodeproj/xcshareddata/xcschemes/UsergridSDK tvOS.xcscheme b/UsergridSDK.xcodeproj/xcshareddata/xcschemes/UsergridSDK tvOS.xcscheme index ed7fbc6..b41aeaa 100644 --- a/UsergridSDK.xcodeproj/xcshareddata/xcschemes/UsergridSDK tvOS.xcscheme +++ b/UsergridSDK.xcodeproj/xcshareddata/xcschemes/UsergridSDK tvOS.xcscheme @@ -1,6 +1,6 @@ @@ -70,6 +71,7 @@ buildConfiguration = "Debug" selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" + language = "" launchStyle = "0" useCustomWorkingDirectory = "NO" ignoresPersistentStateOnLaunch = "NO" diff --git a/UsergridSDK.xcodeproj/xcshareddata/xcschemes/UsergridSDK watchOS.xcscheme b/UsergridSDK.xcodeproj/xcshareddata/xcschemes/UsergridSDK watchOS.xcscheme index 66d0592..1f8c0c4 100644 --- a/UsergridSDK.xcodeproj/xcshareddata/xcschemes/UsergridSDK watchOS.xcscheme +++ b/UsergridSDK.xcodeproj/xcshareddata/xcschemes/UsergridSDK watchOS.xcscheme @@ -1,6 +1,6 @@ @@ -36,6 +37,7 @@ buildConfiguration = "Debug" selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" + language = "" launchStyle = "0" useCustomWorkingDirectory = "NO" ignoresPersistentStateOnLaunch = "NO" diff --git a/UsergridSDK.xcodeproj/xcshareddata/xcschemes/UsergridSDK_OSX_Tests.xcscheme b/UsergridSDK.xcodeproj/xcshareddata/xcschemes/UsergridSDK_OSX_Tests.xcscheme index 27f424a..e29e437 100644 --- a/UsergridSDK.xcodeproj/xcshareddata/xcschemes/UsergridSDK_OSX_Tests.xcscheme +++ b/UsergridSDK.xcodeproj/xcshareddata/xcschemes/UsergridSDK_OSX_Tests.xcscheme @@ -1,6 +1,6 @@ @@ -31,6 +32,7 @@ buildConfiguration = "Debug" selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" + language = "" launchStyle = "0" useCustomWorkingDirectory = "NO" ignoresPersistentStateOnLaunch = "NO"