RN MLKit Wrapper for Expo
RNMLKit provides Expo modules that allow developers to use MLKit native libraries in their Expo apps.
Here are some previews in action:
| Face Detection | Object Detection |
|---|---|
Quickstart: Running the example app
1. Clone the project
2. Install dependencies
3. Build native modules
4. Create a development build of the app
iOS
Note: MLKit is not supported in the iOS simulator. You will need to use a hardware device.
Via Terminal
npx expo run:ios -d
Via XCode
- Create the native project folders
npx expo prebuild
- Open
apps/ExampleApp/ios/ExampleApp.xcworkspacein XCode - Select the
ExampleApptarget, and select a Team on the "Signing & Capabilities" tab - Select your target hardware device (MLKit is not supported in the simulator at this time)
- Click the play button to build the app
Android
Note: Android support is currently under active development, some modules may not function as intended
# run on hardware device
npx expo run:android -d
Organization
The monorepo is organized into the following sections:
- Apps -- holds the example app (
ExampleApp) that demonstrates how to use the modules. - Modules -- holds the modules themselves. Each module is a separate npm package, and they are published to npm
under the name
@infinitered/[module name]. - Packages -- holds internal packages that are only used by the modules and are not published to npm. Things like the linter config.
Usage
For usage instructions see the readme in each module's directory.
Building
Use yarn build at the root level to compile typescript in all workspaces. You will need to do this when you make
changes before other modules to be able to see the changes. (The packages have a main field that points to the compiled
code.)
Running yarn build inside of an expo module workspace will start watch mode for files inside of that module.
Compatibility
| Expo SDK | MLKit |
|---|---|
| ^49.0.0 | <= 0.7.7 |
| ^50.0.0 | ^1.0.0 |
| ^51.0.0 | ^2.0.0 |
| ^52.0.0 | ^3.0.0 |
| ^53.0.0 | ^4.0.0 |
| ^54.0.0 | ^5.0.0 |
React Native Firebase
When using React Native MLKit alongside React Native Firebase, you may encounter dependency conflicts with the underlying Google libraries. This occurs because Firebase requires newer versions of shared dependencies than those used by Google's MLKit SDK.
Specific conflicts:
- React Native Firebase needs GoogleDataTransport ~> 10.0 and GoogleUtilities ~> 8.0
- MLKit uses GoogleDataTransport ~> 3.2 or ~> 8.0 and GoogleUtilities ~> 6.0
Solutions
- For standard React Native projects:
# In your Podfile
pod 'GoogleDataTransport', '~> 10.0'
pod 'GoogleUtilities', '~> 8.0'