Skip to content

Commit 6cb922c

Browse files
author
Hilen
committed
Swift 5 compatibility
1 parent 29d7ab8 commit 6cb922c

25 files changed

+93
-342
lines changed

.swift-version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
4.0
1+
5.0

Demo/Podfile.lock

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ EXTERNAL SOURCES:
99
:path: "../"
1010

1111
SPEC CHECKSUMS:
12-
TimedSilver: 9a4db36b50fe8dd2f76ec28a1d5b6f0e98f6bb30
12+
TimedSilver: 7b9773d84a2c479893786b4123d6d41ae8be3d4c
1313

1414
PODFILE CHECKSUM: 416a9304df26078601f30ee2451b2f3dbe8abf38
1515

16-
COCOAPODS: 1.2.0
16+
COCOAPODS: 1.7.2

Demo/TimedSilverExample.xcodeproj/project.pbxproj

Lines changed: 21 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,6 @@
132132
AEBAE9391D8E8AF200CFDBD5 /* Frameworks */,
133133
AEBAE93A1D8E8AF200CFDBD5 /* Resources */,
134134
ED52BC296B9EF83249163349 /* [CP] Embed Pods Frameworks */,
135-
201A5143EF5307CE6CDE43D3 /* [CP] Copy Pods Resources */,
136135
);
137136
buildRules = (
138137
);
@@ -168,7 +167,7 @@
168167
isa = PBXProject;
169168
attributes = {
170169
LastSwiftUpdateCheck = 0800;
171-
LastUpgradeCheck = 0910;
170+
LastUpgradeCheck = 1030;
172171
ORGANIZATIONNAME = Hilen;
173172
TargetAttributes = {
174173
AEBAE93B1D8E8AF200CFDBD5 = {
@@ -178,7 +177,7 @@
178177
};
179178
AEBAE94F1D8E8AF200CFDBD5 = {
180179
CreatedOnToolsVersion = 8.0;
181-
LastSwiftMigration = 0910;
180+
LastSwiftMigration = 1030;
182181
ProvisioningStyle = Automatic;
183182
TestTargetID = AEBAE93B1D8E8AF200CFDBD5;
184183
};
@@ -189,6 +188,7 @@
189188
developmentRegion = English;
190189
hasScannedForEncodings = 0;
191190
knownRegions = (
191+
English,
192192
en,
193193
Base,
194194
);
@@ -230,28 +230,16 @@
230230
files = (
231231
);
232232
inputPaths = (
233+
"${PODS_PODFILE_DIR_PATH}/Podfile.lock",
234+
"${PODS_ROOT}/Manifest.lock",
233235
);
234236
name = "[CP] Check Pods Manifest.lock";
235237
outputPaths = (
238+
"$(DERIVED_FILE_DIR)/Pods-TimedSilverExample-checkManifestLockResult.txt",
236239
);
237240
runOnlyForDeploymentPostprocessing = 0;
238241
shellPath = /bin/sh;
239-
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";
240-
showEnvVarsInLog = 0;
241-
};
242-
201A5143EF5307CE6CDE43D3 /* [CP] Copy Pods Resources */ = {
243-
isa = PBXShellScriptBuildPhase;
244-
buildActionMask = 2147483647;
245-
files = (
246-
);
247-
inputPaths = (
248-
);
249-
name = "[CP] Copy Pods Resources";
250-
outputPaths = (
251-
);
252-
runOnlyForDeploymentPostprocessing = 0;
253-
shellPath = /bin/sh;
254-
shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-TimedSilverExample/Pods-TimedSilverExample-resources.sh\"\n";
242+
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# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n";
255243
showEnvVarsInLog = 0;
256244
};
257245
ED52BC296B9EF83249163349 /* [CP] Embed Pods Frameworks */ = {
@@ -260,13 +248,16 @@
260248
files = (
261249
);
262250
inputPaths = (
251+
"${PODS_ROOT}/Target Support Files/Pods-TimedSilverExample/Pods-TimedSilverExample-frameworks.sh",
252+
"${BUILT_PRODUCTS_DIR}/TimedSilver/TimedSilver.framework",
263253
);
264254
name = "[CP] Embed Pods Frameworks";
265255
outputPaths = (
256+
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/TimedSilver.framework",
266257
);
267258
runOnlyForDeploymentPostprocessing = 0;
268259
shellPath = /bin/sh;
269-
shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-TimedSilverExample/Pods-TimedSilverExample-frameworks.sh\"\n";
260+
shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-TimedSilverExample/Pods-TimedSilverExample-frameworks.sh\"\n";
270261
showEnvVarsInLog = 0;
271262
};
272263
/* End PBXShellScriptBuildPhase section */
@@ -323,6 +314,7 @@
323314
isa = XCBuildConfiguration;
324315
buildSettings = {
325316
ALWAYS_SEARCH_USER_PATHS = NO;
317+
CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
326318
CLANG_ANALYZER_NONNULL = YES;
327319
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
328320
CLANG_CXX_LIBRARY = "libc++";
@@ -332,13 +324,15 @@
332324
CLANG_WARN_BOOL_CONVERSION = YES;
333325
CLANG_WARN_COMMA = YES;
334326
CLANG_WARN_CONSTANT_CONVERSION = YES;
327+
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
335328
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
336329
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
337330
CLANG_WARN_EMPTY_BODY = YES;
338331
CLANG_WARN_ENUM_CONVERSION = YES;
339332
CLANG_WARN_INFINITE_RECURSION = YES;
340333
CLANG_WARN_INT_CONVERSION = YES;
341334
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
335+
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
342336
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
343337
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
344338
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
@@ -379,6 +373,7 @@
379373
isa = XCBuildConfiguration;
380374
buildSettings = {
381375
ALWAYS_SEARCH_USER_PATHS = NO;
376+
CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
382377
CLANG_ANALYZER_NONNULL = YES;
383378
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
384379
CLANG_CXX_LIBRARY = "libc++";
@@ -388,13 +383,15 @@
388383
CLANG_WARN_BOOL_CONVERSION = YES;
389384
CLANG_WARN_COMMA = YES;
390385
CLANG_WARN_CONSTANT_CONVERSION = YES;
386+
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
391387
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
392388
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
393389
CLANG_WARN_EMPTY_BODY = YES;
394390
CLANG_WARN_ENUM_CONVERSION = YES;
395391
CLANG_WARN_INFINITE_RECURSION = YES;
396392
CLANG_WARN_INT_CONVERSION = YES;
397393
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
394+
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
398395
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
399396
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
400397
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
@@ -433,7 +430,7 @@
433430
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
434431
PRODUCT_BUNDLE_IDENTIFIER = Hilen.TimedSilverExample;
435432
PRODUCT_NAME = "$(TARGET_NAME)";
436-
SWIFT_VERSION = 4.0;
433+
SWIFT_VERSION = 5.0;
437434
};
438435
name = Debug;
439436
};
@@ -446,7 +443,7 @@
446443
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
447444
PRODUCT_BUNDLE_IDENTIFIER = Hilen.TimedSilverExample;
448445
PRODUCT_NAME = "$(TARGET_NAME)";
449-
SWIFT_VERSION = 4.0;
446+
SWIFT_VERSION = 5.0;
450447
};
451448
name = Release;
452449
};
@@ -459,8 +456,7 @@
459456
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
460457
PRODUCT_BUNDLE_IDENTIFIER = Hilen.TimedSilverExampleTests;
461458
PRODUCT_NAME = "$(TARGET_NAME)";
462-
SWIFT_SWIFT3_OBJC_INFERENCE = On;
463-
SWIFT_VERSION = 4.0;
459+
SWIFT_VERSION = 5.0;
464460
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/TimedSilverExample.app/TimedSilverExample";
465461
};
466462
name = Debug;
@@ -474,8 +470,7 @@
474470
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
475471
PRODUCT_BUNDLE_IDENTIFIER = Hilen.TimedSilverExampleTests;
476472
PRODUCT_NAME = "$(TARGET_NAME)";
477-
SWIFT_SWIFT3_OBJC_INFERENCE = On;
478-
SWIFT_VERSION = 4.0;
473+
SWIFT_VERSION = 5.0;
479474
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/TimedSilverExample.app/TimedSilverExample";
480475
};
481476
name = Release;

