Skip to content

Swift 3 Migration #500

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 20 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
language: objective-c
env:
- BUILD_SCHEME="SQLite iOS"
- BUILD_SCHEME="SQLite Mac"
matrix:
include:
- env: BUILD_SCHEME="SQLite iOS"
- env: BUILD_SCHEME="SQLite Mac"
- env: VALIDATOR_SUBSPEC="none"
- env: VALIDATOR_SUBSPEC="standard"
- env: VALIDATOR_SUBSPEC="standalone"
before_install:
- gem install xcpretty --no-document
script:
- make test
- cd CocoaPodsTests && make test
- ./run-tests.sh
osx_image: xcode7.3
2 changes: 1 addition & 1 deletion CocoaPods/appletvos/module.modulemap
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module CSQLite [system] {
header "/Applications/Xcode-beta.app/Contents/Developer/Platforms/AppleTVOS.platform/Developer/SDKs/AppleTVOS.sdk/usr/include/sqlite3.h"
header "/Applications/Xcode.app/Contents/Developer/Platforms/AppleTVOS.platform/Developer/SDKs/AppleTVOS.sdk/usr/include/sqlite3.h"
export *
}
2 changes: 1 addition & 1 deletion CocoaPods/appletvsimulator/module.modulemap
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module CSQLite [system] {
header "/Applications/Xcode-beta.app/Contents/Developer/Platforms/AppleTVSimulator.platform/Developer/SDKs/AppleTVSimulator.sdk/usr/include/sqlite3.h"
header "/Applications/Xcode.app/Contents/Developer/Platforms/AppleTVSimulator.platform/Developer/SDKs/AppleTVSimulator.sdk/usr/include/sqlite3.h"
export *
}
2 changes: 1 addition & 1 deletion CocoaPods/iphoneos/module.modulemap
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module CSQLite [system] {
header "/Applications/Xcode-beta.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/usr/include/sqlite3.h"
header "/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/usr/include/sqlite3.h"
export *
}
2 changes: 1 addition & 1 deletion CocoaPods/iphonesimulator/module.modulemap
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module CSQLite [system] {
header "/Applications/Xcode-beta.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk/usr/include/sqlite3.h"
header "/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk/usr/include/sqlite3.h"
export *
}
2 changes: 1 addition & 1 deletion CocoaPods/macosx/module.modulemap
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module CSQLite [system] {
header "/Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk/usr/include/sqlite3.h"
header "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk/usr/include/sqlite3.h"
export *
}
2 changes: 1 addition & 1 deletion CocoaPods/watchos/module.modulemap
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module CSQLite [system] {
header "/Applications/Xcode-beta.app/Contents/Developer/Platforms/WatchOS.platform/Developer/SDKs/WatchOS.sdk/usr/include/sqlite3.h"
header "/Applications/Xcode.app/Contents/Developer/Platforms/WatchOS.platform/Developer/SDKs/WatchOS.sdk/usr/include/sqlite3.h"
export *
}
2 changes: 1 addition & 1 deletion CocoaPods/watchsimulator/module.modulemap
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module CSQLite [system] {
header "/Applications/Xcode-beta.app/Contents/Developer/Platforms/WatchSimulator.platform/Developer/SDKs/WatchSimulator.sdk/usr/include/sqlite3.h"
header "/Applications/Xcode.app/Contents/Developer/Platforms/WatchSimulator.platform/Developer/SDKs/WatchSimulator.sdk/usr/include/sqlite3.h"
export *
}
6 changes: 6 additions & 0 deletions CocoaPodsTests/integration_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,19 @@ def test_validate_project

def validator
@validator ||= TestRunningValidator.new(podspec, []).tap do |validator|
subspec = ENV["VALIDATOR_SUBSPEC"]
validator.test_files = Dir["#{project_test_dir}/*.swift"]
validator.config.verbose = true
validator.no_clean = true
validator.use_frameworks = true
validator.fail_fast = true
validator.local = true
validator.allow_warnings = true
if subspec == "none"
validator.no_subspecs = true
else
validator.only_subspec = subspec
end
end
end

