Skip to content

Commit 2c513b8

Browse files
committed
update to swift3
1 parent 9604f28 commit 2c513b8

13 files changed

+133
-64
lines changed

Vendor/SQLite.swift

YTKKeyValueStore.xcodeproj/project.pbxproj

+61-1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,27 @@
2222
/* End PBXBuildFile section */
2323

2424
/* Begin PBXContainerItemProxy section */
25+
1A21656F1EC9585700EBDF0B /* PBXContainerItemProxy */ = {
26+
isa = PBXContainerItemProxy;
27+
containerPortal = 1A9239591C8FCAC600190AF1 /* SQLite.xcodeproj */;
28+
proxyType = 2;
29+
remoteGlobalIDString = 03A65E5A1C6BB0F50062603F;
30+
remoteInfo = "SQLite tvOS";
31+
};
32+
1A2165711EC9585700EBDF0B /* PBXContainerItemProxy */ = {
33+
isa = PBXContainerItemProxy;
34+
containerPortal = 1A9239591C8FCAC600190AF1 /* SQLite.xcodeproj */;
35+
proxyType = 2;
36+
remoteGlobalIDString = 03A65E631C6BB0F60062603F;
37+
remoteInfo = "SQLiteTests tvOS";
38+
};
39+
1A2165731EC9585700EBDF0B /* PBXContainerItemProxy */ = {
40+
isa = PBXContainerItemProxy;
41+
containerPortal = 1A9239591C8FCAC600190AF1 /* SQLite.xcodeproj */;
42+
proxyType = 2;
43+
remoteGlobalIDString = A121AC451CA35C79005A31D1;
44+
remoteInfo = "SQLite watchOS";
45+
};
2546
1A5891B21A8B4F6300155614 /* PBXContainerItemProxy */ = {
2647
isa = PBXContainerItemProxy;
2748
containerPortal = 1A58919C1A8B4F6200155614 /* Project object */;
@@ -176,6 +197,9 @@
176197
1A9239631C8FCAC600190AF1 /* SQLiteTests iOS.xctest */,
177198
1A9239651C8FCAC600190AF1 /* SQLite.framework */,
178199
1A9239671C8FCAC600190AF1 /* SQLiteTests Mac.xctest */,
200+
1A2165701EC9585700EBDF0B /* SQLite.framework */,
201+
1A2165721EC9585700EBDF0B /* SQLiteTests tvOS.xctest */,
202+
1A2165741EC9585700EBDF0B /* SQLite.framework */,
179203
);
180204
name = Products;
181205
sourceTree = "<group>";
@@ -238,14 +262,16 @@
238262
isa = PBXProject;
239263
attributes = {
240264
LastSwiftUpdateCheck = 0700;
241-
LastUpgradeCheck = 0700;
265+
LastUpgradeCheck = 0830;
242266
ORGANIZATIONNAME = sgxiang;
243267
TargetAttributes = {
244268
1A5891A41A8B4F6200155614 = {
245269
CreatedOnToolsVersion = 6.3;
270+
LastSwiftMigration = 0830;
246271
};
247272
1A5891AF1A8B4F6300155614 = {
248273
CreatedOnToolsVersion = 6.3;
274+
LastSwiftMigration = 0830;
249275
};
250276
};
251277
};
@@ -274,6 +300,27 @@
274300
/* End PBXProject section */
275301

