Skip to content

Commit 23f55bb

Browse files
committed
cocoaPods support
1 parent 21eebbc commit 23f55bb

18 files changed

+89
-201
lines changed

.gitmodules

-3
Original file line numberDiff line numberDiff line change
@@ -1,3 +0,0 @@
1-
[submodule "SQLite.swift"]
2-
path = SQLite.swift
3-
url = https://github.com/stephencelis/SQLite.swift.git

LICENSE.txt

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
(The MIT License)
2+
3+
Copyright (c) 2014-2015 Stephen Celis (<[email protected]>)
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

SQLite.swift

-1
This file was deleted.

YTKKeyValueStore/YTKKeyValueStore.xcodeproj/project.pbxproj YTKKeyValueStore.xcodeproj/project.pbxproj

+1-156
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,12 @@
1111
1A5891B11A8B4F6300155614 /* YTKKeyValueStore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1A5891A51A8B4F6200155614 /* YTKKeyValueStore.framework */; };
1212
1A5891B81A8B4F6300155614 /* YTKKeyValueStoreTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1A5891B71A8B4F6300155614 /* YTKKeyValueStoreTests.swift */; };
1313
1A5891C21A8B4F7A00155614 /* YTKKeyValueStore.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1A5891C11A8B4F7A00155614 /* YTKKeyValueStore.swift */; };
14-
1A5891D41A8B4FE400155614 /* SQLite.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1A5891CB1A8B4FC100155614 /* SQLite.framework */; };
15-
1A5891D61A8B4FEE00155614 /* SQLite.framework in CopyFiles */ = {isa = PBXBuildFile; fileRef = 1A5891CB1A8B4FC100155614 /* SQLite.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
1614
1A5891EC1A8B5DB600155614 /* YTKObject.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1A5891EB1A8B5DB600155614 /* YTKObject.swift */; };
1715
1A5891F11A8B5DEE00155614 /* YTKSetter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1A5891F01A8B5DEE00155614 /* YTKSetter.swift */; };
1816
1A5891F31A8B5E1B00155614 /* YTKTable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1A5891F21A8B5E1B00155614 /* YTKTable.swift */; };
1917
1A5891F51A8B5E5D00155614 /* YTKConfig.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1A5891F41A8B5E5D00155614 /* YTKConfig.swift */; };
2018
1A5891F71A8B5EBE00155614 /* YTKItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1A5891F61A8B5EBE00155614 /* YTKItem.swift */; };
21-
1A81A1671BA80B0400A53DE1 /* YTKError.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1A81A1661BA80B0400A53DE1 /* YTKError.swift */; settings = {ASSET_TAGS = (); }; };
19+
1A81A1671BA80B0400A53DE1 /* YTKError.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1A81A1661BA80B0400A53DE1 /* YTKError.swift */; };
2220
/* End PBXBuildFile section */
2321

