Skip to content

Commit

Permalink
Merge pull request #600 from outfoxx/tvos-support
Browse files Browse the repository at this point in the history
Add support for tvOS
  • Loading branch information
groue authored Aug 24, 2019
2 parents 881d4c6 + 055e33b commit 7cf10bf
Show file tree
Hide file tree
Showing 13 changed files with 1,090 additions and 19 deletions.
49 changes: 49 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,27 @@ jobs:
- TID=GRDBiOS (Swift 5, iOS <MIN>)
script: make test_framework_GRDBiOS_minTarget

- stage: Test GRDB Xcode 10.2
gemfile: .ci/gemfiles/Gemfile.travis
osx_image: xcode10.2
env:
- TID=GRDBtvOS (Swift 5, tvOS <MAX>)
script: make test_framework_GRDBtvOS_maxTarget_maxSwift

- stage: Test GRDB Xcode 10.2
gemfile: .ci/gemfiles/Gemfile.travis
osx_image: xcode10.2
env:
- TID=GRDBtvOS (Swift 4.2, tvOS <MAX>)
script: make test_framework_GRDBtvOS_maxTarget_minSwift

- stage: Test GRDB Xcode 10.2
gemfile: .ci/gemfiles/Gemfile.travis
osx_image: xcode10.2
env:
- TID=GRDBtvOS (Swift 5, tvOS <MIN>)
script: make test_framework_GRDBtvOS_minTarget

- stage: Test GRDB Xcode 10.2
gemfile: .ci/gemfiles/Gemfile.travis
osx_image: xcode10.2
Expand Down Expand Up @@ -196,6 +217,20 @@ jobs:
- TID=GRDBiOS (Swift 4.2, iOS <MIN>)
script: make test_framework_GRDBiOS_minTarget

- stage: Test GRDB Xcode 10.1
gemfile: .ci/gemfiles/Gemfile.travis
osx_image: xcode10.1
env:
- TID=GRDBtvOS (Swift 4.2, tvOS <MAX>)
script: make test_framework_GRDBtvOS_maxTarget_maxSwift

- stage: Test GRDB Xcode 10.1
gemfile: .ci/gemfiles/Gemfile.travis
osx_image: xcode10.1
env:
- TID=GRDBtvOS (Swift 4.2, tvOS <MIN>)
script: make test_framework_GRDBtvOS_minTarget

- stage: Test GRDB Xcode 10.1
gemfile: .ci/gemfiles/Gemfile.travis
osx_image: xcode10.1
Expand Down Expand Up @@ -258,6 +293,20 @@ jobs:
- TID=GRDBiOS (Swift 4.2, iOS <MIN>)
script: make test_framework_GRDBiOS_minTarget

- stage: Test GRDB Xcode 10
gemfile: .ci/gemfiles/Gemfile.travis
osx_image: xcode10
env:
- TID=GRDBtvOS (Swift 4.2, tvOS <MAX>)
script: make test_framework_GRDBtvOS_maxTarget_maxSwift

- stage: Test GRDB Xcode 10
gemfile: .ci/gemfiles/Gemfile.travis
osx_image: xcode10
env:
- TID=GRDBtvOS (Swift 4.2, tvOS <MIN>)
script: make test_framework_GRDBtvOS_minTarget

- stage: Test GRDB Xcode 10
gemfile: .ci/gemfiles/Gemfile.travis
osx_image: xcode10
Expand Down
1 change: 1 addition & 0 deletions GRDB.swift.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ Pod::Spec.new do |s|
s.ios.deployment_target = '9.0'
s.osx.deployment_target = '10.9'
s.watchos.deployment_target = '2.0'
s.tvos.deployment_target = '9.0'
s.default_subspec = 'standard'

s.subspec 'standard' do |ss|
Expand Down
877 changes: 877 additions & 0 deletions GRDB.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

