From 1751fb38e53a4986da85dcccc57508f1462cf78c Mon Sep 17 00:00:00 2001 From: Andrey Fidrya Date: Sat, 8 Apr 2017 21:32:58 +0300 Subject: [PATCH 1/3] SPM support --- .gitignore | 4 ++++ GRDB/Core/Configuration.swift | 4 ++++ GRDB/Core/Database.swift | 4 ++++ GRDB/Core/DatabaseError.swift | 4 ++++ GRDB/Core/DatabasePool.swift | 4 ++++ GRDB/Core/DatabaseReader.swift | 4 ++++ GRDB/Core/DatabaseValue.swift | 4 ++++ GRDB/Core/Row.swift | 4 ++++ GRDB/Core/RowAdapter.swift | 2 ++ GRDB/Core/SchedulingWatchdog.swift | 6 ++++++ GRDB/Core/Statement.swift | 4 ++++ GRDB/Core/StatementColumnConvertible.swift | 4 ++++ GRDB/Core/Support/Foundation/ReferenceConvertible.swift | 2 ++ GRDB/Core/Support/StandardLibrary/StandardLibrary.swift | 4 ++++ GRDB/Core/Utils.swift | 3 +++ GRDB/Record/FetchedRecordsController.swift | 1 + Package.swift | 9 +++++++++ 17 files changed, 67 insertions(+) create mode 100644 Package.swift diff --git a/.gitignore b/.gitignore index b8832cf50..30109f913 100644 --- a/.gitignore +++ b/.gitignore @@ -103,3 +103,7 @@ SQLiteCustom/GRDBCustomSQLite-USER.xcconfig # CocoaPods test Tests/CocoaPods/GRDBiOS/Podfile.lock Tests/CocoaPods/GRDBiOS/Pods + +# SPM build directory +.build + diff --git a/GRDB/Core/Configuration.swift b/GRDB/Core/Configuration.swift index 51a1f4478..00c2d78d1 100644 --- a/GRDB/Core/Configuration.swift +++ b/GRDB/Core/Configuration.swift @@ -1,5 +1,9 @@ import Foundation +#if SWIFT_PACKAGE + import SQLiteSDK +#endif + /// Configuration for a DatabaseQueue or DatabasePool. public struct Configuration { diff --git a/GRDB/Core/Database.swift b/GRDB/Core/Database.swift index 25da8827c..4f9e516b6 100644 --- a/GRDB/Core/Database.swift +++ b/GRDB/Core/Database.swift @@ -1,5 +1,9 @@ import Foundation +#if SWIFT_PACKAGE + import SQLiteSDK +#endif + /// A raw SQLite connection, suitable for the SQLite C API. public typealias SQLiteConnection = OpaquePointer diff --git a/GRDB/Core/DatabaseError.swift b/GRDB/Core/DatabaseError.swift index 57ad63e9e..4016de9a1 100644 --- a/GRDB/Core/DatabaseError.swift +++ b/GRDB/Core/DatabaseError.swift @@ -1,5 +1,9 @@ import Foundation +#if SWIFT_PACKAGE + import SQLiteSDK +#endif + public struct ResultCode : RawRepresentable, Equatable, CustomStringConvertible { public let rawValue: Int32 diff --git a/GRDB/Core/DatabasePool.swift b/GRDB/Core/DatabasePool.swift index 45c82e5cb..d09ecb398 100644 --- a/GRDB/Core/DatabasePool.swift +++ b/GRDB/Core/DatabasePool.swift @@ -4,6 +4,10 @@ import Foundation import UIKit #endif +#if SWIFT_PACKAGE + import SQLiteSDK +#endif + /// A DatabasePool grants concurrent accesses to an SQLite database. public final class DatabasePool { diff --git a/GRDB/Core/DatabaseReader.swift b/GRDB/Core/DatabaseReader.swift index a85b78f58..db08e76c5 100644 --- a/GRDB/Core/DatabaseReader.swift +++ b/GRDB/Core/DatabaseReader.swift @@ -1,3 +1,7 @@ +#if SWIFT_PACKAGE + import SQLiteSDK +#endif + /// The protocol for all types that can fetch values from a database. /// /// It is adopted by DatabaseQueue and DatabasePool. diff --git a/GRDB/Core/DatabaseValue.swift b/GRDB/Core/DatabaseValue.swift index 92d343b34..6c24194f1 100644 --- a/GRDB/Core/DatabaseValue.swift +++ b/GRDB/Core/DatabaseValue.swift @@ -1,5 +1,9 @@ import Foundation +#if SWIFT_PACKAGE + import SQLiteSDK +#endif + // MARK: - DatabaseValue /// DatabaseValue is the intermediate type between SQLite and your values. diff --git a/GRDB/Core/Row.swift b/GRDB/Core/Row.swift index e9bb2a4ff..4132bb2a1 100644 --- a/GRDB/Core/Row.swift +++ b/GRDB/Core/Row.swift @@ -1,5 +1,9 @@ import Foundation +#if SWIFT_PACKAGE + import SQLiteSDK +#endif + /// A database row. public final class Row { diff --git a/GRDB/Core/RowAdapter.swift b/GRDB/Core/RowAdapter.swift index f1b2b71e0..5188b1152 100644 --- a/GRDB/Core/RowAdapter.swift +++ b/GRDB/Core/RowAdapter.swift @@ -1,3 +1,5 @@ +import Foundation + /// LayoutedColumnMapping is a type that supports the RowAdapter protocol. public struct LayoutedColumnMapping { /// An array of (baseIndex, mappedName) pairs, where baseIndex is the index diff --git a/GRDB/Core/SchedulingWatchdog.swift b/GRDB/Core/SchedulingWatchdog.swift index 280efbcbc..f67241641 100644 --- a/GRDB/Core/SchedulingWatchdog.swift +++ b/GRDB/Core/SchedulingWatchdog.swift @@ -1,3 +1,9 @@ +import Dispatch + +#if SWIFT_PACKAGE + import SQLiteSDK +#endif + /// SchedulingWatchdog makes sure that databases connections are used on correct /// dispatch queues, and warns the user with a fatal error whenever she misuses /// a database connection. diff --git a/GRDB/Core/Statement.swift b/GRDB/Core/Statement.swift index 180d5abf8..6a751741f 100644 --- a/GRDB/Core/Statement.swift +++ b/GRDB/Core/Statement.swift @@ -1,5 +1,9 @@ import Foundation +#if SWIFT_PACKAGE + import SQLiteSDK +#endif + /// A raw SQLite statement, suitable for the SQLite C API. public typealias SQLiteStatement = OpaquePointer diff --git a/GRDB/Core/StatementColumnConvertible.swift b/GRDB/Core/StatementColumnConvertible.swift index bb9e89c43..20666725f 100644 --- a/GRDB/Core/StatementColumnConvertible.swift +++ b/GRDB/Core/StatementColumnConvertible.swift @@ -1,3 +1,7 @@ +#if SWIFT_PACKAGE + import SQLiteSDK +#endif + /// When a type adopts both DatabaseValueConvertible and /// StatementColumnConvertible, it is granted with faster access to the SQLite /// database values. diff --git a/GRDB/Core/Support/Foundation/ReferenceConvertible.swift b/GRDB/Core/Support/Foundation/ReferenceConvertible.swift index 50bd8b47f..570171b2a 100644 --- a/GRDB/Core/Support/Foundation/ReferenceConvertible.swift +++ b/GRDB/Core/Support/Foundation/ReferenceConvertible.swift @@ -1,3 +1,5 @@ +import Foundation + /// DatabaseValueConvertible is free for ReferenceConvertible types whose /// ReferenceType is itself DatabaseValueConvertible. /// diff --git a/GRDB/Core/Support/StandardLibrary/StandardLibrary.swift b/GRDB/Core/Support/StandardLibrary/StandardLibrary.swift index 83fae436c..01bc1c2bc 100644 --- a/GRDB/Core/Support/StandardLibrary/StandardLibrary.swift +++ b/GRDB/Core/Support/StandardLibrary/StandardLibrary.swift @@ -1,3 +1,7 @@ +#if SWIFT_PACKAGE + import SQLiteSDK +#endif + // MARK: - Value Types /// Bool adopts DatabaseValueConvertible and StatementColumnConvertible. diff --git a/GRDB/Core/Utils.swift b/GRDB/Core/Utils.swift index 0f538e3ad..bf13ecbb5 100644 --- a/GRDB/Core/Utils.swift +++ b/GRDB/Core/Utils.swift @@ -1,5 +1,8 @@ import Foundation +#if SWIFT_PACKAGE + import SQLiteSDK +#endif // MARK: - Public diff --git a/GRDB/Record/FetchedRecordsController.swift b/GRDB/Record/FetchedRecordsController.swift index a1c177c28..a1cfa4728 100644 --- a/GRDB/Record/FetchedRecordsController.swift +++ b/GRDB/Record/FetchedRecordsController.swift @@ -1,3 +1,4 @@ +import Foundation #if os(iOS) import UIKit #endif diff --git a/Package.swift b/Package.swift new file mode 100644 index 000000000..28fcc3060 --- /dev/null +++ b/Package.swift @@ -0,0 +1,9 @@ +import PackageDescription + +let package = Package( + name: "GRDB.swift", + dependencies: [ + .Package(url: "https://github.com/groue/SQLiteSDK.git", majorVersion: 0) + ], + exclude: ["GRDB.xcworkspace", "Playgrounds", "SQLCipher", "SQLiteCustom", "Support", "DemoApps", "Tests", "Documentation"] +) From 63b3b4225a36c50d7266a4be01fd62d9921b4d67 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gwendal=20Roue=CC=81?= Date: Tue, 11 Apr 2017 13:22:26 +0200 Subject: [PATCH 2/3] Rename package to GRDB, and rename SQLite module to CSQLite --- GRDB/Core/Configuration.swift | 2 +- GRDB/Core/Database.swift | 2 +- GRDB/Core/DatabaseError.swift | 2 +- GRDB/Core/DatabasePool.swift | 2 +- GRDB/Core/DatabaseReader.swift | 2 +- GRDB/Core/DatabaseValue.swift | 2 +- GRDB/Core/Row.swift | 2 +- GRDB/Core/SchedulingWatchdog.swift | 2 +- GRDB/Core/Statement.swift | 2 +- GRDB/Core/StatementColumnConvertible.swift | 2 +- GRDB/Core/Support/StandardLibrary/StandardLibrary.swift | 2 +- GRDB/Core/Utils.swift | 2 +- Package.swift | 4 ++-- 13 files changed, 14 insertions(+), 14 deletions(-) diff --git a/GRDB/Core/Configuration.swift b/GRDB/Core/Configuration.swift index 00c2d78d1..bb0e78670 100644 --- a/GRDB/Core/Configuration.swift +++ b/GRDB/Core/Configuration.swift @@ -1,7 +1,7 @@ import Foundation #if SWIFT_PACKAGE - import SQLiteSDK + import CSQLite #endif /// Configuration for a DatabaseQueue or DatabasePool. diff --git a/GRDB/Core/Database.swift b/GRDB/Core/Database.swift index 4f9e516b6..46bc1abdb 100644 --- a/GRDB/Core/Database.swift +++ b/GRDB/Core/Database.swift @@ -1,7 +1,7 @@ import Foundation #if SWIFT_PACKAGE - import SQLiteSDK + import CSQLite #endif /// A raw SQLite connection, suitable for the SQLite C API. diff --git a/GRDB/Core/DatabaseError.swift b/GRDB/Core/DatabaseError.swift index 4016de9a1..4c1711c36 100644 --- a/GRDB/Core/DatabaseError.swift +++ b/GRDB/Core/DatabaseError.swift @@ -1,7 +1,7 @@ import Foundation #if SWIFT_PACKAGE - import SQLiteSDK + import CSQLite #endif public struct ResultCode : RawRepresentable, Equatable, CustomStringConvertible { diff --git a/GRDB/Core/DatabasePool.swift b/GRDB/Core/DatabasePool.swift index d09ecb398..b0d2bf3df 100644 --- a/GRDB/Core/DatabasePool.swift +++ b/GRDB/Core/DatabasePool.swift @@ -5,7 +5,7 @@ import Foundation #endif #if SWIFT_PACKAGE - import SQLiteSDK + import CSQLite #endif /// A DatabasePool grants concurrent accesses to an SQLite database. diff --git a/GRDB/Core/DatabaseReader.swift b/GRDB/Core/DatabaseReader.swift index db08e76c5..cf12d8827 100644 --- a/GRDB/Core/DatabaseReader.swift +++ b/GRDB/Core/DatabaseReader.swift @@ -1,5 +1,5 @@ #if SWIFT_PACKAGE - import SQLiteSDK + import CSQLite #endif /// The protocol for all types that can fetch values from a database. diff --git a/GRDB/Core/DatabaseValue.swift b/GRDB/Core/DatabaseValue.swift index 6c24194f1..ef6c779ca 100644 --- a/GRDB/Core/DatabaseValue.swift +++ b/GRDB/Core/DatabaseValue.swift @@ -1,7 +1,7 @@ import Foundation #if SWIFT_PACKAGE - import SQLiteSDK + import CSQLite #endif // MARK: - DatabaseValue diff --git a/GRDB/Core/Row.swift b/GRDB/Core/Row.swift index 4132bb2a1..d772d832a 100644 --- a/GRDB/Core/Row.swift +++ b/GRDB/Core/Row.swift @@ -1,7 +1,7 @@ import Foundation #if SWIFT_PACKAGE - import SQLiteSDK + import CSQLite #endif /// A database row. diff --git a/GRDB/Core/SchedulingWatchdog.swift b/GRDB/Core/SchedulingWatchdog.swift index f67241641..c83bcf326 100644 --- a/GRDB/Core/SchedulingWatchdog.swift +++ b/GRDB/Core/SchedulingWatchdog.swift @@ -1,7 +1,7 @@ import Dispatch #if SWIFT_PACKAGE - import SQLiteSDK + import CSQLite #endif /// SchedulingWatchdog makes sure that databases connections are used on correct diff --git a/GRDB/Core/Statement.swift b/GRDB/Core/Statement.swift index 6a751741f..379e166e3 100644 --- a/GRDB/Core/Statement.swift +++ b/GRDB/Core/Statement.swift @@ -1,7 +1,7 @@ import Foundation #if SWIFT_PACKAGE - import SQLiteSDK + import CSQLite #endif /// A raw SQLite statement, suitable for the SQLite C API. diff --git a/GRDB/Core/StatementColumnConvertible.swift b/GRDB/Core/StatementColumnConvertible.swift index 20666725f..1bc96dafc 100644 --- a/GRDB/Core/StatementColumnConvertible.swift +++ b/GRDB/Core/StatementColumnConvertible.swift @@ -1,5 +1,5 @@ #if SWIFT_PACKAGE - import SQLiteSDK + import CSQLite #endif /// When a type adopts both DatabaseValueConvertible and diff --git a/GRDB/Core/Support/StandardLibrary/StandardLibrary.swift b/GRDB/Core/Support/StandardLibrary/StandardLibrary.swift index 01bc1c2bc..12ab7e443 100644 --- a/GRDB/Core/Support/StandardLibrary/StandardLibrary.swift +++ b/GRDB/Core/Support/StandardLibrary/StandardLibrary.swift @@ -1,5 +1,5 @@ #if SWIFT_PACKAGE - import SQLiteSDK + import CSQLite #endif // MARK: - Value Types diff --git a/GRDB/Core/Utils.swift b/GRDB/Core/Utils.swift index bf13ecbb5..24cdea227 100644 --- a/GRDB/Core/Utils.swift +++ b/GRDB/Core/Utils.swift @@ -1,7 +1,7 @@ import Foundation #if SWIFT_PACKAGE - import SQLiteSDK + import CSQLite #endif // MARK: - Public diff --git a/Package.swift b/Package.swift index 28fcc3060..2e1482232 100644 --- a/Package.swift +++ b/Package.swift @@ -1,9 +1,9 @@ import PackageDescription let package = Package( - name: "GRDB.swift", + name: "GRDB", dependencies: [ - .Package(url: "https://github.com/groue/SQLiteSDK.git", majorVersion: 0) + .Package(url: "https://github.com/groue/CSQLite.git", majorVersion: 0) ], exclude: ["GRDB.xcworkspace", "Playgrounds", "SQLCipher", "SQLiteCustom", "Support", "DemoApps", "Tests", "Documentation"] ) From 6c2b421b578c88a0d3e22cea243b5c54916d44b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gwendal=20Roue=CC=81?= Date: Tue, 11 Apr 2017 13:33:36 +0200 Subject: [PATCH 3/3] Add test_framework_SPM target to Makefile --- Makefile | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 1d5e9c6b6..44c871382 100644 --- a/Makefile +++ b/Makefile @@ -38,7 +38,7 @@ MAX_IOS_DESTINATION = "platform=iOS Simulator,name=iPhone 7,OS=10.3" # We test framework test suites, and if GRBD can be installed in an application: test: test_framework test_install -test_framework: test_framework_GRDB test_framework_GRDBCustom test_framework_GRDBCipher +test_framework: test_framework_GRDB test_framework_GRDBCustom test_framework_GRDBCipher test_framework_SPM test_framework_GRDB: test_framework_GRDBOSX test_framework_GRDBWatchOS test_framework_GRDBiOS test_framework_GRDBCustom: test_framework_GRDBCustomSQLiteOSX test_framework_GRDBCustomSQLiteiOS test_framework_GRDBCipher: test_framework_GRDBCipherOSX test_framework_GRDBCipheriOS @@ -117,6 +117,10 @@ test_framework_GRDBCipheriOS_minTarget: SQLCipher -destination $(MIN_IOS_DESTINATION) \ $(TEST_ACTIONS) +test_framework_SPM: + swift package clean + swift build + test_install_manual: xcodebuild \ -project DemoApps/GRDBDemoiOS/GRDBDemoiOS.xcodeproj \