diff --git a/.gitignore b/.gitignore index b8832cf506..30109f9139 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 51a1f4478d..bb0e786708 100644 --- a/GRDB/Core/Configuration.swift +++ b/GRDB/Core/Configuration.swift @@ -1,5 +1,9 @@ import Foundation +#if SWIFT_PACKAGE + import CSQLite +#endif + /// Configuration for a DatabaseQueue or DatabasePool. public struct Configuration { diff --git a/GRDB/Core/Database.swift b/GRDB/Core/Database.swift index 25da8827cb..46bc1abdbb 100644 --- a/GRDB/Core/Database.swift +++ b/GRDB/Core/Database.swift @@ -1,5 +1,9 @@ import Foundation +#if SWIFT_PACKAGE + import CSQLite +#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 57ad63e9ee..4c1711c367 100644 --- a/GRDB/Core/DatabaseError.swift +++ b/GRDB/Core/DatabaseError.swift @@ -1,5 +1,9 @@ import Foundation +#if SWIFT_PACKAGE + import CSQLite +#endif + public struct ResultCode : RawRepresentable, Equatable, CustomStringConvertible { public let rawValue: Int32 diff --git a/GRDB/Core/DatabasePool.swift b/GRDB/Core/DatabasePool.swift index 45c82e5cb9..b0d2bf3df0 100644 --- a/GRDB/Core/DatabasePool.swift +++ b/GRDB/Core/DatabasePool.swift @@ -4,6 +4,10 @@ import Foundation import UIKit #endif +#if SWIFT_PACKAGE + import CSQLite +#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 a85b78f587..cf12d88277 100644 --- a/GRDB/Core/DatabaseReader.swift +++ b/GRDB/Core/DatabaseReader.swift @@ -1,3 +1,7 @@ +#if SWIFT_PACKAGE + import CSQLite +#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 92d343b344..ef6c779ca4 100644 --- a/GRDB/Core/DatabaseValue.swift +++ b/GRDB/Core/DatabaseValue.swift @@ -1,5 +1,9 @@ import Foundation +#if SWIFT_PACKAGE + import CSQLite +#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 e9bb2a4ff6..d772d832aa 100644 --- a/GRDB/Core/Row.swift +++ b/GRDB/Core/Row.swift @@ -1,5 +1,9 @@ import Foundation +#if SWIFT_PACKAGE + import CSQLite +#endif + /// A database row. public final class Row { diff --git a/GRDB/Core/RowAdapter.swift b/GRDB/Core/RowAdapter.swift index f1b2b71e00..5188b1152b 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 280efbcbc0..c83bcf326e 100644 --- a/GRDB/Core/SchedulingWatchdog.swift +++ b/GRDB/Core/SchedulingWatchdog.swift @@ -1,3 +1,9 @@ +import Dispatch + +#if SWIFT_PACKAGE + import CSQLite +#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 180d5abf8a..379e166e32 100644 --- a/GRDB/Core/Statement.swift +++ b/GRDB/Core/Statement.swift @@ -1,5 +1,9 @@ import Foundation +#if SWIFT_PACKAGE + import CSQLite +#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 bb9e89c43b..1bc96dafc2 100644 --- a/GRDB/Core/StatementColumnConvertible.swift +++ b/GRDB/Core/StatementColumnConvertible.swift @@ -1,3 +1,7 @@ +#if SWIFT_PACKAGE + import CSQLite +#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 50bd8b47f4..570171b2a7 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 83fae436ce..12ab7e443e 100644 --- a/GRDB/Core/Support/StandardLibrary/StandardLibrary.swift +++ b/GRDB/Core/Support/StandardLibrary/StandardLibrary.swift @@ -1,3 +1,7 @@ +#if SWIFT_PACKAGE + import CSQLite +#endif + // MARK: - Value Types /// Bool adopts DatabaseValueConvertible and StatementColumnConvertible. diff --git a/GRDB/Core/Utils.swift b/GRDB/Core/Utils.swift index 0f538e3ad0..24cdea2277 100644 --- a/GRDB/Core/Utils.swift +++ b/GRDB/Core/Utils.swift @@ -1,5 +1,8 @@ import Foundation +#if SWIFT_PACKAGE + import CSQLite +#endif // MARK: - Public diff --git a/GRDB/Record/FetchedRecordsController.swift b/GRDB/Record/FetchedRecordsController.swift index a1c177c288..a1cfa47282 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/Makefile b/Makefile index 1d5e9c6b6a..44c8713826 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 \ diff --git a/Package.swift b/Package.swift new file mode 100644 index 0000000000..2e1482232a --- /dev/null +++ b/Package.swift @@ -0,0 +1,9 @@ +import PackageDescription + +let package = Package( + name: "GRDB", + dependencies: [ + .Package(url: "https://github.com/groue/CSQLite.git", majorVersion: 0) + ], + exclude: ["GRDB.xcworkspace", "Playgrounds", "SQLCipher", "SQLiteCustom", "Support", "DemoApps", "Tests", "Documentation"] +)