diff --git a/.travis.yml b/.travis.yml index b484ec2f94..d36ca19811 100644 --- a/.travis.yml +++ b/.travis.yml @@ -183,8 +183,16 @@ jobs: gemfile: .ci/gemfiles/Gemfile.travis osx_image: xcode11 env: - - TID=SPM - script: make test_install_SPM + - TID=SPM Package + script: make test_install_SPM_Package + + # SPM Install + - stage: Test Installation Xcode 11 + gemfile: .ci/gemfiles/Gemfile.travis + osx_image: xcode11 + env: + - TID=SPM Package in Xcode Project + script: make test_install_SPM_Project ########################################### ## Test GRDB Xcode 10.3 diff --git a/Makefile b/Makefile index 8b6138f85e..6e9f2f9325 100644 --- a/Makefile +++ b/Makefile @@ -324,17 +324,27 @@ test_install_manual: clean build \ $(XCPRETTY) -test_install_SPM: - cd Tests/SPM && \ +test_install_SPM: test_install_SPM_Package test_install_SPM_Project + +test_install_SPM_Package: + cd Tests/SPM/PlainPackage && \ ( if [ -a .build ] && [ -a Package.resolved ]; then $(SWIFT) package reset; fi ) && \ rm -rf Packages/GRDB && \ $(SWIFT) package edit GRDB --revision master && \ rm -rf Packages/GRDB && \ - ln -s ../../.. Packages/GRDB && \ + ln -s ../../../.. Packages/GRDB && \ $(SWIFT) build && \ ./.build/debug/SPM && \ $(SWIFT) package unedit --force GRDB +test_install_SPM_Project: + $(XCODEBUILD) \ + -project Tests/SPM/PlainProject/Plain.xcodeproj \ + -scheme Plain \ + -configuration Release \ + clean build \ + $(XCPRETTY) + test_install_GRDB_CocoaPods: test_install_GRDB_CocoaPods_framework test_install_GRDB_CocoaPods_static test_install_GRDB_CocoaPods_framework: diff --git a/Package.swift b/Package.swift index a7589da8dc..8761bb1962 100644 --- a/Package.swift +++ b/Package.swift @@ -9,10 +9,15 @@ let package = Package( .library(name: "GRDB", targets: ["GRDB"]), ], dependencies: [ - .package(url: "https://github.com/groue/CSQLite.git", from: "0.2.0"), ], targets: [ - .target(name: "GRDB", path: "GRDB"), + .systemLibrary( + name: "sqlite3", + providers: [.apt(["libsqlite3-dev"])]), + .target( + name: "GRDB", + dependencies: ["sqlite3"], + path: "GRDB"), .testTarget( name: "GRDBTests", dependencies: ["GRDB"], @@ -21,7 +26,7 @@ let package = Package( "CocoaPods", "Crash", "Performance", - "SPM" + "SPM", ]) ], swiftLanguageVersions: [.v4_2, .version("5")] diff --git a/Sources/sqlite3/module.modulemap b/Sources/sqlite3/module.modulemap new file mode 100644 index 0000000000..3631b172b1 --- /dev/null +++ b/Sources/sqlite3/module.modulemap @@ -0,0 +1,5 @@ +module CSQLite { + header "shim.h" + link "sqlite3" + export * +} diff --git a/Sources/sqlite3/shim.h b/Sources/sqlite3/shim.h new file mode 100644 index 0000000000..d018d2fcec --- /dev/null +++ b/Sources/sqlite3/shim.h @@ -0,0 +1,9 @@ +#include + +typedef void(*errorLogCallback)(void *pArg, int iErrCode, const char *zMsg); + +// Wrapper around sqlite3_config(SQLITE_CONFIG_LOG, ...) which is a variadic +// function that can't be used from Swift. +static inline void registerErrorLogCallback(errorLogCallback callback) { + sqlite3_config(SQLITE_CONFIG_LOG, callback, 0); +} diff --git a/Tests/SPM/Package.swift b/Tests/SPM/PlainPackage/Package.swift similarity index 100% rename from Tests/SPM/Package.swift rename to Tests/SPM/PlainPackage/Package.swift diff --git a/Tests/SPM/Sources/SPM/main.swift b/Tests/SPM/PlainPackage/Sources/SPM/main.swift similarity index 100% rename from Tests/SPM/Sources/SPM/main.swift rename to Tests/SPM/PlainPackage/Sources/SPM/main.swift diff --git a/Tests/SPM/PlainProject/Plain.xcodeproj/project.pbxproj b/Tests/SPM/PlainProject/Plain.xcodeproj/project.pbxproj new file mode 100644 index 0000000000..5b75e5ba60 --- /dev/null +++ b/Tests/SPM/PlainProject/Plain.xcodeproj/project.pbxproj @@ -0,0 +1,320 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 52; + objects = { + +/* Begin PBXBuildFile section */ + 56C0D3B42344F90100DD47F3 /* main.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56C0D3B32344F90100DD47F3 /* main.swift */; }; + 56C0D3BC2344F96900DD47F3 /* GRDB in Frameworks */ = {isa = PBXBuildFile; productRef = 56C0D3BB2344F96900DD47F3 /* GRDB */; }; +/* End PBXBuildFile section */ + +/* Begin PBXCopyFilesBuildPhase section */ + 56C0D3AE2344F90100DD47F3 /* CopyFiles */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = /usr/share/man/man1/; + dstSubfolderSpec = 0; + files = ( + ); + runOnlyForDeploymentPostprocessing = 1; + }; +/* End PBXCopyFilesBuildPhase section */ + +/* Begin PBXFileReference section */ + 56C0D3B02344F90100DD47F3 /* Plain */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = Plain; sourceTree = BUILT_PRODUCTS_DIR; }; + 56C0D3B32344F90100DD47F3 /* main.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = main.swift; sourceTree = ""; }; + 56C0D3BD2344F97C00DD47F3 /* GRDB.swift */ = {isa = PBXFileReference; lastKnownFileType = folder; name = GRDB.swift; path = ../../..; sourceTree = ""; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + 56C0D3AD2344F90100DD47F3 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 56C0D3BC2344F96900DD47F3 /* GRDB in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 56C0D3A72344F90100DD47F3 = { + isa = PBXGroup; + children = ( + 56C0D3B22344F90100DD47F3 /* Plain */, + 56C0D3BD2344F97C00DD47F3 /* GRDB.swift */, + 56C0D3B12344F90100DD47F3 /* Products */, + ); + sourceTree = ""; + }; + 56C0D3B12344F90100DD47F3 /* Products */ = { + isa = PBXGroup; + children = ( + 56C0D3B02344F90100DD47F3 /* Plain */, + ); + name = Products; + sourceTree = ""; + }; + 56C0D3B22344F90100DD47F3 /* Plain */ = { + isa = PBXGroup; + children = ( + 56C0D3B32344F90100DD47F3 /* main.swift */, + ); + path = Plain; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + 56C0D3AF2344F90100DD47F3 /* Plain */ = { + isa = PBXNativeTarget; + buildConfigurationList = 56C0D3B72344F90100DD47F3 /* Build configuration list for PBXNativeTarget "Plain" */; + buildPhases = ( + 56C0D3AC2344F90100DD47F3 /* Sources */, + 56C0D3AD2344F90100DD47F3 /* Frameworks */, + 56C0D3AE2344F90100DD47F3 /* CopyFiles */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = Plain; + packageProductDependencies = ( + 56C0D3BB2344F96900DD47F3 /* GRDB */, + ); + productName = Plain; + productReference = 56C0D3B02344F90100DD47F3 /* Plain */; + productType = "com.apple.product-type.tool"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + 56C0D3A82344F90100DD47F3 /* Project object */ = { + isa = PBXProject; + attributes = { + LastSwiftUpdateCheck = 1110; + LastUpgradeCheck = 1110; + ORGANIZATIONNAME = "Gwendal Roué"; + TargetAttributes = { + 56C0D3AF2344F90100DD47F3 = { + CreatedOnToolsVersion = 11.1; + }; + }; + }; + buildConfigurationList = 56C0D3AB2344F90100DD47F3 /* Build configuration list for PBXProject "Plain" */; + compatibilityVersion = "Xcode 9.3"; + developmentRegion = en; + hasScannedForEncodings = 0; + knownRegions = ( + en, + Base, + ); + mainGroup = 56C0D3A72344F90100DD47F3; + packageReferences = ( + 56C0D3BA2344F96900DD47F3 /* XCRemoteSwiftPackageReference "GRDB" */, + ); + productRefGroup = 56C0D3B12344F90100DD47F3 /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + 56C0D3AF2344F90100DD47F3 /* Plain */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXSourcesBuildPhase section */ + 56C0D3AC2344F90100DD47F3 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 56C0D3B42344F90100DD47F3 /* main.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin XCBuildConfiguration section */ + 56C0D3B52344F90100DD47F3 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_ENABLE_OBJC_WEAK = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = dwarf; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_DYNAMIC_NO_PIC = NO; + GCC_NO_COMMON_BLOCKS = YES; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + MACOSX_DEPLOYMENT_TARGET = 10.14; + MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; + MTL_FAST_MATH = YES; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = macosx; + SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; + SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + }; + name = Debug; + }; + 56C0D3B62344F90100DD47F3 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_ENABLE_OBJC_WEAK = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + MACOSX_DEPLOYMENT_TARGET = 10.14; + MTL_ENABLE_DEBUG_INFO = NO; + MTL_FAST_MATH = YES; + SDKROOT = macosx; + SWIFT_COMPILATION_MODE = wholemodule; + SWIFT_OPTIMIZATION_LEVEL = "-O"; + }; + name = Release; + }; + 56C0D3B82344F90100DD47F3 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + CODE_SIGN_STYLE = Manual; + DEVELOPMENT_TEAM = ""; + ENABLE_HARDENED_RUNTIME = YES; + PRODUCT_NAME = "$(TARGET_NAME)"; + PROVISIONING_PROFILE_SPECIFIER = ""; + SWIFT_VERSION = 5.0; + }; + name = Debug; + }; + 56C0D3B92344F90100DD47F3 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + CODE_SIGN_STYLE = Manual; + DEVELOPMENT_TEAM = ""; + ENABLE_HARDENED_RUNTIME = YES; + PRODUCT_NAME = "$(TARGET_NAME)"; + PROVISIONING_PROFILE_SPECIFIER = ""; + SWIFT_VERSION = 5.0; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + 56C0D3AB2344F90100DD47F3 /* Build configuration list for PBXProject "Plain" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 56C0D3B52344F90100DD47F3 /* Debug */, + 56C0D3B62344F90100DD47F3 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 56C0D3B72344F90100DD47F3 /* Build configuration list for PBXNativeTarget "Plain" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 56C0D3B82344F90100DD47F3 /* Debug */, + 56C0D3B92344F90100DD47F3 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + +/* Begin XCRemoteSwiftPackageReference section */ + 56C0D3BA2344F96900DD47F3 /* XCRemoteSwiftPackageReference "GRDB" */ = { + isa = XCRemoteSwiftPackageReference; + repositoryURL = "https://github.com/groue/GRDB.swift"; + requirement = { + kind = upToNextMajorVersion; + minimumVersion = 4.4.0; + }; + }; +/* End XCRemoteSwiftPackageReference section */ + +/* Begin XCSwiftPackageProductDependency section */ + 56C0D3BB2344F96900DD47F3 /* GRDB */ = { + isa = XCSwiftPackageProductDependency; + package = 56C0D3BA2344F96900DD47F3 /* XCRemoteSwiftPackageReference "GRDB" */; + productName = GRDB; + }; +/* End XCSwiftPackageProductDependency section */ + }; + rootObject = 56C0D3A82344F90100DD47F3 /* Project object */; +} diff --git a/Tests/SPM/PlainProject/Plain.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/Tests/SPM/PlainProject/Plain.xcodeproj/project.xcworkspace/contents.xcworkspacedata new file mode 100644 index 0000000000..6f56eb538d --- /dev/null +++ b/Tests/SPM/PlainProject/Plain.xcodeproj/project.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/Tests/SPM/PlainProject/Plain.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/Tests/SPM/PlainProject/Plain.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 0000000000..18d981003d --- /dev/null +++ b/Tests/SPM/PlainProject/Plain.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/Tests/SPM/PlainProject/Plain/main.swift b/Tests/SPM/PlainProject/Plain/main.swift new file mode 100644 index 0000000000..3c6ac9e860 --- /dev/null +++ b/Tests/SPM/PlainProject/Plain/main.swift @@ -0,0 +1,3 @@ +import GRDB + +try! print(DatabaseQueue().read { try String.fetchOne($0, sql: "SELECT 'Hello world!'")! })