Skip to content

Commit

Permalink
Swift 4 compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
Hilen committed Nov 8, 2017
1 parent c72c36f commit 8213bc6
Show file tree
Hide file tree
Showing 16 changed files with 97 additions and 76 deletions.
2 changes: 1 addition & 1 deletion .swift-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.0
4.0
10 changes: 6 additions & 4 deletions Demo/Podfile.lock
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
PODS:
- TimedSilver (0.1.1)
- TimedSilver (1.1.0)

DEPENDENCIES:
- TimedSilver (from `../`)

EXTERNAL SOURCES:
TimedSilver:
:path: ../
:path: "../"

SPEC CHECKSUMS:
TimedSilver: 56137f4a9f7ee4bb07e3f7a9833691e5c4beb983
TimedSilver: 9a4db36b50fe8dd2f76ec28a1d5b6f0e98f6bb30

COCOAPODS: 0.39.0
PODFILE CHECKSUM: 416a9304df26078601f30ee2451b2f3dbe8abf38

COCOAPODS: 1.2.0
82 changes: 49 additions & 33 deletions Demo/TimedSilverExample.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@
objects = {

/* Begin PBXBuildFile section */
6640AF2AC6CA686EB97CB29B /* Pods_TimedSilverExample.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C667354C03077DB65A58E241 /* Pods_TimedSilverExample.framework */; };
AEBAE9401D8E8AF200CFDBD5 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = AEBAE93F1D8E8AF200CFDBD5 /* AppDelegate.swift */; };
AEBAE9421D8E8AF200CFDBD5 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = AEBAE9411D8E8AF200CFDBD5 /* ViewController.swift */; };
AEBAE9451D8E8AF200CFDBD5 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = AEBAE9431D8E8AF200CFDBD5 /* Main.storyboard */; };
AEBAE9471D8E8AF200CFDBD5 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = AEBAE9461D8E8AF200CFDBD5 /* Assets.xcassets */; };
AEBAE94A1D8E8AF200CFDBD5 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = AEBAE9481D8E8AF200CFDBD5 /* LaunchScreen.storyboard */; };
AEBAE9551D8E8AF200CFDBD5 /* TimedSilverExampleTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = AEBAE9541D8E8AF200CFDBD5 /* TimedSilverExampleTests.swift */; };
F3B884ECE2427EB04D2A3DC5 /* Pods_TimedSilverExample.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 7B9D3E48314E78737066C491 /* Pods_TimedSilverExample.framework */; };
/* End PBXBuildFile section */

/* Begin PBXContainerItemProxy section */
Expand All @@ -27,9 +27,8 @@
/* End PBXContainerItemProxy section */

/* Begin PBXFileReference section */
71CF4986250D365A62A131F6 /* Pods-TimedSilverExample.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-TimedSilverExample.release.xcconfig"; path = "Pods/Target Support Files/Pods-TimedSilverExample/Pods-TimedSilverExample.release.xcconfig"; sourceTree = "<group>"; };
7B9D3E48314E78737066C491 /* Pods_TimedSilverExample.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_TimedSilverExample.framework; sourceTree = BUILT_PRODUCTS_DIR; };
829DD242BE8471F96F3FD65C /* Pods-TimedSilverExample.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-TimedSilverExample.debug.xcconfig"; path = "Pods/Target Support Files/Pods-TimedSilverExample/Pods-TimedSilverExample.debug.xcconfig"; sourceTree = "<group>"; };
74904B260662CC4D85CA4568 /* Pods-TimedSilverExample.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-TimedSilverExample.debug.xcconfig"; path = "Pods/Target Support Files/Pods-TimedSilverExample/Pods-TimedSilverExample.debug.xcconfig"; sourceTree = "<group>"; };
96DEBC55B60AFCE4512BCF98 /* Pods-TimedSilverExample.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-TimedSilverExample.release.xcconfig"; path = "Pods/Target Support Files/Pods-TimedSilverExample/Pods-TimedSilverExample.release.xcconfig"; sourceTree = "<group>"; };
AEBAE93C1D8E8AF200CFDBD5 /* TimedSilverExample.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = TimedSilverExample.app; sourceTree = BUILT_PRODUCTS_DIR; };
AEBAE93F1D8E8AF200CFDBD5 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
AEBAE9411D8E8AF200CFDBD5 /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = "<group>"; };
Expand All @@ -40,14 +39,15 @@
AEBAE9501D8E8AF200CFDBD5 /* TimedSilverExampleTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = TimedSilverExampleTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
AEBAE9541D8E8AF200CFDBD5 /* TimedSilverExampleTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TimedSilverExampleTests.swift; sourceTree = "<group>"; };
AEBAE9561D8E8AF200CFDBD5 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
C667354C03077DB65A58E241 /* Pods_TimedSilverExample.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_TimedSilverExample.framework; sourceTree = BUILT_PRODUCTS_DIR; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
AEBAE9391D8E8AF200CFDBD5 /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
F3B884ECE2427EB04D2A3DC5 /* Pods_TimedSilverExample.framework in Frameworks */,
6640AF2AC6CA686EB97CB29B /* Pods_TimedSilverExample.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand All @@ -61,13 +61,12 @@
/* End PBXFrameworksBuildPhase section */

