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 d5f53e62a..49da5f1d0 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 7b8525e7e..c22e962b9 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 57ad63e9e..4c1711c36 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 45c82e5cb..b0d2bf3df 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 a85b78f58..cf12d8827 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 4ed0a38f1..15c0c3843 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 b113e9677..a19d8d023 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 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..c83bcf326 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 180d5abf8..379e166e3 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 bb9e89c43..1bc96dafc 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 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..12ab7e443 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 0f538e3ad..24cdea227 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 19c1a3892..101b1ce5b 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 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 \ diff --git a/Package.swift b/Package.swift new file mode 100644 index 000000000..2e1482232 --- /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"] +)