Description
Xcode fails when building a Swift Package Manager-generate project that has SQLite.swift as a dependency.
Steps to reproduce
- Create a new SwiftPM command-line project.
$ mkdir test-sqlite
$ cd test-sqlite
$ swift package init --type=executable
- Edit the Package.swift to add a SQLite.swift dependency
// swift-tools-version:5.0
import PackageDescription
let package = Package(
name: "test-sqlite-swift",
dependencies: [
.package(url: "https://github.com/stephencelis/SQLite.swift.git", from: "0.12.0")
],
targets: [
.target(name: "test-sqlite", dependencies: ["SQLite"]),
.testTarget(name: "test-sqliteTests", dependencies: ["test-sqlite"]),
]
)
- Generate xcode project.
$ swift package generate-xcodeproj
- Open this project in Xcode and press build. I get a lot of errors of the following type while building the SQLiteObjc target:
error: use of '@import' when modules are disabled
Complete output of xcodebuild
:
note: Using new build system note: Planning build note: Using build description from disk CompileC /Users/simon/code/test-sqlite/build/test-sqlite-swift.build/Release/SQLiteObjc.build/Objects-normal/x86_64/SQLite-Bridging.o /Users/simon/code/test-sqlite/.build/checkouts/SQLite.swift/Sources/SQLiteObjc/SQLite-Bridging.m normal x86_64 objective-c com.apple.compilers.llvm.clang.1_0.compiler (in target: SQLiteObjc) cd /Users/simon/code/test-sqlite export LANG=en_US.US-ASCII /Applications/Xcode-10.2.1.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -x objective-c -arch x86_64 -fmessage-length=0 -fdiagnostics-show-note-include-stack -fmacro-backtrace-limit=0 -fobjc-arc -Wno-trigraphs -fpascal-strings -Os -Wno-missing-field-initializers -Wno-missing-prototypes -Wno-return-type -Wno-implicit-atomic-properties -Wno-objc-interface-ivars -Wno-arc-repeated-use-of-weak -Wno-missing-braces -Wparentheses -Wswitch -Wno-unused-function -Wno-unused-label -Wno-unused-parameter -Wno-unused-variable -Wunused-value -Wno-empty-body -Wno-uninitialized -Wno-unknown-pragmas -Wno-shadow -Wno-four-char-constants -Wno-conversion -Wno-constant-conversion -Wno-int-conversion -Wno-bool-conversion -Wno-enum-conversion -Wno-float-conversion -Wno-non-literal-null-conversion -Wno-objc-literal-conversion -Wno-shorten-64-to-32 -Wpointer-sign -Wno-newline-eof -Wno-selector -Wno-strict-selector-match -Wno-undeclared-selector -Wno-deprecated-implementations -DSWIFT_PACKAGE=1 -DOBJC_OLD_DISPATCH_PROTOTYPES=1 -isysroot /Applications/Xcode-10.2.1.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk -fasm-blocks -fstrict-aliasing -Wprotocol -Wdeprecated-declarations -mmacosx-version-min=10.10 -g -Wno-sign-conversion -Wno-infinite-recursion -Wno-comma -Wno-block-capture-autoreleasing -Wno-strict-prototypes -Wno-semicolon-before-method-body -I/Users/simon/code/test-sqlite/build/Release/include -I/Users/simon/code/test-sqlite/.build/checkouts/SQLite.swift/Sources/SQLiteObjc/include -I/Users/simon/code/test-sqlite/build/test-sqlite-swift.build/Release/SQLiteObjc.build/DerivedSources-normal/x86_64 -I/Users/simon/code/test-sqlite/build/test-sqlite-swift.build/Release/SQLiteObjc.build/DerivedSources/x86_64 -I/Users/simon/code/test-sqlite/build/test-sqlite-swift.build/Release/SQLiteObjc.build/DerivedSources -F/Users/simon/code/test-sqlite/build/Release -F/Applications/Xcode-10.2.1.app/Contents/Developer/Platforms/MacOSX.platform/Developer/Library/Frameworks -MMD -MT dependencies -MF /Users/simon/code/test-sqlite/build/test-sqlite-swift.build/Release/SQLiteObjc.build/Objects-normal/x86_64/SQLite-Bridging.d --serialize-diagnostics /Users/simon/code/test-sqlite/build/test-sqlite-swift.build/Release/SQLiteObjc.build/Objects-normal/x86_64/SQLite-Bridging.dia -c /Users/simon/code/test-sqlite/.build/checkouts/SQLite.swift/Sources/SQLiteObjc/SQLite-Bridging.m -o /Users/simon/code/test-sqlite/build/test-sqlite-swift.build/Release/SQLiteObjc.build/Objects-normal/x86_64/SQLite-Bridging.o In file included from /Users/simon/code/test-sqlite/.build/checkouts/SQLite.swift/Sources/SQLiteObjc/SQLite-Bridging.m:25: /Users/simon/code/test-sqlite/.build/checkouts/SQLite.swift/Sources/SQLiteObjc/include/SQLite-Bridging.h:25:1: error: use of '@import' when modules are disabled @import Foundation; ^ /Users/simon/code/test-sqlite/.build/checkouts/SQLite.swift/Sources/SQLiteObjc/include/SQLite-Bridging.h:26:1: error: use of '@import' when modules are disabled @import SQLite3; ^ /Users/simon/code/test-sqlite/.build/checkouts/SQLite.swift/Sources/SQLiteObjc/include/SQLite-Bridging.h:28:1: error: unknown type name 'NS_ASSUME_NONNULL_BEGIN' NS_ASSUME_NONNULL_BEGIN ^ /Users/simon/code/test-sqlite/.build/checkouts/SQLite.swift/Sources/SQLiteObjc/include/SQLite-Bridging.h:29:1: error: expected identifier or '(' typedef NSString * _Nullable (^_SQLiteTokenizerNextCallback)(const char *input, int *inputOffset, int *inputLength); ^ /Users/simon/code/test-sqlite/.build/checkouts/SQLite.swift/Sources/SQLiteObjc/include/SQLite-Bridging.h:30:30: error: unknown type name 'sqlite3' int _SQLiteRegisterTokenizer(sqlite3 *db, const char *module, const char *tokenizer, _Nullable _SQLiteTokenizerNextCallback callback); ^ /Users/simon/code/test-sqlite/.build/checkouts/SQLite.swift/Sources/SQLiteObjc/include/SQLite-Bridging.h:30:96: error: unknown type name '_SQLiteTokenizerNextCallback' int _SQLiteRegisterTokenizer(sqlite3 *db, const char *module, const char *tokenizer, _Nullable _SQLiteTokenizerNextCallback callback); ^ /Users/simon/code/test-sqlite/.build/checkouts/SQLite.swift/Sources/SQLiteObjc/include/SQLite-Bridging.h:30:38: warning: pointer is missing a nullability type specifier (_Nonnull, _Nullable, or _Null_unspecified) [-Wnullability-completeness] int _SQLiteRegisterTokenizer(sqlite3 *db, const char *module, const char *tokenizer, _Nullable _SQLiteTokenizerNextCallback callback); ^ /Users/simon/code/test-sqlite/.build/checkouts/SQLite.swift/Sources/SQLiteObjc/include/SQLite-Bridging.h:30:38: note: insert '_Nullable' if the pointer may be null int _SQLiteRegisterTokenizer(sqlite3 *db, const char *module, const char *tokenizer, _Nullable _SQLiteTokenizerNextCallback callback); ^ _Nullable /Users/simon/code/test-sqlite/.build/checkouts/SQLite.swift/Sources/SQLiteObjc/include/SQLite-Bridging.h:30:38: note : insert '_Nonnull' if the pointer should never be null int _SQLiteRegisterTokenizer(sqlite3 *db, const char *module, const char *tokenizer, _Nullable _SQLiteTokenizerNextCallback callback); ^ _Nonnull/Users/simon/code/test-sqlite/.build/checkouts/SQLite.swift/Sources/SQLiteObjc/include/SQLite-Bridging.h:30:86:
error: nullability specifier '_Nullable' cannot be applied to non-pointer type 'int'
int _SQLiteRegisterTokenizer(sqlite3 *db, const char *module, const char *tokenizer, _Nullable _SQLiteTokenizerNextCallback callback);
^
/Users/simon/code/test-sqlite/.build/checkouts/SQLite.swift/Sources/SQLiteObjc/include/SQLite-Bridging.h:31:1: error: unknown type name 'NS_ASSUME_NONNULL_END'
NS_ASSUME_NONNULL_END
^
In file included from /Users/simon/code/test-sqlite/.build/checkouts/SQLite.swift/Sources/SQLiteObjc/SQLite-Bridging.m:26:
In file included from
/Users/simon/code/test-sqlite/.build/checkouts/SQLite.swift/Sources/SQLiteObjc/fts3_tokenizer.h:27:
In file included from /Applications/Xcode-10.2.1.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/usr/include/sqlite3.h:35:
/Applications/Xcode-10.2.1.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/10.0.1/include/stdarg.h:30
:1: error
: expected identifier or '('
typedef __builtin_va_list va_list;
^
/Users/simon/code/test-sqlite/.build/checkouts/SQLite.swift/Sources/SQLiteObjc/SQLite-Bridging.m:32:25: error: unknown type name '_SQLiteTokenizerNextCallback'
__unsafe_unretained _SQLiteTokenizerNextCallback callback;
^
/Users/simon/code/test-sqlite/.build/checkouts/SQLite.swift/Sources/SQLiteObjc/SQLite-Bridging.m:32:5: warning:
'objc_ownership' only applies to Objective-C object or block pointer types; type here is 'int' [-Wignored-attributes]
__unsafe_unretained _SQLiteTokenizerNextCallback callback;
^
:334:44: note: expanded from here
#define __unsafe_unretained attribute((objc_ownership(none)))
^
/Users/simon/code/test-sqlite/.build/checkouts/SQLite.swift/Sources/SQLiteObjc/SQLite-Bridging.m:43:8: error: unknown type name 'NSMutableDictionary'
static NSMutableDictionary * __SQLiteTokenizerMap;
^
/Users/simon/code/test-sqlite/.build/checkouts/SQLite.swift/Sources/SQLiteObjc/SQLite-Bridging.m:50:5: warning: implicitly declaring library function 'memset' with type 'void *(void , int, unsigned long)' [-Wimplicit-function-declaration]
memset(tokenizer, 0, sizeof( tokenizer));
^
/Users/simon/code/test-sqlite/.build/checkouts/SQLite.swift/Sources/SQLiteObjc/SQLite-Bridging.m:50:5: note: include the header <string.h> or explicitly provide a declaration for 'memset'
/Users/simon/code/test-sqlite/.build/checkouts/SQLite.swift/Sources/SQLiteObjc/SQLite-Bridging.m:52:5: error: use of undeclared identifier 'NSString'
NSString * key = [NSString stringWithUTF8String:argv[0]];
^
/Users/simon/code/test-sqlite/.build/checkouts/SQLite.swift/Sources/SQLiteObjc/SQLite-Bridging.m:52:16: error
: use of undeclared identifier 'key'
NSString * key = [NSString stringWithUTF8String:argv[0]];
^
/Users/simon/code/test-sqlite/.build/checkouts/SQLite.swift/Sources/SQLiteObjc/SQLite-Bridging.m:52:23: error: use of undeclared identifier 'NSString'
NSString * key = [NSString stringWithUTF8String:argv[0]];
^
/Users/simon/code/test-sqlite/.build/checkouts/SQLite.swift/Sources/SQLiteObjc/SQLite-Bridging.m:99:21: warning: implicitly declaring library function 'strlen' with type 'unsigned long (const char *)' [-Wimplicit-function-declaration]
*pnBytes = (int)strlen(token);
^
/Users/simon/code/test-sqlite/.build/checkouts/SQLite.swift/Sources/SQLiteObjc/SQLite-Bridging.m:99:
21: note: include the header <string.h> or explicitly provide a declaration for 'strlen'
/Users/simon/code/test-sqlite/.build/checkouts/SQLite.swift/Sources/SQLiteObjc/SQLite-Bridging.m:115:96: error: unknown type name '_SQLiteTokenizerNextCallback'
int _SQLiteRegisterTokenizer(sqlite3 *db, const char * moduleName, const char * submoduleName, _SQLiteTokenizerNextCallback callback) {
^
/Users/simon/code/test-sqlite/.build/checkouts/SQLite.swift/Sources/SQLiteObjc/SQLite-Bridging.m:116:12: error: unknown type name 'dispatch_once_t'
static dispatch_once_t onceToken;
^
/Users/simon/code/test-sqlite/.build/checkouts/SQLite.swift/Sources/SQLiteObjc/SQLite-Bridging.m:117:5: warning: implicit declaration of function 'dispatch_once' is invalid in C99 [-Wimplicit-function-declaration]
dispatch_once(&onceToken, ^{
^
/Users/simon/code/test-sqlite/.build/checkouts/SQLite.swift/Sources/SQLiteObjc/SQLite-Bridging.m:118:33: error: use of undeclared identifier 'NSMutableDictionary'
__SQLiteTokenizerMap = [NSMutableDictionary new];
^
5 warnings and 17 errors generated.** BUILD FAILED **
The following build commands failed:
CompileC /Users/simon/code/test-sqlite/build/test-sqlite-swift.build/Release/SQLiteObjc.build/Objects-normal/x86_64/SQLite-Bridging.o /Users/simon/code/test-sqlite/.build/checkouts/SQLite.swift/Sources/SQLiteObjc/SQLite-Bridging.m normal x86_64 objective-c com.apple.compilers.llvm.clang.1_0.compiler
(1 failure)
Build Information
- Xcode version 10.2.1, Swift 5, macOS 10.14.4