feat(react-native): Expo module for on-device Moss (#432)#473
feat(react-native): Expo module for on-device Moss (#432)#473samanyugoyal2010 wants to merge 2 commits into
Conversation
Introduce @moss-dev/moss-react-native under sdks/react-native with an Expo Modules SharedObject wrapping Moss.xcframework on iOS, an Android stub pointing at usemoss#411, a config plugin, and a usage example. Co-authored-by: Cursor <cursoragent@cursor.com>
Raise the iOS deployment target to 16.4, wire MossC module/search paths and system frameworks, and exclude x86_64 simulator so prebuild + link succeed on Apple Silicon. Co-authored-by: Cursor <cursoragent@cursor.com>
|
@cubic.dev |
@samanyugoyal2010 I can't start this review because you've reached your trial's review limit. Trial plans have lower review limits than paid plans. Upgrade now to resume reviews. To help optimise your usage, you can tune cubic to get the most out of your usage limits:
|
| # System frameworks used by libmoss (see examples/c + Swift SDK) | ||
| s.frameworks = 'Security', 'SystemConfiguration', 'UIKit' | ||
|
|
||
| s.prepare_command = <<-CMD |
There was a problem hiding this comment.
BLOCKING ```ruby
s.prepare_command = <<-CMD
bash "#{dir}/scripts/download-moss-xcframework.sh"
CMD
s.vendored_frameworks = 'Frameworks/Moss.xcframework'
Expo/React Native autolinking installs this pod from `node_modules` as a local `:path` pod, and CocoaPods does not run `prepare_command` for local path pods. Since the npm package excludes `ios/Frameworks`, `Frameworks/Moss.xcframework` will be missing during normal `pod install`/build. Move the download to a hook that runs before CocoaPods resolves the local pod, such as the Expo config plugin or npm `postinstall`, or ship the xcframework in the package.
| guard !closed, let handle else { | ||
| throw Self.mossError(code: -1, message: "MossClient already closed") | ||
| } | ||
| return handle |
There was a problem hiding this comment.
BLOCKING ```swift
private func borrow() throws -> OpaquePointer {
...
return handle
}
`borrow()` releases the lock before each async native method calls into `moss_client_*`, so `client.close()` can concurrently free the same handle while an operation is still using it. This is a use-after-free risk and may also race shared client state. Replace this with a `withHandle`/serial queue that holds ownership for the entire C call and makes `close()` wait for in-flight operations before calling `moss_client_free`.
| const withMoss = (config) => { | ||
| config = withPodfileProperties(config, (cfg) => { | ||
| cfg.modResults['ios.deploymentTarget'] = | ||
| cfg.modResults['ios.deploymentTarget'] || '16.4'; |
There was a problem hiding this comment.
CONSIDER ```js
cfg.modResults['ios.deploymentTarget'] =
cfg.modResults['ios.deploymentTarget'] || '16.4';
This only fills an empty deployment target. If an app already has a lower value, the plugin leaves it in place even though the podspec requires iOS 16.4, leading to a CocoaPods/build failure. Parse the existing value and set it to `max(existing, '16.4')`.
Codex reviewThe PR adds a React Native/Expo SDK, but the iOS integration has blockers around installing the vendored binary and safely managing the native client handle. |
Summary
@moss-dev/moss-react-nativeundersdks/react-native/— an Expo Modules package that exposes aMossClientSharedObject for on-device semantic search.Moss.xcframework(same binary as the Swift SDK,v0.6.2), downloaded + checksum-verified atpod install.examples/react-native/usage sketch. Updates ROADMAP / AGENTS / root README.Closes #432
Notes
expo prebuild(not Expo Go).createIndex,loadIndex,query,addDocs, index CRUD). Session / Authenticator APIs from the Swift SDK are deferred.Test plan
cd sdks/react-native && npm install && npm run buildplugins: ["@moss-dev/moss-react-native"], runnpx expo prebuild+pod install, confirmMoss.xcframeworkdownloadsMossClientthrows with the SDK: Kotlin / Android bindings #411 messageMade with Cursor