2422
/* Begin PBXContainerItemProxy section */
@@ -29,69 +27,6 @@
2927
remoteGlobalIDString = 1A5891A41A8B4F6200155614;
3028
remoteInfo = YTKKeyValueStore;
3129
};
32-
1A5891CA1A8B4FC100155614 /* PBXContainerItemProxy */ = {
33-
isa = PBXContainerItemProxy;
34-
containerPortal = 1A5891C31A8B4FC100155614 /* SQLite.xcodeproj */;
35-
proxyType = 2;
36-
remoteGlobalIDString = DC3773F319C8CBB3004FCF85;
37-
remoteInfo = "SQLite iOS";
38-
};
39-
1A5891CC1A8B4FC100155614 /* PBXContainerItemProxy */ = {
40-
isa = PBXContainerItemProxy;
41-
containerPortal = 1A5891C31A8B4FC100155614 /* SQLite.xcodeproj */;
42-
proxyType = 2;
43-
remoteGlobalIDString = DC3773FE19C8CBB3004FCF85;
44-
remoteInfo = "SQLite iOS Tests";
45-
};
46-
1A5891CE1A8B4FC100155614 /* PBXContainerItemProxy */ = {
47-
isa = PBXContainerItemProxy;
48-
containerPortal = 1A5891C31A8B4FC100155614 /* SQLite.xcodeproj */;
49-
proxyType = 2;
50-
remoteGlobalIDString = DC37741419C8CC2F004FCF85;
51-
remoteInfo = "SQLite Mac";
52-
};
53-
1A5891D01A8B4FC100155614 /* PBXContainerItemProxy */ = {
54-
isa = PBXContainerItemProxy;
55-
containerPortal = 1A5891C31A8B4FC100155614 /* SQLite.xcodeproj */;
56-
proxyType = 2;
57-
remoteGlobalIDString = DC37741E19C8CC2F004FCF85;
58-
remoteInfo = "SQLite Mac Tests";
59-
};
60-
1A5891D21A8B4FE000155614 /* PBXContainerItemProxy */ = {
61-
isa = PBXContainerItemProxy;
62-
containerPortal = 1A5891C31A8B4FC100155614 /* SQLite.xcodeproj */;
63-
proxyType = 1;
64-
remoteGlobalIDString = DC2B29E11B26F718001C60EA;
65-
remoteInfo = "SQLite iOS";
66-
};
67-
1A81A15E1BA7F48200A53DE1 /* PBXContainerItemProxy */ = {
68-
isa = PBXContainerItemProxy;
69-
containerPortal = 1A5891C31A8B4FC100155614 /* SQLite.xcodeproj */;
70-
proxyType = 2;
71-
remoteGlobalIDString = DCE7BB7A1B7434F90040D364;
72-
remoteInfo = "SQLiteCipher iOS";
73-
};
74-
1A81A1601BA7F48200A53DE1 /* PBXContainerItemProxy */ = {
75-
isa = PBXContainerItemProxy;
76-
containerPortal = 1A5891C31A8B4FC100155614 /* SQLite.xcodeproj */;
77-
proxyType = 2;
78-
remoteGlobalIDString = DCE7BB831B7434F90040D364;
79-
remoteInfo = "SQLiteCipher iOS Tests";
80-
};
81-
1A81A1621BA7F48200A53DE1 /* PBXContainerItemProxy */ = {
82-
isa = PBXContainerItemProxy;
83-
containerPortal = 1A5891C31A8B4FC100155614 /* SQLite.xcodeproj */;
84-
proxyType = 2;
85-
remoteGlobalIDString = DCE7BBB01B7438610040D364;
86-
remoteInfo = "SQLiteCipher Mac";
87-
};
88-
1A81A1641BA7F48200A53DE1 /* PBXContainerItemProxy */ = {
89-
isa = PBXContainerItemProxy;
90-
containerPortal = 1A5891C31A8B4FC100155614 /* SQLite.xcodeproj */;
91-
proxyType = 2;
92-
remoteGlobalIDString = DCE7BBB91B7438620040D364;
93-
remoteInfo = "SQLiteCipher Mac Tests";
94-
};
9530
/* End PBXContainerItemProxy section */
9631