276302
/* Begin PBXReferenceProxy section */
303+
1A2165701EC9585700EBDF0B /* SQLite.framework */ = {
304+
isa = PBXReferenceProxy;
305+
fileType = wrapper.framework;
306+
path = SQLite.framework;
307+
remoteRef = 1A21656F1EC9585700EBDF0B /* PBXContainerItemProxy */;
308+
sourceTree = BUILT_PRODUCTS_DIR;
309+
};
310+
1A2165721EC9585700EBDF0B /* SQLiteTests tvOS.xctest */ = {
311+
isa = PBXReferenceProxy;
312+
fileType = wrapper.cfbundle;
313+
path = "SQLiteTests tvOS.xctest";
314+
remoteRef = 1A2165711EC9585700EBDF0B /* PBXContainerItemProxy */;
315+
sourceTree = BUILT_PRODUCTS_DIR;
316+
};
317+
1A2165741EC9585700EBDF0B /* SQLite.framework */ = {
318+
isa = PBXReferenceProxy;
319+
fileType = wrapper.framework;
320+
path = SQLite.framework;
321+
remoteRef = 1A2165731EC9585700EBDF0B /* PBXContainerItemProxy */;
322+
sourceTree = BUILT_PRODUCTS_DIR;
323+
};
277324
1A9239611C8FCAC600190AF1 /* SQLite.framework */ = {
278325
isa = PBXReferenceProxy;
279326
fileType = wrapper.framework;
@@ -368,8 +415,10 @@
368415
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
369416
CLANG_WARN_EMPTY_BODY = YES;
370417
CLANG_WARN_ENUM_CONVERSION = YES;
418+
CLANG_WARN_INFINITE_RECURSION = YES;
371419
CLANG_WARN_INT_CONVERSION = YES;
372420
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
421+
CLANG_WARN_SUSPICIOUS_MOVE = YES;
373422
CLANG_WARN_UNREACHABLE_CODE = YES;
374423
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
375424
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
@@ -380,6 +429,7 @@
380429
ENABLE_TESTABILITY = YES;
381430
GCC_C_LANGUAGE_STANDARD = gnu99;
382431
GCC_DYNAMIC_NO_PIC = NO;
432+
GCC_NO_COMMON_BLOCKS = YES;
383433
GCC_OPTIMIZATION_LEVEL = 0;
384434
GCC_PREPROCESSOR_DEFINITIONS = (
385435
"DEBUG=1",
@@ -416,8 +466,10 @@
416466
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
417467
CLANG_WARN_EMPTY_BODY = YES;
418468
CLANG_WARN_ENUM_CONVERSION = YES;
469+
CLANG_WARN_INFINITE_RECURSION = YES;
419470
CLANG_WARN_INT_CONVERSION = YES;
420471
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
472+
CLANG_WARN_SUSPICIOUS_MOVE = YES;
421473
CLANG_WARN_UNREACHABLE_CODE = YES;
422474
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
423475
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
@@ -427,6 +479,7 @@
427479
ENABLE_NS_ASSERTIONS = NO;
428480
ENABLE_STRICT_OBJC_MSGSEND = YES;
429481
GCC_C_LANGUAGE_STANDARD = gnu99;
482+
GCC_NO_COMMON_BLOCKS = YES;
430483
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
431484
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
432485
GCC_WARN_UNDECLARED_SELECTOR = YES;
@@ -436,6 +489,7 @@
436489
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
437490
MTL_ENABLE_DEBUG_INFO = NO;
438491
SDKROOT = iphoneos;
492+
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
439493
TARGETED_DEVICE_FAMILY = "1,2";
440494
VALIDATE_PRODUCT = YES;
441495
VERSIONING_SYSTEM = "apple-generic";
@@ -448,6 +502,7 @@
448502
buildSettings = {
449503
APPLICATION_EXTENSION_API_ONLY = YES;
450504
CLANG_ENABLE_MODULES = YES;
505+
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "";
451506
DEFINES_MODULE = YES;
452507
DYLIB_COMPATIBILITY_VERSION = 1;
453508
DYLIB_CURRENT_VERSION = 1;
@@ -460,6 +515,7 @@
460515
PRODUCT_NAME = "$(TARGET_NAME)";
461516
SKIP_INSTALL = YES;
462517
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
518+
SWIFT_VERSION = 3.0;
463519
};
464520
name = Debug;
465521
};
@@ -468,6 +524,7 @@
468524
buildSettings = {
469525
APPLICATION_EXTENSION_API_ONLY = YES;
470526
CLANG_ENABLE_MODULES = YES;
527+
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "";
471528
DEFINES_MODULE = YES;
472529
DYLIB_COMPATIBILITY_VERSION = 1;
473530
DYLIB_CURRENT_VERSION = 1;
@@ -479,6 +536,7 @@
479536
PRODUCT_BUNDLE_IDENTIFIER = "com.sgxiang.$(PRODUCT_NAME:rfc1034identifier)";
480537
PRODUCT_NAME = "$(TARGET_NAME)";
481538
SKIP_INSTALL = YES;
539+
SWIFT_VERSION = 3.0;
482540
};
483541
name = Release;
484542
};
@@ -497,6 +555,7 @@
497555
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
498556
PRODUCT_BUNDLE_IDENTIFIER = "com.sgxiang.$(PRODUCT_NAME:rfc1034identifier)";
499557
PRODUCT_NAME = "$(TARGET_NAME)";
558+
SWIFT_VERSION = 3.0;
500559
};
501560
name = Debug;
502561
};
@@ -511,6 +570,7 @@
511570
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
512571
PRODUCT_BUNDLE_IDENTIFIER = "com.sgxiang.$(PRODUCT_NAME:rfc1034identifier)";
513572
PRODUCT_NAME = "$(TARGET_NAME)";
573+
SWIFT_VERSION = 3.0;
514574
};
515575
name = Release;
516576
};

