Skip to content

Commit e240552

Browse files
committed
Merge pull request stephencelis#154 from stephencelis/swift-2
Swift 2
2 parents d87e05d + c6e8b94 commit e240552

File tree

87 files changed

+9127
-7341
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

87 files changed

+9127
-7341
lines changed

.travis.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
language: objective-c
22
env:
3-
- BUILD_SDK=iphonesimulator ONLY_ACTIVE_ARCH=NO
4-
- BUILD_SDK=macosx
3+
- BUILD_SCHEME="SQLite iOS"
4+
- BUILD_SCHEME="SQLite Mac"
55
before_install:
66
- gem install xcpretty --no-document
77
script:
88
- make test
9-
osx_image: beta-xcode6.3
9+
osx_image: xcode7

CONTRIBUTING.md

Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -54,29 +54,7 @@ first.
5454
While Swift error messaging is improving with each release, complex
5555
expressions still lend themselves to misleading errors. If you encounter an
5656
error on a complex line, breaking it down into smaller pieces generally
57-
yields a more understandable error. _E.g._:
58-
59-
``` swift
60-
users.insert(email <- "alice@mac.com" <- managerId <- db.lastInsertRowid)
61-
// Cannot invoke 'insert' with an argument list of type '(Setter, Setter)'
62-
```
63-
64-
Not very helpful! If we break the expression down into smaller parts,
65-
however, the real error materializes on the appropriate line.
66-
67-
``` swift
68-
let emailSetter = email <- "alice@mac.com"
69-
let managerIdSetter = managerId <- db.lastInsertRowId
70-
// Binary operator '<-' cannot be applied to operands of type 'Expression<Int>' and 'Int64'
71-
users.insert(emailSetter, managerIdSetter)
72-
```
73-
74-
The problem turns out to be a simple type mismatch. The fix is elsewhere:
75-
76-
``` diff
77-
-let managerId = Expression<Int>("manager_id")
78-
+let managerId = Expression<Int64>("manager_id")
79-
```
57+
yields a more understandable error.
8058

8159
- **Is it an _even more_ unhelpful build error?** <a name='bugs-5'/>
8260

Documentation/Index.md

Lines changed: 184 additions & 190 deletions
Large diffs are not rendered by default.
40.9 KB
Loading

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
BUILD_TOOL = xcodebuild
2-
BUILD_SDK = macosx
3-
BUILD_ARGUMENTS = -scheme SQLite -sdk $(BUILD_SDK)
2+
BUILD_SCHEME = SQLite Mac
3+
BUILD_ARGUMENTS = -scheme "$(BUILD_SCHEME)"
44

55
XCPRETTY := $(shell command -v xcpretty)
66
SWIFTCOV := $(shell command -v swiftcov)

README.md

Lines changed: 48 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -34,46 +34,44 @@ syntax _and_ intent.
3434
``` swift
3535
import SQLite
3636

37-
let db = Database("path/to/db.sqlite3")
37+
let db = try Connection("path/to/db.sqlite3")
3838

39-
let users = db["users"]
39+
let users = Table("users")
4040
let id = Expression<Int64>("id")
4141
let name = Expression<String?>("name")
4242
let email = Expression<String>("email")
4343

44-
db.create(table: users) { t in
44+
try db.run(users.create { t in
4545
t.column(id, primaryKey: true)
4646
t.column(name)
4747
t.column(email, unique: true)
48-
}
48+
})
4949
// CREATE TABLE "users" (
5050
// "id" INTEGER PRIMARY KEY NOT NULL,
5151
// "name" TEXT,
5252
// "email" TEXT NOT NULL UNIQUE
5353
// )
5454

55-
var alice: Query?
56-
if let rowid = users.insert(name <- "Alice", email <- "alice@mac.com").rowid {
57-
println("inserted id: \(rowid)")
58-
// inserted id: 1
59-
alice = users.filter(id == rowid)
60-
}
55+
let insert = users.insert(name <- "Alice", email <- "alice@mac.com")
56+
let rowid = try db.run(insert)
6157
// INSERT INTO "users" ("name", "email") VALUES ('Alice', 'alice@mac.com')
6258

63-
for user in users {
59+
for user in db.prepare(users) {
6460
println("id: \(user[id]), name: \(user[name]), email: \(user[email])")
6561
// id: 1, name: Optional("Alice"), email: alice@mac.com
6662
}
6763
// SELECT * FROM "users"
6864

69-
alice?.update(email <- replace(email, "mac.com", "me.com"))
65+
let alice = users.filter(id == rowid)
66+
67+
try db.run(alice.update(email <- email.replace("mac.com", "me.com")))
7068
// UPDATE "users" SET "email" = replace("email", 'mac.com', 'me.com')
7169
// WHERE ("id" = 1)
7270

73-
alice?.delete()
71+
try db.run(alice.delete())
7472
// DELETE FROM "users" WHERE ("id" = 1)
7573

76-
users.count
74+
db.scalar(users.count) // 0
7775
// SELECT count(*) FROM "users"
7876
```
7977