9732
/* Begin PBXCopyFilesBuildPhase section */
@@ -101,7 +36,6 @@
10136
dstPath = "";
10237
dstSubfolderSpec = 10;
10338
files = (
104-
1A5891D61A8B4FEE00155614 /* SQLite.framework in CopyFiles */,
10539
);
10640
runOnlyForDeploymentPostprocessing = 0;
10741
};
@@ -115,7 +49,6 @@
11549
1A5891B61A8B4F6300155614 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
11650
1A5891B71A8B4F6300155614 /* YTKKeyValueStoreTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YTKKeyValueStoreTests.swift; sourceTree = "<group>"; };
11751
1A5891C11A8B4F7A00155614 /* YTKKeyValueStore.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = YTKKeyValueStore.swift; sourceTree = "<group>"; };
118-
1A5891C31A8B4FC100155614 /* SQLite.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = SQLite.xcodeproj; path = ../../SQLite.swift/SQLite.xcodeproj; sourceTree = "<group>"; };
11952
1A5891EB1A8B5DB600155614 /* YTKObject.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = YTKObject.swift; sourceTree = "<group>"; };
12053
1A5891F01A8B5DEE00155614 /* YTKSetter.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = YTKSetter.swift; sourceTree = "<group>"; };
12154
1A5891F21A8B5E1B00155614 /* YTKTable.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = YTKTable.swift; sourceTree = "<group>"; };
@@ -129,7 +62,6 @@
12962
isa = PBXFrameworksBuildPhase;
13063
buildActionMask = 2147483647;
13164
files = (
132-
1A5891D41A8B4FE400155614 /* SQLite.framework in Frameworks */,
13365
);
13466
runOnlyForDeploymentPostprocessing = 0;
13567
};
@@ -165,7 +97,6 @@
16597
1A5891A71A8B4F6200155614 /* YTKKeyValueStore */ = {
16698
isa = PBXGroup;
16799
children = (
168-
1A5891C31A8B4FC100155614 /* SQLite.xcodeproj */,
169100
1A5891C11A8B4F7A00155614 /* YTKKeyValueStore.swift */,
170101
1A5891F21A8B5E1B00155614 /* YTKTable.swift */,
171102
1A5891F01A8B5DEE00155614 /* YTKSetter.swift */,
@@ -204,21 +135,6 @@
204135
name = "Supporting Files";
205136
sourceTree = "<group>";
206137
};
207-
1A5891C41A8B4FC100155614 /* Products */ = {
208-
isa = PBXGroup;
209-
children = (
210-
1A5891CB1A8B4FC100155614 /* SQLite.framework */,
211-
1A5891CD1A8B4FC100155614 /* SQLite iOS Tests.xctest */,
212-
1A5891CF1A8B4FC100155614 /* SQLite.framework */,
213-
1A5891D11A8B4FC100155614 /* SQLite Mac Tests.xctest */,
214-
1A81A15F1BA7F48200A53DE1 /* SQLiteCipher.framework */,
215-
1A81A1611BA7F48200A53DE1 /* SQLiteCipher iOS Tests.xctest */,
216-
1A81A1631BA7F48200A53DE1 /* SQLiteCipher.framework */,
217-
1A81A1651BA7F48200A53DE1 /* SQLiteCipher Mac Tests.xctest */,
218-
);
219-
name = Products;
220-
sourceTree = "<group>";
221-
};
222138
/* End PBXGroup section */
223139

224140
/* Begin PBXHeadersBuildPhase section */
@@ -246,7 +162,6 @@
246162
buildRules = (
247163
);
248164
dependencies = (
249-
1A5891D31A8B4FE000155614 /* PBXTargetDependency */,
250165
);
251166
name = YTKKeyValueStore;
252167
productName = YTKKeyValueStore;
@@ -299,12 +214,6 @@
299214
mainGroup = 1A58919B1A8B4F6200155614;
300215
productRefGroup = 1A5891A61A8B4F6200155614 /* Products */;
301216
projectDirPath = "";
302-
projectReferences = (
303-
{
304-
ProductGroup = 1A5891C41A8B4FC100155614 /* Products */;
305-
ProjectRef = 1A5891C31A8B4FC100155614 /* SQLite.xcodeproj */;
306-
},
307-
);
308217
projectRoot = "";
309218
targets = (
310219
1A5891A41A8B4F6200155614 /* YTKKeyValueStore */,
@@ -313,65 +222,6 @@
313222
};
314223
/* End PBXProject section */
315224

316-
/* Begin PBXReferenceProxy section */
317-
1A5891CB1A8B4FC100155614 /* SQLite.framework */ = {
318-
isa = PBXReferenceProxy;
319-
fileType = wrapper.framework;
320-
path = SQLite.framework;
321-
remoteRef = 1A5891CA1A8B4FC100155614 /* PBXContainerItemProxy */;
322-
sourceTree = BUILT_PRODUCTS_DIR;
323-
};
324-
1A5891CD1A8B4FC100155614 /* SQLite iOS Tests.xctest */ = {
325-
isa = PBXReferenceProxy;
326-
fileType = wrapper.cfbundle;
327-
path = "SQLite iOS Tests.xctest";
328-
remoteRef = 1A5891CC1A8B4FC100155614 /* PBXContainerItemProxy */;
329-
sourceTree = BUILT_PRODUCTS_DIR;
330-
};
331-
1A5891CF1A8B4FC100155614 /* SQLite.framework */ = {
332-
isa = PBXReferenceProxy;
333-
fileType = wrapper.framework;
334-
path = SQLite.framework;
335-
remoteRef = 1A5891CE1A8B4FC100155614 /* PBXContainerItemProxy */;
336-
sourceTree = BUILT_PRODUCTS_DIR;
337-
};
338-
1A5891D11A8B4FC100155614 /* SQLite Mac Tests.xctest */ = {
339-
isa = PBXReferenceProxy;
340-
fileType = wrapper.cfbundle;
341-
path = "SQLite Mac Tests.xctest";
342-
remoteRef = 1A5891D01A8B4FC100155614 /* PBXContainerItemProxy */;
343-
sourceTree = BUILT_PRODUCTS_DIR;
344-
};
345-
1A81A15F1BA7F48200A53DE1 /* SQLiteCipher.framework */ = {
346-
isa = PBXReferenceProxy;
347-
fileType = wrapper.framework;
348-
path = SQLiteCipher.framework;
349-
remoteRef = 1A81A15E1BA7F48200A53DE1 /* PBXContainerItemProxy */;
350-
sourceTree = BUILT_PRODUCTS_DIR;
351-
};
352-
1A81A1611BA7F48200A53DE1 /* SQLiteCipher iOS Tests.xctest */ = {
353-
isa = PBXReferenceProxy;
354-
fileType = wrapper.cfbundle;
355-
path = "SQLiteCipher iOS Tests.xctest";
356-
remoteRef = 1A81A1601BA7F48200A53DE1 /* PBXContainerItemProxy */;
357-
sourceTree = BUILT_PRODUCTS_DIR;
358-
};
359-
1A81A1631BA7F48200A53DE1 /* SQLiteCipher.framework */ = {
360-
isa = PBXReferenceProxy;
361-
fileType = wrapper.framework;
362-
path = SQLiteCipher.framework;
363-
remoteRef = 1A81A1621BA7F48200A53DE1 /* PBXContainerItemProxy */;
364-
sourceTree = BUILT_PRODUCTS_DIR;
365-
};
366-
1A81A1651BA7F48200A53DE1 /* SQLiteCipher Mac Tests.xctest */ = {
367-
isa = PBXReferenceProxy;
368-
fileType = wrapper.cfbundle;
369-
path = "SQLiteCipher Mac Tests.xctest";
370-
remoteRef = 1A81A1641BA7F48200A53DE1 /* PBXContainerItemProxy */;
371-
sourceTree = BUILT_PRODUCTS_DIR;
372-
};
373-
/* End PBXReferenceProxy section */
374-
375225
/* Begin PBXResourcesBuildPhase section */
376226
1A5891A31A8B4F6200155614 /* Resources */ = {
377227
isa = PBXResourcesBuildPhase;
@@ -420,11 +270,6 @@
420270
target = 1A5891A41A8B4F6200155614 /* YTKKeyValueStore */;
421271
targetProxy = 1A5891B21A8B4F6300155614 /* PBXContainerItemProxy */;
422272
};
423-
1A5891D31A8B4FE000155614 /* PBXTargetDependency */ = {
424-
isa = PBXTargetDependency;
425-
name = "SQLite iOS";
426-
targetProxy = 1A5891D21A8B4FE000155614 /* PBXContainerItemProxy */;
427-
};
428273
/* End PBXTargetDependency section */
429274

430275
/* Begin XCBuildConfiguration section */
File renamed without changes.
File renamed without changes.

YTKKeyValueStore/YTKKeyValueStore/YTKTable.swift YTKKeyValueStore/YTKTable.swift

+49-36
Original file line numberDiff line numberDiff line change
@@ -102,60 +102,73 @@ public struct YTKTable{
102102
}
103103

104104
let query = tableHandle!.filter(ID == set.objectId).limit(1)
105-
106-
if let filter = db?.prepare(query){
107-
if filter.generate().next() == nil{
108-
do{
109-
try db?.run( tableHandle!.insert(ID <- set.objectId,JSON <- jsonString,CREATEDTIME <- NSDate()) )
110-
print("[insert] id : \(set.objectId) jsonString : \(set.jsonString!)")
111-
}catch let error{
112-
throw error
113-
}
114-
}else{
115-
do{
116-
try db?.run(query.update(JSON <- jsonString,CREATEDTIME <- NSDate()))
117-
print("[update] id : \(set.objectId) jsonString : \(set.jsonString!)")
118-
}catch let error{
119-
throw error
105+
do{
106+
if let filter = try db?.prepare(query){
107+
if filter.generate().next() == nil{
108+
do{
109+
try db?.run( tableHandle!.insert(ID <- set.objectId,JSON <- jsonString,CREATEDTIME <- NSDate()) )
110+
print("[insert] id : \(set.objectId) jsonString : \(set.jsonString!)")
111+
}catch let error{
112+
throw error
113+
}
114+
}else{
115+
do{
116+
try db?.run(query.update(JSON <- jsonString,CREATEDTIME <- NSDate()))
117+
print("[update] id : \(set.objectId) jsonString : \(set.jsonString!)")
118+
}catch let error{
119+
throw error
120+
}
120121
}
121122
}
123+
}catch let error{
124+
throw error
122125
}
123126

124127
}
125128

126-
public func get( objectId : String! ) -> YTKObject?{
127-
if let item = self.getItem(objectId){
128-
return item.itemObject
129+
public func get( objectId : String! ) throws -> YTKObject?{
130+
do{
131+
if let item = try self.getItem(objectId){
132+
return item.itemObject
133+
}
134+
}catch let error{
135+
throw error
129136
}
130137
return nil
131138
}
132139

133-
public func getItem(objectId :String!)->YTKItem?{
134-
135-
if let filter = db?.prepare( tableHandle!.filter(ID == objectId).limit(1) ){
136-
for v in filter{
137-
var item = YTKItem()
138-
item.itemId = objectId
139-
item.itemObject = YTKObject(value: v[JSON] )
140-
item.createdTime = v.get(CREATEDTIME)
141-
return item
140+
public func getItem(objectId :String!) throws ->YTKItem?{
141+
do{
142+
if let filter = try db?.prepare( tableHandle!.filter(ID == objectId).limit(1) ){
143+
for v in filter{
144+
var item = YTKItem()
145+
item.itemId = objectId
146+
item.itemObject = YTKObject(value: v[JSON] )
147+
item.createdTime = v.get(CREATEDTIME)
148+
return item
149+
}
142150
}
151+
}catch let error{
152+
throw error
143153
}
144154
return nil
145155
}
146156

147-
public func getAllItems()->[YTKItem]{
157+
public func getAllItems() throws ->[YTKItem]{
148158

149159
var result : [YTKItem] = []
150-
151-
if let filter = db?.prepare(tableHandle!){
152-
for vs in filter{
153-
var item = YTKItem()
154-
item.itemId = vs[ID]
155-
item.itemObject = YTKObject(value:vs[JSON])
156-
item.createdTime = vs.get(CREATEDTIME)
157-
result.append(item)
160+
do{
161+
if let filter = try db?.prepare(tableHandle!){
162+
for vs in filter{
163+
var item = YTKItem()
164+
item.itemId = vs[ID]
165+
item.itemObject = YTKObject(value:vs[JSON])
166+
item.createdTime = vs.get(CREATEDTIME)
167+
result.append(item)
168+
}
158169
}
170+
}catch let error{
171+
throw error
159172
}
160173
return result
161174
}

0 commit comments

Comments
 (0)