From ef3f88f7d02116c95088d7c5dae9a0af42f4dbfc Mon Sep 17 00:00:00 2001 From: Bradley Walters Date: Fri, 15 Nov 2019 09:52:51 -0700 Subject: [PATCH] Fix building with standalone sqlite3 >= 3.30.0 SQLite 3.30.0 changed the definition of SQLITE_DETERMINISTIC: `-#define SQLITE_DETERMINISTIC 0x800` `+#define SQLITE_DETERMINISTIC 0x000000800` Meaning that the (older) system sqlite3 library and the pod have different definitions, even though they're the same value. We've been importing the system sqlite3 module in SQLiteObjc.h even when linking against standalone sqlite. I added a check to SQLiteObjc.h to import the sqlite3 pod when we're using it, instead of always importing the system module. This leads to there being only one definition in scope. --- SQLite.swift.podspec | 3 ++- Sources/SQLiteObjc/include/SQLiteObjc.h | 4 ++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/SQLite.swift.podspec b/SQLite.swift.podspec index 2341cfc4..712ddc36 100644 --- a/SQLite.swift.podspec +++ b/SQLite.swift.podspec @@ -50,7 +50,8 @@ Pod::Spec.new do |s| ss.private_header_files = 'Sources/SQLiteObjc/*.h' ss.xcconfig = { - 'OTHER_SWIFT_FLAGS' => '$(inherited) -DSQLITE_SWIFT_STANDALONE' + 'OTHER_SWIFT_FLAGS' => '$(inherited) -DSQLITE_SWIFT_STANDALONE', + 'GCC_PREPROCESSOR_DEFINITIONS' => '$(inherited) SQLITE_SWIFT_STANDALONE=1' } ss.dependency 'sqlite3' diff --git a/Sources/SQLiteObjc/include/SQLiteObjc.h b/Sources/SQLiteObjc/include/SQLiteObjc.h index f8c2a3b3..e8ba9a7d 100644 --- a/Sources/SQLiteObjc/include/SQLiteObjc.h +++ b/Sources/SQLiteObjc/include/SQLiteObjc.h @@ -23,7 +23,11 @@ // @import Foundation; +#if defined(SQLITE_SWIFT_STANDALONE) +@import sqlite3; +#else @import SQLite3; +#endif NS_ASSUME_NONNULL_BEGIN typedef NSString * _Nullable (^_SQLiteTokenizerNextCallback)(const char *input, int *inputOffset, int *inputLength);