Skip to content

Commit 628a289

Browse files
committed
Use an embedded module instead of a bridging header
I'd taken advantage of the fact that renaming the umbrella header disabled the framework bridging header check, which is a bug and could stop working at any moment. Instead, let's embed a `sqlite3` framework module that points to the appropriate system header. As soon as the system provides an appropriate `sqlite3` module at the system level, we merely have to delete this internal dependency. Signed-off-by: Stephen Celis <[email protected]>
1 parent a06a550 commit 628a289

13 files changed

+300
-83
lines changed

Documentation/Index.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,9 +102,12 @@ It’s possible to use SQLite.swift in a target that doesn’t support framework
102102

103103
2. Copy the SQLite.swift source files (from its **SQLite** directory) into your Xcode project.
104104

105-
3. Add the following line to your project’s [bridging header](https://developer.apple.com/library/prerelease/ios/documentation/Swift/Conceptual/BuildingCocoaApps/MixandMatch.html#//apple_ref/doc/uid/TP40014216-CH10-XID_79) (a file usually in the form of `$(TARGET_NAME)-Bridging-Header.h`.
105+
3. Remove `import sqlite3` (and `@import sqlite3;`) from the SQLite.swift source files that call it.
106+
107+
4. Add the following lines to your project’s [bridging header](https://developer.apple.com/library/prerelease/ios/documentation/Swift/Conceptual/BuildingCocoaApps/MixandMatch.html#//apple_ref/doc/uid/TP40014216-CH10-XID_79) (a file usually in the form of `$(TARGET_NAME)-Bridging-Header.h`.
106108

107109
``` swift
110+
#import <sqlite3.h>
108111
#import "SQLite-Bridging.h"
109112
```
110113

SQLite.xcodeproj/project.pbxproj

Lines changed: 245 additions & 74 deletions
Large diffs are not rendered by default.

SQLite/Database.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
// THE SOFTWARE.
2323
//
2424

25-
import Foundation
25+
import sqlite3
2626

2727
/// A connection (handle) to a SQLite database.
2828
public final class Database {

SQLite/SQLite-Bridging-Header.h

Lines changed: 0 additions & 1 deletion
This file was deleted.

SQLite/SQLite-Bridging.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,9 @@
2222
// THE SOFTWARE.
2323
//
2424

25+
@import sqlite3;
2526
@import Foundation;
2627

27-
#include <sqlite3.h>
28-
29-
#include "fts3_tokenizer.h"
30-
3128
typedef int (^SQLiteBusyHandlerCallback)(int times);
3229
int SQLiteBusyHandler(sqlite3 * handle, SQLiteBusyHandlerCallback callback);
3330

SQLite/SQLite-Bridging.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@
2222
// THE SOFTWARE.
2323
//
2424

25-
#include "SQLite-Bridging.h"
25+
#import "SQLite-Bridging.h"
2626

27-
@import Foundation;
27+
#import "fts3_tokenizer.h"
2828

2929
static int _SQLiteBusyHandler(void * context, int tries) {
3030
return ((__bridge SQLiteBusyHandlerCallback)context)(tries);

SQLite/SQLite.swift.h renamed to SQLite/SQLite.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,5 @@ FOUNDATION_EXPORT double SQLite_VersionNumber;
55

66
//! Project version string for SQLite.
77
FOUNDATION_EXPORT const unsigned char SQLite_VersionString[];
8+
9+
#import <SQLite/SQLite-Bridging.h>

SQLite/Statement.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222
// THE SOFTWARE.
2323
//
2424

25+
import sqlite3
26+
2527
internal let SQLITE_STATIC = sqlite3_destructor_type(COpaquePointer(bitPattern: 0))
2628
internal let SQLITE_TRANSIENT = sqlite3_destructor_type(COpaquePointer(bitPattern: -1))
2729

sqlite3/Info.plist

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<key>CFBundleDevelopmentRegion</key>
6+
<string>en</string>
7+
<key>CFBundleExecutable</key>
8+
<string>$(EXECUTABLE_NAME)</string>
9+
<key>CFBundleIdentifier</key>
10+
<string>com.stephencelis.$(PRODUCT_NAME:rfc1034identifier)</string>
11+
<key>CFBundleInfoDictionaryVersion</key>
12+
<string>6.0</string>
13+
<key>CFBundleName</key>
14+
<string>$(PRODUCT_NAME)</string>
15+
<key>CFBundlePackageType</key>
16+
<string>FMWK</string>
17+
<key>CFBundleShortVersionString</key>
18+
<string>1.0</string>
19+
<key>CFBundleSignature</key>
20+
<string>????</string>
21+
<key>CFBundleVersion</key>
22+
<string>$(CURRENT_PROJECT_VERSION)</string>
23+
<key>NSPrincipalClass</key>
24+
<string></string>
25+
</dict>
26+
</plist>

sqlite3/iphoneos.modulemap

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
module sqlite3 [system] {
2+
header "/Applications/Xcode-beta.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/usr/include/sqlite3.h"
3+
export *
4+
}

sqlite3/iphonesimulator.modulemap

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
module sqlite3 [system] {
2+
header "/Applications/Xcode-beta.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk/usr/include/sqlite3.h"
3+
export *
4+
}

sqlite3/macosx.modulemap

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
module sqlite3 [system] {
2+
header "/usr/include/sqlite3.h"
3+
export *
4+
}

sqlite3/sqlite3.xcconfig

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#include "../SQLite/SQLite.xcconfig"
2+
3+
MODULEMAP_FILE[sdk=iphoneos*] = $(SRCROOT)/sqlite3/iphoneos.modulemap
4+
MODULEMAP_FILE[sdk=iphonesimulator*] = $(SRCROOT)/sqlite3/iphonesimulator.modulemap
5+
MODULEMAP_FILE[sdk=macosx*] = $(SRCROOT)/sqlite3/macosx.modulemap

0 commit comments

Comments
 (0)