/* Begin PBXGroup section */
2CA1DF2484E33BAFD69880F1 /* Pods */ = {
9F8718EE01F821E5C854F8F6 /* Frameworks */ = {
isa = PBXGroup;
children = (
829DD242BE8471F96F3FD65C /* Pods-TimedSilverExample.debug.xcconfig */,
71CF4986250D365A62A131F6 /* Pods-TimedSilverExample.release.xcconfig */,
C667354C03077DB65A58E241 /* Pods_TimedSilverExample.framework */,
);
name = Pods;
name = Frameworks;
sourceTree = "<group>";
};
AEBAE9331D8E8AF200CFDBD5 = {
Expand All @@ -76,8 +75,8 @@
AEBAE93E1D8E8AF200CFDBD5 /* TimedSilverExample */,
AEBAE9531D8E8AF200CFDBD5 /* TimedSilverExampleTests */,
AEBAE93D1D8E8AF200CFDBD5 /* Products */,
2CA1DF2484E33BAFD69880F1 /* Pods */,
C29E39200D01CC9351A7EB70 /* Frameworks */,
D47055B4FC0570C764FE0D24 /* Pods */,
9F8718EE01F821E5C854F8F6 /* Frameworks */,
);
sourceTree = "<group>";
};
Expand Down Expand Up @@ -112,12 +111,13 @@
path = TimedSilverExampleTests;
sourceTree = "<group>";
};
C29E39200D01CC9351A7EB70 /* Frameworks */ = {
D47055B4FC0570C764FE0D24 /* Pods */ = {
isa = PBXGroup;
children = (
7B9D3E48314E78737066C491 /* Pods_TimedSilverExample.framework */,
74904B260662CC4D85CA4568 /* Pods-TimedSilverExample.debug.xcconfig */,
96DEBC55B60AFCE4512BCF98 /* Pods-TimedSilverExample.release.xcconfig */,
);
name = Frameworks;
name = Pods;
sourceTree = "<group>";
};
/* End PBXGroup section */
Expand All @@ -127,12 +127,12 @@
isa = PBXNativeTarget;
buildConfigurationList = AEBAE9591D8E8AF200CFDBD5 /* Build configuration list for PBXNativeTarget "TimedSilverExample" */;
buildPhases = (
F3536D336CE396E39A57E469 /* Check Pods Manifest.lock */,
0249506483674692E9C1309A /* [CP] Check Pods Manifest.lock */,
AEBAE9381D8E8AF200CFDBD5 /* Sources */,
AEBAE9391D8E8AF200CFDBD5 /* Frameworks */,
AEBAE93A1D8E8AF200CFDBD5 /* Resources */,
CD04BFB02355E7694C064855 /* Embed Pods Frameworks */,
F0ED6F48A43F8B623CCC6510 /* Copy Pods Resources */,
ED52BC296B9EF83249163349 /* [CP] Embed Pods Frameworks */,
201A5143EF5307CE6CDE43D3 /* [CP] Copy Pods Resources */,
);
buildRules = (
);
Expand Down Expand Up @@ -168,7 +168,7 @@
isa = PBXProject;
attributes = {
LastSwiftUpdateCheck = 0800;
LastUpgradeCheck = 0800;
LastUpgradeCheck = 0910;
ORGANIZATIONNAME = Hilen;
TargetAttributes = {
AEBAE93B1D8E8AF200CFDBD5 = {
Expand All @@ -178,7 +178,7 @@
};
AEBAE94F1D8E8AF200CFDBD5 = {
CreatedOnToolsVersion = 8.0;
LastSwiftMigration = 0800;
LastSwiftMigration = 0910;
ProvisioningStyle = Automatic;
TestTargetID = AEBAE93B1D8E8AF200CFDBD5;
};
Expand Down Expand Up @@ -224,49 +224,49 @@
/* End PBXResourcesBuildPhase section */

/* Begin PBXShellScriptBuildPhase section */
CD04BFB02355E7694C064855 /* Embed Pods Frameworks */ = {
0249506483674692E9C1309A /* [CP] Check Pods Manifest.lock */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
);
name = "Embed Pods Frameworks";
name = "[CP] Check Pods Manifest.lock";
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-TimedSilverExample/Pods-TimedSilverExample-frameworks.sh\"\n";
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";
showEnvVarsInLog = 0;
};
F0ED6F48A43F8B623CCC6510 /* Copy Pods Resources */ = {
201A5143EF5307CE6CDE43D3 /* [CP] Copy Pods Resources */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
);
name = "Copy Pods Resources";
name = "[CP] Copy Pods Resources";
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-TimedSilverExample/Pods-TimedSilverExample-resources.sh\"\n";
showEnvVarsInLog = 0;
};
F3536D336CE396E39A57E469 /* Check Pods Manifest.lock */ = {
ED52BC296B9EF83249163349 /* [CP] Embed Pods Frameworks */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
);
name = "Check Pods Manifest.lock";
name = "[CP] Embed Pods Frameworks";
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [[ $? != 0 ]] ; then\n cat << EOM\nerror: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\nEOM\n exit 1\nfi\n";
shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-TimedSilverExample/Pods-TimedSilverExample-frameworks.sh\"\n";
showEnvVarsInLog = 0;
};
/* End PBXShellScriptBuildPhase section */
Expand Down Expand Up @@ -328,15 +328,22 @@
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_SUSPICIOUS_MOVES = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
Expand Down Expand Up @@ -377,15 +384,22 @@
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_SUSPICIOUS_MOVES = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
Expand All @@ -412,27 +426,27 @@
};
AEBAE95A1D8E8AF200CFDBD5 /* Debug */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = 829DD242BE8471F96F3FD65C /* Pods-TimedSilverExample.debug.xcconfig */;
baseConfigurationReference = 74904B260662CC4D85CA4568 /* Pods-TimedSilverExample.debug.xcconfig */;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
INFOPLIST_FILE = TimedSilverExample/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = Hilen.TimedSilverExample;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 3.0;
SWIFT_VERSION = 4.0;
};
name = Debug;
};
AEBAE95B1D8E8AF200CFDBD5 /* Release */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = 71CF4986250D365A62A131F6 /* Pods-TimedSilverExample.release.xcconfig */;
baseConfigurationReference = 96DEBC55B60AFCE4512BCF98 /* Pods-TimedSilverExample.release.xcconfig */;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
INFOPLIST_FILE = TimedSilverExample/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = Hilen.TimedSilverExample;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 3.0;
SWIFT_VERSION = 4.0;
};
name = Release;
};
Expand All @@ -445,7 +459,8 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = Hilen.TimedSilverExampleTests;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 3.0;
SWIFT_SWIFT3_OBJC_INFERENCE = On;
SWIFT_VERSION = 4.0;
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/TimedSilverExample.app/TimedSilverExample";
};
name = Debug;
Expand All @@ -459,7 +474,8 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = Hilen.TimedSilverExampleTests;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 3.0;
SWIFT_SWIFT3_OBJC_INFERENCE = On;
SWIFT_VERSION = 4.0;
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/TimedSilverExample.app/TimedSilverExample";
};
name = Release;
Expand Down
4 changes: 2 additions & 2 deletions Sources/Foundation/NotificationCenter+TSBlock.swift
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,10 @@ private func ts_observationRemoversForObject(_ object: AnyObject) -> NSMutableAr
}
}