Expand Down
14 changes: 7 additions & 7 deletions Documentation/Index.md
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,7 @@ The `column` function is used for a single column definition. It takes an [expre
t.column(email, collate: .Nocase)
// "email" TEXT NOT NULL COLLATE "NOCASE"

t.column(name, collate: .Rtrim)
t.column(name, collate: .rtrim)
// "name" TEXT COLLATE "RTRIM"
```

Expand Down Expand Up @@ -999,7 +999,7 @@ The `addColumn` function shares several of the same [`column` function parameter
try db.run(users.addColumn(email, collate: .Nocase))
// ALTER TABLE "users" ADD COLUMN "email" TEXT NOT NULL COLLATE "NOCASE"

try db.run(users.addColumn(name, collate: .Rtrim))
try db.run(users.addColumn(name, collate: .rtrim))
// ALTER TABLE "users" ADD COLUMN "name" TEXT COLLATE "RTRIM"
```

Expand Down Expand Up @@ -1388,14 +1388,14 @@ let emails = VirtualTable("emails")
let subject = Expression<String>("subject")
let body = Expression<String>("body")

try db.run(emails.create(.FTS4(subject, body)))
try db.run(emails.create(.fts4(subject, body)))
// CREATE VIRTUAL TABLE "emails" USING fts4("subject", "body")
```

We can specify a [tokenizer](http://www.sqlite.org/fts3.html#tokenizer) using the `tokenize` parameter.

``` swift
try db.run(emails.create(.FTS4([subject, body], tokenize: .Porter)))
try db.run(emails.create(.fts4([subject, body], tokenize: .Porter)))
// CREATE VIRTUAL TABLE "emails" USING fts4("subject", "body", tokenize=porter)
```

Expand All @@ -1409,9 +1409,9 @@ let config = FTS4Config()
.column(subject)
.column(body, [.unindexed])
.languageId("lid")
.order(.Desc)
.order(.desc)

try db.run(emails.create(.FTS4(config))
try db.run(emails.create(.fts4(config))
// CREATE VIRTUAL TABLE "emails" USING fts4("subject", "body", notindexed="body", languageid="lid", order="desc")
```

Expand Down Expand Up @@ -1443,7 +1443,7 @@ let config = FTS5Config()
.column(subject)
.column(body, [.unindexed])

try db.run(emails.create(.FTS5(config))
try db.run(emails.create(.fts5(config))
// CREATE VIRTUAL TABLE "emails" USING fts5("subject", "body" UNINDEXED)
```

Expand Down
6 changes: 5 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
BUILD_TOOL = xcodebuild
BUILD_SCHEME = SQLite Mac
BUILD_ARGUMENTS = -scheme "$(BUILD_SCHEME)"
ifeq ($(BUILD_SCHEME),SQLite iOS)
BUILD_ARGUMENTS = -scheme "$(BUILD_SCHEME)" -sdk iphonesimulator
else
BUILD_ARGUMENTS = -scheme "$(BUILD_SCHEME)"
endif

XCPRETTY := $(shell command -v xcpretty)
SWIFTCOV := $(shell command -v swiftcov)
Expand Down
2 changes: 1 addition & 1 deletion SQLite.playground/Contents.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ try! db.run(users.create { t in
t.column(email, unique: true, check: email.like("%@%"))
t.column(name)
})

e9a8f36
let rowid = try! db.run(users.insert(email <- "alice@mac.com"))
let alice = users.filter(id == rowid)

Expand Down
2 changes: 1 addition & 1 deletion SQLite.playground/contents.xcplayground
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<playground version='5.0' target-platform='ios' display-mode='raw'>
<playground version='5.0' target-platform='ios' display-mode='raw' last-migration='0800'>
<timeline fileName='timeline.xctimeline'/>
</playground>
12 changes: 12 additions & 0 deletions SQLite.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -679,9 +679,11 @@
TargetAttributes = {
03A65E591C6BB0F50062603F = {
CreatedOnToolsVersion = 7.2;
LastSwiftMigration = 0800;
};
03A65E621C6BB0F60062603F = {
CreatedOnToolsVersion = 7.2;
LastSwiftMigration = 0800;
};
A121AC441CA35C79005A31D1 = {
CreatedOnToolsVersion = 7.3;
Expand All @@ -696,9 +698,11 @@
};
EE247B3B1C3F3ED000AE3E12 = {
CreatedOnToolsVersion = 7.2;
LastSwiftMigration = 0800;
};
EE247B441C3F3ED000AE3E12 = {
CreatedOnToolsVersion = 7.2;
LastSwiftMigration = 0800;
};
};
};
Expand Down Expand Up @@ -969,6 +973,7 @@
SKIP_INSTALL = YES;
"SWIFT_INCLUDE_PATHS[sdk=appletvos*]" = "$(SRCROOT)/CocoaPods/appletvos";
"SWIFT_INCLUDE_PATHS[sdk=appletvsimulator*]" = "$(SRCROOT)/CocoaPods/appletvsimulator";
SWIFT_VERSION = 3.0;
TVOS_DEPLOYMENT_TARGET = 9.1;
};
name = Debug;
Expand All @@ -990,6 +995,7 @@
"SWIFT_INCLUDE_PATHS[sdk=appletvos*]" = "$(SRCROOT)/CocoaPods/appletvos";
"SWIFT_INCLUDE_PATHS[sdk=appletvsimulator*]" = "$(SRCROOT)/CocoaPods/appletvsimulator";
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
SWIFT_VERSION = 3.0;
TVOS_DEPLOYMENT_TARGET = 9.1;
};
name = Release;
Expand All @@ -1002,6 +1008,7 @@
PRODUCT_BUNDLE_IDENTIFIER = com.stephencelis.SQLiteTests;
PRODUCT_NAME = "$(TARGET_NAME)";
SDKROOT = appletvos;
SWIFT_VERSION = 3.0;
TVOS_DEPLOYMENT_TARGET = 9.1;
};
name = Debug;
Expand All @@ -1015,6 +1022,7 @@
PRODUCT_NAME = "$(TARGET_NAME)";
SDKROOT = appletvos;
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
SWIFT_VERSION = 3.0;
TVOS_DEPLOYMENT_TARGET = 9.1;
};
name = Release;
Expand Down Expand Up @@ -1244,6 +1252,7 @@
SKIP_INSTALL = YES;
SWIFT_INCLUDE_PATHS = "";
"SWIFT_INCLUDE_PATHS[sdk=macosx*]" = "$(SRCROOT)/CocoaPods/macosx";
SWIFT_VERSION = 3.0;
};
name = Debug;
};
Expand All @@ -1269,6 +1278,7 @@
SWIFT_INCLUDE_PATHS = "";
"SWIFT_INCLUDE_PATHS[sdk=macosx*]" = "$(SRCROOT)/CocoaPods/macosx";
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
SWIFT_VERSION = 3.0;
};
name = Release;
};
Expand All @@ -1283,6 +1293,7 @@
PRODUCT_BUNDLE_IDENTIFIER = com.stephencelis.SQLiteTests;
PRODUCT_NAME = "$(TARGET_NAME)";
SDKROOT = macosx;
SWIFT_VERSION = 3.0;
};
name = Debug;
};
Expand All @@ -1298,6 +1309,7 @@
PRODUCT_NAME = "$(TARGET_NAME)";
SDKROOT = macosx;
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
SWIFT_VERSION = 3.0;
};
name = Release;
};
Expand Down
80 changes: 80 additions & 0 deletions SQLite.xcodeproj/xcshareddata/xcschemes/SQLite watchOS.xcscheme
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0800"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "A121AC441CA35C79005A31D1"
BuildableName = "SQLite.framework"
BlueprintName = "SQLite watchOS"
ReferencedContainer = "container:SQLite.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
</Testables>
<AdditionalOptions>
</AdditionalOptions>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "A121AC441CA35C79005A31D1"
BuildableName = "SQLite.framework"
BlueprintName = "SQLite watchOS"
ReferencedContainer = "container:SQLite.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "A121AC441CA35C79005A31D1"
BuildableName = "SQLite.framework"
BlueprintName = "SQLite watchOS"
ReferencedContainer = "container:SQLite.xcodeproj">
</BuildableReference>
</MacroExpansion>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>
4 changes: 2 additions & 2 deletions SQLite/Core/Blob.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ public struct Blob {
self.bytes = bytes
}

public init(bytes: UnsafePointer<Void>, length: Int) {
public init(bytes: UnsafeRawPointer, length: Int) {
self.init(bytes: [UInt8](UnsafeBufferPointer(
start: UnsafePointer(bytes), count: length
start: bytes.assumingMemoryBound(to: UInt8.self), count: length
)))
}

Expand Down
Loading