YTKKeyValueStore.xcodeproj/xcshareddata/xcschemes/YTKKeyValueStore.xcscheme

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<Scheme
3-
LastUpgradeVersion = "0720"
3+
LastUpgradeVersion = "0830"
44
version = "1.3">
55
<BuildAction
66
parallelizeBuildables = "YES"

YTKKeyValueStore/Info.plist

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
<key>CFBundlePackageType</key>
1616
<string>FMWK</string>
1717
<key>CFBundleShortVersionString</key>
18-
<string>0.3.4</string>
18+
<string>0.4</string>
1919
<key>CFBundleSignature</key>
2020
<string>????</string>
2121
<key>CFBundleVersion</key>

YTKKeyValueStore/YTKConfig.swift

+3-3
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@ import SQLite
1111

1212
internal let YTKDEBUG = true
1313

14-
internal let PATH_OF_DOCUMENT : String = NSSearchPathForDirectoriesInDomains(.DocumentDirectory, .UserDomainMask, true)[0]
14+
internal let PATH_OF_DOCUMENT : String = NSSearchPathForDirectoriesInDomains(.documentDirectory, .userDomainMask, true)[0]
1515

16-
internal let DEFAULT_DB_NAME = "database_swift.sqlite"
16+
internal let DEFAULT_DB_NAME = "database_swift.sqlite3"
1717

1818
internal let ID = Expression<String>("id")
1919
internal let JSON = Expression<String>("json")
20-
internal let CREATEDTIME = Expression<NSDate>("createdTime")
20+
internal let CREATEDTIME = Expression<Date>("createdTime")

YTKKeyValueStore/YTKError.swift

+4-4
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88

99
import UIKit
1010