Demo/TimedSilverExample/AppDelegate.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
1414
var window: UIWindow?
1515

1616

17-
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
17+
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
1818
// Override point for customization after application launch.
1919
return true
2020
}

README.md

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,26 +4,25 @@ All about swift extension 😉
44

55
## Installation
66

7-
Swift 4.0
7+
Swift 5.0
88
```ruby
99
source 'https://github.com/CocoaPods/Specs.git'
10-
platform :ios, '8.0'
10+
platform :ios, '9.0'
1111
use_frameworks!
1212

1313
target 'YourApp' do
14-
pod 'TimedSilver', '1.1.0'
14+
pod 'TimedSilver', '1.2.0'
1515
end
1616
```
1717

18-
19-
Swift 3.0
18+
Swift 4.0
2019
```ruby
2120
source 'https://github.com/CocoaPods/Specs.git'
2221
platform :ios, '8.0'
2322
use_frameworks!
2423

2524
target 'YourApp' do
26-
pod 'TimedSilver', '1.0.0'
25+
pod 'TimedSilver', '1.1.0'
2726
end
2827
```
2928

Sources/Foundation/Bundle+TSExtension.swift

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,41 +12,41 @@ import UIKit
1212

1313
public extension Bundle {
1414
/// The app's name
15-
public static var ts_appName: String? {
15+
static var ts_appName: String? {
1616
guard let name = Bundle.main.object(forInfoDictionaryKey: "CFBundleDisplayName") as? String else {
1717
return nil
1818
}
1919
return name
2020
}
2121

2222
/// The app's version
23-
public static var ts_appVersion: String {
23+
static var ts_appVersion: String {
2424
return Bundle.main.infoDictionary!["CFBundleShortVersionString"] as! String
2525
}
2626

2727
/// The app's build number
28-
public static var ts_appBuild: String {
28+
static var ts_appBuild: String {
2929
return Bundle.main.object(forInfoDictionaryKey: kCFBundleVersionKey as String) as! String
3030
}
3131

3232
/// The app's bundle identifier
33-
public static var ts_bundleIdentifier: String {
33+
static var ts_bundleIdentifier: String {
3434
return Bundle.main.infoDictionary!["CFBundleIdentifier"] as! String
3535
}
3636

3737
/// The app's bundle name
38-
public static var ts_bundleName: String {
38+
static var ts_bundleName: String {
3939
return Bundle.main.infoDictionary!["CFBundleName"] as! String
4040
}
4141

4242
/// The app's version and build number
43-
public static var ts_appVersionAndBuild: String {
43+
static var ts_appVersionAndBuild: String {
4444
let version = ts_appVersion, build = ts_appBuild
4545
return version == build ? "v\(version)" : "v\(version)(\(build))"
4646
}
4747

4848
/// App's icon file path
49-
public class var ts_iconFilePath: String {
49+
class var ts_iconFilePath: String {
5050
let iconFilename = Bundle.main.object(forInfoDictionaryKey: "CFBundleIconFile")
5151
let iconBasename = (iconFilename as! NSString).deletingPathExtension
5252
let iconExtension = (iconFilename as! NSString).pathExtension
@@ -58,7 +58,7 @@ public extension Bundle {
5858

5959
- returns: UIImage
6060
*/
61-
public class func ts_iconImage() -> UIImage? {
61+
class func ts_iconImage() -> UIImage? {
6262
guard let image = UIImage(contentsOfFile:self.ts_iconFilePath) else {
6363
return nil
6464
}

Sources/Foundation/Data+TSExtension.swift

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -39,17 +39,5 @@ public extension Data {
3939
return nil
4040
}
4141
}
42-
43-
/// Convert NSData to MD5 String
44-
var ts_md5String: String {
45-
let MD5Calculator = TS_MD5(Array(UnsafeBufferPointer(start: (self as NSData).bytes.bindMemory(to: UInt8.self, capacity: self.count), count: self.count)))
46-
let MD5Data = MD5Calculator.calculate()
47-
48-
let MD5String = NSMutableString()
49-
for c in MD5Data {
50-
MD5String.appendFormat("%02x", c)
51-
}
52-
return MD5String as String
53-
}
5442
}
5543

Sources/Foundation/NSDictionary+TSExtension.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public extension NSDictionary {
1717

1818
- returns: NSDictionary or nil
1919
*/
20-
public convenience init? (ts_JSONString: String) {
20+
convenience init? (ts_JSONString: String) {
2121
if let data = (try? JSONSerialization.jsonObject(with: ts_JSONString.data(using: String.Encoding.utf8, allowLossyConversion: true)!, options: JSONSerialization.ReadingOptions.mutableContainers)) as? NSDictionary {
2222
self.init(dictionary: data)
2323
} else {
@@ -31,7 +31,7 @@ public extension NSDictionary {
3131

3232
- returns: string or nil
3333
*/
34-
public func ts_formatJSON() -> String? {
34+
func ts_formatJSON() -> String? {
3535
if let jsonData = try? JSONSerialization.data(withJSONObject: self, options: JSONSerialization.WritingOptions()) {
3636
let jsonStr = NSString(data: jsonData, encoding: String.Encoding.utf8.rawValue)
3737
return String(jsonStr ?? "")

Sources/Foundation/NSRange+TSExtension.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ public extension NSRange {
1919
- returns: NSRange
2020
*/
2121
init(ts_location:Int, ts_length:Int) {
22+
self.init()
2223
self.location = ts_location
2324
self.length = ts_length
2425
}
@@ -32,6 +33,7 @@ public extension NSRange {
3233
- returns: NSRange
3334
*/
3435
init(_ ts_location:Int, _ ts_length:Int) {
36+
self.init()
3537
self.location = ts_location
3638
self.length = ts_length
3739
}
@@ -44,6 +46,7 @@ public extension NSRange {
4446
- returns: NSRange
4547
*/
4648
init(ts_range:Range <Int>) {
49+
self.init()
4750
self.location = ts_range.lowerBound
4851
self.length = ts_range.upperBound - ts_range.lowerBound
4952
}
@@ -56,6 +59,7 @@ public extension NSRange {
5659
- returns: NSRange
5760
*/
5861
init(_ ts_range:Range <Int>) {
62+
self.init()
5963
self.location = ts_range.lowerBound
6064
self.length = ts_range.upperBound - ts_range.lowerBound
6165
}

Sources/Foundation/Timer+TSBlock.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,8 @@ extension Timer {
9090
/// By default, the timer is scheduled on the current run loop for the default mode.
9191
/// Specify `runLoop` or `modes` to override these defaults.
9292

93-
public func ts_start(runLoop: RunLoop = RunLoop.current, modes: RunLoopMode...) {
94-
let modes = modes.isEmpty ? [RunLoopMode.defaultRunLoopMode] : modes
93+
public func ts_start(runLoop: RunLoop = RunLoop.current, modes: RunLoop.Mode...) {
94+
let modes = modes.isEmpty ? [RunLoop.Mode.default] : modes
9595

9696
for mode in modes {
9797
runLoop.add(self, forMode: mode)

0 commit comments

Comments
 (0)