Skip to content

Commit 9db14cb

Browse files
authored
Merge pull request groue#1776 from Jason-Abbott/development
Add custom build instruction for hardened runtime
2 parents 79a41dc + b26f60e commit 9db14cb

File tree

1 file changed

+30
-26
lines changed

1 file changed

+30
-26
lines changed

Documentation/CustomSQLiteBuilds.md

Lines changed: 30 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -12,47 +12,47 @@ GRDB builds SQLite with [swiftlyfalling/SQLiteLib](https://github.com/swiftlyfal
1212
**To install GRDB with a custom SQLite build:**
1313

1414
1. Clone the GRDB git repository, checkout the latest tagged version:
15-
15+
1616
```sh
1717
cd [GRDB directory]
1818
git checkout [latest tag]
1919
git submodule update --init SQLiteCustom/src
2020
```
21-
21+
2222
2. Choose your [extra compilation options](https://www.sqlite.org/compile.html). For example, `SQLITE_ENABLE_FTS5`, `SQLITE_ENABLE_PREUPDATE_HOOK`.
23-
23+
2424
It is recommended that you enable the `SQLITE_ENABLE_SNAPSHOT` option. It allows GRDB to optimize [ValueObservation](https://swiftpackageindex.com/groue/GRDB.swift/documentation/grdb/valueobservation) when you use a [Database Pool](https://swiftpackageindex.com/groue/GRDB.swift/documentation/grdb/databasepool).
2525

2626
3. Create a folder named `GRDBCustomSQLite` somewhere in your project directory.
2727

2828
4. Create four files in the `GRDBCustomSQLite` folder:
2929

3030
- `SQLiteLib-USER.xcconfig`: this file sets the extra SQLite compilation flags.
31-
31+
3232
```xcconfig
3333
// As many -D options as there are custom SQLite compilation options
3434
// Note: there is no space between -D and the option name.
3535
CUSTOM_SQLLIBRARY_CFLAGS = -DSQLITE_ENABLE_SNAPSHOT -DSQLITE_ENABLE_FTS5
3636
```
37-
37+
3838
- `GRDBCustomSQLite-USER.xcconfig`: this file lets GRDB know about extra compilation flags, and enables extra GRDB APIs.
39-
39+
4040
```xcconfig
4141
// As many -D options as there are custom SQLite compilation options
4242
// Note: there is one space between -D and the option name.
4343
CUSTOM_OTHER_SWIFT_FLAGS = -D SQLITE_ENABLE_SNAPSHOT -D SQLITE_ENABLE_FTS5
4444
```
45-
45+
4646
- `GRDBCustomSQLite-USER.h`: this file lets your application know about extra compilation flags.
47-
47+
4848
```c
4949
// As many #define as there are custom SQLite compilation options
5050
#define SQLITE_ENABLE_SNAPSHOT
5151
#define SQLITE_ENABLE_FTS5
5252
```
53-
53+
5454
- `GRDBCustomSQLite-INSTALL.sh`: this file installs the three other files.
55-
55+
5656
```sh
5757
# License: MIT License
5858
# https://github.com/swiftlyfalling/SQLiteLib/blob/master/LICENSE
@@ -61,52 +61,52 @@ GRDB builds SQLite with [swiftlyfalling/SQLiteLib](https://github.com/swiftlyfal
6161
# PROJECT PATHS
6262
# !! MODIFY THESE TO MATCH YOUR PROJECT HIERARCHY !!
6363
#######################################################
64-
64+
6565
# The path to the folder containing GRDBCustom.xcodeproj:
6666
GRDB_SOURCE_PATH="${PROJECT_DIR}/GRDB"
67-
67+
6868
# The path to your custom "SQLiteLib-USER.xcconfig":
6969
SQLITELIB_XCCONFIG_USER_PATH="${PROJECT_DIR}/GRDBCustomSQLite/SQLiteLib-USER.xcconfig"
70-
70+
7171
# The path to your custom "GRDBCustomSQLite-USER.xcconfig":
7272
CUSTOMSQLITE_XCCONFIG_USER_PATH="${PROJECT_DIR}/GRDBCustomSQLite/GRDBCustomSQLite-USER.xcconfig"
73-
73+
7474
# The path to your custom "GRDBCustomSQLite-USER.h":
7575
CUSTOMSQLITE_H_USER_PATH="${PROJECT_DIR}/GRDBCustomSQLite/GRDBCustomSQLite-USER.h"
76-
76+
7777
#######################################################
7878
#
7979
#######################################################
80-
81-
80+
81+
8282
if [ ! -d "$GRDB_SOURCE_PATH" ];
8383
then
8484
echo "error: Path to GRDB source (GRDB_SOURCE_PATH) missing/incorrect: $GRDB_SOURCE_PATH"
8585
exit 1
8686
fi
87-
87+
8888
SyncFileChanges () {
8989
SOURCE=$1
9090
DESTINATIONPATH=$2
9191
DESTINATIONFILENAME=$3
9292
DESTINATION="${DESTINATIONPATH}/${DESTINATIONFILENAME}"
93-
93+
9494
if [ ! -f "$SOURCE" ];
9595
then
9696
echo "error: Source file missing: $SOURCE"
9797
exit 1
9898
fi
99-
99+
100100
rsync -a "$SOURCE" "$DESTINATION"
101101
}
102-
102+
103103
SyncFileChanges $SQLITELIB_XCCONFIG_USER_PATH "${GRDB_SOURCE_PATH}/SQLiteCustom/src" "SQLiteLib-USER.xcconfig"
104104
SyncFileChanges $CUSTOMSQLITE_XCCONFIG_USER_PATH "${GRDB_SOURCE_PATH}/SQLiteCustom" "GRDBCustomSQLite-USER.xcconfig"
105105
SyncFileChanges $CUSTOMSQLITE_H_USER_PATH "${GRDB_SOURCE_PATH}/SQLiteCustom" "GRDBCustomSQLite-USER.h"
106-
106+
107107
echo "Finished syncing"
108108
```
109-
109+
110110
Modify the top of `GRDBCustomSQLite-INSTALL.sh` file so that it contains correct paths.
111111

112112
5. Embed the `GRDBCustom.xcodeproj` project in your own project.
@@ -116,17 +116,21 @@ GRDB builds SQLite with [swiftlyfalling/SQLiteLib](https://github.com/swiftlyfal
116116
7. Add the `GRDBCustom.framework` from the targeted platform to the **Embedded Binaries** section of the **General** tab of your **application target**.
117117

118118
8. Add a Run Script phase for your target in the **Pre-actions** section of the **Build** tab of your **application scheme**:
119-
119+
120120
```sh
121121
source "${PROJECT_DIR}/GRDBCustomSQLite/GRDBCustomSQLite-INSTALL.sh"
122122
```
123-
123+
124124
The path should be the path to your `GRDBCustomSQLite-INSTALL.sh` file.
125-
125+
126126
Select your application target in the "Provide build settings from" menu.
127127

128128
9. Check the "Shared" checkbox of your application scheme (this lets you commit the pre-action in your Version Control System).
129129

130+
10. If you have enabled "Hardened Runtime" for your target (**Build Settings**/**Signing**) then you may need to check **Disable Library Validation** under the **Hardened Runtime** section of the **Signing & Capabilities** tab.
131+
132+
(The build error without this exception is "Library not loaded ... different Team IDs")
133+
130134
Now you can use GRDB with your custom SQLite build:
131135

132136
```swift

0 commit comments

Comments
 (0)