11-
enum YTKError: ErrorType {
12-
case DBConnectionError
13-
case NameFormatError
14-
case ValueNoSupport
11+
enum YTKError: Error {
12+
case dbConnectionError
13+
case nameFormatError
14+
case valueNoSupport
1515
}

YTKKeyValueStore/YTKItem.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,6 @@ import UIKit
1111
public struct YTKItem{
1212
public var itemId : String?
1313
public var itemObject : YTKObject?
14-
public var createdTime : NSDate?
14+
public var createdTime : Date?
1515
}
1616

YTKKeyValueStore/YTKKeyValueStore.swift

+5-5
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@ public class YTKKeyValueStore{
1919

2020
convenience public init(_ dbName : String! = DEFAULT_DB_NAME , path : String! = PATH_OF_DOCUMENT) throws{
2121

22-
self.init(dbPath:"\(path)/\(dbName)")
22+
self.init(dbPath:"\(path!)/\(dbName!)")
2323

2424
guard db != nil else{
25-
throw YTKError.DBConnectionError
25+
throw YTKError.dbConnectionError
2626
}
2727

2828
}
@@ -34,14 +34,14 @@ public class YTKKeyValueStore{
3434
public func createTable(tableName:String!) throws{
3535

3636
guard YTKTable.checkTableName(tableName) else{
37-
throw YTKError.NameFormatError
37+
throw YTKError.nameFormatError
3838
}
3939

4040
do{
4141
try db?.run(Table(tableName).create(ifNotExists: true){ t in
4242
t.column(ID,primaryKey:true)
4343
t.column(JSON)
44-
t.column(CREATEDTIME,defaultValue:NSDate())
44+
t.column(CREATEDTIME,defaultValue:Date())
4545
})
4646
}catch let error{
4747
print("failed to create table : \(tableName)")
@@ -53,7 +53,7 @@ public class YTKKeyValueStore{
5353
public func dropTable(tableName:String!) throws{
5454

5555
guard YTKTable.checkTableName(tableName) else{
56-
throw YTKError.NameFormatError
56+
throw YTKError.nameFormatError
5757
}
5858

5959
do{

YTKKeyValueStore/YTKObject.swift

+3-3
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public struct YTKObject{
3535
}else{
3636

3737
do{
38-
let result: AnyObject? = try NSJSONSerialization.JSONObjectWithData(self.value!.dataUsingEncoding(NSUTF8StringEncoding)!, options: .AllowFragments)
38+
let result: Any? = try JSONSerialization.jsonObject(with: self.value!.data(using: String.Encoding.utf8.rawValue)!, options: .allowFragments)
3939
if let num = result as? [NSNumber]{
4040
return num[0]
4141
}else{
@@ -56,7 +56,7 @@ public struct YTKObject{
5656
if self.value == nil { return nil}
5757

5858
do{
59-
let result: AnyObject? = try NSJSONSerialization.JSONObjectWithData(self.value!.dataUsingEncoding(NSUTF8StringEncoding)!, options: .AllowFragments)
59+
let result: Any? = try JSONSerialization.jsonObject(with: self.value!.data(using: String.Encoding.utf8.rawValue)!, options: .allowFragments)
6060
if let dic = result as? Dictionary<String , AnyObject>{
6161
return dic
6262
}else{
@@ -76,7 +76,7 @@ public struct YTKObject{
7676
if self.value == nil { return nil}
7777

7878
do{
79-
let result: AnyObject? = try NSJSONSerialization.JSONObjectWithData(self.value!.dataUsingEncoding(NSUTF8StringEncoding)!, options: .AllowFragments)
79+
let result: Any? = try JSONSerialization.jsonObject(with: self.value!.data(using: String.Encoding.utf8.rawValue)!, options: .allowFragments)
8080
if let dic = result as? Array<AnyObject>{
8181
return dic
8282
}else{

YTKKeyValueStore/YTKSetter.swift

+14-9
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import UIKit
1010

1111
public struct YTKSetter {
1212
internal var objectId : String!
13-
private var object : Any!
13+
fileprivate var object : Any!
1414
public init(_ id : String!, _ object : Any!){
1515
self.objectId = id
1616
self.object = object
@@ -23,33 +23,38 @@ public struct YTKSetter {
2323
return (object as! String)
2424
}else{
2525

26-
var sqlObject : AnyObject?
26+
var sqlObject : Any?
2727

2828
if let number = self.object as? NSNumber{
2929
sqlObject = [number]
30-
}else if let arrayObject = self.object as? [AnyObject]{
31-
sqlObject = arrayObject
30+
}else if let arrayObject = self.object as? [Any]{
31+
sqlObject = arrayObject as AnyObject
3232
}else if let dictionaryObject = self.object as? Dictionary<String,AnyObject>{
33-
sqlObject = dictionaryObject
33+
sqlObject = dictionaryObject as AnyObject
3434
}else{
3535
return nil
3636
}
3737

3838
do{
39-
let data = try NSJSONSerialization.dataWithJSONObject(sqlObject!, options: NSJSONWritingOptions(rawValue: 0))
40-
return NSString(data: data, encoding: NSUTF8StringEncoding) as? String
39+
let data = try JSONSerialization.data(withJSONObject: sqlObject!, options: JSONSerialization.WritingOptions(rawValue: 0))
40+
return NSString(data: data, encoding: String.Encoding.utf8.rawValue) as String?
4141
}catch{
4242
print("faild to get json data")
4343
return nil
4444
}
45-
4645
}
4746

4847
}
4948
}
5049
}
5150

52-
infix operator <- { associativity left precedence 140 }
51+
52+
infix operator <- : MultiplicationPrecedence
53+
precedencegroup MultiplicationPrecedence {
54+
associativity: left
55+
higherThan: AdditionPrecedence
56+
}
57+
5358
public func <- (objectId: String!, object: Any!) -> YTKSetter{
5459
return YTKSetter(objectId , object)
5560
}

0 commit comments

Comments
 (0)