@@ -107,29 +105,54 @@ interactively, from the Xcode project’s playground.
107105

108106
## Installation
109107

110-
> _Note:_ SQLite.swift requires Swift 1.2 (and [Xcode][] 6.3) or
111-
> greater.
108+
> _Note:_ SQLite.swift requires Swift 2 (and [Xcode][] 7) or greater.
112109
>
113110
> The following instructions apply to targets that support embedded
114111
> Swift frameworks. To use SQLite.swift in iOS 7 or an OS X command line
115112
> tool, please read the [Frameworkless Targets][] section of the
116113
> documentation.
117114
118115

116+
### Carthage
117+
118+
[Carthage][] is a simple, decentralized dependency manager for Cocoa. To
119+
install SQLite.swift with Carthage:
120+
121+
1. Make sure Carthage is [installed][Carthage Installation].
122+
123+
2. Update your Cartfile to include the following:
124+
125+
```
126+
github "stephencelis/SQLite.swift" "master"
127+
```
128+
129+
3. Run `carthage update` and [add the appropriate framework][Carthage Usage].
130+
131+
132+
[Carthage]: https://github.com/Carthage/Carthage
133+
[Carthage Installation]: https://github.com/Carthage/Carthage#installing-carthage
134+
[Carthage Usage]: https://github.com/Carthage/Carthage#adding-frameworks-to-an-application
135+
136+
119137
### CocoaPods
120138
121139
[CocoaPods][] is a dependency manager for Cocoa projects. To install
122140
SQLite.swift with CocoaPods:
123141
124-
1. Make sure CocoaPods is [installed][CocoaPods Installation] (SQLite.swift
125-
requires version 0.37 or greater).
142+
1. Make sure CocoaPods is [installed][CocoaPods Installation]. (SQLite.swift
143+
requires version 0.37 or greater.)
126144
127145
2. Update your Podfile to include the following:
128146
129147
``` ruby
130148
use_frameworks!
131-
pod 'SQLite.swift', git: 'https://github.com/stephencelis/SQLite.swift.git'
132-
# pod 'SQLite.swift/Cipher', git: ... # instead, for SQLCipher support
149+
150+
pod 'SQLite.swift',
151+
git: 'https://github.com/stephencelis/SQLite.swift.git'
152+
153+
# instead, for SQLCipher support
154+
pod 'SQLiteCipher.swift',
155+
git: 'https://github.com/stephencelis/SQLite.swift.git'
133156
```
134157
135158
3. Run `pod install`.
@@ -145,16 +168,14 @@ To install SQLite.swift as an Xcode sub-project:
145168
1. Drag the **SQLite.xcodeproj** file into your own project.
146169
([Submodule][], clone, or [download][] the project first.)
147170
148-
![](Documentation/Resources/installation@2x.png)
171+
![Installation Screen Shot](Documentation/Resources/installation@2x.png)
149172
150-
2. In your target’s **Build Phases**, add **SQLite** to the **Target
151-
Dependencies** build phase.
173+
2. In your target’s **General** tab, click the **+** button under **Linked
174+
Frameworks and Libraries**.
152175
153-
3. Add **SQLite.framework** to the **Link Binary With Libraries** build
154-
phase.
176+
3. Select the appropriate **SQLite.framework** for your platform.
155177
156-
4. Add **SQLite.framework** to a **Copy Files** build phase with a
157-
**Frameworks** destination. (Add a new build phase if need be.)
178+
4. **Add**.
158179
159180
[Frameworkless Targets]: Documentation/Index.md#frameworkless-targets
160181
[Xcode]: https://developer.apple.com/xcode/downloads/

0 commit comments

Comments
 (0)