Skip to content
This repository was archived by the owner on Jan 5, 2022. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Source/UsergridAsset.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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 -

Expand Down
2 changes: 1 addition & 1 deletion Source/UsergridEntity.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
6 changes: 3 additions & 3 deletions Source/UsergridRequestManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions Source/UsergridResponse.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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 ?? ""
}
Expand Down
4 changes: 2 additions & 2 deletions Source/UsergridResponseError.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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 -
Expand Down
2 changes: 1 addition & 1 deletion Source/UsergridSessionDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions Tests/ASSET_Tests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -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()
}
}
Expand Down
2 changes: 1 addition & 1 deletion Tests/User_Tests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
}
Expand Down
30 changes: 13 additions & 17 deletions UsergridSDK.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -498,7 +498,7 @@
isa = PBXProject;
attributes = {
LastSwiftUpdateCheck = 0720;
LastUpgradeCheck = 0800;
LastUpgradeCheck = 0920;
ORGANIZATIONNAME = "Apigee Inc.";
TargetAttributes = {
630A219E1C49BFFC008BE87F = {
Expand All @@ -507,7 +507,7 @@
};
630A21B71C49C473008BE87F = {
CreatedOnToolsVersion = 7.2;
LastSwiftMigration = 0800;
LastSwiftMigration = 0920;
};
6319202A1C48436500F99E86 = {
LastSwiftMigration = 0800;
Expand All @@ -522,7 +522,7 @@
};
63AF0E871BBC38FB009D4196 = {
CreatedOnToolsVersion = 7.0.1;
LastSwiftMigration = 0800;
LastSwiftMigration = 0920;
};
63EE60F11C406E1600AFC2CF = {
LastSwiftMigration = 0800;
Expand Down Expand Up @@ -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;
};
Expand All @@ -804,7 +803,6 @@
PRODUCT_NAME = "$(TARGET_NAME)";
SDKROOT = macosx;
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
SWIFT_VERSION = 3.0;
};
name = Release;
};
Expand All @@ -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;
};
Expand All @@ -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;
};
Expand All @@ -854,7 +850,6 @@
SDKROOT = macosx;
SKIP_INSTALL = YES;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 3.0;
};
name = Debug;
};
Expand All @@ -879,7 +874,6 @@
SDKROOT = macosx;
SKIP_INSTALL = YES;
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
SWIFT_VERSION = 3.0;
};
name = Release;
};
Expand All @@ -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;
};
Expand All @@ -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;
};
Expand All @@ -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;
Expand All @@ -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;
};
Expand All @@ -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;
Expand All @@ -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;
};
Expand Down Expand Up @@ -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 = "";
Expand Down Expand Up @@ -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";
Expand All @@ -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;
Expand All @@ -1063,7 +1060,6 @@
PRODUCT_NAME = UsergridSDK;
SKIP_INSTALL = YES;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 3.0;
};
name = Debug;
};
Expand All @@ -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;
Expand All @@ -1084,14 +1081,14 @@
PRODUCT_NAME = UsergridSDK;
SKIP_INSTALL = YES;
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
SWIFT_VERSION = 3.0;
};
name = Release;
};
63EE61091C406E1600AFC2CF /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
CLANG_ENABLE_MODULES = YES;
"CODE_SIGN_IDENTITY[sdk=appletvos*]" = "";
DEFINES_MODULE = YES;
DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 1;
Expand All @@ -1105,7 +1102,6 @@
SDKROOT = appletvos;
SKIP_INSTALL = YES;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 3.0;
TARGETED_DEVICE_FAMILY = 3;
};
name = Debug;
Expand All @@ -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;
Expand All @@ -1127,7 +1124,6 @@
SDKROOT = appletvos;
SKIP_INSTALL = YES;
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
SWIFT_VERSION = 3.0;
TARGETED_DEVICE_FAMILY = 3;
};
name = Release;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0800"
LastUpgradeVersion = "0920"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand All @@ -26,6 +26,7 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
language = ""
shouldUseLaunchSchemeArgsEnv = "YES"
codeCoverageEnabled = "YES">
<Testables>
Expand Down Expand Up @@ -56,6 +57,7 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
language = ""
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0800"
LastUpgradeVersion = "0920"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand All @@ -26,6 +26,7 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
language = ""
shouldUseLaunchSchemeArgsEnv = "YES"
codeCoverageEnabled = "YES">
<Testables>
Expand Down Expand Up @@ -56,6 +57,7 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
language = ""
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0800"
LastUpgradeVersion = "0920"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down Expand Up @@ -40,6 +40,7 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
language = ""
shouldUseLaunchSchemeArgsEnv = "YES"
codeCoverageEnabled = "YES">
<Testables>
Expand Down Expand Up @@ -70,6 +71,7 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
language = ""
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
Expand Down
Loading