|
1 | 1 | --- |
2 | 2 | title: iOS |
3 | | -description: Database storage, app groups, and CocoaPods overrides. |
| 3 | +description: Database storage, app groups, and Swift Package Manager build options. |
4 | 4 | --- |
5 | 5 |
|
6 | 6 | <span id="rtree-support" /> |
@@ -29,35 +29,38 @@ Enable the App Groups capability for your app and extension, then add the group |
29 | 29 |
|
30 | 30 | The group container takes precedence over the database location setting. An invalid or inaccessible container causes initialization to throw. |
31 | 31 |
|
| 32 | +## Build settings |
| 33 | + |
| 34 | +Swift Package Manager reads the SQLite build settings when it resolves Nitro SQLite's package, and it caches the result. Changed environment variables are picked up automatically, but changes to [`package.json` settings](/docs/configuration) are not. After changing them, delete `~/Library/Caches/org.swift.swiftpm/manifests` and rebuild. |
| 35 | + |
32 | 36 | ## Bundled or system SQLite |
33 | 37 |
|
34 | | -To use system SQLite instead of the bundled library, install Pods with `NITRO_SQLITE_USE_PHONE_VERSION=1`. The shared build settings cannot change system SQLite's capabilities. |
| 38 | +To use system SQLite instead of the bundled library, set `NITRO_SQLITE_USE_PHONE_VERSION=1` in the environment of the command that builds the app, for example `NITRO_SQLITE_USE_PHONE_VERSION=1 npx react-native run-ios`. Builds started from the Xcode app do not read your shell environment. The shared build settings cannot change system SQLite's capabilities. |
35 | 39 |
|
36 | 40 | ## Thread safety and performance mode |
37 | 41 |
|
38 | | -For one Pod installation, `NITRO_SQLITE_THREADSAFE` and `NITRO_SQLITE_PERFORMANCE_MODE` override the corresponding [`package.json` settings](/docs/configuration). Both accept `true`, `false`, `1`, or `0`. |
| 42 | +When set in the environment of the command that builds the app, `NITRO_SQLITE_THREADSAFE` and `NITRO_SQLITE_PERFORMANCE_MODE` override the corresponding [`package.json` settings](/docs/configuration). Both accept `true`, `false`, `1`, or `0`. |
39 | 43 |
|
40 | 44 | ## Additional compile flags |
41 | 45 |
|
42 | | -To enable FTS5 full-text search, add this inside your existing `post_install` block in `ios/Podfile`: |
| 46 | +Use `iosSqliteFlags` in your app's `package.json` for additional SQLite features or to override individual build defaults. For example, to enable FTS5 full-text search: |
43 | 47 |
|
44 | | -```ruby |
45 | | -installer.pods_project.targets.each do |target| |
46 | | - next unless target.name == 'RNNitroSQLite' |
47 | | - |
48 | | - target.build_configurations.each do |config| |
49 | | - definitions = Array(config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] || '$(inherited)') |
50 | | - config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] = definitions + ['SQLITE_ENABLE_FTS5=1'] |
51 | | - end |
52 | | -end |
| 48 | +```json |
| 49 | +{ |
| 50 | + "nitroSQLite": { |
| 51 | + "iosSqliteFlags": "-DSQLITE_ENABLE_FTS5=1" |
| 52 | + } |
| 53 | +} |
53 | 54 | ``` |
54 | 55 |
|
| 56 | +The value accepts only `-DNAME` and `-DNAME=VALUE` definitions, separated by spaces. Custom definitions take precedence over the defaults from your other `package.json` settings. |
| 57 | + |
55 | 58 | ## Vector search |
56 | 59 |
|
57 | | -Install `react-native-nitro-sqlite-vec`, then run: |
| 60 | +Install `react-native-nitro-sqlite-vec`, then refresh the Swift packages from your app directory: |
58 | 61 |
|
59 | 62 | ```sh |
60 | | -NITRO_SQLITE_VEC=1 npx pod-install |
| 63 | +npx react-native spm |
61 | 64 | ``` |
62 | 65 |
|
63 | 66 | Rebuild and follow the [vector search guide](/docs/integrations/vector-search). For SEE build settings, see [encryption](/docs/guides/encryption). |
0 commit comments