var retainedRemovers = objc_getAssociatedObject(object, TSObservationRemoverKey) as! NSMutableArray?
var retainedRemovers = objc_getAssociatedObject(object, TSObservationRemoverKey!) as! NSMutableArray?
if retainedRemovers == nil {
retainedRemovers = NSMutableArray()
objc_setAssociatedObject(object, TSObservationRemoverKey, retainedRemovers, objc_AssociationPolicy.OBJC_ASSOCIATION_RETAIN)
objc_setAssociatedObject(object, TSObservationRemoverKey!, retainedRemovers, objc_AssociationPolicy.OBJC_ASSOCIATION_RETAIN)
}
return retainedRemovers!
}
Expand Down
4 changes: 2 additions & 2 deletions Sources/Foundation/URLRequest+TScURLCommand.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import Foundation

extension URLRequest {
fileprivate func escapeQuotesInString(_ string: String) -> String {
assert(string.characters.count > 0 , "Error: String is not valid")
assert(string.count > 0 , "Error: String is not valid")
return string.replacingOccurrences(of: "\"", with:"\\\"", options: NSString.CompareOptions.literal, range: nil)
}

Expand Down Expand Up @@ -53,7 +53,7 @@ extension URLRequest {

if let body: Data = self.httpBody , self.httpBody != nil {
if var bodyDataString = String(data: body, encoding: String.Encoding.utf8) {
if bodyDataString.characters.count > 0 {
if bodyDataString.count > 0 {
bodyDataString = self.escapeQuotesInString(bodyDataString)
curlString.appendFormat(" -d \"%@\"", bodyDataString)
}
Expand Down
12 changes: 6 additions & 6 deletions Sources/Struct/String+TSExtension.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import UIKit
public extension String {
/// String's length
var ts_length: Int {
return self.characters.count
return self.count
}

/**
Expand All @@ -29,7 +29,7 @@ public extension String {
let size: CGSize = self.boundingRect(
with: constraintRect,
options: NSStringDrawingOptions.usesLineFragmentOrigin,
attributes: [NSFontAttributeName: font],
attributes: [NSAttributedStringKey.font: font],
context: nil
).size
return size
Expand All @@ -48,7 +48,7 @@ public extension String {
let boundingBox = self.boundingRect(
with: constraintRect,
options: .usesLineFragmentOrigin,
attributes: [NSFontAttributeName: font],
attributes: [NSAttributedStringKey.font: font],
context: nil)
return boundingBox.height
}
Expand All @@ -65,7 +65,7 @@ public extension String {
let boundingBox = self.boundingRect(
with: constraintRect,
options: .usesLineFragmentOrigin,
attributes: [NSFontAttributeName: font],
attributes: [NSAttributedStringKey.font: font],
context: nil)
return boundingBox.width
}
Expand All @@ -83,8 +83,8 @@ public extension String {
let from = range.lowerBound
let to = range.upperBound

let location = characters.distance(from: startIndex, to: from)
let length = characters.distance(from: from, to: to)
let location = self.distance(from: startIndex, to: from)
let length = self.distance(from: from, to: to)

return NSRange(location: location, length: length)
}
Expand Down
2 changes: 1 addition & 1 deletion Sources/UIKit/UIColor+TSExtension.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public extension UIColor {
var int = UInt32()
Scanner(string: hex).scanHexInt32(&int)
let r, g, b: UInt32
switch hex.characters.count {
switch hex.count {
case 3: // RGB (12-bit)
(r, g, b) = ((int >> 8) * 17, (int >> 4 & 0xF) * 17, (int & 0xF) * 17)
case 6: // RGB (24-bit)
Expand Down
Loading

0 comments on commit 8213bc6

Please sign in to comment.