100 changes: 100 additions & 0 deletions GRDB.xcodeproj/xcshareddata/xcschemes/GRDBtvOS.xcscheme
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1030"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "AAA4DC75230F1E0600C74B15"
BuildableName = "GRDB.framework"
BlueprintName = "GRDBtvOS"
ReferencedContainer = "container:GRDB.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
codeCoverageEnabled = "YES"
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
<TestableReference
skipped = "NO">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "AAA4DD07230F262000C74B15"
BuildableName = "GRDBtvOSTests.xctest"
BlueprintName = "GRDBtvOSTests"
ReferencedContainer = "container:GRDB.xcodeproj">
</BuildableReference>
</TestableReference>
</Testables>
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "AAA4DC75230F1E0600C74B15"
BuildableName = "GRDB.framework"
BlueprintName = "GRDBtvOS"
ReferencedContainer = "container:GRDB.xcodeproj">
</BuildableReference>
</MacroExpansion>
<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 = "AAA4DC75230F1E0600C74B15"
BuildableName = "GRDB.framework"
BlueprintName = "GRDBtvOS"
ReferencedContainer = "container:GRDB.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "AAA4DC75230F1E0600C74B15"
BuildableName = "GRDB.framework"
BlueprintName = "GRDBtvOS"
ReferencedContainer = "container:GRDB.xcodeproj">
</BuildableReference>
</MacroExpansion>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>
2 changes: 1 addition & 1 deletion GRDB/Core/Database.swift
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ extension Database {
#elseif os(Linux)
setupTrace_v1()
#else
if #available(iOS 10.0, OSX 10.12, watchOS 3.0, *) {
if #available(iOS 10.0, OSX 10.12, tvOS 10.0, watchOS 3.0, *) {
let dbPointer = Unmanaged.passUnretained(self).toOpaque()
sqlite3_trace_v2(
sqliteConnection,
Expand Down
2 changes: 1 addition & 1 deletion GRDB/Core/Statement.swift
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public class Statement {
&sqliteStatement, statementEnd)
#else
let code: Int32
if #available(iOS 12.0, OSX 10.14, watchOS 5.0, *) {
if #available(iOS 12.0, OSX 10.14, tvOS 12.0, watchOS 5.0, *) {
code = sqlite3_prepare_v3(
database.sqliteConnection, statementStart, -1, UInt32(bitPattern: prepFlags),
&sqliteStatement, statementEnd)
Expand Down
2 changes: 1 addition & 1 deletion GRDB/FTS/FTS5.swift
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ public struct FTS5: VirtualTableModule {
// GRDB is linked against the system SQLite.
//
// Do we use SQLite 3.19.3 (iOS 11.4), or SQLite 3.24.0 (iOS 12.0)?
if #available(iOS 12.0, OSX 10.14, watchOS 5.0, *) {
if #available(iOS 12.0, OSX 10.14, tvOS 12.0, watchOS 5.0, *) {
// SQLite 3.24.0 or more
return api_v2(db, sqlite3_prepare_v3, sqlite3_bind_pointer)
} else {
Expand Down
4 changes: 2 additions & 2 deletions GRDB/Record/EncodableRecord.swift
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public protocol EncodableRecord {
/// - dataEncodingStrategy: .base64
/// - dateEncodingStrategy: .millisecondsSince1970
/// - nonConformingFloatEncodingStrategy: .throw
/// - outputFormatting: .sortedKeys (iOS 11.0+, macOS 10.13+, watchOS 4.0+)
/// - outputFormatting: .sortedKeys (iOS 11.0+, macOS 10.13+, tvOS 11.0+, watchOS 4.0+)
///
/// You can override those defaults:
///
Expand Down Expand Up @@ -129,7 +129,7 @@ extension EncodableRecord {
encoder.dataEncodingStrategy = .base64
encoder.dateEncodingStrategy = .millisecondsSince1970
encoder.nonConformingFloatEncodingStrategy = .throw
if #available(watchOS 4.0, OSX 10.13, iOS 11.0, *) {
if #available(watchOS 4.0, OSX 10.13, iOS 11.0, tvOS 11.0, *) {
// guarantee some stability in order to ease record comparison
encoder.outputFormatting = .sortedKeys
}
Expand Down
46 changes: 45 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -54,19 +54,27 @@ ifeq ($(XCODEVERSION),10.3)
MIN_SWIFT_VERSION = 4.2
MAX_IOS_DESTINATION = "platform=iOS Simulator,name=iPhone X,OS=12.4"
MIN_IOS_DESTINATION = "platform=iOS Simulator,name=iPhone 4s,OS=9.0"
MAX_TVOS_DESTINATION = "platform=tvOS Simulator,name=Apple TV 4K,OS=12.4"
MIN_TVOS_DESTINATION = "platform=tvOS Simulator,name=Apple TV,OS=10.0"
else ifeq ($(XCODEVERSION),10.2)
MAX_SWIFT_VERSION = 5
MIN_SWIFT_VERSION = 4.2
MAX_IOS_DESTINATION = "platform=iOS Simulator,name=iPhone X,OS=12.2"
MIN_IOS_DESTINATION = "platform=iOS Simulator,name=iPhone 4s,OS=9.0"
MAX_TVOS_DESTINATION = "platform=tvOS Simulator,name=Apple TV 4K,OS=12.2"
MIN_TVOS_DESTINATION = "platform=tvOS Simulator,name=Apple TV,OS=10.0"
else ifeq ($(XCODEVERSION),10.1)
MAX_SWIFT_VERSION = 4.2
MAX_IOS_DESTINATION = "platform=iOS Simulator,name=iPhone X,OS=12.1"
MIN_IOS_DESTINATION = "platform=iOS Simulator,name=iPhone 4s,OS=9.0"
MAX_TVOS_DESTINATION = "platform=tvOS Simulator,name=Apple TV 4K,OS=12.1"
MIN_TVOS_DESTINATION = "platform=tvOS Simulator,name=Apple TV,OS=10.0"
else ifeq ($(XCODEVERSION),10.0)
MAX_SWIFT_VERSION = 4.2
MAX_IOS_DESTINATION = "platform=iOS Simulator,name=iPhone 8,OS=12.0"
MIN_IOS_DESTINATION = "platform=iOS Simulator,name=iPhone 4s,OS=9.0"
MAX_TVOS_DESTINATION = "platform=tvOS Simulator,name=Apple TV 4K,OS=12.0"
MIN_TVOS_DESTINATION = "platform=tvOS Simulator,name=Apple TV,OS=10.0"
else
# Swift 4.1 required: Xcode < 9.3 is not supported
endif
Expand Down Expand Up @@ -105,7 +113,7 @@ test: test_framework test_install

test_framework: test_framework_darwin
test_framework_darwin: test_framework_GRDB test_framework_GRDBCustom test_framework_SQLCipher test_SPM
test_framework_GRDB: test_framework_GRDBOSX test_framework_GRDBWatchOS test_framework_GRDBiOS
test_framework_GRDB: test_framework_GRDBOSX test_framework_GRDBWatchOS test_framework_GRDBiOS test_framework_GRDBtvOS
test_framework_GRDBCustom: test_framework_GRDBCustomSQLiteOSX test_framework_GRDBCustomSQLiteiOS
test_framework_SQLCipher: test_framework_SQLCipher3 test_framework_SQLCipher4
test_install: test_install_manual test_install_SPM test_install_GRDB_CocoaPods test_CocoaPodsLint
Expand Down Expand Up @@ -180,6 +188,42 @@ test_framework_GRDBiOS_minTarget:
$(TEST_ACTIONS) \
$(XCPRETTY)

test_framework_GRDBtvOS: test_framework_GRDBtvOS_maxTarget test_framework_GRDBtvOS_minTarget
test_framework_GRDBtvOS_maxTarget: test_framework_GRDBtvOS_maxTarget_maxSwift test_framework_GRDBtvOS_maxTarget_minSwift

test_framework_GRDBtvOS_maxTarget_maxSwift:
# SQLITE_ENABLE_FTS5 requires iOS 11.4+
$(XCODEBUILD) \
-project GRDB.xcodeproj \
-scheme GRDBtvOS \
-destination $(MAX_TVOS_DESTINATION) \
SWIFT_VERSION=$(MAX_SWIFT_VERSION) \
'OTHER_SWIFT_FLAGS=$(inherited) -D SQLITE_ENABLE_FTS5' \
$(TEST_ACTIONS) \
$(XCPRETTY)

test_framework_GRDBtvOS_maxTarget_minSwift:
ifdef MIN_SWIFT_VERSION
# SQLITE_ENABLE_FTS5 requires iOS 11.4+
$(XCODEBUILD) \
-project GRDB.xcodeproj \
-scheme GRDBtvOS \
-destination $(MAX_TVOS_DESTINATION) \
SWIFT_VERSION=$(MIN_SWIFT_VERSION) \
'OTHER_SWIFT_FLAGS=$(inherited) -D SQLITE_ENABLE_FTS5' \
$(TEST_ACTIONS) \
$(XCPRETTY)
endif

test_framework_GRDBtvOS_minTarget:
$(XCODEBUILD) \
-project GRDB.xcodeproj \
-scheme GRDBtvOS \
-destination $(MIN_TVOS_DESTINATION) \
SWIFT_VERSION=$(MAX_SWIFT_VERSION) \
$(TEST_ACTIONS) \
$(XCPRETTY)

test_framework_GRDBCustomSQLiteOSX: SQLiteCustom
$(XCODEBUILD) \
-project GRDBCustom.xcodeproj \
Expand Down
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ GRDB 4 [![Swift 4.2](https://img.shields.io/badge/swift-4.2-orange.svg?style=fla

**Latest release**: August 13, 2019 • version 4.2.1 • [CHANGELOG](CHANGELOG.md) • [Migrating From GRDB 3 to GRDB 4](Documentation/GRDB3MigrationGuide.md)

**Requirements**: iOS 9.0+ / macOS 10.9+ / watchOS 2.0+ &bull; Swift 4.2+ / Xcode 10.0+
**Requirements**: iOS 9.0+ / macOS 10.9+ / tvOS 9.0+ / watchOS 2.0+ &bull; Swift 4.2+ / Xcode 10.0+

| Swift version | GRDB version |
| ------------- | ----------------------------------------------------------- |
Expand Down Expand Up @@ -357,7 +357,7 @@ Note that Linux is not currently supported.

2. Embed the `GRDB.xcodeproj` project in your own project.

3. Add the `GRDBOSX`, `GRDBiOS`, or `GRDBWatchOS` target in the **Target Dependencies** section of the **Build Phases** tab of your application target (extension target for WatchOS).
3. Add the `GRDBOSX`, `GRDBiOS`, `GRDBtvOS`, or `GRDBWatchOS` target in the **Target Dependencies** section of the **Build Phases** tab of your application target (extension target for WatchOS).

4. Add the `GRDB.framework` from the targetted platform to the **Embedded Binaries** section of the **General** tab of your application target (extension target for WatchOS).

Expand Down Expand Up @@ -2790,7 +2790,7 @@ protocol EncodableRecord {
}
```

> :bulb: **Tip**: Make sure you set the JSONEncoder `sortedKeys` option, available from iOS 11.0+, macOS 10.13+, and watchOS 4.0+. This option makes sure that the JSON output is stable. This stability is required for [Record Comparison] to work as expected, and database observation tools such as [ValueObservation] to accurately recognize changed records.
> :bulb: **Tip**: Make sure you set the JSONEncoder `sortedKeys` option, available from iOS 11.0+, macOS 10.13+, tvOS 9.0+ and watchOS 4.0+. This option makes sure that the JSON output is stable. This stability is required for [Record Comparison] to work as expected, and database observation tools such as [ValueObservation] to accurately recognize changed records.


### Date and UUID Coding Strategies
Expand Down Expand Up @@ -4964,7 +4964,7 @@ Generally speaking, FTS5 is better than FTS4 which improves on FTS3. But this do

- **The location of the indexed text in your database schema.** Only FTS4 and FTS5 support "contentless" and "external content" tables.

- **The SQLite library integrated in your application.** The version of SQLite that ships with iOS, macOS and watchOS supports FTS3 and FTS4 out of the box, but not always FTS5. To use FTS5, see [Enabling FTS5 Support](#enabling-fts5-support).
- **The SQLite library integrated in your application.** The version of SQLite that ships with iOS, macOS, tvOS and watchOS supports FTS3 and FTS4 out of the box, but not always FTS5. To use FTS5, see [Enabling FTS5 Support](#enabling-fts5-support).

- See [FST3 vs. FTS4](https://www.sqlite.org/fts3.html#differences_between_fts3_and_fts4) and [FTS5 vs. FTS3/4](https://www.sqlite.org/fts5.html#appendix_a) for more differences.

Expand Down Expand Up @@ -5185,9 +5185,9 @@ let documents = try Document.filter(Column("content").match(pattern)).fetchAll(d

When the FTS3 and FTS4 full-text engines don't suit your needs, you may want to use FTS5. See [Choosing the Full-Text Engine](#choosing-the-full-text-engine) to help you make a decision.

The version of SQLite that ships with iOS, macOS and watchOS does not always support the FTS5 engine. To enable FTS5 support, you'll need to install GRDB with one of those installation techniques:
The version of SQLite that ships with iOS, macOS, tvOS and watchOS does not always support the FTS5 engine. To enable FTS5 support, you'll need to install GRDB with one of those installation techniques:

1. Use the GRDB.swift CocoaPod with a custom compilation option, as below. It uses the system SQLite, which is compiled with FTS5 support, but only on iOS 11.4+ / macOS 10.13+ / watchOS 4.3+:
1. Use the GRDB.swift CocoaPod with a custom compilation option, as below. It uses the system SQLite, which is compiled with FTS5 support, but only on iOS 11.4+ / macOS 10.13+ / tvOS 11.4+ / watchOS 4.3+:

```ruby
pod 'GRDB.swift'
Expand Down
4 changes: 2 additions & 2 deletions Tests/GRDBTests/DatabasePoolConcurrencyTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -960,7 +960,7 @@ class DatabasePoolConcurrencyTests: GRDBTestCase {

func testTargetQueue() throws {
// dispatchPrecondition(condition:) availability
if #available(OSX 10.12, iOS 10.0, *) {
if #available(OSX 10.12, iOS 10.0, tvOS 10.0, *) {
func test(targetQueue: DispatchQueue) throws {
dbConfiguration.targetQueue = targetQueue
let dbPool = try makeDatabasePool()
Expand All @@ -987,7 +987,7 @@ class DatabasePoolConcurrencyTests: GRDBTestCase {

func testQoS() throws {
// dispatchPrecondition(condition:) availability
if #available(OSX 10.12, iOS 10.0, *) {
if #available(OSX 10.12, iOS 10.0, tvOS 10.0, *) {
func test(qos: DispatchQoS) throws {
// https://forums.swift.org/t/what-is-the-default-target-queue-for-a-serial-queue/18094/5
//
Expand Down
4 changes: 2 additions & 2 deletions Tests/GRDBTests/DatabaseQueueTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ class DatabaseQueueTests: GRDBTestCase {

func testTargetQueue() throws {
// dispatchPrecondition(condition:) availability
if #available(OSX 10.12, iOS 10.0, *) {
if #available(OSX 10.12, iOS 10.0, tvOS 10.0, *) {
func test(targetQueue: DispatchQueue) throws {
dbConfiguration.targetQueue = targetQueue
let dbQueue = try makeDatabaseQueue()
Expand All @@ -155,7 +155,7 @@ class DatabaseQueueTests: GRDBTestCase {

func testQoS() throws {
// dispatchPrecondition(condition:) availability
if #available(OSX 10.12, iOS 10.0, *) {
if #available(OSX 10.12, iOS 10.0, tvOS 10.0, *) {
func test(qos: DispatchQoS) throws {
// https://forums.swift.org/t/what-is-the-default-target-queue-for-a-serial-queue/18094/5
//
Expand Down
Loading

0 comments on commit 7cf10bf

Please sign in to comment.