Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1,139 changes: 973 additions & 166 deletions bun.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/content/docs/configuration/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Add the options you want to change to your app's `package.json`. These are the d
}
```

All values are booleans. Rebuild the native app on every platform after changing them. On iOS with the Nitro V1 prerelease, delete `~/Library/Caches/org.swift.swiftpm/manifests` before rebuilding so Swift Package Manager reads the new settings. On macOS and visionOS with Nitro SQLite 10.x, install Pods again before rebuilding.
All values are booleans. Rebuild the native app on every platform after changing them. On iOS with the Nitro V1 prerelease, delete `~/Library/Caches/org.swift.swiftpm/manifests` before rebuilding so Swift Package Manager reads the new settings. On macOS, and on visionOS with Nitro SQLite 10.x, install Pods again before rebuilding.

## Thread safety

Expand Down
32 changes: 25 additions & 7 deletions docs/content/docs/configuration/macos.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,43 @@ title: macOS
description: Installation, database storage, and Apple build options.
---

Use Nitro SQLite 10.x and Nitro Modules 0.37.2 in a CocoaPods-based React Native macOS app. The 10.x SQLite pod declares macOS 10.15, and the app must also meet the minimums of React Native macOS and Xcode. React Native macOS 0.81 and 0.83 both require macOS 14.
React Native macOS has no Swift Package Manager build of React Native yet, so Nitro SQLite builds through CocoaPods on macOS. Use React Native macOS 0.83 or later with Hermes. It requires macOS 14 and the same Xcode as iOS.

The Nitro V1 prerelease requires React Native 0.88 or later. React Native macOS 0.83 lacks JSI APIs that Nitro V1 uses.
CocoaPods support for Nitro V1 is not published yet. It needs a Nitro release with [CocoaPods support](https://github.com/margelo/nitro/pull/2054) and [support for older JSI versions](https://github.com/margelo/nitro/issues/2073), because React Native macOS 0.83 ships the JSI of React Native 0.83. Until then, use Nitro SQLite 10.x with Nitro Modules 0.37.2 on macOS, as described in the [10.4.0 macOS guide](https://github.com/margelo/nitro-sqlite/blob/v10.4.0/docs/content/docs/configuration/macos.mdx).

Install the 10.x packages, then install Pods and rebuild:
Install the packages, then load Nitro's CocoaPods helper in the Podfile and call its hooks:

```ruby title="macos/Podfile"
require Pod::Executable.execute_command('node', ['-p',
'require.resolve("react-native-nitro-modules/cocoapods.rb", { paths: [process.argv[1]] })', __dir__]).strip

target 'MyApp-macOS' do
use_native_modules!
use_nitro_modules!

# use_react_native!(...)

post_install do |installer|
react_native_post_install(installer)
nitro_post_install(installer)
end
end
```

Then install Pods and rebuild:

```sh
npm install react-native-nitro-sqlite@10 react-native-nitro-modules@0.37.2
cd macos && pod install
```

Databases use an app-specific Application Support directory. See [file locations](/docs/guides/database-lifecycle#file-location-and-prepopulated-databases) for the `location` option. Sandboxed apps can access only their permitted containers.

## Apple build options

Use [Configuration](/docs/configuration) for shared `package.json` settings. For system SQLite, environment overrides, and additional compile flags, use the [10.x CocoaPods options](https://github.com/margelo/nitro-sqlite/blob/v10.4.0/docs/content/docs/configuration/ios.mdx#bundled-or-system-sqlite) from `macos`.
The `RNNitroSQLite` pod reads the shared [Configuration](/docs/configuration) settings from `package.json` when you install Pods. It also accepts the environment overrides `NITRO_SQLITE_THREADSAFE` and `NITRO_SQLITE_PERFORMANCE_MODE`. To link Apple's system SQLite instead of the bundled copy, run `NITRO_SQLITE_USE_PHONE_VERSION=1 pod install`.

For vector search, install `react-native-nitro-sqlite-vec@10` and run `NITRO_SQLITE_VEC=1 pod install` from `macos`. Rebuild and follow the [vector search guide](/docs/integrations/vector-search).
For vector search, install `react-native-nitro-sqlite-vec` and run `NITRO_SQLITE_VEC=1 pod install` from `macos`. Rebuild and follow the [vector search guide](/docs/integrations/vector-search).

## Run the example

Use the [example from the 10.4.0 tag](https://github.com/margelo/nitro-sqlite/tree/v10.4.0/example/macos). It requires macOS 14 or later. Install its workspace and Ruby dependencies, then run the `pods:macos` and `macos` scripts. To run Metro separately, use the `start` script and pass `--no-packager` to `macos`. For a release build, pass `--mode Release --no-packager`.
The repository's `example/macos` app requires macOS 14 or later. Install the workspace and Ruby dependencies, then run the `pods:macos` and `macos` scripts from `example`. To run Metro separately, use the `start` script and pass `--no-packager` to `macos`. For a release build, pass `--mode Release --no-packager`. Until Nitro publishes its CocoaPods support, the example applies it through the patches in the repository's `patches` directory.
4 changes: 2 additions & 2 deletions docs/content/docs/guides/encryption.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@ Pass `encryptionKey` to `open()` to use an encrypted database. This requires a n
}
```

On macOS, add the definition to the `RNNitroSQLite` target inside your existing Podfile `post_install` block:
On macOS, add the definition to the `RNNitroSQLiteCxx` target, which compiles SQLite, inside your existing Podfile `post_install` block:

```ruby
installer.pods_project.targets.each do |target|
next unless target.name == 'RNNitroSQLite'
next unless target.name == 'RNNitroSQLiteCxx'

target.build_configurations.each do |config|
definitions = Array(config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] || '$(inherited)')
Expand Down
4 changes: 2 additions & 2 deletions docs/content/docs/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ title: Getting Started
description: Install Nitro SQLite, rebuild your React Native app, and run your first query.
---

Nitro SQLite gives React Native apps a local SQLite database on iOS and Android in the Nitro V1 prerelease. The stable 10.x line also supports macOS and visionOS. Start by installing its native package and Nitro Modules, then open a database with `open()`.
Nitro SQLite gives React Native apps a local SQLite database on iOS, Android and macOS in the Nitro V1 prerelease. The stable 10.x line also supports visionOS. Start by installing its native package and Nitro Modules, then open a database with `open()`.

## 1. Install the packages

Expand All @@ -17,7 +17,7 @@ npm install react-native-nitro-sqlite@nitro-v1 react-native-nitro-modules@1.0.0-

For iOS, follow the [React Native SwiftPM setup](/docs/configuration/ios#set-up-swift-package-manager). If your app uses Expo prebuild, follow the [Expo setup](/docs/configuration/expo#generate-and-rebuild) to generate the Xcode project and set up SwiftPM before building.

Android needs no additional Nitro SQLite configuration for the default setup. For macOS and visionOS, install Nitro SQLite 10.x with Nitro Modules 0.37.2 and reinstall Pods in your platform's native project. The [macOS setup](/docs/configuration/macos) describes the stable macOS example, and the [10.x CocoaPods options](https://github.com/margelo/nitro-sqlite/blob/v10.4.0/docs/content/docs/configuration/ios.mdx) cover Apple build settings for both platforms. Use [Configuration](/docs/configuration) for the shared `package.json` options.
Android needs no additional Nitro SQLite configuration for the default setup. For macOS, follow the [macOS setup](/docs/configuration/macos), which builds Nitro SQLite through CocoaPods. For visionOS, install Nitro SQLite 10.x with Nitro Modules 0.37.2 and reinstall Pods, using the [10.x CocoaPods options](https://github.com/margelo/nitro-sqlite/blob/v10.4.0/docs/content/docs/configuration/ios.mdx) for Apple build settings. Use [Configuration](/docs/configuration) for the shared `package.json` options.

## 3. Rebuild the app

Expand Down
12 changes: 8 additions & 4 deletions example/macos/NitroSQLiteExample.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -205,11 +205,11 @@
);
inputPaths = (
"${PODS_ROOT}/Target Support Files/Pods-NitroSQLiteExample-macOS/Pods-NitroSQLiteExample-macOS-frameworks.sh",
"${PODS_ROOT}/hermes-engine/destroot/Library/Frameworks/macosx/hermes.framework",
"${PODS_ROOT}/hermes-engine/destroot/Library/Frameworks/macosx/hermesvm.framework",
);
name = "[CP] Embed Pods Frameworks";
outputPaths = (
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/hermes.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/hermesvm.framework",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
Expand Down Expand Up @@ -390,7 +390,9 @@
);
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
REACT_NATIVE_PATH = "${PODS_ROOT}/../../../node_modules/react-native-macos-local";
OTHER_CFLAGS = "$(inherited)";
OTHER_CPLUSPLUSFLAGS = "$(inherited)";
REACT_NATIVE_PATH = "${PODS_ROOT}/../node_modules/react-native-macos-local";
SDKROOT = iphoneos;
SWIFT_ACTIVE_COMPILATION_CONDITIONS = "$(inherited) DEBUG";
USE_HERMES = true;
Expand Down Expand Up @@ -445,7 +447,9 @@
"\"$(inherited)\"",
);
MTL_ENABLE_DEBUG_INFO = NO;
REACT_NATIVE_PATH = "${PODS_ROOT}/../../../node_modules/react-native-macos-local";
OTHER_CFLAGS = "$(inherited)";
OTHER_CPLUSPLUSFLAGS = "$(inherited)";
REACT_NATIVE_PATH = "${PODS_ROOT}/../node_modules/react-native-macos-local";
SDKROOT = iphoneos;
USE_HERMES = true;
VALIDATE_PRODUCT = YES;
Expand Down
4 changes: 4 additions & 0 deletions example/macos/Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ ws_dir = ws_dir.parent until
File.exist?("#{ws_dir}/node_modules/react-native-macos-local/scripts/react_native_pods.rb") ||
ws_dir.expand_path.to_s == '/'
require "#{ws_dir}/node_modules/react-native-macos-local/scripts/react_native_pods.rb"
require Pod::Executable.execute_command('node', ['-p',
'require.resolve("react-native-nitro-modules/cocoapods.rb", { paths: [process.argv[1]] })', __dir__]).strip

react_native_macos_path = ws_dir.join('node_modules', 'react-native-macos-local').relative_path_from(Pathname.new(__dir__))

Expand All @@ -20,6 +22,7 @@ prepare_react_native_project!
target 'NitroSQLiteExample-macOS' do
platform :macos, '14.0'
use_native_modules!(['node', File.join(__dir__, 'scripts', 'react-native-macos-config.js')])
use_nitro_modules!

use_react_native!(
:path => react_native_macos_path.to_s,
Expand All @@ -30,5 +33,6 @@ target 'NitroSQLiteExample-macOS' do

post_install do |installer|
react_native_post_install(installer, react_native_macos_path.to_s)
nitro_post_install(installer)
end
end
Loading