Skip to content
This repository has been archived by the owner on Mar 10, 2022. It is now read-only.

Commit

Permalink
Upgrade to Swift5
Browse files Browse the repository at this point in the history
  • Loading branch information
Jakob Mygind committed Mar 27, 2019
1 parent d5ec01a commit f3aa715
Show file tree
Hide file tree
Showing 9 changed files with 34 additions and 35 deletions.
23 changes: 11 additions & 12 deletions Serpent/Serpent.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -699,16 +699,16 @@
isa = PBXProject;
attributes = {
LastSwiftUpdateCheck = 0720;
LastUpgradeCheck = 1010;
LastUpgradeCheck = 1020;
ORGANIZATIONNAME = Nodes;
TargetAttributes = {
272F1DC51C6A392A0098F620 = {
CreatedOnToolsVersion = 7.2.1;
LastSwiftMigration = 1010;
LastSwiftMigration = 1020;
};
272F1DCF1C6A392A0098F620 = {
CreatedOnToolsVersion = 7.2.1;
LastSwiftMigration = 1010;
LastSwiftMigration = 1020;
};
2732EC8C1C9F21A500BFD4E1 = {
CreatedOnToolsVersion = 7.2.1;
Expand All @@ -734,10 +734,11 @@
};
buildConfigurationList = 272F1DC01C6A392A0098F620 /* Build configuration list for PBXProject "Serpent" */;
compatibilityVersion = "Xcode 3.2";
developmentRegion = English;
developmentRegion = en;
hasScannedForEncodings = 0;
knownRegions = (
en,
Base,
);
mainGroup = 272F1DBC1C6A392A0098F620;
productRefGroup = 272F1DC71C6A392A0098F620 /* Products */;
Expand Down Expand Up @@ -1029,6 +1030,7 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
Expand Down Expand Up @@ -1093,6 +1095,7 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
Expand Down Expand Up @@ -1165,8 +1168,7 @@
PRODUCT_NAME = Serpent;
SKIP_INSTALL = YES;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
SWIFT_VERSION = 4.2;
SWIFT_VERSION = 5.0;
};
name = Debug;
};
Expand All @@ -1187,8 +1189,7 @@
PRODUCT_BUNDLE_IDENTIFIER = com.nodes.Serpent;
PRODUCT_NAME = Serpent;
SKIP_INSTALL = YES;
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
SWIFT_VERSION = 4.2;
SWIFT_VERSION = 5.0;
};
name = Release;
};
Expand All @@ -1203,8 +1204,7 @@
PRODUCT_BUNDLE_IDENTIFIER = com.nodes.SerpentTests;
PRODUCT_NAME = "$(TARGET_NAME)";
REEXPORTED_LIBRARY_PATHS = "";
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
SWIFT_VERSION = 4.2;
SWIFT_VERSION = 5.0;
};
name = Debug;
};
Expand All @@ -1219,8 +1219,7 @@
PRODUCT_BUNDLE_IDENTIFIER = com.nodes.SerpentTests;
PRODUCT_NAME = "$(TARGET_NAME)";
REEXPORTED_LIBRARY_PATHS = "";
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
SWIFT_VERSION = 4.2;
SWIFT_VERSION = 5.0;
};
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 = "1010"
LastUpgradeVersion = "1020"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
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 = "1010"
LastUpgradeVersion = "1020"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
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 = "1010"
LastUpgradeVersion = "1020"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
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 = "1010"
LastUpgradeVersion = "1020"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
8 changes: 4 additions & 4 deletions Serpent/Serpent/Classes/Extensions/AlamofireExtension.swift
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public extension Parser {
The default unwrapper. Default implementation just passes data straight through.
*/

public static var defaultUnwrapper: Unwrapper = { a, b in return a }
static var defaultUnwrapper: Unwrapper = { a, b in return a }
}


Expand All @@ -74,7 +74,7 @@ public extension Alamofire.DataRequest
- returns: The request
*/
@discardableResult
public func responseSerializable<T:Decodable>(_ completionHandler: @escaping (DataResponse<T>) -> Void,
func responseSerializable<T:Decodable>(_ completionHandler: @escaping (DataResponse<T>) -> Void,
unwrapper:@escaping Parser.Unwrapper = Parser.defaultUnwrapper) -> Self {
let serializer = Parser.serializer { (data: Any?) -> T? in

Expand Down Expand Up @@ -104,7 +104,7 @@ public extension Alamofire.DataRequest
- returns: The request
*/
@discardableResult
public func responseSerializable<T:Decodable>(_ completionHandler: @escaping (DataResponse<[T]>) -> Void,
func responseSerializable<T:Decodable>(_ completionHandler: @escaping (DataResponse<[T]>) -> Void,
unwrapper:@escaping Parser.Unwrapper = Parser.defaultUnwrapper) -> Self {

let serializer = Parser.serializer { (data: Any?) -> [T]? in
Expand All @@ -129,7 +129,7 @@ public extension Alamofire.DataRequest
*/

@discardableResult
public func responseSerializable(_ completionHandler: @escaping (DataResponse<NilSerializable>) -> Void) -> Self {
func responseSerializable(_ completionHandler: @escaping (DataResponse<NilSerializable>) -> Void) -> Self {
return validate().responseJSON(completionHandler: completionHandler)
}

Expand Down
12 changes: 6 additions & 6 deletions Serpent/Serpent/Classes/Extensions/CashierExtension.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public extension Cashier {
- object: Generic type which confroms with `Serializable`.
- key: Key as a `String`.
*/
public func setSerializable<T>(_ object: T, forKey key: String) where T: Serializable {
func setSerializable<T>(_ object: T, forKey key: String) where T: Serializable {
let box = BridgingBox(object)
self.setObject(box, forKey: key)
BridgingBox.sharedBoxCache[self.id+key] = object
Expand All @@ -31,7 +31,7 @@ public extension Cashier {
- object: Generic type which confroms with `_ArrayType`.
- key: Key as a `String`.
*/
public func setSerializable<T>(_ object: T, forKey key: String) where T: Sequence, T.Iterator.Element: Serializable {
func setSerializable<T>(_ object: T, forKey key: String) where T: Sequence, T.Iterator.Element: Serializable {
let boxedArray = object.map { BridgingBox($0) }
self.setObject(boxedArray, forKey: key)
BridgingBox.sharedBoxCache[self.id+key] = object
Expand All @@ -47,7 +47,7 @@ public extension Cashier {
- Parameter key: `Key` for `BridgingBox` or `objectForKey` as `String`.
- Returns: Generic type stored value/object that conforms with `Serializable` or return `nil`.
*/
public func serializableForKey<T>(_ key: String) -> T? where T:Serializable {
func serializableForKey<T>(_ key: String) -> T? where T:Serializable {
if let cachedSerializable = BridgingBox.sharedBoxCache[self.id+key] as? T {
return self.object(forKeyIsValid: key) ? cachedSerializable : nil
}
Expand All @@ -72,7 +72,7 @@ public extension Cashier {
- Parameter key: `Key` for `BridgingBox` as `String`.
- Returns: Array that holds object that conforms with `Serializable` or return `nil`.
*/
public func serializableForKey<T>(_ key: String) -> [T]? where T:Serializable {
func serializableForKey<T>(_ key: String) -> [T]? where T:Serializable {
if let cachedSerializable = BridgingBox.sharedBoxCache[self.id+key] as? [T] {
return self.object(forKeyIsValid: key) ? cachedSerializable : nil
}
Expand Down Expand Up @@ -100,7 +100,7 @@ public extension Cashier {
- parameter purgeMemoryCaches: If set to `true`, it will also purge all memory caches, including
the shared bridging box cache for objects adhering to `Serializable`.
*/
public func clearAllData(_ purgeMemoryCaches: Bool) {
func clearAllData(_ purgeMemoryCaches: Bool) {
self.clearAllData()

if purgeMemoryCaches {
Expand All @@ -114,7 +114,7 @@ public extension Cashier {
- parameter key: `Key` for `BridgingBox` as `String`.
- parameter purgeMemoryCache: If set to `true`, it will also purge the memory cache.
*/
public func deleteSerializableForKey(_ key: String, purgeMemoryCache purge: Bool = true) {
func deleteSerializableForKey(_ key: String, purgeMemoryCache purge: Bool = true) {
if purge {
BridgingBox.sharedBoxCache.removeValue(forKey: self.id+key)
}
Expand Down
2 changes: 1 addition & 1 deletion Serpent/Serpent/Classes/Extensions/Extensions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ public extension Sequence where Iterator.Element:Encodable {
// MARK: RawRepresentable

public extension RawRepresentable {
public func encodableRepresentation() -> RawValue {
func encodableRepresentation() -> RawValue {
return self.rawValue
}
}
Expand Down
16 changes: 8 additions & 8 deletions Serpent/Serpent/Classes/Serpent.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public protocol Decodable {
}

public extension Decodable {
public static func array(_ source: Any?) -> [Self] {
static func array(_ source: Any?) -> [Self] {
guard let source = source as? [NSDictionary] else {
return [Self]()
}
Expand Down Expand Up @@ -53,7 +53,7 @@ public extension Keymappable {

- returns: A mapped object conforming to *Serializable*, or nil if parsing failed
*/
public func mapped<T>(_ dictionary: NSDictionary?, key: String) -> T? where T:Decodable {
func mapped<T>(_ dictionary: NSDictionary?, key: String) -> T? where T:Decodable {

// Ensure the dictionary is not nil
guard let dict = dictionary else { return nil }
Expand All @@ -77,7 +77,7 @@ public extension Keymappable {

- returns: An array of mapped objects conforming to *Serializable*, or an empty array if parsing failed.
*/
public func mapped<T>(_ dictionary: NSDictionary?, key: String) -> T? where T:Sequence, T.Iterator.Element: Decodable {
func mapped<T>(_ dictionary: NSDictionary?, key: String) -> T? where T:Sequence, T.Iterator.Element: Decodable {
// Ensure the dictionary is not nil and get the value from the dictionary for our key
guard let dict = dictionary, let sourceOpt = dict[key] else { return nil }

Expand All @@ -103,7 +103,7 @@ public extension Keymappable {

- returns: The value of primitive type `T` or `nil` if parsing was unsuccessful.
*/
public func mapped<T>(_ dictionary: NSDictionary?, key: String) -> T? {
func mapped<T>(_ dictionary: NSDictionary?, key: String) -> T? {

// Ensure the dictionary is not nil
guard let dict = dictionary else { return nil }
Expand Down Expand Up @@ -159,7 +159,7 @@ public extension Keymappable {

- returns: The value of type `T` or `nil` if parsing was unsuccessful.
*/
public func mapped<T:StringInitializable>(_ dictionary: NSDictionary?, key: String) -> T? {
func mapped<T:StringInitializable>(_ dictionary: NSDictionary?, key: String) -> T? {
if let dict = dictionary, let source = dict[key] as? String , source.isEmpty == false {
return T.fromString(source)
}
Expand All @@ -184,7 +184,7 @@ public extension Keymappable {
- returns: The enumeration of enum type `T` or `nil` if parsing was unsuccessful or
enumeration does not exist.
*/
public func mapped<T:RawRepresentable>(_ dictionary: NSDictionary?, key: String) -> T? {
func mapped<T:RawRepresentable>(_ dictionary: NSDictionary?, key: String) -> T? {
guard let source: T.RawValue = self.mapped(dictionary, key: key) else {
return nil
}
Expand All @@ -205,7 +205,7 @@ public extension Keymappable {

- returns: An array of enum type `T` or an empty array if parsing was unsuccessful.
*/
public func mapped<T>(_ dictionary: NSDictionary?, key: String) -> T? where T:Sequence, T.Iterator.Element: RawRepresentable {
func mapped<T>(_ dictionary: NSDictionary?, key: String) -> T? where T:Sequence, T.Iterator.Element: RawRepresentable {
if let dict = dictionary, let source = dict[key] as? [T.Iterator.Element.RawValue] {
let finalArray = source.map { T.Iterator.Element.init(rawValue: $0)! }
return (finalArray as! T)
Expand All @@ -229,7 +229,7 @@ public extension Keymappable {

- returns: The value of type `T` or `nil` if parsing was unsuccessful.
*/
public func mapped<T: HexInitializable>(_ dictionary: NSDictionary?, key: String) -> T? {
func mapped<T: HexInitializable>(_ dictionary: NSDictionary?, key: String) -> T? {
guard let dict = dictionary, let source = dict[key] else {
return nil
}
Expand Down

0 comments on commit f3aa715

Please sign in to comment.