├── .circleci └── config.yml ├── .editorconfig ├── .gitattributes ├── .github └── FUNDING.yml ├── .gitignore ├── CONTRIBUTING.md ├── LICENSE ├── README.md ├── android ├── build.gradle ├── gradle.properties └── src │ ├── main │ ├── AndroidManifest.xml │ └── java │ │ └── com │ │ └── reactnativemlkitocr │ │ ├── MlkitOcrModuleImpl.kt │ │ └── MlkitOcrPackage.kt │ ├── newarch │ └── java │ │ └── com │ │ └── reactnativemlkitocr │ │ └── MlkitOcrModule.kt │ └── oldarch │ └── java │ └── com │ └── reactnativemlkitocr │ └── MlkitOcrModule.kt ├── babel.config.js ├── example ├── android │ ├── app │ │ ├── _BUCK │ │ ├── build.gradle │ │ ├── build_defs.bzl │ │ ├── debug.keystore │ │ ├── proguard-rules.pro │ │ └── src │ │ │ ├── debug │ │ │ ├── AndroidManifest.xml │ │ │ └── java │ │ │ │ └── com │ │ │ │ └── example │ │ │ │ └── reactnativemlkitocr │ │ │ │ └── ReactNativeFlipper.java │ │ │ └── main │ │ │ ├── AndroidManifest.xml │ │ │ ├── java │ │ │ └── com │ │ │ │ └── example │ │ │ │ └── reactnativemlkitocr │ │ │ │ ├── MainActivity.java │ │ │ │ ├── MainApplication.java │ │ │ │ └── newarchitecture │ │ │ │ ├── MainApplicationReactNativeHost.java │ │ │ │ ├── components │ │ │ │ └── MainComponentsRegistry.java │ │ │ │ └── modules │ │ │ │ └── MainApplicationTurboModuleManagerDelegate.java │ │ │ ├── jni │ │ │ ├── Android.mk │ │ │ ├── MainApplicationModuleProvider.cpp │ │ │ ├── MainApplicationModuleProvider.h │ │ │ ├── MainApplicationTurboModuleManagerDelegate.cpp │ │ │ ├── MainApplicationTurboModuleManagerDelegate.h │ │ │ ├── MainComponentsRegistry.cpp │ │ │ ├── MainComponentsRegistry.h │ │ │ └── OnLoad.cpp │ │ │ └── res │ │ │ ├── mipmap-hdpi │ │ │ ├── ic_launcher.png │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-mdpi │ │ │ ├── ic_launcher.png │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-xhdpi │ │ │ ├── ic_launcher.png │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-xxhdpi │ │ │ ├── ic_launcher.png │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-xxxhdpi │ │ │ ├── ic_launcher.png │ │ │ └── ic_launcher_round.png │ │ │ └── values │ │ │ ├── strings.xml │ │ │ └── styles.xml │ ├── build.gradle │ ├── gradle.properties │ ├── gradle │ │ └── wrapper │ │ │ ├── gradle-wrapper.jar │ │ │ └── gradle-wrapper.properties │ ├── gradlew │ ├── gradlew.bat │ └── settings.gradle ├── app.json ├── babel.config.js ├── index.js ├── ios │ ├── MlkitOcrExample.xcodeproj │ │ ├── project.pbxproj │ │ └── xcshareddata │ │ │ └── xcschemes │ │ │ └── MlkitOcrExample.xcscheme │ ├── MlkitOcrExample.xcworkspace │ │ ├── contents.xcworkspacedata │ │ └── xcshareddata │ │ │ └── IDEWorkspaceChecks.plist │ ├── MlkitOcrExample │ │ ├── AppDelegate.h │ │ ├── AppDelegate.mm │ │ ├── Base.lproj │ │ │ └── LaunchScreen.xib │ │ ├── Images.xcassets │ │ │ ├── AppIcon.appiconset │ │ │ │ └── Contents.json │ │ │ └── Contents.json │ │ ├── Info.plist │ │ └── main.m │ ├── Podfile │ └── Podfile.lock ├── metro.config.js ├── package.json ├── src │ └── App.tsx └── yarn.lock ├── ios ├── MlkitOcr.h ├── MlkitOcr.mm └── MlkitOcr.xcodeproj │ └── project.pbxproj ├── package.json ├── react-native-mlkit-ocr.podspec ├── src ├── NativeMlkitOcr.ts ├── __tests__ │ └── index.test.tsx ├── index.d.ts └── index.ts ├── tsconfig.build.json ├── tsconfig.json └── yarn.lock /.circleci/config.yml: -------------------------------------------------------------------------------- 1 | version: 2.1 2 | 3 | executors: 4 | default: 5 | docker: 6 | - image: circleci/node:10 7 | working_directory: ~/project 8 | 9 | commands: 10 | attach_project: 11 | steps: 12 | - attach_workspace: 13 | at: ~/project 14 | 15 | jobs: 16 | install-dependencies: 17 | executor: default 18 | steps: 19 | - checkout 20 | - attach_project 21 | - restore_cache: 22 | keys: 23 | - dependencies-{{ checksum "package.json" }} 24 | - dependencies- 25 | - restore_cache: 26 | keys: 27 | - dependencies-example-{{ checksum "example/package.json" }} 28 | - dependencies-example- 29 | - run: 30 | name: Install dependencies 31 | command: | 32 | yarn install --cwd example --frozen-lockfile 33 | yarn install --frozen-lockfile 34 | - save_cache: 35 | key: dependencies-{{ checksum "package.json" }} 36 | paths: node_modules 37 | - save_cache: 38 | key: dependencies-example-{{ checksum "example/package.json" }} 39 | paths: example/node_modules 40 | - persist_to_workspace: 41 | root: . 42 | paths: . 43 | 44 | lint: 45 | executor: default 46 | steps: 47 | - attach_project 48 | - run: 49 | name: Lint files 50 | command: | 51 | yarn lint 52 | 53 | typescript: 54 | executor: default 55 | steps: 56 | - attach_project 57 | - run: 58 | name: Typecheck files 59 | command: | 60 | yarn typescript 61 | 62 | unit-tests: 63 | executor: default 64 | steps: 65 | - attach_project 66 | - run: 67 | name: Run unit tests 68 | command: | 69 | yarn test --coverage 70 | - store_artifacts: 71 | path: coverage 72 | destination: coverage 73 | 74 | build-package: 75 | executor: default 76 | steps: 77 | - attach_project 78 | - run: 79 | name: Build package 80 | command: | 81 | yarn prepare 82 | 83 | workflows: 84 | build-and-test: 85 | jobs: 86 | - install-dependencies 87 | - lint: 88 | requires: 89 | - install-dependencies 90 | - typescript: 91 | requires: 92 | - install-dependencies 93 | - unit-tests: 94 | requires: 95 | - install-dependencies 96 | - build-package: 97 | requires: 98 | - install-dependencies 99 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | # EditorConfig helps developers define and maintain consistent 2 | # coding styles between different editors and IDEs 3 | # editorconfig.org 4 | 5 | root = true 6 | 7 | [*] 8 | 9 | indent_style = space 10 | indent_size = 2 11 | 12 | end_of_line = lf 13 | charset = utf-8 14 | trim_trailing_whitespace = true 15 | insert_final_newline = true 16 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | *.pbxproj -text 2 | # specific for windows script files 3 | *.bat text eol=crlf -------------------------------------------------------------------------------- /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | # These are supported funding model platforms 2 | 3 | github: [agoldis] 4 | patreon: # Replace with a single Patreon username 5 | open_collective: # Replace with a single Open Collective username 6 | ko_fi: # Replace with a single Ko-fi username 7 | tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel 8 | community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry 9 | liberapay: # Replace with a single Liberapay username 10 | issuehunt: # Replace with a single IssueHunt username 11 | otechie: # Replace with a single Otechie username 12 | custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2'] 13 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # OSX 2 | # 3 | .DS_Store 4 | 5 | # XDE 6 | .expo/ 7 | 8 | # VSCode 9 | .vscode/ 10 | jsconfig.json 11 | 12 | # Xcode 13 | # 14 | build/ 15 | *.pbxuser 16 | !default.pbxuser 17 | *.mode1v3 18 | !default.mode1v3 19 | *.mode2v3 20 | !default.mode2v3 21 | *.perspectivev3 22 | !default.perspectivev3 23 | xcuserdata 24 | *.xccheckout 25 | *.moved-aside 26 | DerivedData 27 | *.hmap 28 | *.ipa 29 | *.xcuserstate 30 | project.xcworkspace 31 | 32 | # Android/IJ 33 | # 34 | .idea 35 | .gradle 36 | local.properties 37 | android.iml 38 | 39 | # Cocoapods 40 | # 41 | example/ios/Pods 42 | 43 | # node.js 44 | # 45 | node_modules/ 46 | npm-debug.log 47 | yarn-debug.log 48 | yarn-error.log 49 | 50 | # BUCK 51 | buck-out/ 52 | \.buckd/ 53 | android/app/libs 54 | android/keystores/debug.keystore 55 | 56 | # Expo 57 | .expo/* 58 | 59 | # generated by bob 60 | lib/ 61 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing 2 | 3 | We want this community to be friendly and respectful to each other. Please follow it in all your interactions with the project. 4 | 5 | ## Development workflow 6 | 7 | To get started with the project, run `yarn bootstrap` in the root directory to install the required dependencies for each package: 8 | 9 | ```sh 10 | yarn bootstrap 11 | ``` 12 | 13 | While developing, you can run the [example app](/example/) to test your changes. 14 | 15 | To start the packager: 16 | 17 | ```sh 18 | yarn example start 19 | ``` 20 | 21 | To run the example app on Android: 22 | 23 | ```sh 24 | yarn example android 25 | ``` 26 | 27 | To run the example app on iOS: 28 | 29 | ```sh 30 | yarn example ios 31 | ``` 32 | 33 | Make sure your code passes TypeScript and ESLint. Run the following to verify: 34 | 35 | ```sh 36 | yarn typescript 37 | yarn lint 38 | ``` 39 | 40 | To fix formatting errors, run the following: 41 | 42 | ```sh 43 | yarn lint --fix 44 | ``` 45 | 46 | Remember to add tests for your change if possible. Run the unit tests by: 47 | 48 | ```sh 49 | yarn test 50 | ``` 51 | 52 | To edit the Objective-C files, open `example/ios/MlkitOcrExample.xcworkspace` in XCode and find the source files at `Pods > Development Pods > react-native-mlkit-ocr`. 53 | 54 | To edit the Kotlin files, open `example/android` in Android studio and find the source files at `reactnativemlkitocr` under `Android`. 55 | 56 | ### Commit message convention 57 | 58 | We follow the [conventional commits specification](https://www.conventionalcommits.org/en) for our commit messages: 59 | 60 | - `fix`: bug fixes, e.g. fix crash due to deprecated method. 61 | - `feat`: new features, e.g. add new method to the module. 62 | - `refactor`: code refactor, e.g. migrate from class components to hooks. 63 | - `docs`: changes into documentation, e.g. add usage example for the module.. 64 | - `test`: adding or updating tests, eg add integration tests using detox. 65 | - `chore`: tooling changes, e.g. change CI config. 66 | 67 | Our pre-commit hooks verify that your commit message matches this format when committing. 68 | 69 | ### Linting and tests 70 | 71 | [ESLint](https://eslint.org/), [Prettier](https://prettier.io/), [TypeScript](https://www.typescriptlang.org/) 72 | 73 | We use [TypeScript](https://www.typescriptlang.org/) for type checking, [ESLint](https://eslint.org/) with [Prettier](https://prettier.io/) for linting and formatting the code, and [Jest](https://jestjs.io/) for testing. 74 | 75 | Our pre-commit hooks verify that the linter and tests pass when committing. 76 | 77 | ### Scripts 78 | 79 | The `package.json` file contains various scripts for common tasks: 80 | 81 | - `yarn bootstrap`: setup project by installing all dependencies and pods. 82 | - `yarn typescript`: type-check files with TypeScript. 83 | - `yarn lint`: lint files with ESLint. 84 | - `yarn test`: run unit tests with Jest. 85 | - `yarn example start`: start the Metro server for the example app. 86 | - `yarn example android`: run the example app on Android. 87 | - `yarn example ios`: run the example app on iOS. 88 | 89 | ### Sending a pull request 90 | 91 | > **Working on your first pull request?** You can learn how from this _free_ series: [How to Contribute to an Open Source Project on GitHub](https://egghead.io/series/how-to-contribute-to-an-open-source-project-on-github). 92 | 93 | When you're sending a pull request: 94 | 95 | - Prefer small pull requests focused on one change. 96 | - Verify that linters and tests are passing. 97 | - Review the documentation to make sure it looks good. 98 | - Follow the pull request template when opening a pull request. 99 | - For pull requests that change the API or implementation, discuss with maintainers first by opening an issue. 100 | 101 | ## Code of Conduct 102 | 103 | ### Our Pledge 104 | 105 | We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation. 106 | 107 | We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community. 108 | 109 | ### Our Standards 110 | 111 | Examples of behavior that contributes to a positive environment for our community include: 112 | 113 | - Demonstrating empathy and kindness toward other people 114 | - Being respectful of differing opinions, viewpoints, and experiences 115 | - Giving and gracefully accepting constructive feedback 116 | - Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience 117 | - Focusing on what is best not just for us as individuals, but for the overall community 118 | 119 | Examples of unacceptable behavior include: 120 | 121 | - The use of sexualized language or imagery, and sexual attention or 122 | advances of any kind 123 | - Trolling, insulting or derogatory comments, and personal or political attacks 124 | - Public or private harassment 125 | - Publishing others' private information, such as a physical or email 126 | address, without their explicit permission 127 | - Other conduct which could reasonably be considered inappropriate in a 128 | professional setting 129 | 130 | ### Enforcement Responsibilities 131 | 132 | Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful. 133 | 134 | Community leaders have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, and will communicate reasons for moderation decisions when appropriate. 135 | 136 | ### Scope 137 | 138 | This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces. Examples of representing our community include using an official e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. 139 | 140 | ### Enforcement 141 | 142 | Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at [INSERT CONTACT METHOD]. All complaints will be reviewed and investigated promptly and fairly. 143 | 144 | All community leaders are obligated to respect the privacy and security of the reporter of any incident. 145 | 146 | ### Enforcement Guidelines 147 | 148 | Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct: 149 | 150 | #### 1. Correction 151 | 152 | **Community Impact**: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community. 153 | 154 | **Consequence**: A private, written warning from community leaders, providing clarity around the nature of the violation and an explanation of why the behavior was inappropriate. A public apology may be requested. 155 | 156 | #### 2. Warning 157 | 158 | **Community Impact**: A violation through a single incident or series of actions. 159 | 160 | **Consequence**: A warning with consequences for continued behavior. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban. 161 | 162 | #### 3. Temporary Ban 163 | 164 | **Community Impact**: A serious violation of community standards, including sustained inappropriate behavior. 165 | 166 | **Consequence**: A temporary ban from any sort of interaction or public communication with the community for a specified period of time. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban. 167 | 168 | #### 4. Permanent Ban 169 | 170 | **Community Impact**: Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals. 171 | 172 | **Consequence**: A permanent ban from any sort of public interaction within the community. 173 | 174 | ### Attribution 175 | 176 | This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.0, 177 | available at https://www.contributor-covenant.org/version/2/0/code_of_conduct.html. 178 | 179 | Community Impact Guidelines were inspired by [Mozilla's code of conduct enforcement ladder](https://github.com/mozilla/diversity). 180 | 181 | [homepage]: https://www.contributor-covenant.org 182 | 183 | For answers to common questions about this code of conduct, see the FAQ at 184 | https://www.contributor-covenant.org/faq. Translations are available at https://www.contributor-covenant.org/translations. 185 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 Andrew Goldis 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # react-native-mlkit-ocr 2 |

3 | Google on-device MLKit text recognition for React Native 4 |

5 | 6 |

7 | 8 |

9 | 10 | 11 | ## Installation 12 | 13 | ```sh 14 | npm install react-native-mlkit-ocr 15 | ``` 16 | ## Post-install Steps 17 | 18 | ### iOS 19 | Run 20 | 21 | ```js 22 | cd ios && pod install 23 | ``` 24 | 25 | ## Usage 26 | 27 | ```js 28 | import MlkitOcr from 'react-native-mlkit-ocr'; 29 | 30 | // ... 31 | 32 | const resultFromUri = await MlkitOcr.detectFromUri(uri); 33 | const resultFromFile = await MlkitOcr.detectFromFile(path); 34 | ``` 35 | 36 | 37 | ## Example 38 | 39 | To get started with the project, run `yarn bootstrap` in the root directory to install the required dependencies for each package: 40 | 41 | ```sh 42 | yarn bootstrap 43 | ``` 44 | 45 | To start the packager: 46 | 47 | ```sh 48 | yarn example start 49 | ``` 50 | 51 | To run the example app on Android: 52 | 53 | ```sh 54 | yarn example android 55 | ``` 56 | 57 | To run the example app on iOS: 58 | 59 | ```sh 60 | yarn example ios 61 | ``` 62 | 63 | ## Contributing 64 | 65 | See the [contributing guide](CONTRIBUTING.md) to learn how to contribute to the repository and the development workflow. 66 | 67 | ## License 68 | 69 | MIT 70 | -------------------------------------------------------------------------------- /android/build.gradle: -------------------------------------------------------------------------------- 1 | import groovy.json.JsonSlurper 2 | import java.nio.file.Paths 3 | 4 | buildscript { 5 | 6 | def kotlin_version = rootProject.ext.has('kotlinVersion') ? rootProject.ext.get('kotlinVersion') : project.properties['MlkitOcr_kotlinVersion'] 7 | 8 | ext.safeExtGet = { prop -> 9 | rootProject.ext.has(prop) ? rootProject.ext.get(prop) : project.properties["MlkitOcr_${prop}"] 10 | } 11 | 12 | repositories { 13 | google() 14 | gradlePluginPortal() 15 | mavenCentral() 16 | } 17 | 18 | dependencies { 19 | classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" 20 | } 21 | } 22 | 23 | def getExtOrDefault(name) { 24 | return rootProject.ext.has(name) ? rootProject.ext.get(name) : project.properties["MlkitOcr_${name}"] 25 | } 26 | 27 | def isNewArchitectureEnabled() { 28 | return project.hasProperty("newArchEnabled") && project.newArchEnabled == "true" 29 | } 30 | 31 | static def findNodeModulePath(baseDir, packageName) { 32 | def basePath = baseDir.toPath().normalize() 33 | // Node's module resolution algorithm searches up to the root directory, 34 | // after which the base path will be null 35 | while (basePath) { 36 | def candidatePath = Paths.get(basePath.toString(), "node_modules", packageName) 37 | if (candidatePath.toFile().exists()) { 38 | return candidatePath.toString() 39 | } 40 | basePath = basePath.getParent() 41 | } 42 | return null 43 | } 44 | 45 | def findNodeModulePath(packageName) { 46 | // Don't start in the project dir, as its path ends with node_modules/react-native-mlkit-ocr/android 47 | // we want to go two levels up, so we end up in the first_node modules and eventually 48 | // search upwards if the package is not found there 49 | return findNodeModulePath(projectDir.toPath().parent.parent.toFile(), packageName) 50 | } 51 | 52 | apply plugin: 'com.android.library' 53 | apply plugin: 'kotlin-android' 54 | 55 | if (isNewArchitectureEnabled()) { 56 | apply plugin: 'com.facebook.react' 57 | } 58 | 59 | android { 60 | compileSdkVersion safeExtGet('compileSdkVersion') 61 | 62 | // Used to override the NDK path/version on internal CI or by allowing 63 | // users to customize the NDK path/version from their root project (e.g. for M1 support) 64 | if (rootProject.hasProperty("ndkPath")) { 65 | ndkPath rootProject.ext.ndkPath 66 | } 67 | if (rootProject.hasProperty("ndkVersion")) { 68 | ndkVersion rootProject.ext.ndkVersion 69 | } 70 | 71 | defaultConfig { 72 | minSdkVersion getExtOrDefault('minSdkVersion') 73 | targetSdkVersion getExtOrDefault('targetSdkVersion') 74 | buildConfigField "boolean", "IS_NEW_ARCHITECTURE_ENABLED", isNewArchitectureEnabled().toString() 75 | versionCode 110 76 | versionName "1.1.0" 77 | } 78 | 79 | compileOptions { 80 | sourceCompatibility JavaVersion.VERSION_1_8 81 | targetCompatibility JavaVersion.VERSION_1_8 82 | } 83 | 84 | lintOptions { 85 | abortOnError false 86 | } 87 | 88 | sourceSets { 89 | main { 90 | if (isNewArchitectureEnabled()) { 91 | java.srcDirs += ["src/newarch", 92 | "${project.buildDir}/generated/source/codegen/java"] 93 | } else { 94 | java.srcDirs += ["src/oldarch"] 95 | } 96 | } 97 | } 98 | } 99 | 100 | repositories { 101 | maven { 102 | // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm 103 | url "${rootDir}/../node_modules/react-native/android" 104 | } 105 | mavenCentral() 106 | google() 107 | } 108 | 109 | def kotlin_version = getExtOrDefault('kotlinVersion') 110 | 111 | dependencies { 112 | 113 | if (isNewArchitectureEnabled()) { 114 | implementation project(":ReactAndroid") 115 | } else { 116 | implementation 'com.facebook.react:react-native:+' 117 | } 118 | 119 | implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" 120 | 121 | implementation 'com.google.android.gms:play-services-mlkit-text-recognition:18.0.2' 122 | } 123 | 124 | if (isNewArchitectureEnabled()) { 125 | react { 126 | reactNativeDir = rootProject.file(findNodeModulePath(rootProject.rootDir, "react-native") ?: "../node_modules/react-native/") 127 | jsRootDir = file("../src/") 128 | codegenDir = rootProject.file(findNodeModulePath(rootProject.rootDir, "react-native-codegen") ?: "../node_modules/react-native-codegen/") 129 | libraryName = "mlkitocr" 130 | codegenJavaPackageName = "com.reactnativemlkitocr" 131 | } 132 | 133 | // Resolves "LOCAL_SRC_FILES points to a missing file, Check that libfb.so exists or that its path is correct". 134 | tasks.whenTaskAdded { task -> 135 | if (task.name.contains("configureCMakeDebug")) { 136 | rootProject.getTasksByName("packageReactNdkDebugLibs", true).forEach { 137 | task.dependsOn(it) 138 | } 139 | } 140 | // We want to add a dependency for both configureCMakeRelease and configureCMakeRelWithDebInfo 141 | if (task.name.contains("configureCMakeRel")) { 142 | rootProject.getTasksByName("packageReactNdkReleaseLibs", true).forEach { 143 | task.dependsOn(it) 144 | } 145 | } 146 | } 147 | } 148 | -------------------------------------------------------------------------------- /android/gradle.properties: -------------------------------------------------------------------------------- 1 | MlkitOcr_kotlinVersion=1.6.10 2 | MlkitOcr_minSdkVersion=21 3 | MlkitOcr_compileSdkVersion=31 4 | MlkitOcr_targetSdkVersion=31 5 | -------------------------------------------------------------------------------- /android/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /android/src/main/java/com/reactnativemlkitocr/MlkitOcrModuleImpl.kt: -------------------------------------------------------------------------------- 1 | package com.reactnativemlkitocr 2 | 3 | import android.graphics.Point 4 | import android.graphics.Rect 5 | import android.net.Uri 6 | import com.facebook.react.bridge.* 7 | import com.google.mlkit.vision.common.InputImage 8 | import com.google.mlkit.vision.text.Text 9 | import com.google.mlkit.vision.text.TextRecognition 10 | import com.google.mlkit.vision.text.latin.TextRecognizerOptions 11 | import java.lang.Exception 12 | 13 | class MlkitOcrModuleImpl { 14 | 15 | companion object { 16 | const val NAME = "MlkitOcr" 17 | 18 | fun detectFromResource(context: ReactApplicationContext, path: String, promise: Promise) { 19 | val image: InputImage; 20 | try { 21 | image = InputImage.fromFilePath(context, Uri.parse(path)) 22 | val recognizer = TextRecognition.getClient(TextRecognizerOptions.DEFAULT_OPTIONS) 23 | recognizer.process(image).addOnSuccessListener { visionText -> 24 | promise.resolve(getDataAsArray(visionText)) 25 | }.addOnFailureListener { e -> 26 | promise.reject(e); 27 | e.printStackTrace(); 28 | } 29 | } catch (e: Exception) { 30 | promise.reject(e); 31 | e.printStackTrace(); 32 | } 33 | } 34 | 35 | private fun getCoordinates(boundingBox: Rect?): WritableMap { 36 | val coordinates: WritableMap = Arguments.createMap() 37 | if (boundingBox == null) { 38 | coordinates.putNull("top") 39 | coordinates.putNull("left") 40 | coordinates.putNull("width") 41 | coordinates.putNull("height") 42 | } else { 43 | coordinates.putInt("top", boundingBox.top) 44 | coordinates.putInt("left", boundingBox.left) 45 | coordinates.putInt("width", boundingBox.width()) 46 | coordinates.putInt("height", boundingBox.height()) 47 | } 48 | return coordinates; 49 | } 50 | 51 | private fun getCornerPoints(pointsList: Array?): WritableArray { 52 | val p: WritableArray = Arguments.createArray() 53 | if (pointsList == null) { 54 | return p; 55 | } 56 | 57 | pointsList.forEach { point -> 58 | val i: WritableMap = Arguments.createMap() 59 | i.putInt("x", point.x); 60 | i.putInt("y", point.y); 61 | p.pushMap(i); 62 | } 63 | 64 | return p; 65 | } 66 | 67 | 68 | private fun getDataAsArray(visionText: Text): WritableArray? { 69 | val data: WritableArray = Arguments.createArray() 70 | 71 | for (block in visionText.textBlocks) { 72 | val blockElements: WritableArray = Arguments.createArray() 73 | for (line in block.lines) { 74 | val lineElements: WritableArray = Arguments.createArray() 75 | for (element in line.elements) { 76 | val e: WritableMap = Arguments.createMap() 77 | e.putString("text", element.text) 78 | e.putMap("bounding", getCoordinates(element.boundingBox)) 79 | e.putArray("cornerPoints", getCornerPoints(element.cornerPoints)) 80 | e.putString("confidence", element.confidence.toString()) 81 | lineElements.pushMap(e) 82 | } 83 | val l: WritableMap = Arguments.createMap() 84 | val lCoordinates = getCoordinates(line.boundingBox) 85 | l.putString("text", line.text) 86 | l.putMap("bounding", lCoordinates) 87 | l.putArray("elements", lineElements) 88 | l.putArray("cornerPoints", getCornerPoints(line.cornerPoints)) 89 | l.putString("confidence", line.confidence.toString()) 90 | 91 | blockElements.pushMap(l) 92 | } 93 | 94 | val info: WritableMap = Arguments.createMap() 95 | 96 | 97 | info.putMap("bounding", getCoordinates(block.boundingBox)) 98 | info.putString("text", block.text) 99 | info.putArray("lines", blockElements) 100 | info.putArray("cornerPoints", getCornerPoints(block.cornerPoints)) 101 | data.pushMap(info) 102 | } 103 | return data 104 | } 105 | } 106 | } 107 | -------------------------------------------------------------------------------- /android/src/main/java/com/reactnativemlkitocr/MlkitOcrPackage.kt: -------------------------------------------------------------------------------- 1 | package com.reactnativemlkitocr 2 | 3 | import com.facebook.react.TurboReactPackage 4 | import com.facebook.react.bridge.NativeModule 5 | import com.facebook.react.bridge.ReactApplicationContext 6 | import com.facebook.react.module.annotations.ReactModule 7 | import com.facebook.react.module.model.ReactModuleInfo 8 | import com.facebook.react.module.model.ReactModuleInfoProvider 9 | import com.facebook.react.turbomodule.core.interfaces.TurboModule 10 | import java.util.* 11 | 12 | class MlkitOcrPackage : TurboReactPackage() { 13 | 14 | override fun getModule(name: String, reactContext: ReactApplicationContext): NativeModule? { 15 | return if (name == MlkitOcrModuleImpl.NAME) { 16 | MlkitOcrModule(reactContext) 17 | } else { 18 | null 19 | } 20 | } 21 | 22 | override fun getReactModuleInfoProvider(): ReactModuleInfoProvider { 23 | return ReactModuleInfoProvider { 24 | val moduleInfos: MutableMap = 25 | HashMap() 26 | val isTurboModule = BuildConfig.IS_NEW_ARCHITECTURE_ENABLED 27 | moduleInfos[MlkitOcrModuleImpl.NAME] = ReactModuleInfo( 28 | MlkitOcrModuleImpl.NAME, 29 | MlkitOcrModuleImpl.NAME, 30 | false, // canOverrideExistingModule 31 | false, // needsEagerInit 32 | true, // hasConstants 33 | false, // isCxxModule 34 | isTurboModule // isTurboModule 35 | ) 36 | moduleInfos 37 | } 38 | } 39 | } 40 | 41 | -------------------------------------------------------------------------------- /android/src/newarch/java/com/reactnativemlkitocr/MlkitOcrModule.kt: -------------------------------------------------------------------------------- 1 | package com.reactnativemlkitocr 2 | 3 | import com.facebook.react.bridge.Promise 4 | import com.facebook.react.bridge.ReactApplicationContext 5 | 6 | class MlkitOcrModule(reactContext: ReactApplicationContext) : 7 | NativeMlkitOcrSpec(reactContext) { 8 | 9 | override fun getName(): String { 10 | return NAME 11 | } 12 | 13 | override fun detectFromUri(imagePath: String, promise: Promise) { 14 | return MlkitOcrModuleImpl.detectFromResource(this.reactApplicationContext, imagePath, promise) 15 | } 16 | 17 | override fun detectFromFile(imagePath: String, promise: Promise) { 18 | return MlkitOcrModuleImpl.detectFromResource(this.reactApplicationContext, imagePath, promise) 19 | } 20 | 21 | companion object { 22 | const val NAME = MlkitOcrModuleImpl.NAME 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /android/src/oldarch/java/com/reactnativemlkitocr/MlkitOcrModule.kt: -------------------------------------------------------------------------------- 1 | package com.reactnativemlkitocr 2 | 3 | import com.facebook.react.bridge.Promise 4 | import com.facebook.react.bridge.ReactApplicationContext 5 | import com.facebook.react.bridge.ReactContextBaseJavaModule 6 | import com.facebook.react.bridge.ReactMethod 7 | 8 | class MlkitOcrModule internal constructor(context: ReactApplicationContext?) : 9 | ReactContextBaseJavaModule(context) { 10 | 11 | override fun getName(): String { 12 | return MlkitOcrModuleImpl.NAME 13 | } 14 | 15 | @ReactMethod 16 | fun detectFromUri(imagePath: String, promise: Promise) { 17 | return MlkitOcrModuleImpl.detectFromResource(this.reactApplicationContext, imagePath, promise) 18 | } 19 | 20 | @ReactMethod 21 | fun detectFromFile(imagePath: String, promise: Promise) { 22 | return MlkitOcrModuleImpl.detectFromResource(this.reactApplicationContext, imagePath, promise) 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /babel.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | presets: ['module:metro-react-native-babel-preset'], 3 | }; 4 | -------------------------------------------------------------------------------- /example/android/app/_BUCK: -------------------------------------------------------------------------------- 1 | # To learn about Buck see [Docs](https://buckbuild.com/). 2 | # To run your application with Buck: 3 | # - install Buck 4 | # - `npm start` - to start the packager 5 | # - `cd android` 6 | # - `keytool -genkey -v -keystore keystores/debug.keystore -storepass android -alias androiddebugkey -keypass android -dname "CN=Android Debug,O=Android,C=US"` 7 | # - `./gradlew :app:copyDownloadableDepsToLibs` - make all Gradle compile dependencies available to Buck 8 | # - `buck install -r android/app` - compile, install and run application 9 | # 10 | 11 | load(":build_defs.bzl", "create_aar_targets", "create_jar_targets") 12 | 13 | lib_deps = [] 14 | 15 | create_aar_targets(glob(["libs/*.aar"])) 16 | 17 | create_jar_targets(glob(["libs/*.jar"])) 18 | 19 | android_library( 20 | name = "all-libs", 21 | exported_deps = lib_deps, 22 | ) 23 | 24 | android_library( 25 | name = "app-code", 26 | srcs = glob([ 27 | "src/main/java/**/*.java", 28 | ]), 29 | deps = [ 30 | ":all-libs", 31 | ":build_config", 32 | ":res", 33 | ], 34 | ) 35 | 36 | android_build_config( 37 | name = "build_config", 38 | package = "com.example.reactnativemlkitocr", 39 | ) 40 | 41 | android_resource( 42 | name = "res", 43 | package = "com.example.reactnativemlkitocr", 44 | res = "src/main/res", 45 | ) 46 | 47 | android_binary( 48 | name = "app", 49 | keystore = "//android/keystores:debug", 50 | manifest = "src/main/AndroidManifest.xml", 51 | package_type = "debug", 52 | deps = [ 53 | ":app-code", 54 | ], 55 | ) 56 | -------------------------------------------------------------------------------- /example/android/app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: "com.android.application" 2 | 3 | if (isNewArchitectureEnabled()) { 4 | apply plugin: "com.facebook.react" 5 | } 6 | 7 | import com.android.build.OutputFile 8 | import org.apache.tools.ant.taskdefs.condition.Os 9 | 10 | /** 11 | * The react.gradle file registers a task for each build variant (e.g. bundleDebugJsAndAssets 12 | * and bundleReleaseJsAndAssets). 13 | * These basically call `react-native bundle` with the correct arguments during the Android build 14 | * cycle. By default, bundleDebugJsAndAssets is skipped, as in debug/dev mode we prefer to load the 15 | * bundle directly from the development server. Below you can see all the possible configurations 16 | * and their defaults. If you decide to add a configuration block, make sure to add it before the 17 | * `apply from: "../../node_modules/react-native/react.gradle"` line. 18 | * 19 | * project.ext.react = [ 20 | * // the name of the generated asset file containing your JS bundle 21 | * bundleAssetName: "index.android.bundle", 22 | * 23 | * // the entry file for bundle generation. If none specified and 24 | * // "index.android.js" exists, it will be used. Otherwise "index.js" is 25 | * // default. Can be overridden with ENTRY_FILE environment variable. 26 | * entryFile: "index.android.js", 27 | * 28 | * // https://reactnative.dev/docs/performance#enable-the-ram-format 29 | * bundleCommand: "ram-bundle", 30 | * 31 | * // whether to bundle JS and assets in debug mode 32 | * bundleInDebug: false, 33 | * 34 | * // whether to bundle JS and assets in release mode 35 | * bundleInRelease: true, 36 | * 37 | * // whether to bundle JS and assets in another build variant (if configured). 38 | * // See http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Build-Variants 39 | * // The configuration property can be in the following formats 40 | * // 'bundleIn${productFlavor}${buildType}' 41 | * // 'bundleIn${buildType}' 42 | * // bundleInFreeDebug: true, 43 | * // bundleInPaidRelease: true, 44 | * // bundleInBeta: true, 45 | * 46 | * // whether to disable dev mode in custom build variants (by default only disabled in release) 47 | * // for MlkitOcrExample: to disable dev mode in the staging build type (if configured) 48 | * devDisabledInStaging: true, 49 | * // The configuration property can be in the following formats 50 | * // 'devDisabledIn${productFlavor}${buildType}' 51 | * // 'devDisabledIn${buildType}' 52 | * 53 | * // the root of your project, i.e. where "package.json" lives 54 | * root: "../../", 55 | * 56 | * // where to put the JS bundle asset in debug mode 57 | * jsBundleDirDebug: "$buildDir/intermediates/assets/debug", 58 | * 59 | * // where to put the JS bundle asset in release mode 60 | * jsBundleDirRelease: "$buildDir/intermediates/assets/release", 61 | * 62 | * // where to put drawable resources / React Native assets, e.g. the ones you use via 63 | * // require('./image.png')), in debug mode 64 | * resourcesDirDebug: "$buildDir/intermediates/res/merged/debug", 65 | * 66 | * // where to put drawable resources / React Native assets, e.g. the ones you use via 67 | * // require('./image.png')), in release mode 68 | * resourcesDirRelease: "$buildDir/intermediates/res/merged/release", 69 | * 70 | * // by default the gradle tasks are skipped if none of the JS files or assets change; this means 71 | * // that we don't look at files in android/ or ios/ to determine whether the tasks are up to 72 | * // date; if you have any other folders that you want to ignore for performance reasons (gradle 73 | * // indexes the entire tree), add them here. Alternatively, if you have JS files in android/ 74 | * // for MlkitOcrExample, you might want to remove it from here. 75 | * inputExcludes: ["android/**", "ios/**"], 76 | * 77 | * // override which node gets called and with what additional arguments 78 | * nodeExecutableAndArgs: ["node"], 79 | * 80 | * // supply additional arguments to the packager 81 | * extraPackagerArgs: [] 82 | * ] 83 | */ 84 | 85 | project.ext.react = [ 86 | enableHermes: true, // clean and rebuild if changing 87 | ] 88 | 89 | apply from: "../../node_modules/react-native/react.gradle" 90 | 91 | /** 92 | * Set this to true to create two separate APKs instead of one: 93 | * - An APK that only works on ARM devices 94 | * - An APK that only works on x86 devices 95 | * The advantage is the size of the APK is reduced by about 4MB. 96 | * Upload all the APKs to the Play Store and people will download 97 | * the correct one based on the CPU architecture of their device. 98 | */ 99 | def enableSeparateBuildPerCPUArchitecture = false 100 | 101 | /** 102 | * Run Proguard to shrink the Java bytecode in release builds. 103 | */ 104 | def enableProguardInReleaseBuilds = false 105 | 106 | /** 107 | * The preferred build flavor of JavaScriptCore. 108 | * 109 | * For MlkitOcrExample, to use the international variant, you can use: 110 | * `def jscFlavor = 'org.webkit:android-jsc-intl:+'` 111 | * 112 | * The international variant includes ICU i18n library and necessary data 113 | * allowing to use e.g. `Date.toLocaleString` and `String.localeCompare` that 114 | * give correct results when using with locales other than en-US. Note that 115 | * this variant is about 6MiB larger per architecture than default. 116 | */ 117 | def jscFlavor = 'org.webkit:android-jsc:+' 118 | 119 | /** 120 | * Whether to enable the Hermes VM. 121 | * 122 | * This should be set on project.ext.react and that value will be read here. If it is not set 123 | * on project.ext.react, JavaScript will not be compiled to Hermes Bytecode 124 | * and the benefits of using Hermes will therefore be sharply reduced. 125 | */ 126 | def enableHermes = project.ext.react.get("enableHermes", false); 127 | 128 | /** 129 | * Architectures to build native code for. 130 | */ 131 | def reactNativeArchitectures() { 132 | def value = project.getProperties().get("reactNativeArchitectures") 133 | return value ? value.split(",") : ["armeabi-v7a", "x86", "x86_64", "arm64-v8a"] 134 | } 135 | 136 | android { 137 | ndkVersion rootProject.ext.ndkVersion 138 | 139 | compileSdkVersion rootProject.ext.compileSdkVersion 140 | 141 | defaultConfig { 142 | applicationId "com.example.reactnativemlkitocr" 143 | minSdkVersion rootProject.ext.minSdkVersion 144 | targetSdkVersion rootProject.ext.targetSdkVersion 145 | versionCode 1 146 | versionName "1.0" 147 | buildConfigField "boolean", "IS_NEW_ARCHITECTURE_ENABLED", isNewArchitectureEnabled().toString() 148 | 149 | if (isNewArchitectureEnabled()) { 150 | // We configure the NDK build only if you decide to opt-in for the New Architecture. 151 | externalNativeBuild { 152 | ndkBuild { 153 | arguments "APP_PLATFORM=android-21", 154 | "APP_STL=c++_shared", 155 | "NDK_TOOLCHAIN_VERSION=clang", 156 | "GENERATED_SRC_DIR=$buildDir/generated/source", 157 | "PROJECT_BUILD_DIR=$buildDir", 158 | "REACT_ANDROID_DIR=$rootDir/../node_modules/react-native/ReactAndroid", 159 | "REACT_ANDROID_BUILD_DIR=$rootDir/../node_modules/react-native/ReactAndroid/build", 160 | "NODE_MODULES_DIR=$rootDir/../node_modules" 161 | cFlags "-Wall", "-Werror", "-fexceptions", "-frtti", "-DWITH_INSPECTOR=1" 162 | cppFlags "-std=c++17" 163 | // Make sure this target name is the same you specify inside the 164 | // src/main/jni/Android.mk file for the `LOCAL_MODULE` variable. 165 | targets "mlkitocrexample_appmodules" 166 | } 167 | } 168 | if (!enableSeparateBuildPerCPUArchitecture) { 169 | ndk { 170 | abiFilters (*reactNativeArchitectures()) 171 | } 172 | } 173 | } 174 | } 175 | 176 | if (isNewArchitectureEnabled()) { 177 | // We configure the NDK build only if you decide to opt-in for the New Architecture. 178 | externalNativeBuild { 179 | ndkBuild { 180 | path "$projectDir/src/main/jni/Android.mk" 181 | } 182 | } 183 | def reactAndroidProjectDir = project(':ReactAndroid').projectDir 184 | def packageReactNdkDebugLibs = tasks.register("packageReactNdkDebugLibs", Copy) { 185 | dependsOn(":ReactAndroid:packageReactNdkDebugLibsForBuck") 186 | from("$reactAndroidProjectDir/src/main/jni/prebuilt/lib") 187 | into("$buildDir/react-ndk/exported") 188 | } 189 | def packageReactNdkReleaseLibs = tasks.register("packageReactNdkReleaseLibs", Copy) { 190 | dependsOn(":ReactAndroid:packageReactNdkReleaseLibsForBuck") 191 | from("$reactAndroidProjectDir/src/main/jni/prebuilt/lib") 192 | into("$buildDir/react-ndk/exported") 193 | } 194 | afterEvaluate { 195 | // If you wish to add a custom TurboModule or component locally, 196 | // you should uncomment this line. 197 | // preBuild.dependsOn("generateCodegenArtifactsFromSchema") 198 | preDebugBuild.dependsOn(packageReactNdkDebugLibs) 199 | preReleaseBuild.dependsOn(packageReactNdkReleaseLibs) 200 | 201 | // Due to a bug inside AGP, we have to explicitly set a dependency 202 | // between configureNdkBuild* tasks and the preBuild tasks. 203 | // This can be removed once this is solved: https://issuetracker.google.com/issues/207403732 204 | configureNdkBuildRelease.dependsOn(preReleaseBuild) 205 | configureNdkBuildDebug.dependsOn(preDebugBuild) 206 | reactNativeArchitectures().each { architecture -> 207 | tasks.findByName("configureNdkBuildDebug[${architecture}]")?.configure { 208 | dependsOn("preDebugBuild") 209 | } 210 | tasks.findByName("configureNdkBuildRelease[${architecture}]")?.configure { 211 | dependsOn("preReleaseBuild") 212 | } 213 | } 214 | } 215 | } 216 | 217 | splits { 218 | abi { 219 | reset() 220 | enable enableSeparateBuildPerCPUArchitecture 221 | universalApk false // If true, also generate a universal APK 222 | include(*reactNativeArchitectures()) 223 | } 224 | } 225 | 226 | signingConfigs { 227 | debug { 228 | storeFile file('debug.keystore') 229 | storePassword 'android' 230 | keyAlias 'androiddebugkey' 231 | keyPassword 'android' 232 | } 233 | } 234 | 235 | buildTypes { 236 | debug { 237 | signingConfig signingConfigs.debug 238 | } 239 | release { 240 | // Caution! In production, you need to generate your own keystore file. 241 | // see https://reactnative.dev/docs/signed-apk-android. 242 | signingConfig signingConfigs.debug 243 | minifyEnabled enableProguardInReleaseBuilds 244 | proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro" 245 | } 246 | } 247 | 248 | // applicationVariants are e.g. debug, release 249 | applicationVariants.all { variant -> 250 | variant.outputs.each { output -> 251 | // For each separate APK per architecture, set a unique version code as described here: 252 | // https://developer.android.com/studio/build/configure-apk-splits.html 253 | // Example: versionCode 1 will generate 1001 for armeabi-v7a, 1002 for x86, etc. 254 | def versionCodes = ["armeabi-v7a": 1, "x86": 2, "arm64-v8a": 3, "x86_64": 4] 255 | def abi = output.getFilter(OutputFile.ABI) 256 | if (abi != null) { // null for the universal-debug, universal-release variants 257 | output.versionCodeOverride = 258 | defaultConfig.versionCode * 1000 + versionCodes.get(abi) 259 | } 260 | } 261 | } 262 | 263 | packagingOptions { 264 | pickFirst '**/*/libc++_shared.so' 265 | pickFirst '**/*/libjsc.so' 266 | pickFirst '**/*/libfb.so' 267 | } 268 | } 269 | 270 | dependencies { 271 | implementation fileTree(dir: "libs", include: ["*.jar"]) 272 | 273 | //noinspection GradleDynamicVersion 274 | implementation "com.facebook.react:react-native:+" // From node_modules 275 | 276 | implementation "androidx.swiperefreshlayout:swiperefreshlayout:1.0.0" 277 | 278 | debugImplementation("com.facebook.flipper:flipper:${FLIPPER_VERSION}") { 279 | exclude group:'com.facebook.fbjni' 280 | } 281 | 282 | debugImplementation("com.facebook.flipper:flipper-network-plugin:${FLIPPER_VERSION}") { 283 | exclude group:'com.facebook.flipper' 284 | exclude group:'com.squareup.okhttp3', module:'okhttp' 285 | } 286 | 287 | debugImplementation("com.facebook.flipper:flipper-fresco-plugin:${FLIPPER_VERSION}") { 288 | exclude group:'com.facebook.flipper' 289 | } 290 | 291 | if (enableHermes) { 292 | //noinspection GradleDynamicVersion 293 | implementation("com.facebook.react:hermes-engine:+") { // From node_modules 294 | exclude group:'com.facebook.fbjni' 295 | } 296 | } else { 297 | implementation jscFlavor 298 | } 299 | } 300 | 301 | if (isNewArchitectureEnabled()) { 302 | // If new architecture is enabled, we let you build RN from source 303 | // Otherwise we fallback to a prebuilt .aar bundled in the NPM package. 304 | // This will be applied to all the imported transtitive dependency. 305 | configurations.all { 306 | resolutionStrategy.dependencySubstitution { 307 | substitute(module("com.facebook.react:react-native")) 308 | .using(project(":ReactAndroid")) 309 | .because("On New Architecture we're building React Native from source") 310 | substitute(module("com.facebook.react:hermes-engine")) 311 | .using(project(":ReactAndroid:hermes-engine")) 312 | .because("On New Architecture we're building Hermes from source") 313 | } 314 | } 315 | } 316 | 317 | // Run this once to be able to run the application with BUCK 318 | // puts all compile dependencies into folder libs for BUCK to use 319 | task copyDownloadableDepsToLibs(type: Copy) { 320 | from configurations.implementation 321 | into 'libs' 322 | } 323 | 324 | apply from: file("../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesAppBuildGradle(project) 325 | 326 | def isNewArchitectureEnabled() { 327 | // To opt-in for the New Architecture, you can either: 328 | // - Set `newArchEnabled` to true inside the `gradle.properties` file 329 | // - Invoke gradle with `-newArchEnabled=true` 330 | // - Set an environment variable `ORG_GRADLE_PROJECT_newArchEnabled=true` 331 | return project.hasProperty("newArchEnabled") && project.newArchEnabled == "true" 332 | } 333 | -------------------------------------------------------------------------------- /example/android/app/build_defs.bzl: -------------------------------------------------------------------------------- 1 | """Helper definitions to glob .aar and .jar targets""" 2 | 3 | def create_aar_targets(aarfiles): 4 | for aarfile in aarfiles: 5 | name = "aars__" + aarfile[aarfile.rindex("/") + 1:aarfile.rindex(".aar")] 6 | lib_deps.append(":" + name) 7 | android_prebuilt_aar( 8 | name = name, 9 | aar = aarfile, 10 | ) 11 | 12 | def create_jar_targets(jarfiles): 13 | for jarfile in jarfiles: 14 | name = "jars__" + jarfile[jarfile.rindex("/") + 1:jarfile.rindex(".jar")] 15 | lib_deps.append(":" + name) 16 | prebuilt_jar( 17 | name = name, 18 | binary_jar = jarfile, 19 | ) 20 | -------------------------------------------------------------------------------- /example/android/app/debug.keystore: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/agoldis/react-native-mlkit-ocr/38064ca19f20a498f5e1c8bd32e22efc548ba0b5/example/android/app/debug.keystore -------------------------------------------------------------------------------- /example/android/app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in /usr/local/Cellar/android-sdk/24.3.3/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | -------------------------------------------------------------------------------- /example/android/app/src/debug/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /example/android/app/src/debug/java/com/example/reactnativemlkitocr/ReactNativeFlipper.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Meta Platforms, Inc. and affiliates. 3 | * 4 | *

This source code is licensed under the MIT license found in the LICENSE file in the root 5 | * directory of this source tree. 6 | */ 7 | package com.example.reactnativemlkitocr; 8 | 9 | import android.content.Context; 10 | import com.facebook.flipper.android.AndroidFlipperClient; 11 | import com.facebook.flipper.android.utils.FlipperUtils; 12 | import com.facebook.flipper.core.FlipperClient; 13 | import com.facebook.flipper.plugins.crashreporter.CrashReporterPlugin; 14 | import com.facebook.flipper.plugins.databases.DatabasesFlipperPlugin; 15 | import com.facebook.flipper.plugins.fresco.FrescoFlipperPlugin; 16 | import com.facebook.flipper.plugins.inspector.DescriptorMapping; 17 | import com.facebook.flipper.plugins.inspector.InspectorFlipperPlugin; 18 | import com.facebook.flipper.plugins.network.FlipperOkhttpInterceptor; 19 | import com.facebook.flipper.plugins.network.NetworkFlipperPlugin; 20 | import com.facebook.flipper.plugins.react.ReactFlipperPlugin; 21 | import com.facebook.flipper.plugins.sharedpreferences.SharedPreferencesFlipperPlugin; 22 | import com.facebook.react.ReactInstanceEventListener; 23 | import com.facebook.react.ReactInstanceManager; 24 | import com.facebook.react.bridge.ReactContext; 25 | import com.facebook.react.modules.network.NetworkingModule; 26 | import okhttp3.OkHttpClient; 27 | 28 | public class ReactNativeFlipper { 29 | public static void initializeFlipper(Context context, ReactInstanceManager reactInstanceManager) { 30 | if (FlipperUtils.shouldEnableFlipper(context)) { 31 | final FlipperClient client = AndroidFlipperClient.getInstance(context); 32 | 33 | client.addPlugin(new InspectorFlipperPlugin(context, DescriptorMapping.withDefaults())); 34 | client.addPlugin(new ReactFlipperPlugin()); 35 | client.addPlugin(new DatabasesFlipperPlugin(context)); 36 | client.addPlugin(new SharedPreferencesFlipperPlugin(context)); 37 | client.addPlugin(CrashReporterPlugin.getInstance()); 38 | 39 | NetworkFlipperPlugin networkFlipperPlugin = new NetworkFlipperPlugin(); 40 | NetworkingModule.setCustomClientBuilder( 41 | new NetworkingModule.CustomClientBuilder() { 42 | @Override 43 | public void apply(OkHttpClient.Builder builder) { 44 | builder.addNetworkInterceptor(new FlipperOkhttpInterceptor(networkFlipperPlugin)); 45 | } 46 | }); 47 | client.addPlugin(networkFlipperPlugin); 48 | client.start(); 49 | 50 | // Fresco Plugin needs to ensure that ImagePipelineFactory is initialized 51 | // Hence we run if after all native modules have been initialized 52 | ReactContext reactContext = reactInstanceManager.getCurrentReactContext(); 53 | if (reactContext == null) { 54 | reactInstanceManager.addReactInstanceEventListener( 55 | new ReactInstanceEventListener() { 56 | @Override 57 | public void onReactContextInitialized(ReactContext reactContext) { 58 | reactInstanceManager.removeReactInstanceEventListener(this); 59 | reactContext.runOnNativeModulesQueueThread( 60 | new Runnable() { 61 | @Override 62 | public void run() { 63 | client.addPlugin(new FrescoFlipperPlugin()); 64 | } 65 | }); 66 | } 67 | }); 68 | } else { 69 | client.addPlugin(new FrescoFlipperPlugin()); 70 | } 71 | } 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /example/android/app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | 13 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /example/android/app/src/main/java/com/example/reactnativemlkitocr/MainActivity.java: -------------------------------------------------------------------------------- 1 | package com.example.reactnativemlkitocr; 2 | 3 | import com.facebook.react.ReactActivity; 4 | import com.facebook.react.ReactActivityDelegate; 5 | import com.facebook.react.ReactRootView; 6 | 7 | public class MainActivity extends ReactActivity { 8 | 9 | /** 10 | * Returns the name of the main component registered from JavaScript. This is used to schedule 11 | * rendering of the component. 12 | */ 13 | @Override 14 | protected String getMainComponentName() { 15 | return "MlkitOcrExample"; 16 | } 17 | 18 | /** 19 | * Returns the instance of the {@link ReactActivityDelegate}. There the RootView is created and 20 | * you can specify the rendered you wish to use (Fabric or the older renderer). 21 | */ 22 | @Override 23 | protected ReactActivityDelegate createReactActivityDelegate() { 24 | return new MainActivityDelegate(this, getMainComponentName()); 25 | } 26 | 27 | public static class MainActivityDelegate extends ReactActivityDelegate { 28 | public MainActivityDelegate(ReactActivity activity, String mainComponentName) { 29 | super(activity, mainComponentName); 30 | } 31 | 32 | @Override 33 | protected ReactRootView createRootView() { 34 | ReactRootView reactRootView = new ReactRootView(getContext()); 35 | // If you opted-in for the New Architecture, we enable the Fabric Renderer. 36 | reactRootView.setIsFabric(BuildConfig.IS_NEW_ARCHITECTURE_ENABLED); 37 | return reactRootView; 38 | } 39 | } 40 | } 41 | 42 | -------------------------------------------------------------------------------- /example/android/app/src/main/java/com/example/reactnativemlkitocr/MainApplication.java: -------------------------------------------------------------------------------- 1 | package com.example.reactnativemlkitocr; 2 | 3 | import android.app.Application; 4 | import android.content.Context; 5 | 6 | import com.facebook.react.PackageList; 7 | import com.facebook.react.ReactApplication; 8 | import com.facebook.react.ReactInstanceManager; 9 | import com.facebook.react.ReactNativeHost; 10 | import com.facebook.react.ReactPackage; 11 | import com.facebook.react.config.ReactFeatureFlags; 12 | import com.facebook.soloader.SoLoader; 13 | import com.example.reactnativemlkitocr.newarchitecture.MainApplicationReactNativeHost; 14 | 15 | import java.lang.reflect.InvocationTargetException; 16 | import java.util.List; 17 | 18 | 19 | public class MainApplication extends Application implements ReactApplication { 20 | 21 | private final ReactNativeHost mReactNativeHost = 22 | new ReactNativeHost(this) { 23 | @Override 24 | public boolean getUseDeveloperSupport() { 25 | return BuildConfig.DEBUG; 26 | } 27 | 28 | @Override 29 | protected List getPackages() { 30 | @SuppressWarnings("UnnecessaryLocalVariable") 31 | List packages = new PackageList(this).getPackages(); 32 | // Packages that cannot be autolinked yet can be added manually here, for example: 33 | // packages.add(new MyReactNativePackage()); 34 | return packages; 35 | } 36 | 37 | @Override 38 | protected String getJSMainModuleName() { 39 | return "index"; 40 | } 41 | }; 42 | 43 | private final ReactNativeHost mNewArchitectureNativeHost = 44 | new MainApplicationReactNativeHost(this); 45 | 46 | @Override 47 | public ReactNativeHost getReactNativeHost() { 48 | if (BuildConfig.IS_NEW_ARCHITECTURE_ENABLED) { 49 | return mNewArchitectureNativeHost; 50 | } else { 51 | return mReactNativeHost; 52 | } 53 | } 54 | 55 | @Override 56 | public void onCreate() { 57 | super.onCreate(); 58 | // If you opted-in for the New Architecture, we enable the TurboModule system 59 | ReactFeatureFlags.useTurboModules = BuildConfig.IS_NEW_ARCHITECTURE_ENABLED; 60 | SoLoader.init(this, /* native exopackage */ false); 61 | initializeFlipper(this, getReactNativeHost().getReactInstanceManager()); 62 | } 63 | 64 | /** 65 | * Loads Flipper in React Native templates. Call this in the onCreate method with something like 66 | * initializeFlipper(this, getReactNativeHost().getReactInstanceManager()); 67 | * 68 | * @param context 69 | * @param reactInstanceManager 70 | */ 71 | private static void initializeFlipper( 72 | Context context, ReactInstanceManager reactInstanceManager) { 73 | if (BuildConfig.DEBUG) { 74 | try { 75 | /* 76 | We use reflection here to pick up the class that initializes Flipper, 77 | since Flipper library is not available in release mode 78 | */ 79 | Class aClass = Class.forName("com.example.reactnativemlkitocr.ReactNativeFlipper"); 80 | aClass 81 | .getMethod("initializeFlipper", Context.class, ReactInstanceManager.class) 82 | .invoke(null, context, reactInstanceManager); 83 | } catch (ClassNotFoundException e) { 84 | e.printStackTrace(); 85 | } catch (NoSuchMethodException e) { 86 | e.printStackTrace(); 87 | } catch (IllegalAccessException e) { 88 | e.printStackTrace(); 89 | } catch (InvocationTargetException e) { 90 | e.printStackTrace(); 91 | } 92 | } 93 | } 94 | } 95 | 96 | -------------------------------------------------------------------------------- /example/android/app/src/main/java/com/example/reactnativemlkitocr/newarchitecture/MainApplicationReactNativeHost.java: -------------------------------------------------------------------------------- 1 | package com.example.reactnativemlkitocr.newarchitecture; 2 | 3 | import android.app.Application; 4 | import androidx.annotation.NonNull; 5 | import com.facebook.react.PackageList; 6 | import com.facebook.react.ReactInstanceManager; 7 | import com.facebook.react.ReactNativeHost; 8 | import com.facebook.react.ReactPackage; 9 | import com.facebook.react.ReactPackageTurboModuleManagerDelegate; 10 | import com.facebook.react.bridge.JSIModulePackage; 11 | import com.facebook.react.bridge.JSIModuleProvider; 12 | import com.facebook.react.bridge.JSIModuleSpec; 13 | import com.facebook.react.bridge.JSIModuleType; 14 | import com.facebook.react.bridge.JavaScriptContextHolder; 15 | import com.facebook.react.bridge.ReactApplicationContext; 16 | import com.facebook.react.bridge.UIManager; 17 | import com.facebook.react.fabric.ComponentFactory; 18 | import com.facebook.react.fabric.CoreComponentsRegistry; 19 | import com.facebook.react.fabric.EmptyReactNativeConfig; 20 | import com.facebook.react.fabric.FabricJSIModuleProvider; 21 | import com.facebook.react.uimanager.ViewManagerRegistry; 22 | import com.example.reactnativemlkitocr.BuildConfig; 23 | import com.example.reactnativemlkitocr.newarchitecture.components.MainComponentsRegistry; 24 | import com.example.reactnativemlkitocr.newarchitecture.modules.MainApplicationTurboModuleManagerDelegate; 25 | import java.util.ArrayList; 26 | import java.util.List; 27 | 28 | import com.reactnativemlkitocr.MlkitOcrPackage; 29 | 30 | /** 31 | * A {@link ReactNativeHost} that helps you load everything needed for the New Architecture, both 32 | * TurboModule delegates and the Fabric Renderer. 33 | * 34 | *

Please note that this class is used ONLY if you opt-in for the New Architecture (see the 35 | * `newArchEnabled` property). Is ignored otherwise. 36 | */ 37 | public class MainApplicationReactNativeHost extends ReactNativeHost { 38 | public MainApplicationReactNativeHost(Application application) { 39 | super(application); 40 | } 41 | 42 | @Override 43 | public boolean getUseDeveloperSupport() { 44 | return BuildConfig.DEBUG; 45 | } 46 | 47 | @Override 48 | protected List getPackages() { 49 | List packages = new PackageList(this).getPackages(); 50 | // Packages that cannot be autolinked yet can be added manually here, for example: 51 | // packages.add(new MyReactNativePackage()); 52 | // TurboModules must also be loaded here providing a valid TurboReactPackage implementation: 53 | // packages.add(new TurboReactPackage() { ... }); 54 | // If you have custom Fabric Components, their ViewManagers should also be loaded here 55 | // inside a ReactPackage. 56 | packages.add(new MlkitOcrPackage()); 57 | return packages; 58 | } 59 | 60 | @Override 61 | protected String getJSMainModuleName() { 62 | return "index"; 63 | } 64 | 65 | @NonNull 66 | @Override 67 | protected ReactPackageTurboModuleManagerDelegate.Builder 68 | getReactPackageTurboModuleManagerDelegateBuilder() { 69 | // Here we provide the ReactPackageTurboModuleManagerDelegate Builder. This is necessary 70 | // for the new architecture and to use TurboModules correctly. 71 | return new MainApplicationTurboModuleManagerDelegate.Builder(); 72 | } 73 | 74 | @Override 75 | protected JSIModulePackage getJSIModulePackage() { 76 | return new JSIModulePackage() { 77 | @Override 78 | public List getJSIModules( 79 | final ReactApplicationContext reactApplicationContext, 80 | final JavaScriptContextHolder jsContext) { 81 | final List specs = new ArrayList<>(); 82 | 83 | // Here we provide a new JSIModuleSpec that will be responsible of providing the 84 | // custom Fabric Components. 85 | specs.add( 86 | new JSIModuleSpec() { 87 | @Override 88 | public JSIModuleType getJSIModuleType() { 89 | return JSIModuleType.UIManager; 90 | } 91 | 92 | @Override 93 | public JSIModuleProvider getJSIModuleProvider() { 94 | final ComponentFactory componentFactory = new ComponentFactory(); 95 | CoreComponentsRegistry.register(componentFactory); 96 | 97 | // Here we register a Components Registry. 98 | // The one that is generated with the template contains no components 99 | // and just provides you the one from React Native core. 100 | MainComponentsRegistry.register(componentFactory); 101 | 102 | final ReactInstanceManager reactInstanceManager = getReactInstanceManager(); 103 | 104 | ViewManagerRegistry viewManagerRegistry = 105 | new ViewManagerRegistry( 106 | reactInstanceManager.getOrCreateViewManagers(reactApplicationContext)); 107 | 108 | return new FabricJSIModuleProvider( 109 | reactApplicationContext, 110 | componentFactory, 111 | new EmptyReactNativeConfig(), 112 | viewManagerRegistry); 113 | } 114 | }); 115 | return specs; 116 | } 117 | }; 118 | } 119 | } 120 | -------------------------------------------------------------------------------- /example/android/app/src/main/java/com/example/reactnativemlkitocr/newarchitecture/components/MainComponentsRegistry.java: -------------------------------------------------------------------------------- 1 | package com.example.reactnativemlkitocr.newarchitecture.components; 2 | 3 | import com.facebook.jni.HybridData; 4 | import com.facebook.proguard.annotations.DoNotStrip; 5 | import com.facebook.react.fabric.ComponentFactory; 6 | import com.facebook.soloader.SoLoader; 7 | 8 | /** 9 | * Class responsible to load the custom Fabric Components. This class has native methods and needs a 10 | * corresponding C++ implementation/header file to work correctly (already placed inside the jni/ 11 | * folder for you). 12 | * 13 | *

Please note that this class is used ONLY if you opt-in for the New Architecture (see the 14 | * `newArchEnabled` property). Is ignored otherwise. 15 | */ 16 | @DoNotStrip 17 | public class MainComponentsRegistry { 18 | static { 19 | SoLoader.loadLibrary("fabricjni"); 20 | } 21 | 22 | @DoNotStrip private final HybridData mHybridData; 23 | 24 | @DoNotStrip 25 | private native HybridData initHybrid(ComponentFactory componentFactory); 26 | 27 | @DoNotStrip 28 | private MainComponentsRegistry(ComponentFactory componentFactory) { 29 | mHybridData = initHybrid(componentFactory); 30 | } 31 | 32 | @DoNotStrip 33 | public static MainComponentsRegistry register(ComponentFactory componentFactory) { 34 | return new MainComponentsRegistry(componentFactory); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /example/android/app/src/main/java/com/example/reactnativemlkitocr/newarchitecture/modules/MainApplicationTurboModuleManagerDelegate.java: -------------------------------------------------------------------------------- 1 | package com.example.reactnativemlkitocr.newarchitecture.modules; 2 | 3 | import com.facebook.jni.HybridData; 4 | import com.facebook.react.ReactPackage; 5 | import com.facebook.react.ReactPackageTurboModuleManagerDelegate; 6 | import com.facebook.react.bridge.ReactApplicationContext; 7 | import com.facebook.soloader.SoLoader; 8 | import java.util.List; 9 | 10 | /** 11 | * Class responsible to load the TurboModules. This class has native methods and needs a 12 | * corresponding C++ implementation/header file to work correctly (already placed inside the jni/ 13 | * folder for you). 14 | * 15 | *

Please note that this class is used ONLY if you opt-in for the New Architecture (see the 16 | * `newArchEnabled` property). Is ignored otherwise. 17 | */ 18 | public class MainApplicationTurboModuleManagerDelegate 19 | extends ReactPackageTurboModuleManagerDelegate { 20 | 21 | private static volatile boolean sIsSoLibraryLoaded; 22 | 23 | protected MainApplicationTurboModuleManagerDelegate( 24 | ReactApplicationContext reactApplicationContext, List packages) { 25 | super(reactApplicationContext, packages); 26 | } 27 | 28 | protected native HybridData initHybrid(); 29 | 30 | native boolean canCreateTurboModule(String moduleName); 31 | 32 | public static class Builder extends ReactPackageTurboModuleManagerDelegate.Builder { 33 | protected MainApplicationTurboModuleManagerDelegate build( 34 | ReactApplicationContext context, List packages) { 35 | return new MainApplicationTurboModuleManagerDelegate(context, packages); 36 | } 37 | } 38 | 39 | @Override 40 | protected synchronized void maybeLoadOtherSoLibraries() { 41 | if (!sIsSoLibraryLoaded) { 42 | // If you change the name of your application .so file in the Android.mk file, 43 | // make sure you update the name here as well. 44 | SoLoader.loadLibrary("mlkitocrexample_appmodules"); 45 | sIsSoLibraryLoaded = true; 46 | } 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /example/android/app/src/main/jni/Android.mk: -------------------------------------------------------------------------------- 1 | THIS_DIR := $(call my-dir) 2 | 3 | include $(REACT_ANDROID_DIR)/Android-prebuilt.mk 4 | 5 | # MLKitOCR 6 | include $(REACT_ANDROID_DIR)/../../react-native-mlkit-ocr/android/build/generated/source/codegen/jni/Android.mk 7 | 8 | include $(CLEAR_VARS) 9 | 10 | LOCAL_PATH := $(THIS_DIR) 11 | 12 | # You can customize the name of your application .so file here. 13 | LOCAL_MODULE := mlkitocrexample_appmodules 14 | 15 | LOCAL_C_INCLUDES := $(LOCAL_PATH) 16 | LOCAL_SRC_FILES := $(wildcard $(LOCAL_PATH)/*.cpp) 17 | LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH) 18 | 19 | LOCAL_SHARED_LIBRARIES := \ 20 | libfabricjni \ 21 | libfbjni \ 22 | libfolly_runtime \ 23 | libglog \ 24 | libjsi \ 25 | libreact_codegen_rncore \ 26 | libreact_debug \ 27 | libreact_nativemodule_core \ 28 | libreact_render_componentregistry \ 29 | libreact_render_core \ 30 | libreact_render_debug \ 31 | libreact_render_graphics \ 32 | librrc_view \ 33 | libruntimeexecutor \ 34 | libturbomodulejsijni \ 35 | libyoga 36 | 37 | # MLKitOCR 38 | LOCAL_SHARED_LIBRARIES += libreact_codegen_mlkitocr 39 | 40 | LOCAL_CFLAGS := -DLOG_TAG=\"ReactNative\" -fexceptions -frtti -std=c++17 -Wall 41 | 42 | include $(BUILD_SHARED_LIBRARY) 43 | -------------------------------------------------------------------------------- /example/android/app/src/main/jni/MainApplicationModuleProvider.cpp: -------------------------------------------------------------------------------- 1 | #include "MainApplicationModuleProvider.h" 2 | 3 | #include 4 | #include 5 | 6 | namespace facebook { 7 | namespace react { 8 | 9 | std::shared_ptr MainApplicationModuleProvider( 10 | const std::string moduleName, 11 | const JavaTurboModule::InitParams ¶ms) { 12 | // Here you can provide your own module provider for TurboModules coming from 13 | // either your application or from external libraries. The approach to follow 14 | // is similar to the following (for a library called `samplelibrary`: 15 | // 16 | auto module = mlkitocr_ModuleProvider(moduleName, params); 17 | if (module != nullptr) { 18 | return module; 19 | } 20 | return rncore_ModuleProvider(moduleName, params); 21 | } 22 | 23 | } // namespace react 24 | } // namespace facebook 25 | -------------------------------------------------------------------------------- /example/android/app/src/main/jni/MainApplicationModuleProvider.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | #include 7 | 8 | namespace facebook { 9 | namespace react { 10 | 11 | std::shared_ptr MainApplicationModuleProvider( 12 | const std::string moduleName, 13 | const JavaTurboModule::InitParams ¶ms); 14 | 15 | } // namespace react 16 | } // namespace facebook 17 | -------------------------------------------------------------------------------- /example/android/app/src/main/jni/MainApplicationTurboModuleManagerDelegate.cpp: -------------------------------------------------------------------------------- 1 | #include "MainApplicationTurboModuleManagerDelegate.h" 2 | #include "MainApplicationModuleProvider.h" 3 | 4 | namespace facebook { 5 | namespace react { 6 | 7 | jni::local_ref 8 | MainApplicationTurboModuleManagerDelegate::initHybrid( 9 | jni::alias_ref) { 10 | return makeCxxInstance(); 11 | } 12 | 13 | void MainApplicationTurboModuleManagerDelegate::registerNatives() { 14 | registerHybrid({ 15 | makeNativeMethod( 16 | "initHybrid", MainApplicationTurboModuleManagerDelegate::initHybrid), 17 | makeNativeMethod( 18 | "canCreateTurboModule", 19 | MainApplicationTurboModuleManagerDelegate::canCreateTurboModule), 20 | }); 21 | } 22 | 23 | std::shared_ptr 24 | MainApplicationTurboModuleManagerDelegate::getTurboModule( 25 | const std::string name, 26 | const std::shared_ptr jsInvoker) { 27 | // Not implemented yet: provide pure-C++ NativeModules here. 28 | return nullptr; 29 | } 30 | 31 | std::shared_ptr 32 | MainApplicationTurboModuleManagerDelegate::getTurboModule( 33 | const std::string name, 34 | const JavaTurboModule::InitParams ¶ms) { 35 | return MainApplicationModuleProvider(name, params); 36 | } 37 | 38 | bool MainApplicationTurboModuleManagerDelegate::canCreateTurboModule( 39 | std::string name) { 40 | return getTurboModule(name, nullptr) != nullptr || 41 | getTurboModule(name, {.moduleName = name}) != nullptr; 42 | } 43 | 44 | } // namespace react 45 | } // namespace facebook 46 | -------------------------------------------------------------------------------- /example/android/app/src/main/jni/MainApplicationTurboModuleManagerDelegate.h: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include 5 | #include 6 | 7 | namespace facebook { 8 | namespace react { 9 | 10 | class MainApplicationTurboModuleManagerDelegate 11 | : public jni::HybridClass< 12 | MainApplicationTurboModuleManagerDelegate, 13 | TurboModuleManagerDelegate> { 14 | public: 15 | // Adapt it to the package you used for your Java class. 16 | static constexpr auto kJavaDescriptor = 17 | "Lcom/example/reactnativemlkitocr/newarchitecture/modules/MainApplicationTurboModuleManagerDelegate;"; 18 | 19 | static jni::local_ref initHybrid(jni::alias_ref); 20 | 21 | static void registerNatives(); 22 | 23 | std::shared_ptr getTurboModule( 24 | const std::string name, 25 | const std::shared_ptr jsInvoker) override; 26 | std::shared_ptr getTurboModule( 27 | const std::string name, 28 | const JavaTurboModule::InitParams ¶ms) override; 29 | 30 | /** 31 | * Test-only method. Allows user to verify whether a TurboModule can be 32 | * created by instances of this class. 33 | */ 34 | bool canCreateTurboModule(std::string name); 35 | }; 36 | 37 | } // namespace react 38 | } // namespace facebook 39 | -------------------------------------------------------------------------------- /example/android/app/src/main/jni/MainComponentsRegistry.cpp: -------------------------------------------------------------------------------- 1 | #include "MainComponentsRegistry.h" 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | namespace facebook { 9 | namespace react { 10 | 11 | MainComponentsRegistry::MainComponentsRegistry(ComponentFactory *delegate) {} 12 | 13 | std::shared_ptr 14 | MainComponentsRegistry::sharedProviderRegistry() { 15 | auto providerRegistry = CoreComponentsRegistry::sharedProviderRegistry(); 16 | 17 | // Custom Fabric Components go here. You can register custom 18 | // components coming from your App or from 3rd party libraries here. 19 | // 20 | // providerRegistry->add(concreteComponentDescriptorProvider< 21 | // AocViewerComponentDescriptor>()); 22 | return providerRegistry; 23 | } 24 | 25 | jni::local_ref 26 | MainComponentsRegistry::initHybrid( 27 | jni::alias_ref, 28 | ComponentFactory *delegate) { 29 | auto instance = makeCxxInstance(delegate); 30 | 31 | auto buildRegistryFunction = 32 | [](EventDispatcher::Weak const &eventDispatcher, 33 | ContextContainer::Shared const &contextContainer) 34 | -> ComponentDescriptorRegistry::Shared { 35 | auto registry = MainComponentsRegistry::sharedProviderRegistry() 36 | ->createComponentDescriptorRegistry( 37 | {eventDispatcher, contextContainer}); 38 | 39 | auto mutableRegistry = 40 | std::const_pointer_cast(registry); 41 | 42 | mutableRegistry->setFallbackComponentDescriptor( 43 | std::make_shared( 44 | ComponentDescriptorParameters{ 45 | eventDispatcher, contextContainer, nullptr})); 46 | 47 | return registry; 48 | }; 49 | 50 | delegate->buildRegistryFunction = buildRegistryFunction; 51 | return instance; 52 | } 53 | 54 | void MainComponentsRegistry::registerNatives() { 55 | registerHybrid({ 56 | makeNativeMethod("initHybrid", MainComponentsRegistry::initHybrid), 57 | }); 58 | } 59 | 60 | } // namespace react 61 | } // namespace facebook 62 | -------------------------------------------------------------------------------- /example/android/app/src/main/jni/MainComponentsRegistry.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | namespace facebook { 9 | namespace react { 10 | 11 | class MainComponentsRegistry 12 | : public facebook::jni::HybridClass { 13 | public: 14 | // Adapt it to the package you used for your Java class. 15 | constexpr static auto kJavaDescriptor = 16 | "Lcom/example/reactnativemlkitocr/newarchitecture/components/MainComponentsRegistry;"; 17 | 18 | static void registerNatives(); 19 | 20 | MainComponentsRegistry(ComponentFactory *delegate); 21 | 22 | private: 23 | static std::shared_ptr 24 | sharedProviderRegistry(); 25 | 26 | static jni::local_ref initHybrid( 27 | jni::alias_ref, 28 | ComponentFactory *delegate); 29 | }; 30 | 31 | } // namespace react 32 | } // namespace facebook 33 | -------------------------------------------------------------------------------- /example/android/app/src/main/jni/OnLoad.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "MainApplicationTurboModuleManagerDelegate.h" 3 | #include "MainComponentsRegistry.h" 4 | 5 | JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM *vm, void *) { 6 | return facebook::jni::initialize(vm, [] { 7 | facebook::react::MainApplicationTurboModuleManagerDelegate:: 8 | registerNatives(); 9 | facebook::react::MainComponentsRegistry::registerNatives(); 10 | }); 11 | } 12 | -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/agoldis/react-native-mlkit-ocr/38064ca19f20a498f5e1c8bd32e22efc548ba0b5/example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-hdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/agoldis/react-native-mlkit-ocr/38064ca19f20a498f5e1c8bd32e22efc548ba0b5/example/android/app/src/main/res/mipmap-hdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/agoldis/react-native-mlkit-ocr/38064ca19f20a498f5e1c8bd32e22efc548ba0b5/example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-mdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/agoldis/react-native-mlkit-ocr/38064ca19f20a498f5e1c8bd32e22efc548ba0b5/example/android/app/src/main/res/mipmap-mdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/agoldis/react-native-mlkit-ocr/38064ca19f20a498f5e1c8bd32e22efc548ba0b5/example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/agoldis/react-native-mlkit-ocr/38064ca19f20a498f5e1c8bd32e22efc548ba0b5/example/android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/agoldis/react-native-mlkit-ocr/38064ca19f20a498f5e1c8bd32e22efc548ba0b5/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/agoldis/react-native-mlkit-ocr/38064ca19f20a498f5e1c8bd32e22efc548ba0b5/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/agoldis/react-native-mlkit-ocr/38064ca19f20a498f5e1c8bd32e22efc548ba0b5/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/agoldis/react-native-mlkit-ocr/38064ca19f20a498f5e1c8bd32e22efc548ba0b5/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | MlkitOcr Example 3 | 4 | -------------------------------------------------------------------------------- /example/android/app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /example/android/build.gradle: -------------------------------------------------------------------------------- 1 | import org.apache.tools.ant.taskdefs.condition.Os 2 | 3 | // Top-level build file where you can add configuration options common to all sub-projects/modules. 4 | 5 | buildscript { 6 | ext { 7 | buildToolsVersion = "31.0.0" 8 | minSdkVersion = 21 9 | compileSdkVersion = 31 10 | targetSdkVersion = 31 11 | 12 | if (System.properties['os.arch'] == "aarch64") { 13 | // For M1 Users we need to use the NDK 24 which added support for aarch64 14 | ndkVersion = "24.0.8215888" 15 | } else if (Os.isFamily(Os.FAMILY_WINDOWS)) { 16 | // For Android Users, we need to use NDK 23, otherwise the build will 17 | // fail due to paths longer than the OS limit 18 | ndkVersion = "23.1.7779620" 19 | } else { 20 | // Otherwise we default to the side-by-side NDK version from AGP. 21 | ndkVersion = "21.4.7075529" 22 | } 23 | } 24 | repositories { 25 | google() 26 | mavenCentral() 27 | } 28 | dependencies { 29 | classpath("com.android.tools.build:gradle:7.2.2") 30 | classpath("com.facebook.react:react-native-gradle-plugin") 31 | classpath("de.undercouch:gradle-download-task:5.0.1") 32 | // NOTE: Do not place your application dependencies here; they belong 33 | // in the individual module build.gradle files 34 | } 35 | } 36 | 37 | allprojects { 38 | repositories { 39 | maven { 40 | // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm 41 | url("$rootDir/../node_modules/react-native/android") 42 | } 43 | maven { 44 | // Android JSC is installed from npm 45 | url("$rootDir/../node_modules/jsc-android/dist") 46 | } 47 | mavenCentral { 48 | // We don't want to fetch react-native from Maven Central as there are 49 | // older versions over there. 50 | content { 51 | excludeGroup "com.facebook.react" 52 | } 53 | } 54 | google() 55 | maven { url 'https://www.jitpack.io' } 56 | } 57 | } 58 | 59 | wrapper { 60 | gradleVersion = "7.3.3" 61 | distributionType = Wrapper.DistributionType.ALL 62 | } 63 | -------------------------------------------------------------------------------- /example/android/gradle.properties: -------------------------------------------------------------------------------- 1 | # Project-wide Gradle settings. 2 | 3 | # IDE (e.g. Android Studio) users: 4 | # Gradle settings configured through the IDE *will override* 5 | # any settings specified in this file. 6 | 7 | # For more details on how to configure your build environment visit 8 | # http://www.gradle.org/docs/current/userguide/build_environment.html 9 | 10 | # Specifies the JVM arguments used for the daemon process. 11 | # The setting is particularly useful for tweaking memory settings. 12 | # Default value: -Xmx512m -XX:MaxMetaspaceSize=256m 13 | org.gradle.jvmargs=-Xmx2048m -XX:MaxMetaspaceSize=512m 14 | 15 | # When configured, Gradle will run in incubating parallel mode. 16 | # This option should only be used with decoupled projects. More details, visit 17 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 18 | # org.gradle.parallel=true 19 | 20 | # AndroidX package structure to make it clearer which packages are bundled with the 21 | # Android operating system, and which are packaged with your app's APK 22 | # https://developer.android.com/topic/libraries/support-library/androidx-rn 23 | android.useAndroidX=true 24 | # Automatically convert third-party libraries to use AndroidX 25 | android.enableJetifier=true 26 | 27 | # Version of flipper SDK to use with React Native 28 | FLIPPER_VERSION=0.125.0 29 | 30 | # Use this property to specify which architecture you want to build. 31 | # You can also override it from the CLI using 32 | # ./gradlew -PreactNativeArchitectures=x86_64 33 | reactNativeArchitectures=armeabi-v7a,arm64-v8a,x86,x86_64 34 | 35 | # Use this property to enable support to the new architecture. 36 | # This will allow you to use TurboModules and the Fabric render in 37 | # your application. You should enable this flag either if you want 38 | # to write custom TurboModules/Fabric components OR use libraries that 39 | # are providing them. 40 | newArchEnabled=false 41 | -------------------------------------------------------------------------------- /example/android/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/agoldis/react-native-mlkit-ocr/38064ca19f20a498f5e1c8bd32e22efc548ba0b5/example/android/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /example/android/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-all.zip 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | -------------------------------------------------------------------------------- /example/android/gradlew: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # 4 | # Copyright © 2015-2021 the original authors. 5 | # 6 | # Licensed under the Apache License, Version 2.0 (the "License"); 7 | # you may not use this file except in compliance with the License. 8 | # You may obtain a copy of the License at 9 | # 10 | # https://www.apache.org/licenses/LICENSE-2.0 11 | # 12 | # Unless required by applicable law or agreed to in writing, software 13 | # distributed under the License is distributed on an "AS IS" BASIS, 14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | # See the License for the specific language governing permissions and 16 | # limitations under the License. 17 | # 18 | 19 | ############################################################################## 20 | # 21 | # Gradle start up script for POSIX generated by Gradle. 22 | # 23 | # Important for running: 24 | # 25 | # (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is 26 | # noncompliant, but you have some other compliant shell such as ksh or 27 | # bash, then to run this script, type that shell name before the whole 28 | # command line, like: 29 | # 30 | # ksh Gradle 31 | # 32 | # Busybox and similar reduced shells will NOT work, because this script 33 | # requires all of these POSIX shell features: 34 | # * functions; 35 | # * expansions «$var», «${var}», «${var:-default}», «${var+SET}», 36 | # «${var#prefix}», «${var%suffix}», and «$( cmd )»; 37 | # * compound commands having a testable exit status, especially «case»; 38 | # * various built-in commands including «command», «set», and «ulimit». 39 | # 40 | # Important for patching: 41 | # 42 | # (2) This script targets any POSIX shell, so it avoids extensions provided 43 | # by Bash, Ksh, etc; in particular arrays are avoided. 44 | # 45 | # The "traditional" practice of packing multiple parameters into a 46 | # space-separated string is a well documented source of bugs and security 47 | # problems, so this is (mostly) avoided, by progressively accumulating 48 | # options in "$@", and eventually passing that to Java. 49 | # 50 | # Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, 51 | # and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; 52 | # see the in-line comments for details. 53 | # 54 | # There are tweaks for specific operating systems such as AIX, CygWin, 55 | # Darwin, MinGW, and NonStop. 56 | # 57 | # (3) This script is generated from the Groovy template 58 | # https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt 59 | # within the Gradle project. 60 | # 61 | # You can find Gradle at https://github.com/gradle/gradle/. 62 | # 63 | ############################################################################## 64 | 65 | # Attempt to set APP_HOME 66 | 67 | # Resolve links: $0 may be a link 68 | app_path=$0 69 | 70 | # Need this for daisy-chained symlinks. 71 | while 72 | APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path 73 | [ -h "$app_path" ] 74 | do 75 | ls=$( ls -ld "$app_path" ) 76 | link=${ls#*' -> '} 77 | case $link in #( 78 | /*) app_path=$link ;; #( 79 | *) app_path=$APP_HOME$link ;; 80 | esac 81 | done 82 | 83 | APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit 84 | 85 | APP_NAME="Gradle" 86 | APP_BASE_NAME=${0##*/} 87 | 88 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 89 | DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' 90 | 91 | # Use the maximum available, or set MAX_FD != -1 to use that value. 92 | MAX_FD=maximum 93 | 94 | warn () { 95 | echo "$*" 96 | } >&2 97 | 98 | die () { 99 | echo 100 | echo "$*" 101 | echo 102 | exit 1 103 | } >&2 104 | 105 | # OS specific support (must be 'true' or 'false'). 106 | cygwin=false 107 | msys=false 108 | darwin=false 109 | nonstop=false 110 | case "$( uname )" in #( 111 | CYGWIN* ) cygwin=true ;; #( 112 | Darwin* ) darwin=true ;; #( 113 | MSYS* | MINGW* ) msys=true ;; #( 114 | NONSTOP* ) nonstop=true ;; 115 | esac 116 | 117 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 118 | 119 | 120 | # Determine the Java command to use to start the JVM. 121 | if [ -n "$JAVA_HOME" ] ; then 122 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 123 | # IBM's JDK on AIX uses strange locations for the executables 124 | JAVACMD=$JAVA_HOME/jre/sh/java 125 | else 126 | JAVACMD=$JAVA_HOME/bin/java 127 | fi 128 | if [ ! -x "$JAVACMD" ] ; then 129 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 130 | 131 | Please set the JAVA_HOME variable in your environment to match the 132 | location of your Java installation." 133 | fi 134 | else 135 | JAVACMD=java 136 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 137 | 138 | Please set the JAVA_HOME variable in your environment to match the 139 | location of your Java installation." 140 | fi 141 | 142 | # Increase the maximum file descriptors if we can. 143 | if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then 144 | case $MAX_FD in #( 145 | max*) 146 | MAX_FD=$( ulimit -H -n ) || 147 | warn "Could not query maximum file descriptor limit" 148 | esac 149 | case $MAX_FD in #( 150 | '' | soft) :;; #( 151 | *) 152 | ulimit -n "$MAX_FD" || 153 | warn "Could not set maximum file descriptor limit to $MAX_FD" 154 | esac 155 | fi 156 | 157 | # Collect all arguments for the java command, stacking in reverse order: 158 | # * args from the command line 159 | # * the main class name 160 | # * -classpath 161 | # * -D...appname settings 162 | # * --module-path (only if needed) 163 | # * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. 164 | 165 | # For Cygwin or MSYS, switch paths to Windows format before running java 166 | if "$cygwin" || "$msys" ; then 167 | APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) 168 | CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) 169 | 170 | JAVACMD=$( cygpath --unix "$JAVACMD" ) 171 | 172 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 173 | for arg do 174 | if 175 | case $arg in #( 176 | -*) false ;; # don't mess with options #( 177 | /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath 178 | [ -e "$t" ] ;; #( 179 | *) false ;; 180 | esac 181 | then 182 | arg=$( cygpath --path --ignore --mixed "$arg" ) 183 | fi 184 | # Roll the args list around exactly as many times as the number of 185 | # args, so each arg winds up back in the position where it started, but 186 | # possibly modified. 187 | # 188 | # NB: a `for` loop captures its iteration list before it begins, so 189 | # changing the positional parameters here affects neither the number of 190 | # iterations, nor the values presented in `arg`. 191 | shift # remove old arg 192 | set -- "$@" "$arg" # push replacement arg 193 | done 194 | fi 195 | 196 | # Collect all arguments for the java command; 197 | # * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of 198 | # shell script including quotes and variable substitutions, so put them in 199 | # double quotes to make sure that they get re-expanded; and 200 | # * put everything else in single quotes, so that it's not re-expanded. 201 | 202 | set -- \ 203 | "-Dorg.gradle.appname=$APP_BASE_NAME" \ 204 | -classpath "$CLASSPATH" \ 205 | org.gradle.wrapper.GradleWrapperMain \ 206 | "$@" 207 | 208 | # Use "xargs" to parse quoted args. 209 | # 210 | # With -n1 it outputs one arg per line, with the quotes and backslashes removed. 211 | # 212 | # In Bash we could simply go: 213 | # 214 | # readarray ARGS < <( xargs -n1 <<<"$var" ) && 215 | # set -- "${ARGS[@]}" "$@" 216 | # 217 | # but POSIX shell has neither arrays nor command substitution, so instead we 218 | # post-process each arg (as a line of input to sed) to backslash-escape any 219 | # character that might be a shell metacharacter, then use eval to reverse 220 | # that process (while maintaining the separation between arguments), and wrap 221 | # the whole thing up as a single "set" statement. 222 | # 223 | # This will of course break if any of these variables contains a newline or 224 | # an unmatched quote. 225 | # 226 | 227 | eval "set -- $( 228 | printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | 229 | xargs -n1 | 230 | sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | 231 | tr '\n' ' ' 232 | )" '"$@"' 233 | 234 | exec "$JAVACMD" "$@" 235 | -------------------------------------------------------------------------------- /example/android/gradlew.bat: -------------------------------------------------------------------------------- 1 | @rem 2 | @rem Copyright 2015 the original author or authors. 3 | @rem 4 | @rem Licensed under the Apache License, Version 2.0 (the "License"); 5 | @rem you may not use this file except in compliance with the License. 6 | @rem You may obtain a copy of the License at 7 | @rem 8 | @rem https://www.apache.org/licenses/LICENSE-2.0 9 | @rem 10 | @rem Unless required by applicable law or agreed to in writing, software 11 | @rem distributed under the License is distributed on an "AS IS" BASIS, 12 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | @rem See the License for the specific language governing permissions and 14 | @rem limitations under the License. 15 | @rem 16 | 17 | @if "%DEBUG%" == "" @echo off 18 | @rem ########################################################################## 19 | @rem 20 | @rem Gradle startup script for Windows 21 | @rem 22 | @rem ########################################################################## 23 | 24 | @rem Set local scope for the variables with windows NT shell 25 | if "%OS%"=="Windows_NT" setlocal 26 | 27 | set DIRNAME=%~dp0 28 | if "%DIRNAME%" == "" set DIRNAME=. 29 | set APP_BASE_NAME=%~n0 30 | set APP_HOME=%DIRNAME% 31 | 32 | @rem Resolve any "." and ".." in APP_HOME to make it shorter. 33 | for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi 34 | 35 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 36 | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" 37 | 38 | @rem Find java.exe 39 | if defined JAVA_HOME goto findJavaFromJavaHome 40 | 41 | set JAVA_EXE=java.exe 42 | %JAVA_EXE% -version >NUL 2>&1 43 | if "%ERRORLEVEL%" == "0" goto execute 44 | 45 | echo. 46 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 47 | echo. 48 | echo Please set the JAVA_HOME variable in your environment to match the 49 | echo location of your Java installation. 50 | 51 | goto fail 52 | 53 | :findJavaFromJavaHome 54 | set JAVA_HOME=%JAVA_HOME:"=% 55 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 56 | 57 | if exist "%JAVA_EXE%" goto execute 58 | 59 | echo. 60 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 61 | echo. 62 | echo Please set the JAVA_HOME variable in your environment to match the 63 | echo location of your Java installation. 64 | 65 | goto fail 66 | 67 | :execute 68 | @rem Setup the command line 69 | 70 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 71 | 72 | 73 | @rem Execute Gradle 74 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* 75 | 76 | :end 77 | @rem End local scope for the variables with windows NT shell 78 | if "%ERRORLEVEL%"=="0" goto mainEnd 79 | 80 | :fail 81 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 82 | rem the _cmd.exe /c_ return code! 83 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 84 | exit /b 1 85 | 86 | :mainEnd 87 | if "%OS%"=="Windows_NT" endlocal 88 | 89 | :omega 90 | -------------------------------------------------------------------------------- /example/android/settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'MlkitOcrExample' 2 | apply from: file("../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesSettingsGradle(settings) 3 | include ':app' 4 | includeBuild('../node_modules/react-native-gradle-plugin') 5 | 6 | if (settings.hasProperty("newArchEnabled") && settings.newArchEnabled == "true") { 7 | include(":ReactAndroid") 8 | project(":ReactAndroid").projectDir = file('../node_modules/react-native/ReactAndroid') 9 | include(":ReactAndroid:hermes-engine") 10 | project(":ReactAndroid:hermes-engine").projectDir = file('../node_modules/react-native/ReactAndroid/hermes-engine') 11 | } 12 | 13 | include ':reactnativemlkitocr' 14 | project(':reactnativemlkitocr').projectDir = new File(rootProject.projectDir, '../../android') 15 | 16 | -------------------------------------------------------------------------------- /example/app.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "MlkitOcrExample", 3 | "displayName": "MlkitOcr Example" 4 | } 5 | -------------------------------------------------------------------------------- /example/babel.config.js: -------------------------------------------------------------------------------- 1 | const path = require('path'); 2 | const pak = require('../package.json'); 3 | 4 | module.exports = { 5 | presets: ['module:metro-react-native-babel-preset'], 6 | plugins: [ 7 | [ 8 | 'module-resolver', 9 | { 10 | alias: { 11 | [pak.name]: path.join(__dirname, '..', pak.source), 12 | }, 13 | }, 14 | ], 15 | ], 16 | }; 17 | -------------------------------------------------------------------------------- /example/index.js: -------------------------------------------------------------------------------- 1 | import { AppRegistry } from 'react-native'; 2 | import App from './src/App'; 3 | import { name as appName } from './app.json'; 4 | 5 | AppRegistry.registerComponent(appName, () => App); 6 | -------------------------------------------------------------------------------- /example/ios/MlkitOcrExample.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 13B07FBC1A68108700A75B9A /* AppDelegate.mm in Sources */ = {isa = PBXBuildFile; fileRef = 13B07FB01A68108700A75B9A /* AppDelegate.mm */; }; 11 | 13B07FBD1A68108700A75B9A /* LaunchScreen.xib in Resources */ = {isa = PBXBuildFile; fileRef = 13B07FB11A68108700A75B9A /* LaunchScreen.xib */; }; 12 | 13B07FBF1A68108700A75B9A /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 13B07FB51A68108700A75B9A /* Images.xcassets */; }; 13 | 13B07FC11A68108700A75B9A /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 13B07FB71A68108700A75B9A /* main.m */; }; 14 | FB1273F49F1473D89305AF6D /* libPods-MlkitOcrExample.a in Frameworks */ = {isa = PBXBuildFile; fileRef = A68A76C45A979D57EA8D0EBF /* libPods-MlkitOcrExample.a */; }; 15 | /* End PBXBuildFile section */ 16 | 17 | /* Begin PBXFileReference section */ 18 | 008F07F21AC5B25A0029DE68 /* main.jsbundle */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = main.jsbundle; sourceTree = ""; }; 19 | 083588E7D94D511ABDE58EBE /* Pods-MlkitOcrExample.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-MlkitOcrExample.debug.xcconfig"; path = "Target Support Files/Pods-MlkitOcrExample/Pods-MlkitOcrExample.debug.xcconfig"; sourceTree = ""; }; 20 | 13B07F961A680F5B00A75B9A /* MlkitOcrExample.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; name = MlkitOcrExample.app; path = MlkitOcrExample.app; sourceTree = BUILT_PRODUCTS_DIR; }; 21 | 13B07FAF1A68108700A75B9A /* AppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = AppDelegate.h; path = MlkitOcrExample/AppDelegate.h; sourceTree = ""; }; 22 | 13B07FB01A68108700A75B9A /* AppDelegate.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = AppDelegate.mm; path = MlkitOcrExample/AppDelegate.mm; sourceTree = ""; }; 23 | 13B07FB21A68108700A75B9A /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/LaunchScreen.xib; sourceTree = ""; }; 24 | 13B07FB51A68108700A75B9A /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; name = Images.xcassets; path = MlkitOcrExample/Images.xcassets; sourceTree = ""; }; 25 | 13B07FB61A68108700A75B9A /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = Info.plist; path = MlkitOcrExample/Info.plist; sourceTree = ""; }; 26 | 13B07FB71A68108700A75B9A /* main.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = main.m; path = MlkitOcrExample/main.m; sourceTree = ""; }; 27 | 175DA7A79273A18334856C2C /* Pods-MlkitOcrExample.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-MlkitOcrExample.release.xcconfig"; path = "Target Support Files/Pods-MlkitOcrExample/Pods-MlkitOcrExample.release.xcconfig"; sourceTree = ""; }; 28 | A68A76C45A979D57EA8D0EBF /* libPods-MlkitOcrExample.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-MlkitOcrExample.a"; sourceTree = BUILT_PRODUCTS_DIR; }; 29 | ED297162215061F000B7C4FE /* JavaScriptCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = JavaScriptCore.framework; path = System/Library/Frameworks/JavaScriptCore.framework; sourceTree = SDKROOT; }; 30 | /* End PBXFileReference section */ 31 | 32 | /* Begin PBXFrameworksBuildPhase section */ 33 | 13B07F8C1A680F5B00A75B9A /* Frameworks */ = { 34 | isa = PBXFrameworksBuildPhase; 35 | buildActionMask = 2147483647; 36 | files = ( 37 | FB1273F49F1473D89305AF6D /* libPods-MlkitOcrExample.a in Frameworks */, 38 | ); 39 | runOnlyForDeploymentPostprocessing = 0; 40 | }; 41 | /* End PBXFrameworksBuildPhase section */ 42 | 43 | /* Begin PBXGroup section */ 44 | 13B07FAE1A68108700A75B9A /* MlkitOcrExample */ = { 45 | isa = PBXGroup; 46 | children = ( 47 | 008F07F21AC5B25A0029DE68 /* main.jsbundle */, 48 | 13B07FAF1A68108700A75B9A /* AppDelegate.h */, 49 | 13B07FB01A68108700A75B9A /* AppDelegate.mm */, 50 | 13B07FB51A68108700A75B9A /* Images.xcassets */, 51 | 13B07FB61A68108700A75B9A /* Info.plist */, 52 | 13B07FB11A68108700A75B9A /* LaunchScreen.xib */, 53 | 13B07FB71A68108700A75B9A /* main.m */, 54 | ); 55 | name = MlkitOcrExample; 56 | sourceTree = ""; 57 | }; 58 | 1CFFDEF7170271C97B8B7E5A /* Pods */ = { 59 | isa = PBXGroup; 60 | children = ( 61 | 083588E7D94D511ABDE58EBE /* Pods-MlkitOcrExample.debug.xcconfig */, 62 | 175DA7A79273A18334856C2C /* Pods-MlkitOcrExample.release.xcconfig */, 63 | ); 64 | path = Pods; 65 | sourceTree = ""; 66 | }; 67 | 2D16E6871FA4F8E400B85C8A /* Frameworks */ = { 68 | isa = PBXGroup; 69 | children = ( 70 | ED297162215061F000B7C4FE /* JavaScriptCore.framework */, 71 | A68A76C45A979D57EA8D0EBF /* libPods-MlkitOcrExample.a */, 72 | ); 73 | name = Frameworks; 74 | sourceTree = ""; 75 | }; 76 | 832341AE1AAA6A7D00B99B32 /* Libraries */ = { 77 | isa = PBXGroup; 78 | children = ( 79 | ); 80 | name = Libraries; 81 | sourceTree = ""; 82 | }; 83 | 83CBB9F61A601CBA00E9B192 = { 84 | isa = PBXGroup; 85 | children = ( 86 | 13B07FAE1A68108700A75B9A /* MlkitOcrExample */, 87 | 832341AE1AAA6A7D00B99B32 /* Libraries */, 88 | 83CBBA001A601CBA00E9B192 /* Products */, 89 | 2D16E6871FA4F8E400B85C8A /* Frameworks */, 90 | 1CFFDEF7170271C97B8B7E5A /* Pods */, 91 | ); 92 | indentWidth = 2; 93 | sourceTree = ""; 94 | tabWidth = 2; 95 | usesTabs = 0; 96 | }; 97 | 83CBBA001A601CBA00E9B192 /* Products */ = { 98 | isa = PBXGroup; 99 | children = ( 100 | 13B07F961A680F5B00A75B9A /* MlkitOcrExample.app */, 101 | ); 102 | name = Products; 103 | sourceTree = ""; 104 | }; 105 | /* End PBXGroup section */ 106 | 107 | /* Begin PBXNativeTarget section */ 108 | 13B07F861A680F5B00A75B9A /* MlkitOcrExample */ = { 109 | isa = PBXNativeTarget; 110 | buildConfigurationList = 13B07F931A680F5B00A75B9A /* Build configuration list for PBXNativeTarget "MlkitOcrExample" */; 111 | buildPhases = ( 112 | D879AB5EBCB6D01CD2EF5CDB /* [CP] Check Pods Manifest.lock */, 113 | FD10A7F022414F080027D42C /* Start Packager */, 114 | 13B07F871A680F5B00A75B9A /* Sources */, 115 | 13B07F8C1A680F5B00A75B9A /* Frameworks */, 116 | 13B07F8E1A680F5B00A75B9A /* Resources */, 117 | 00DD1BFF1BD5951E006B06BC /* Bundle React Native code and images */, 118 | 74C99DE3B4F2DBF813691339 /* [CP] Embed Pods Frameworks */, 119 | F282F473528CCC3C6BC4C083 /* [CP] Copy Pods Resources */, 120 | ); 121 | buildRules = ( 122 | ); 123 | dependencies = ( 124 | ); 125 | name = MlkitOcrExample; 126 | productName = MlkitOcrExample; 127 | productReference = 13B07F961A680F5B00A75B9A /* MlkitOcrExample.app */; 128 | productType = "com.apple.product-type.application"; 129 | }; 130 | /* End PBXNativeTarget section */ 131 | 132 | /* Begin PBXProject section */ 133 | 83CBB9F71A601CBA00E9B192 /* Project object */ = { 134 | isa = PBXProject; 135 | attributes = { 136 | LastUpgradeCheck = 0940; 137 | ORGANIZATIONNAME = Facebook; 138 | TargetAttributes = { 139 | 13B07F861A680F5B00A75B9A = { 140 | LastSwiftMigration = 1110; 141 | }; 142 | }; 143 | }; 144 | buildConfigurationList = 83CBB9FA1A601CBA00E9B192 /* Build configuration list for PBXProject "MlkitOcrExample" */; 145 | compatibilityVersion = "Xcode 3.2"; 146 | developmentRegion = English; 147 | hasScannedForEncodings = 0; 148 | knownRegions = ( 149 | English, 150 | en, 151 | Base, 152 | ); 153 | mainGroup = 83CBB9F61A601CBA00E9B192; 154 | productRefGroup = 83CBBA001A601CBA00E9B192 /* Products */; 155 | projectDirPath = ""; 156 | projectRoot = ""; 157 | targets = ( 158 | 13B07F861A680F5B00A75B9A /* MlkitOcrExample */, 159 | ); 160 | }; 161 | /* End PBXProject section */ 162 | 163 | /* Begin PBXResourcesBuildPhase section */ 164 | 13B07F8E1A680F5B00A75B9A /* Resources */ = { 165 | isa = PBXResourcesBuildPhase; 166 | buildActionMask = 2147483647; 167 | files = ( 168 | 13B07FBF1A68108700A75B9A /* Images.xcassets in Resources */, 169 | 13B07FBD1A68108700A75B9A /* LaunchScreen.xib in Resources */, 170 | ); 171 | runOnlyForDeploymentPostprocessing = 0; 172 | }; 173 | /* End PBXResourcesBuildPhase section */ 174 | 175 | /* Begin PBXShellScriptBuildPhase section */ 176 | 00DD1BFF1BD5951E006B06BC /* Bundle React Native code and images */ = { 177 | isa = PBXShellScriptBuildPhase; 178 | buildActionMask = 2147483647; 179 | files = ( 180 | ); 181 | inputPaths = ( 182 | "$(SRCROOT)/.xcode.env.local", 183 | "$(SRCROOT)/.xcode.env", 184 | ); 185 | name = "Bundle React Native code and images"; 186 | outputPaths = ( 187 | ); 188 | runOnlyForDeploymentPostprocessing = 0; 189 | shellPath = /bin/sh; 190 | shellScript = "set -e\n\nWITH_ENVIRONMENT=\"../node_modules/react-native/scripts/xcode/with-environment.sh\"\nREACT_NATIVE_XCODE=\"../node_modules/react-native/scripts/react-native-xcode.sh\"\n\n/bin/sh -c \"$WITH_ENVIRONMENT $REACT_NATIVE_XCODE\"\n"; 191 | }; 192 | 74C99DE3B4F2DBF813691339 /* [CP] Embed Pods Frameworks */ = { 193 | isa = PBXShellScriptBuildPhase; 194 | buildActionMask = 2147483647; 195 | files = ( 196 | ); 197 | inputPaths = ( 198 | "${PODS_ROOT}/Target Support Files/Pods-MlkitOcrExample/Pods-MlkitOcrExample-frameworks.sh", 199 | "${PODS_XCFRAMEWORKS_BUILD_DIR}/Flipper-DoubleConversion/double-conversion.framework/double-conversion", 200 | "${PODS_XCFRAMEWORKS_BUILD_DIR}/Flipper-Glog/glog.framework/glog", 201 | "${PODS_XCFRAMEWORKS_BUILD_DIR}/OpenSSL-Universal/OpenSSL.framework/OpenSSL", 202 | ); 203 | name = "[CP] Embed Pods Frameworks"; 204 | outputPaths = ( 205 | "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/double-conversion.framework", 206 | "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/glog.framework", 207 | "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/OpenSSL.framework", 208 | ); 209 | runOnlyForDeploymentPostprocessing = 0; 210 | shellPath = /bin/sh; 211 | shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-MlkitOcrExample/Pods-MlkitOcrExample-frameworks.sh\"\n"; 212 | showEnvVarsInLog = 0; 213 | }; 214 | D879AB5EBCB6D01CD2EF5CDB /* [CP] Check Pods Manifest.lock */ = { 215 | isa = PBXShellScriptBuildPhase; 216 | buildActionMask = 2147483647; 217 | files = ( 218 | ); 219 | inputFileListPaths = ( 220 | ); 221 | inputPaths = ( 222 | "${PODS_PODFILE_DIR_PATH}/Podfile.lock", 223 | "${PODS_ROOT}/Manifest.lock", 224 | ); 225 | name = "[CP] Check Pods Manifest.lock"; 226 | outputFileListPaths = ( 227 | ); 228 | outputPaths = ( 229 | "$(DERIVED_FILE_DIR)/Pods-MlkitOcrExample-checkManifestLockResult.txt", 230 | ); 231 | runOnlyForDeploymentPostprocessing = 0; 232 | shellPath = /bin/sh; 233 | shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; 234 | showEnvVarsInLog = 0; 235 | }; 236 | F282F473528CCC3C6BC4C083 /* [CP] Copy Pods Resources */ = { 237 | isa = PBXShellScriptBuildPhase; 238 | buildActionMask = 2147483647; 239 | files = ( 240 | ); 241 | inputPaths = ( 242 | "${PODS_ROOT}/Target Support Files/Pods-MlkitOcrExample/Pods-MlkitOcrExample-resources.sh", 243 | "${PODS_CONFIGURATION_BUILD_DIR}/MLKitTextRecognition/LatinOCRResources.bundle", 244 | "${PODS_CONFIGURATION_BUILD_DIR}/React-Core/AccessibilityResources.bundle", 245 | ); 246 | name = "[CP] Copy Pods Resources"; 247 | outputPaths = ( 248 | "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/LatinOCRResources.bundle", 249 | "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/AccessibilityResources.bundle", 250 | ); 251 | runOnlyForDeploymentPostprocessing = 0; 252 | shellPath = /bin/sh; 253 | shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-MlkitOcrExample/Pods-MlkitOcrExample-resources.sh\"\n"; 254 | showEnvVarsInLog = 0; 255 | }; 256 | FD10A7F022414F080027D42C /* Start Packager */ = { 257 | isa = PBXShellScriptBuildPhase; 258 | buildActionMask = 2147483647; 259 | files = ( 260 | ); 261 | inputFileListPaths = ( 262 | ); 263 | inputPaths = ( 264 | ); 265 | name = "Start Packager"; 266 | outputFileListPaths = ( 267 | ); 268 | outputPaths = ( 269 | ); 270 | runOnlyForDeploymentPostprocessing = 0; 271 | shellPath = /bin/sh; 272 | shellScript = "export RCT_METRO_PORT=\"${RCT_METRO_PORT:=8081}\"\necho \"export RCT_METRO_PORT=${RCT_METRO_PORT}\" > \"${SRCROOT}/../node_modules/react-native/scripts/.packager.env\"\nif [ -z \"${RCT_NO_LAUNCH_PACKAGER+xxx}\" ] ; then\n if nc -w 5 -z localhost ${RCT_METRO_PORT} ; then\n if ! curl -s \"http://localhost:${RCT_METRO_PORT}/status\" | grep -q \"packager-status:running\" ; then\n echo \"Port ${RCT_METRO_PORT} already in use, packager is either not running or not running correctly\"\n exit 2\n fi\n else\n open \"$SRCROOT/../node_modules/react-native/scripts/launchPackager.command\" || echo \"Can't start packager automatically\"\n fi\nfi\n"; 273 | showEnvVarsInLog = 0; 274 | }; 275 | /* End PBXShellScriptBuildPhase section */ 276 | 277 | /* Begin PBXSourcesBuildPhase section */ 278 | 13B07F871A680F5B00A75B9A /* Sources */ = { 279 | isa = PBXSourcesBuildPhase; 280 | buildActionMask = 2147483647; 281 | files = ( 282 | 13B07FBC1A68108700A75B9A /* AppDelegate.mm in Sources */, 283 | 13B07FC11A68108700A75B9A /* main.m in Sources */, 284 | ); 285 | runOnlyForDeploymentPostprocessing = 0; 286 | }; 287 | /* End PBXSourcesBuildPhase section */ 288 | 289 | /* Begin PBXVariantGroup section */ 290 | 13B07FB11A68108700A75B9A /* LaunchScreen.xib */ = { 291 | isa = PBXVariantGroup; 292 | children = ( 293 | 13B07FB21A68108700A75B9A /* Base */, 294 | ); 295 | name = LaunchScreen.xib; 296 | path = MlkitOcrExample; 297 | sourceTree = ""; 298 | }; 299 | /* End PBXVariantGroup section */ 300 | 301 | /* Begin XCBuildConfiguration section */ 302 | 13B07F941A680F5B00A75B9A /* Debug */ = { 303 | isa = XCBuildConfiguration; 304 | baseConfigurationReference = 083588E7D94D511ABDE58EBE /* Pods-MlkitOcrExample.debug.xcconfig */; 305 | buildSettings = { 306 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 307 | CLANG_ENABLE_MODULES = YES; 308 | CURRENT_PROJECT_VERSION = 1; 309 | ENABLE_BITCODE = NO; 310 | INFOPLIST_FILE = MlkitOcrExample/Info.plist; 311 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 312 | OTHER_LDFLAGS = ( 313 | "$(inherited)", 314 | "-ObjC", 315 | "-lc++", 316 | ); 317 | PRODUCT_BUNDLE_IDENTIFIER = "org.reactjs.native.MlkitOcrExample.$(PRODUCT_NAME:rfc1034identifier)"; 318 | PRODUCT_NAME = MlkitOcrExample; 319 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 320 | SWIFT_VERSION = 5.0; 321 | VERSIONING_SYSTEM = "apple-generic"; 322 | }; 323 | name = Debug; 324 | }; 325 | 13B07F951A680F5B00A75B9A /* Release */ = { 326 | isa = XCBuildConfiguration; 327 | baseConfigurationReference = 175DA7A79273A18334856C2C /* Pods-MlkitOcrExample.release.xcconfig */; 328 | buildSettings = { 329 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 330 | CLANG_ENABLE_MODULES = YES; 331 | CURRENT_PROJECT_VERSION = 1; 332 | INFOPLIST_FILE = MlkitOcrExample/Info.plist; 333 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 334 | OTHER_LDFLAGS = ( 335 | "$(inherited)", 336 | "-ObjC", 337 | "-lc++", 338 | ); 339 | PRODUCT_BUNDLE_IDENTIFIER = "org.reactjs.native.MlkitOcrExample.$(PRODUCT_NAME:rfc1034identifier)"; 340 | PRODUCT_NAME = MlkitOcrExample; 341 | SWIFT_VERSION = 5.0; 342 | VERSIONING_SYSTEM = "apple-generic"; 343 | }; 344 | name = Release; 345 | }; 346 | 83CBBA201A601CBA00E9B192 /* Debug */ = { 347 | isa = XCBuildConfiguration; 348 | buildSettings = { 349 | ALWAYS_SEARCH_USER_PATHS = NO; 350 | CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES; 351 | CLANG_CXX_LANGUAGE_STANDARD = "c++17"; 352 | CLANG_CXX_LIBRARY = "libc++"; 353 | CLANG_ENABLE_MODULES = YES; 354 | CLANG_ENABLE_OBJC_ARC = YES; 355 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 356 | CLANG_WARN_BOOL_CONVERSION = YES; 357 | CLANG_WARN_COMMA = YES; 358 | CLANG_WARN_CONSTANT_CONVERSION = YES; 359 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 360 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 361 | CLANG_WARN_EMPTY_BODY = YES; 362 | CLANG_WARN_ENUM_CONVERSION = YES; 363 | CLANG_WARN_INFINITE_RECURSION = YES; 364 | CLANG_WARN_INT_CONVERSION = YES; 365 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 366 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 367 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 368 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 369 | CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; 370 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 371 | CLANG_WARN_STRICT_PROTOTYPES = YES; 372 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 373 | CLANG_WARN_UNREACHABLE_CODE = YES; 374 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 375 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 376 | COPY_PHASE_STRIP = NO; 377 | ENABLE_STRICT_OBJC_MSGSEND = YES; 378 | ENABLE_TESTABILITY = YES; 379 | "EXCLUDED_ARCHS[sdk=iphonesimulator*]" = ""; 380 | GCC_C_LANGUAGE_STANDARD = gnu99; 381 | GCC_DYNAMIC_NO_PIC = NO; 382 | GCC_NO_COMMON_BLOCKS = YES; 383 | GCC_OPTIMIZATION_LEVEL = 0; 384 | GCC_PREPROCESSOR_DEFINITIONS = ( 385 | "DEBUG=1", 386 | "$(inherited)", 387 | ); 388 | GCC_SYMBOLS_PRIVATE_EXTERN = NO; 389 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 390 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 391 | GCC_WARN_UNDECLARED_SELECTOR = YES; 392 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 393 | GCC_WARN_UNUSED_FUNCTION = YES; 394 | GCC_WARN_UNUSED_VARIABLE = YES; 395 | IPHONEOS_DEPLOYMENT_TARGET = 12.4; 396 | LD_RUNPATH_SEARCH_PATHS = "/usr/lib/swift $(inherited)"; 397 | LIBRARY_SEARCH_PATHS = ( 398 | "\"$(SDKROOT)/usr/lib/swift\"", 399 | "\"$(TOOLCHAIN_DIR)/usr/lib/swift/$(PLATFORM_NAME)\"", 400 | "\"$(inherited)\"", 401 | ); 402 | MTL_ENABLE_DEBUG_INFO = YES; 403 | ONLY_ACTIVE_ARCH = YES; 404 | OTHER_CPLUSPLUSFLAGS = ( 405 | "$(OTHER_CFLAGS)", 406 | "-DFOLLY_NO_CONFIG", 407 | "-DFOLLY_MOBILE=1", 408 | "-DFOLLY_USE_LIBCPP=1", 409 | ); 410 | REACT_NATIVE_PATH = "${PODS_ROOT}/../../node_modules/react-native"; 411 | SDKROOT = iphoneos; 412 | }; 413 | name = Debug; 414 | }; 415 | 83CBBA211A601CBA00E9B192 /* Release */ = { 416 | isa = XCBuildConfiguration; 417 | buildSettings = { 418 | ALWAYS_SEARCH_USER_PATHS = NO; 419 | CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES; 420 | CLANG_CXX_LANGUAGE_STANDARD = "c++17"; 421 | CLANG_CXX_LIBRARY = "libc++"; 422 | CLANG_ENABLE_MODULES = YES; 423 | CLANG_ENABLE_OBJC_ARC = YES; 424 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 425 | CLANG_WARN_BOOL_CONVERSION = YES; 426 | CLANG_WARN_COMMA = YES; 427 | CLANG_WARN_CONSTANT_CONVERSION = YES; 428 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 429 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 430 | CLANG_WARN_EMPTY_BODY = YES; 431 | CLANG_WARN_ENUM_CONVERSION = YES; 432 | CLANG_WARN_INFINITE_RECURSION = YES; 433 | CLANG_WARN_INT_CONVERSION = YES; 434 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 435 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 436 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 437 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 438 | CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; 439 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 440 | CLANG_WARN_STRICT_PROTOTYPES = YES; 441 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 442 | CLANG_WARN_UNREACHABLE_CODE = YES; 443 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 444 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 445 | COPY_PHASE_STRIP = YES; 446 | ENABLE_NS_ASSERTIONS = NO; 447 | ENABLE_STRICT_OBJC_MSGSEND = YES; 448 | "EXCLUDED_ARCHS[sdk=iphonesimulator*]" = ""; 449 | GCC_C_LANGUAGE_STANDARD = gnu99; 450 | GCC_NO_COMMON_BLOCKS = YES; 451 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 452 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 453 | GCC_WARN_UNDECLARED_SELECTOR = YES; 454 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 455 | GCC_WARN_UNUSED_FUNCTION = YES; 456 | GCC_WARN_UNUSED_VARIABLE = YES; 457 | IPHONEOS_DEPLOYMENT_TARGET = 12.4; 458 | LD_RUNPATH_SEARCH_PATHS = "/usr/lib/swift $(inherited)"; 459 | LIBRARY_SEARCH_PATHS = ( 460 | "\"$(SDKROOT)/usr/lib/swift\"", 461 | "\"$(TOOLCHAIN_DIR)/usr/lib/swift/$(PLATFORM_NAME)\"", 462 | "\"$(inherited)\"", 463 | ); 464 | MTL_ENABLE_DEBUG_INFO = NO; 465 | OTHER_CPLUSPLUSFLAGS = ( 466 | "$(OTHER_CFLAGS)", 467 | "-DFOLLY_NO_CONFIG", 468 | "-DFOLLY_MOBILE=1", 469 | "-DFOLLY_USE_LIBCPP=1", 470 | ); 471 | REACT_NATIVE_PATH = "${PODS_ROOT}/../../node_modules/react-native"; 472 | SDKROOT = iphoneos; 473 | VALIDATE_PRODUCT = YES; 474 | }; 475 | name = Release; 476 | }; 477 | /* End XCBuildConfiguration section */ 478 | 479 | /* Begin XCConfigurationList section */ 480 | 13B07F931A680F5B00A75B9A /* Build configuration list for PBXNativeTarget "MlkitOcrExample" */ = { 481 | isa = XCConfigurationList; 482 | buildConfigurations = ( 483 | 13B07F941A680F5B00A75B9A /* Debug */, 484 | 13B07F951A680F5B00A75B9A /* Release */, 485 | ); 486 | defaultConfigurationIsVisible = 0; 487 | defaultConfigurationName = Release; 488 | }; 489 | 83CBB9FA1A601CBA00E9B192 /* Build configuration list for PBXProject "MlkitOcrExample" */ = { 490 | isa = XCConfigurationList; 491 | buildConfigurations = ( 492 | 83CBBA201A601CBA00E9B192 /* Debug */, 493 | 83CBBA211A601CBA00E9B192 /* Release */, 494 | ); 495 | defaultConfigurationIsVisible = 0; 496 | defaultConfigurationName = Release; 497 | }; 498 | /* End XCConfigurationList section */ 499 | }; 500 | rootObject = 83CBB9F71A601CBA00E9B192 /* Project object */; 501 | } 502 | -------------------------------------------------------------------------------- /example/ios/MlkitOcrExample.xcodeproj/xcshareddata/xcschemes/MlkitOcrExample.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 29 | 35 | 36 | 37 | 38 | 39 | 44 | 45 | 51 | 52 | 53 | 54 | 55 | 56 | 66 | 68 | 74 | 75 | 76 | 77 | 83 | 85 | 91 | 92 | 93 | 94 | 96 | 97 | 100 | 101 | 102 | -------------------------------------------------------------------------------- /example/ios/MlkitOcrExample.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /example/ios/MlkitOcrExample.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /example/ios/MlkitOcrExample/AppDelegate.h: -------------------------------------------------------------------------------- 1 | #import 2 | #import 3 | 4 | @interface AppDelegate : UIResponder 5 | 6 | @property (nonatomic, strong) UIWindow *window; 7 | 8 | @end 9 | -------------------------------------------------------------------------------- /example/ios/MlkitOcrExample/AppDelegate.mm: -------------------------------------------------------------------------------- 1 | #import "AppDelegate.h" 2 | 3 | #import 4 | #import 5 | #import 6 | 7 | #import 8 | 9 | #if RCT_NEW_ARCH_ENABLED 10 | #import 11 | #import 12 | #import 13 | #import 14 | #import 15 | #import 16 | 17 | #import 18 | 19 | @interface AppDelegate () { 20 | RCTTurboModuleManager *_turboModuleManager; 21 | RCTSurfacePresenterBridgeAdapter *_bridgeAdapter; 22 | std::shared_ptr _reactNativeConfig; 23 | facebook::react::ContextContainer::Shared _contextContainer; 24 | } 25 | @end 26 | #endif 27 | 28 | @implementation AppDelegate 29 | 30 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 31 | { 32 | RCTAppSetupPrepareApp(application); 33 | 34 | RCTBridge *bridge = [[RCTBridge alloc] initWithDelegate:self launchOptions:launchOptions]; 35 | 36 | #if RCT_NEW_ARCH_ENABLED 37 | _contextContainer = std::make_shared(); 38 | _reactNativeConfig = std::make_shared(); 39 | _contextContainer->insert("ReactNativeConfig", _reactNativeConfig); 40 | _bridgeAdapter = [[RCTSurfacePresenterBridgeAdapter alloc] initWithBridge:bridge contextContainer:_contextContainer]; 41 | bridge.surfacePresenter = _bridgeAdapter.surfacePresenter; 42 | #endif 43 | 44 | UIView *rootView = RCTAppSetupDefaultRootView(bridge, @"MlkitOcrExample", nil); 45 | 46 | if (@available(iOS 13.0, *)) { 47 | rootView.backgroundColor = [UIColor systemBackgroundColor]; 48 | } else { 49 | rootView.backgroundColor = [UIColor whiteColor]; 50 | } 51 | 52 | self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds]; 53 | UIViewController *rootViewController = [UIViewController new]; 54 | rootViewController.view = rootView; 55 | self.window.rootViewController = rootViewController; 56 | [self.window makeKeyAndVisible]; 57 | return YES; 58 | } 59 | 60 | - (NSURL *)sourceURLForBridge:(RCTBridge *)bridge 61 | { 62 | #if DEBUG 63 | return [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index"]; 64 | #else 65 | return [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"]; 66 | #endif 67 | } 68 | 69 | #if RCT_NEW_ARCH_ENABLED 70 | 71 | #pragma mark - RCTCxxBridgeDelegate 72 | 73 | - (std::unique_ptr)jsExecutorFactoryForBridge:(RCTBridge *)bridge 74 | { 75 | _turboModuleManager = [[RCTTurboModuleManager alloc] initWithBridge:bridge 76 | delegate:self 77 | jsInvoker:bridge.jsCallInvoker]; 78 | return RCTAppSetupDefaultJsExecutorFactory(bridge, _turboModuleManager); 79 | } 80 | 81 | #pragma mark RCTTurboModuleManagerDelegate 82 | 83 | - (Class)getModuleClassFromName:(const char *)name 84 | { 85 | return RCTCoreModulesClassProvider(name); 86 | } 87 | 88 | - (std::shared_ptr)getTurboModule:(const std::string &)name 89 | jsInvoker:(std::shared_ptr)jsInvoker 90 | { 91 | return nullptr; 92 | } 93 | 94 | - (std::shared_ptr)getTurboModule:(const std::string &)name 95 | initParams: 96 | (const facebook::react::ObjCTurboModule::InitParams &)params 97 | { 98 | return nullptr; 99 | } 100 | 101 | - (id)getModuleInstanceFromClass:(Class)moduleClass 102 | { 103 | return RCTAppSetupDefaultModuleFromClass(moduleClass); 104 | } 105 | 106 | #endif 107 | 108 | @end 109 | -------------------------------------------------------------------------------- /example/ios/MlkitOcrExample/Base.lproj/LaunchScreen.xib: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 21 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | -------------------------------------------------------------------------------- /example/ios/MlkitOcrExample/Images.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "scale" : "2x", 6 | "size" : "20x20" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "scale" : "3x", 11 | "size" : "20x20" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "scale" : "2x", 16 | "size" : "29x29" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "scale" : "3x", 21 | "size" : "29x29" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "scale" : "2x", 26 | "size" : "40x40" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "scale" : "3x", 31 | "size" : "40x40" 32 | }, 33 | { 34 | "idiom" : "iphone", 35 | "scale" : "2x", 36 | "size" : "60x60" 37 | }, 38 | { 39 | "idiom" : "iphone", 40 | "scale" : "3x", 41 | "size" : "60x60" 42 | }, 43 | { 44 | "idiom" : "ios-marketing", 45 | "scale" : "1x", 46 | "size" : "1024x1024" 47 | } 48 | ], 49 | "info" : { 50 | "author" : "xcode", 51 | "version" : 1 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /example/ios/MlkitOcrExample/Images.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "version" : 1, 4 | "author" : "xcode" 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /example/ios/MlkitOcrExample/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleDisplayName 8 | MlkitOcr Example 9 | CFBundleExecutable 10 | $(EXECUTABLE_NAME) 11 | CFBundleIdentifier 12 | $(PRODUCT_BUNDLE_IDENTIFIER) 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | $(PRODUCT_NAME) 17 | CFBundlePackageType 18 | APPL 19 | CFBundleShortVersionString 20 | 1.0 21 | CFBundleSignature 22 | ???? 23 | CFBundleVersion 24 | 1 25 | LSRequiresIPhoneOS 26 | 27 | NSAppTransportSecurity 28 | 29 | NSAllowsArbitraryLoads 30 | 31 | NSExceptionDomains 32 | 33 | localhost 34 | 35 | NSExceptionAllowsInsecureHTTPLoads 36 | 37 | 38 | 39 | 40 | NSLocationWhenInUseUsageDescription 41 | 42 | UILaunchStoryboardName 43 | LaunchScreen 44 | UIRequiredDeviceCapabilities 45 | 46 | armv7 47 | 48 | UISupportedInterfaceOrientations 49 | 50 | UIInterfaceOrientationPortrait 51 | UIInterfaceOrientationLandscapeLeft 52 | UIInterfaceOrientationLandscapeRight 53 | 54 | NSPhotoLibraryUsageDescription 55 | Please allow use photo lib 56 | UIViewControllerBasedStatusBarAppearance 57 | 58 | 59 | 60 | -------------------------------------------------------------------------------- /example/ios/MlkitOcrExample/main.m: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Facebook, Inc. and its affiliates. 3 | * 4 | * This source code is licensed under the MIT license found in the 5 | * LICENSE file in the root directory of this source tree. 6 | */ 7 | 8 | #import 9 | 10 | #import "AppDelegate.h" 11 | 12 | int main(int argc, char * argv[]) { 13 | @autoreleasepool { 14 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /example/ios/Podfile: -------------------------------------------------------------------------------- 1 | require_relative '../node_modules/react-native/scripts/react_native_pods' 2 | require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules' 3 | 4 | platform :ios, '12.4' 5 | install! 'cocoapods', :deterministic_uuids => false 6 | 7 | production = ENV["PRODUCTION"] == "1" 8 | 9 | target 'MlkitOcrExample' do 10 | config = use_native_modules! 11 | 12 | # Flags change depending on the env values. 13 | flags = get_default_flags() 14 | 15 | use_react_native!( 16 | :path => config[:reactNativePath], 17 | # to enable hermes on iOS, change `false` to `true` and then install pods 18 | :production => production, 19 | :hermes_enabled => flags[:hermes_enabled], 20 | :fabric_enabled => flags[:fabric_enabled], 21 | :flipper_configuration => FlipperConfiguration.enabled, 22 | # An absolute path to your application root. 23 | :app_path => "#{Pod::Config.instance.installation_root}/.." 24 | ) 25 | 26 | post_install do |installer| 27 | react_native_post_install(installer) 28 | __apply_Xcode_12_5_M1_post_install_workaround(installer) 29 | 30 | # Apple M1 fix 31 | installer.pods_project.targets.each do |target| 32 | target.build_configurations.each do |config| 33 | config.build_settings.delete 'IPHONEOS_DEPLOYMENT_TARGET' 34 | config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] ||= ['$(inherited)', '_LIBCPP_ENABLE_CXX17_REMOVED_UNARY_BINARY_FUNCTION'] 35 | # Disable arm64 builds for the simulator 36 | config.build_settings['EXCLUDED_ARCHS[sdk=iphonesimulator*]'] = 'arm64' 37 | end 38 | end 39 | end 40 | end 41 | -------------------------------------------------------------------------------- /example/ios/Podfile.lock: -------------------------------------------------------------------------------- 1 | PODS: 2 | - boost (1.76.0) 3 | - CocoaAsyncSocket (7.6.5) 4 | - DoubleConversion (1.1.6) 5 | - FBLazyVector (0.69.5) 6 | - FBReactNativeSpec (0.69.5): 7 | - RCT-Folly (= 2021.06.28.00-v2) 8 | - RCTRequired (= 0.69.5) 9 | - RCTTypeSafety (= 0.69.5) 10 | - React-Core (= 0.69.5) 11 | - React-jsi (= 0.69.5) 12 | - ReactCommon/turbomodule/core (= 0.69.5) 13 | - Flipper (0.125.0): 14 | - Flipper-Folly (~> 2.6) 15 | - Flipper-RSocket (~> 1.4) 16 | - Flipper-Boost-iOSX (1.76.0.1.11) 17 | - Flipper-DoubleConversion (3.2.0.1) 18 | - Flipper-Fmt (7.1.7) 19 | - Flipper-Folly (2.6.10): 20 | - Flipper-Boost-iOSX 21 | - Flipper-DoubleConversion 22 | - Flipper-Fmt (= 7.1.7) 23 | - Flipper-Glog 24 | - libevent (~> 2.1.12) 25 | - OpenSSL-Universal (= 1.1.1100) 26 | - Flipper-Glog (0.5.0.5) 27 | - Flipper-PeerTalk (0.0.4) 28 | - Flipper-RSocket (1.4.3): 29 | - Flipper-Folly (~> 2.6) 30 | - FlipperKit (0.125.0): 31 | - FlipperKit/Core (= 0.125.0) 32 | - FlipperKit/Core (0.125.0): 33 | - Flipper (~> 0.125.0) 34 | - FlipperKit/CppBridge 35 | - FlipperKit/FBCxxFollyDynamicConvert 36 | - FlipperKit/FBDefines 37 | - FlipperKit/FKPortForwarding 38 | - SocketRocket (~> 0.6.0) 39 | - FlipperKit/CppBridge (0.125.0): 40 | - Flipper (~> 0.125.0) 41 | - FlipperKit/FBCxxFollyDynamicConvert (0.125.0): 42 | - Flipper-Folly (~> 2.6) 43 | - FlipperKit/FBDefines (0.125.0) 44 | - FlipperKit/FKPortForwarding (0.125.0): 45 | - CocoaAsyncSocket (~> 7.6) 46 | - Flipper-PeerTalk (~> 0.0.4) 47 | - FlipperKit/FlipperKitHighlightOverlay (0.125.0) 48 | - FlipperKit/FlipperKitLayoutHelpers (0.125.0): 49 | - FlipperKit/Core 50 | - FlipperKit/FlipperKitHighlightOverlay 51 | - FlipperKit/FlipperKitLayoutTextSearchable 52 | - FlipperKit/FlipperKitLayoutIOSDescriptors (0.125.0): 53 | - FlipperKit/Core 54 | - FlipperKit/FlipperKitHighlightOverlay 55 | - FlipperKit/FlipperKitLayoutHelpers 56 | - YogaKit (~> 1.18) 57 | - FlipperKit/FlipperKitLayoutPlugin (0.125.0): 58 | - FlipperKit/Core 59 | - FlipperKit/FlipperKitHighlightOverlay 60 | - FlipperKit/FlipperKitLayoutHelpers 61 | - FlipperKit/FlipperKitLayoutIOSDescriptors 62 | - FlipperKit/FlipperKitLayoutTextSearchable 63 | - YogaKit (~> 1.18) 64 | - FlipperKit/FlipperKitLayoutTextSearchable (0.125.0) 65 | - FlipperKit/FlipperKitNetworkPlugin (0.125.0): 66 | - FlipperKit/Core 67 | - FlipperKit/FlipperKitReactPlugin (0.125.0): 68 | - FlipperKit/Core 69 | - FlipperKit/FlipperKitUserDefaultsPlugin (0.125.0): 70 | - FlipperKit/Core 71 | - FlipperKit/SKIOSNetworkPlugin (0.125.0): 72 | - FlipperKit/Core 73 | - FlipperKit/FlipperKitNetworkPlugin 74 | - fmt (6.2.1) 75 | - glog (0.3.5) 76 | - GoogleDataTransport (9.2.5): 77 | - GoogleUtilities/Environment (~> 7.7) 78 | - nanopb (< 2.30910.0, >= 2.30908.0) 79 | - PromisesObjC (< 3.0, >= 1.2) 80 | - GoogleMLKit/MLKitCore (2.6.0): 81 | - MLKitCommon (~> 5.0.0) 82 | - GoogleMLKit/TextRecognition (2.6.0): 83 | - GoogleMLKit/MLKitCore 84 | - MLKitTextRecognition (~> 1.4.0-beta3) 85 | - GoogleToolboxForMac/DebugUtils (2.3.2): 86 | - GoogleToolboxForMac/Defines (= 2.3.2) 87 | - GoogleToolboxForMac/Defines (2.3.2) 88 | - GoogleToolboxForMac/Logger (2.3.2): 89 | - GoogleToolboxForMac/Defines (= 2.3.2) 90 | - "GoogleToolboxForMac/NSData+zlib (2.3.2)": 91 | - GoogleToolboxForMac/Defines (= 2.3.2) 92 | - "GoogleToolboxForMac/NSDictionary+URLArguments (2.3.2)": 93 | - GoogleToolboxForMac/DebugUtils (= 2.3.2) 94 | - GoogleToolboxForMac/Defines (= 2.3.2) 95 | - "GoogleToolboxForMac/NSString+URLArguments (= 2.3.2)" 96 | - "GoogleToolboxForMac/NSString+URLArguments (2.3.2)" 97 | - GoogleUtilities/Environment (7.11.5): 98 | - PromisesObjC (< 3.0, >= 1.2) 99 | - GoogleUtilities/Logger (7.11.5): 100 | - GoogleUtilities/Environment 101 | - GoogleUtilities/UserDefaults (7.11.5): 102 | - GoogleUtilities/Logger 103 | - GoogleUtilitiesComponents (1.1.0): 104 | - GoogleUtilities/Logger 105 | - GTMSessionFetcher/Core (1.7.2) 106 | - libevent (2.1.12) 107 | - MLImage (1.0.0-beta2) 108 | - MLKitCommon (5.0.0): 109 | - GoogleDataTransport (~> 9.0) 110 | - GoogleToolboxForMac/Logger (~> 2.1) 111 | - "GoogleToolboxForMac/NSData+zlib (~> 2.1)" 112 | - "GoogleToolboxForMac/NSDictionary+URLArguments (~> 2.1)" 113 | - GoogleUtilities/UserDefaults (~> 7.0) 114 | - GoogleUtilitiesComponents (~> 1.0) 115 | - GTMSessionFetcher/Core (~> 1.1) 116 | - Protobuf (~> 3.12) 117 | - MLKitTextRecognition (1.4.0-beta3): 118 | - MLKitCommon (~> 5.0) 119 | - MLKitTextRecognitionCommon (= 1.0.0-beta3) 120 | - MLKitVision (~> 3.0) 121 | - MLKitTextRecognitionCommon (1.0.0-beta3): 122 | - MLKitCommon (~> 5.0) 123 | - MLKitVision (~> 3.0) 124 | - MLKitVision (3.0.0): 125 | - GoogleToolboxForMac/Logger (~> 2.1) 126 | - "GoogleToolboxForMac/NSData+zlib (~> 2.1)" 127 | - GTMSessionFetcher/Core (~> 1.1) 128 | - MLImage (= 1.0.0-beta2) 129 | - MLKitCommon (~> 5.0) 130 | - Protobuf (~> 3.12) 131 | - nanopb (2.30909.0): 132 | - nanopb/decode (= 2.30909.0) 133 | - nanopb/encode (= 2.30909.0) 134 | - nanopb/decode (2.30909.0) 135 | - nanopb/encode (2.30909.0) 136 | - OpenSSL-Universal (1.1.1100) 137 | - PromisesObjC (2.3.1) 138 | - Protobuf (3.24.3) 139 | - RCT-Folly (2021.06.28.00-v2): 140 | - boost 141 | - DoubleConversion 142 | - fmt (~> 6.2.1) 143 | - glog 144 | - RCT-Folly/Default (= 2021.06.28.00-v2) 145 | - RCT-Folly/Default (2021.06.28.00-v2): 146 | - boost 147 | - DoubleConversion 148 | - fmt (~> 6.2.1) 149 | - glog 150 | - RCTRequired (0.69.5) 151 | - RCTTypeSafety (0.69.5): 152 | - FBLazyVector (= 0.69.5) 153 | - RCTRequired (= 0.69.5) 154 | - React-Core (= 0.69.5) 155 | - React (0.69.5): 156 | - React-Core (= 0.69.5) 157 | - React-Core/DevSupport (= 0.69.5) 158 | - React-Core/RCTWebSocket (= 0.69.5) 159 | - React-RCTActionSheet (= 0.69.5) 160 | - React-RCTAnimation (= 0.69.5) 161 | - React-RCTBlob (= 0.69.5) 162 | - React-RCTImage (= 0.69.5) 163 | - React-RCTLinking (= 0.69.5) 164 | - React-RCTNetwork (= 0.69.5) 165 | - React-RCTSettings (= 0.69.5) 166 | - React-RCTText (= 0.69.5) 167 | - React-RCTVibration (= 0.69.5) 168 | - React-bridging (0.69.5): 169 | - RCT-Folly (= 2021.06.28.00-v2) 170 | - React-jsi (= 0.69.5) 171 | - React-callinvoker (0.69.5) 172 | - React-Codegen (0.69.5): 173 | - FBReactNativeSpec (= 0.69.5) 174 | - RCT-Folly (= 2021.06.28.00-v2) 175 | - RCTRequired (= 0.69.5) 176 | - RCTTypeSafety (= 0.69.5) 177 | - React-Core (= 0.69.5) 178 | - React-jsi (= 0.69.5) 179 | - React-jsiexecutor (= 0.69.5) 180 | - ReactCommon/turbomodule/core (= 0.69.5) 181 | - React-Core (0.69.5): 182 | - glog 183 | - RCT-Folly (= 2021.06.28.00-v2) 184 | - React-Core/Default (= 0.69.5) 185 | - React-cxxreact (= 0.69.5) 186 | - React-jsi (= 0.69.5) 187 | - React-jsiexecutor (= 0.69.5) 188 | - React-perflogger (= 0.69.5) 189 | - Yoga 190 | - React-Core/CoreModulesHeaders (0.69.5): 191 | - glog 192 | - RCT-Folly (= 2021.06.28.00-v2) 193 | - React-Core/Default 194 | - React-cxxreact (= 0.69.5) 195 | - React-jsi (= 0.69.5) 196 | - React-jsiexecutor (= 0.69.5) 197 | - React-perflogger (= 0.69.5) 198 | - Yoga 199 | - React-Core/Default (0.69.5): 200 | - glog 201 | - RCT-Folly (= 2021.06.28.00-v2) 202 | - React-cxxreact (= 0.69.5) 203 | - React-jsi (= 0.69.5) 204 | - React-jsiexecutor (= 0.69.5) 205 | - React-perflogger (= 0.69.5) 206 | - Yoga 207 | - React-Core/DevSupport (0.69.5): 208 | - glog 209 | - RCT-Folly (= 2021.06.28.00-v2) 210 | - React-Core/Default (= 0.69.5) 211 | - React-Core/RCTWebSocket (= 0.69.5) 212 | - React-cxxreact (= 0.69.5) 213 | - React-jsi (= 0.69.5) 214 | - React-jsiexecutor (= 0.69.5) 215 | - React-jsinspector (= 0.69.5) 216 | - React-perflogger (= 0.69.5) 217 | - Yoga 218 | - React-Core/RCTActionSheetHeaders (0.69.5): 219 | - glog 220 | - RCT-Folly (= 2021.06.28.00-v2) 221 | - React-Core/Default 222 | - React-cxxreact (= 0.69.5) 223 | - React-jsi (= 0.69.5) 224 | - React-jsiexecutor (= 0.69.5) 225 | - React-perflogger (= 0.69.5) 226 | - Yoga 227 | - React-Core/RCTAnimationHeaders (0.69.5): 228 | - glog 229 | - RCT-Folly (= 2021.06.28.00-v2) 230 | - React-Core/Default 231 | - React-cxxreact (= 0.69.5) 232 | - React-jsi (= 0.69.5) 233 | - React-jsiexecutor (= 0.69.5) 234 | - React-perflogger (= 0.69.5) 235 | - Yoga 236 | - React-Core/RCTBlobHeaders (0.69.5): 237 | - glog 238 | - RCT-Folly (= 2021.06.28.00-v2) 239 | - React-Core/Default 240 | - React-cxxreact (= 0.69.5) 241 | - React-jsi (= 0.69.5) 242 | - React-jsiexecutor (= 0.69.5) 243 | - React-perflogger (= 0.69.5) 244 | - Yoga 245 | - React-Core/RCTImageHeaders (0.69.5): 246 | - glog 247 | - RCT-Folly (= 2021.06.28.00-v2) 248 | - React-Core/Default 249 | - React-cxxreact (= 0.69.5) 250 | - React-jsi (= 0.69.5) 251 | - React-jsiexecutor (= 0.69.5) 252 | - React-perflogger (= 0.69.5) 253 | - Yoga 254 | - React-Core/RCTLinkingHeaders (0.69.5): 255 | - glog 256 | - RCT-Folly (= 2021.06.28.00-v2) 257 | - React-Core/Default 258 | - React-cxxreact (= 0.69.5) 259 | - React-jsi (= 0.69.5) 260 | - React-jsiexecutor (= 0.69.5) 261 | - React-perflogger (= 0.69.5) 262 | - Yoga 263 | - React-Core/RCTNetworkHeaders (0.69.5): 264 | - glog 265 | - RCT-Folly (= 2021.06.28.00-v2) 266 | - React-Core/Default 267 | - React-cxxreact (= 0.69.5) 268 | - React-jsi (= 0.69.5) 269 | - React-jsiexecutor (= 0.69.5) 270 | - React-perflogger (= 0.69.5) 271 | - Yoga 272 | - React-Core/RCTSettingsHeaders (0.69.5): 273 | - glog 274 | - RCT-Folly (= 2021.06.28.00-v2) 275 | - React-Core/Default 276 | - React-cxxreact (= 0.69.5) 277 | - React-jsi (= 0.69.5) 278 | - React-jsiexecutor (= 0.69.5) 279 | - React-perflogger (= 0.69.5) 280 | - Yoga 281 | - React-Core/RCTTextHeaders (0.69.5): 282 | - glog 283 | - RCT-Folly (= 2021.06.28.00-v2) 284 | - React-Core/Default 285 | - React-cxxreact (= 0.69.5) 286 | - React-jsi (= 0.69.5) 287 | - React-jsiexecutor (= 0.69.5) 288 | - React-perflogger (= 0.69.5) 289 | - Yoga 290 | - React-Core/RCTVibrationHeaders (0.69.5): 291 | - glog 292 | - RCT-Folly (= 2021.06.28.00-v2) 293 | - React-Core/Default 294 | - React-cxxreact (= 0.69.5) 295 | - React-jsi (= 0.69.5) 296 | - React-jsiexecutor (= 0.69.5) 297 | - React-perflogger (= 0.69.5) 298 | - Yoga 299 | - React-Core/RCTWebSocket (0.69.5): 300 | - glog 301 | - RCT-Folly (= 2021.06.28.00-v2) 302 | - React-Core/Default (= 0.69.5) 303 | - React-cxxreact (= 0.69.5) 304 | - React-jsi (= 0.69.5) 305 | - React-jsiexecutor (= 0.69.5) 306 | - React-perflogger (= 0.69.5) 307 | - Yoga 308 | - React-CoreModules (0.69.5): 309 | - RCT-Folly (= 2021.06.28.00-v2) 310 | - RCTTypeSafety (= 0.69.5) 311 | - React-Codegen (= 0.69.5) 312 | - React-Core/CoreModulesHeaders (= 0.69.5) 313 | - React-jsi (= 0.69.5) 314 | - React-RCTImage (= 0.69.5) 315 | - ReactCommon/turbomodule/core (= 0.69.5) 316 | - React-cxxreact (0.69.5): 317 | - boost (= 1.76.0) 318 | - DoubleConversion 319 | - glog 320 | - RCT-Folly (= 2021.06.28.00-v2) 321 | - React-callinvoker (= 0.69.5) 322 | - React-jsi (= 0.69.5) 323 | - React-jsinspector (= 0.69.5) 324 | - React-logger (= 0.69.5) 325 | - React-perflogger (= 0.69.5) 326 | - React-runtimeexecutor (= 0.69.5) 327 | - React-jsi (0.69.5): 328 | - boost (= 1.76.0) 329 | - DoubleConversion 330 | - glog 331 | - RCT-Folly (= 2021.06.28.00-v2) 332 | - React-jsi/Default (= 0.69.5) 333 | - React-jsi/Default (0.69.5): 334 | - boost (= 1.76.0) 335 | - DoubleConversion 336 | - glog 337 | - RCT-Folly (= 2021.06.28.00-v2) 338 | - React-jsiexecutor (0.69.5): 339 | - DoubleConversion 340 | - glog 341 | - RCT-Folly (= 2021.06.28.00-v2) 342 | - React-cxxreact (= 0.69.5) 343 | - React-jsi (= 0.69.5) 344 | - React-perflogger (= 0.69.5) 345 | - React-jsinspector (0.69.5) 346 | - React-logger (0.69.5): 347 | - glog 348 | - react-native-image-picker (4.10.0): 349 | - React-Core 350 | - react-native-mlkit-ocr (0.3.0): 351 | - GoogleMLKit/TextRecognition (= 2.6.0) 352 | - React-Core 353 | - React-perflogger (0.69.5) 354 | - React-RCTActionSheet (0.69.5): 355 | - React-Core/RCTActionSheetHeaders (= 0.69.5) 356 | - React-RCTAnimation (0.69.5): 357 | - RCT-Folly (= 2021.06.28.00-v2) 358 | - RCTTypeSafety (= 0.69.5) 359 | - React-Codegen (= 0.69.5) 360 | - React-Core/RCTAnimationHeaders (= 0.69.5) 361 | - React-jsi (= 0.69.5) 362 | - ReactCommon/turbomodule/core (= 0.69.5) 363 | - React-RCTBlob (0.69.5): 364 | - RCT-Folly (= 2021.06.28.00-v2) 365 | - React-Codegen (= 0.69.5) 366 | - React-Core/RCTBlobHeaders (= 0.69.5) 367 | - React-Core/RCTWebSocket (= 0.69.5) 368 | - React-jsi (= 0.69.5) 369 | - React-RCTNetwork (= 0.69.5) 370 | - ReactCommon/turbomodule/core (= 0.69.5) 371 | - React-RCTImage (0.69.5): 372 | - RCT-Folly (= 2021.06.28.00-v2) 373 | - RCTTypeSafety (= 0.69.5) 374 | - React-Codegen (= 0.69.5) 375 | - React-Core/RCTImageHeaders (= 0.69.5) 376 | - React-jsi (= 0.69.5) 377 | - React-RCTNetwork (= 0.69.5) 378 | - ReactCommon/turbomodule/core (= 0.69.5) 379 | - React-RCTLinking (0.69.5): 380 | - React-Codegen (= 0.69.5) 381 | - React-Core/RCTLinkingHeaders (= 0.69.5) 382 | - React-jsi (= 0.69.5) 383 | - ReactCommon/turbomodule/core (= 0.69.5) 384 | - React-RCTNetwork (0.69.5): 385 | - RCT-Folly (= 2021.06.28.00-v2) 386 | - RCTTypeSafety (= 0.69.5) 387 | - React-Codegen (= 0.69.5) 388 | - React-Core/RCTNetworkHeaders (= 0.69.5) 389 | - React-jsi (= 0.69.5) 390 | - ReactCommon/turbomodule/core (= 0.69.5) 391 | - React-RCTSettings (0.69.5): 392 | - RCT-Folly (= 2021.06.28.00-v2) 393 | - RCTTypeSafety (= 0.69.5) 394 | - React-Codegen (= 0.69.5) 395 | - React-Core/RCTSettingsHeaders (= 0.69.5) 396 | - React-jsi (= 0.69.5) 397 | - ReactCommon/turbomodule/core (= 0.69.5) 398 | - React-RCTText (0.69.5): 399 | - React-Core/RCTTextHeaders (= 0.69.5) 400 | - React-RCTVibration (0.69.5): 401 | - RCT-Folly (= 2021.06.28.00-v2) 402 | - React-Codegen (= 0.69.5) 403 | - React-Core/RCTVibrationHeaders (= 0.69.5) 404 | - React-jsi (= 0.69.5) 405 | - ReactCommon/turbomodule/core (= 0.69.5) 406 | - React-runtimeexecutor (0.69.5): 407 | - React-jsi (= 0.69.5) 408 | - ReactCommon/turbomodule/core (0.69.5): 409 | - DoubleConversion 410 | - glog 411 | - RCT-Folly (= 2021.06.28.00-v2) 412 | - React-bridging (= 0.69.5) 413 | - React-callinvoker (= 0.69.5) 414 | - React-Core (= 0.69.5) 415 | - React-cxxreact (= 0.69.5) 416 | - React-jsi (= 0.69.5) 417 | - React-logger (= 0.69.5) 418 | - React-perflogger (= 0.69.5) 419 | - SocketRocket (0.6.1) 420 | - Yoga (1.14.0) 421 | - YogaKit (1.18.1): 422 | - Yoga (~> 1.14) 423 | 424 | DEPENDENCIES: 425 | - boost (from `../node_modules/react-native/third-party-podspecs/boost.podspec`) 426 | - DoubleConversion (from `../node_modules/react-native/third-party-podspecs/DoubleConversion.podspec`) 427 | - FBLazyVector (from `../node_modules/react-native/Libraries/FBLazyVector`) 428 | - FBReactNativeSpec (from `../node_modules/react-native/React/FBReactNativeSpec`) 429 | - Flipper (= 0.125.0) 430 | - Flipper-Boost-iOSX (= 1.76.0.1.11) 431 | - Flipper-DoubleConversion (= 3.2.0.1) 432 | - Flipper-Fmt (= 7.1.7) 433 | - Flipper-Folly (= 2.6.10) 434 | - Flipper-Glog (= 0.5.0.5) 435 | - Flipper-PeerTalk (= 0.0.4) 436 | - Flipper-RSocket (= 1.4.3) 437 | - FlipperKit (= 0.125.0) 438 | - FlipperKit/Core (= 0.125.0) 439 | - FlipperKit/CppBridge (= 0.125.0) 440 | - FlipperKit/FBCxxFollyDynamicConvert (= 0.125.0) 441 | - FlipperKit/FBDefines (= 0.125.0) 442 | - FlipperKit/FKPortForwarding (= 0.125.0) 443 | - FlipperKit/FlipperKitHighlightOverlay (= 0.125.0) 444 | - FlipperKit/FlipperKitLayoutPlugin (= 0.125.0) 445 | - FlipperKit/FlipperKitLayoutTextSearchable (= 0.125.0) 446 | - FlipperKit/FlipperKitNetworkPlugin (= 0.125.0) 447 | - FlipperKit/FlipperKitReactPlugin (= 0.125.0) 448 | - FlipperKit/FlipperKitUserDefaultsPlugin (= 0.125.0) 449 | - FlipperKit/SKIOSNetworkPlugin (= 0.125.0) 450 | - glog (from `../node_modules/react-native/third-party-podspecs/glog.podspec`) 451 | - OpenSSL-Universal (= 1.1.1100) 452 | - RCT-Folly (from `../node_modules/react-native/third-party-podspecs/RCT-Folly.podspec`) 453 | - RCTRequired (from `../node_modules/react-native/Libraries/RCTRequired`) 454 | - RCTTypeSafety (from `../node_modules/react-native/Libraries/TypeSafety`) 455 | - React (from `../node_modules/react-native/`) 456 | - React-bridging (from `../node_modules/react-native/ReactCommon`) 457 | - React-callinvoker (from `../node_modules/react-native/ReactCommon/callinvoker`) 458 | - React-Codegen (from `build/generated/ios`) 459 | - React-Core (from `../node_modules/react-native/`) 460 | - React-Core/DevSupport (from `../node_modules/react-native/`) 461 | - React-Core/RCTWebSocket (from `../node_modules/react-native/`) 462 | - React-CoreModules (from `../node_modules/react-native/React/CoreModules`) 463 | - React-cxxreact (from `../node_modules/react-native/ReactCommon/cxxreact`) 464 | - React-jsi (from `../node_modules/react-native/ReactCommon/jsi`) 465 | - React-jsiexecutor (from `../node_modules/react-native/ReactCommon/jsiexecutor`) 466 | - React-jsinspector (from `../node_modules/react-native/ReactCommon/jsinspector`) 467 | - React-logger (from `../node_modules/react-native/ReactCommon/logger`) 468 | - react-native-image-picker (from `../node_modules/react-native-image-picker`) 469 | - react-native-mlkit-ocr (from `../node_modules/react-native-mlkit-ocr`) 470 | - React-perflogger (from `../node_modules/react-native/ReactCommon/reactperflogger`) 471 | - React-RCTActionSheet (from `../node_modules/react-native/Libraries/ActionSheetIOS`) 472 | - React-RCTAnimation (from `../node_modules/react-native/Libraries/NativeAnimation`) 473 | - React-RCTBlob (from `../node_modules/react-native/Libraries/Blob`) 474 | - React-RCTImage (from `../node_modules/react-native/Libraries/Image`) 475 | - React-RCTLinking (from `../node_modules/react-native/Libraries/LinkingIOS`) 476 | - React-RCTNetwork (from `../node_modules/react-native/Libraries/Network`) 477 | - React-RCTSettings (from `../node_modules/react-native/Libraries/Settings`) 478 | - React-RCTText (from `../node_modules/react-native/Libraries/Text`) 479 | - React-RCTVibration (from `../node_modules/react-native/Libraries/Vibration`) 480 | - React-runtimeexecutor (from `../node_modules/react-native/ReactCommon/runtimeexecutor`) 481 | - ReactCommon/turbomodule/core (from `../node_modules/react-native/ReactCommon`) 482 | - Yoga (from `../node_modules/react-native/ReactCommon/yoga`) 483 | 484 | SPEC REPOS: 485 | trunk: 486 | - CocoaAsyncSocket 487 | - Flipper 488 | - Flipper-Boost-iOSX 489 | - Flipper-DoubleConversion 490 | - Flipper-Fmt 491 | - Flipper-Folly 492 | - Flipper-Glog 493 | - Flipper-PeerTalk 494 | - Flipper-RSocket 495 | - FlipperKit 496 | - fmt 497 | - GoogleDataTransport 498 | - GoogleMLKit 499 | - GoogleToolboxForMac 500 | - GoogleUtilities 501 | - GoogleUtilitiesComponents 502 | - GTMSessionFetcher 503 | - libevent 504 | - MLImage 505 | - MLKitCommon 506 | - MLKitTextRecognition 507 | - MLKitTextRecognitionCommon 508 | - MLKitVision 509 | - nanopb 510 | - OpenSSL-Universal 511 | - PromisesObjC 512 | - Protobuf 513 | - SocketRocket 514 | - YogaKit 515 | 516 | EXTERNAL SOURCES: 517 | boost: 518 | :podspec: "../node_modules/react-native/third-party-podspecs/boost.podspec" 519 | DoubleConversion: 520 | :podspec: "../node_modules/react-native/third-party-podspecs/DoubleConversion.podspec" 521 | FBLazyVector: 522 | :path: "../node_modules/react-native/Libraries/FBLazyVector" 523 | FBReactNativeSpec: 524 | :path: "../node_modules/react-native/React/FBReactNativeSpec" 525 | glog: 526 | :podspec: "../node_modules/react-native/third-party-podspecs/glog.podspec" 527 | RCT-Folly: 528 | :podspec: "../node_modules/react-native/third-party-podspecs/RCT-Folly.podspec" 529 | RCTRequired: 530 | :path: "../node_modules/react-native/Libraries/RCTRequired" 531 | RCTTypeSafety: 532 | :path: "../node_modules/react-native/Libraries/TypeSafety" 533 | React: 534 | :path: "../node_modules/react-native/" 535 | React-bridging: 536 | :path: "../node_modules/react-native/ReactCommon" 537 | React-callinvoker: 538 | :path: "../node_modules/react-native/ReactCommon/callinvoker" 539 | React-Codegen: 540 | :path: build/generated/ios 541 | React-Core: 542 | :path: "../node_modules/react-native/" 543 | React-CoreModules: 544 | :path: "../node_modules/react-native/React/CoreModules" 545 | React-cxxreact: 546 | :path: "../node_modules/react-native/ReactCommon/cxxreact" 547 | React-jsi: 548 | :path: "../node_modules/react-native/ReactCommon/jsi" 549 | React-jsiexecutor: 550 | :path: "../node_modules/react-native/ReactCommon/jsiexecutor" 551 | React-jsinspector: 552 | :path: "../node_modules/react-native/ReactCommon/jsinspector" 553 | React-logger: 554 | :path: "../node_modules/react-native/ReactCommon/logger" 555 | react-native-image-picker: 556 | :path: "../node_modules/react-native-image-picker" 557 | react-native-mlkit-ocr: 558 | :path: "../node_modules/react-native-mlkit-ocr" 559 | React-perflogger: 560 | :path: "../node_modules/react-native/ReactCommon/reactperflogger" 561 | React-RCTActionSheet: 562 | :path: "../node_modules/react-native/Libraries/ActionSheetIOS" 563 | React-RCTAnimation: 564 | :path: "../node_modules/react-native/Libraries/NativeAnimation" 565 | React-RCTBlob: 566 | :path: "../node_modules/react-native/Libraries/Blob" 567 | React-RCTImage: 568 | :path: "../node_modules/react-native/Libraries/Image" 569 | React-RCTLinking: 570 | :path: "../node_modules/react-native/Libraries/LinkingIOS" 571 | React-RCTNetwork: 572 | :path: "../node_modules/react-native/Libraries/Network" 573 | React-RCTSettings: 574 | :path: "../node_modules/react-native/Libraries/Settings" 575 | React-RCTText: 576 | :path: "../node_modules/react-native/Libraries/Text" 577 | React-RCTVibration: 578 | :path: "../node_modules/react-native/Libraries/Vibration" 579 | React-runtimeexecutor: 580 | :path: "../node_modules/react-native/ReactCommon/runtimeexecutor" 581 | ReactCommon: 582 | :path: "../node_modules/react-native/ReactCommon" 583 | Yoga: 584 | :path: "../node_modules/react-native/ReactCommon/yoga" 585 | 586 | SPEC CHECKSUMS: 587 | boost: a7c83b31436843459a1961bfd74b96033dc77234 588 | CocoaAsyncSocket: 065fd1e645c7abab64f7a6a2007a48038fdc6a99 589 | DoubleConversion: 5189b271737e1565bdce30deb4a08d647e3f5f54 590 | FBLazyVector: 0045cf98ca4a48af3bf7108d85b1c243740fa289 591 | FBReactNativeSpec: 82e74141263f8c962e288f5cd6b5d149cdc8afe1 592 | Flipper: 26fc4b7382499f1281eb8cb921e5c3ad6de91fe0 593 | Flipper-Boost-iOSX: fd1e2b8cbef7e662a122412d7ac5f5bea715403c 594 | Flipper-DoubleConversion: 2dc99b02f658daf147069aad9dbd29d8feb06d30 595 | Flipper-Fmt: 60cbdd92fc254826e61d669a5d87ef7015396a9b 596 | Flipper-Folly: 584845625005ff068a6ebf41f857f468decd26b3 597 | Flipper-Glog: 70c50ce58ddaf67dc35180db05f191692570f446 598 | Flipper-PeerTalk: 116d8f857dc6ef55c7a5a75ea3ceaafe878aadc9 599 | Flipper-RSocket: d9d9ade67cbecf6ac10730304bf5607266dd2541 600 | FlipperKit: cbdee19bdd4e7f05472a66ce290f1b729ba3cb86 601 | fmt: ff9d55029c625d3757ed641535fd4a75fedc7ce9 602 | glog: 3d02b25ca00c2d456734d0bcff864cbc62f6ae1a 603 | GoogleDataTransport: 54dee9d48d14580407f8f5fbf2f496e92437a2f2 604 | GoogleMLKit: 755661c46990a85e42278015f26400286d98ad95 605 | GoogleToolboxForMac: 8bef7c7c5cf7291c687cf5354f39f9db6399ad34 606 | GoogleUtilities: 13e2c67ede716b8741c7989e26893d151b2b2084 607 | GoogleUtilitiesComponents: 679b2c881db3b615a2777504623df6122dd20afe 608 | GTMSessionFetcher: 5595ec75acf5be50814f81e9189490412bad82ba 609 | libevent: 4049cae6c81cdb3654a443be001fb9bdceff7913 610 | MLImage: a454f9f8ecfd537783a12f9488f5be1a68820829 611 | MLKitCommon: 3bc17c6f7d25ce3660f030350b46ae7ec9ebca6e 612 | MLKitTextRecognition: 8b0e0023a4babc66ca83d8b82864e57931164445 613 | MLKitTextRecognitionCommon: 3e84602c928fe2b775fae81376f2136324cbd763 614 | MLKitVision: e87dc3f2e456a6ab32361ebd985e078dd2746143 615 | nanopb: b552cce312b6c8484180ef47159bc0f65a1f0431 616 | OpenSSL-Universal: ebc357f1e6bc71fa463ccb2fe676756aff50e88c 617 | PromisesObjC: c50d2056b5253dadbd6c2bea79b0674bd5a52fa4 618 | Protobuf: 970f7ee93a3a08e3cf64859b8efd95ee32b4f87f 619 | RCT-Folly: b9d9fe1fc70114b751c076104e52f3b1b5e5a95a 620 | RCTRequired: 85c60c4bde8241278be2c93420de4c65475a2151 621 | RCTTypeSafety: 15990f289215eb0fc65c5eb6e2610faeeda8d5e1 622 | React: 6cfa9367042a85f6235740420df017d51efc6494 623 | React-bridging: bf49ea3fa02446c647748d33cc9cbc0f5509bba7 624 | React-callinvoker: 6b98a94d1f5063afe211379d061b01f40707394a 625 | React-Codegen: 2fe0ade7442acce0b729a228a2d9111b6ef294e2 626 | React-Core: ad82eacbe769f918b0d199df3cb7c780cd3f46ff 627 | React-CoreModules: 72b07fed89ab0e7f2600f9275ec9642130aa920c 628 | React-cxxreact: 2bba16be9eb4116bee86e3dfd85aeb67b2795eca 629 | React-jsi: 013de11039e08ae5d67868a72f1012794d34e72f 630 | React-jsiexecutor: e42f0b46de293a026c2fb20e524d4fe09f81f575 631 | React-jsinspector: e385fb7a1440ae3f3b2cd1a139ca5aadaab43c10 632 | React-logger: 15c734997c06fe9c9b88e528fb7757601e7a56df 633 | react-native-image-picker: 4bc9ed38c8be255b515d8c88babbaf74973f91a8 634 | react-native-mlkit-ocr: 917b31ca7ea79be2dc91d3625f2ae09ba1560a57 635 | React-perflogger: 367418425c5e4a9f0f80385ee1eaacd2a7348f8e 636 | React-RCTActionSheet: e4885e7136f98ded1137cd3daccc05eaed97d5a6 637 | React-RCTAnimation: 7c5a74f301c9b763343ba98a3dd776ed2676993f 638 | React-RCTBlob: 5c294e0415b290b1b3b72ec454c43e3afcfab444 639 | React-RCTImage: e82034ab64dfbadd3e0b42d830a810702f59f758 640 | React-RCTLinking: f007e2b4094e1fd364f3bde8bbd94113d4e1e70f 641 | React-RCTNetwork: 72eaf2f4cbcb5105b2ef4ac6a987b51047d8835f 642 | React-RCTSettings: 61949292107ca7b6cf9601679e952b1b5a3546a7 643 | React-RCTText: 307181243987b73aaefc22afd0b57b10ef970429 644 | React-RCTVibration: 42b34fde72e42446d9b08d2b9a3ddc2fa9ac6189 645 | React-runtimeexecutor: c778439c3c430a5719d027d3c67423b390a221fe 646 | ReactCommon: ab1003b81be740fecd82509c370a45b1a7dda0c1 647 | SocketRocket: f32cd54efbe0f095c4d7594881e52619cfe80b17 648 | Yoga: c2b1f2494060865ac1f27e49639e72371b1205fa 649 | YogaKit: f782866e155069a2cca2517aafea43200b01fd5a 650 | 651 | PODFILE CHECKSUM: d347a449da4aa8b7ad0bde6b08d9d1352634e430 652 | 653 | COCOAPODS: 1.12.1 654 | -------------------------------------------------------------------------------- /example/metro.config.js: -------------------------------------------------------------------------------- 1 | const path = require('path'); 2 | const blacklist = require('metro-config/src/defaults/blacklist'); 3 | const escape = require('escape-string-regexp'); 4 | const pak = require('../package.json'); 5 | 6 | const root = path.resolve(__dirname, '..'); 7 | 8 | const modules = Object.keys({ 9 | ...pak.peerDependencies, 10 | }); 11 | 12 | module.exports = { 13 | projectRoot: __dirname, 14 | watchFolders: [root], 15 | 16 | // We need to make sure that only one version is loaded for peerDependencies 17 | // So we blacklist them at the root, and alias them to the versions in example's node_modules 18 | resolver: { 19 | blacklistRE: blacklist( 20 | modules.map( 21 | (m) => 22 | new RegExp(`^${escape(path.join(root, 'node_modules', m))}\\/.*$`) 23 | ) 24 | ), 25 | 26 | extraNodeModules: modules.reduce((acc, name) => { 27 | acc[name] = path.join(__dirname, 'node_modules', name); 28 | return acc; 29 | }, {}), 30 | }, 31 | 32 | transformer: { 33 | getTransformOptions: async () => ({ 34 | transform: { 35 | experimentalImportSupport: false, 36 | inlineRequires: true, 37 | }, 38 | }), 39 | }, 40 | }; 41 | -------------------------------------------------------------------------------- /example/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "react-native-mlkit-ocr-example", 3 | "description": "Example app for react-native-mlkit-ocr", 4 | "version": "0.0.1", 5 | "private": true, 6 | "scripts": { 7 | "android": "react-native run-android", 8 | "ios": "react-native run-ios", 9 | "start": "react-native start" 10 | }, 11 | "dependencies": { 12 | "react": "18.0.0", 13 | "react-native": "0.69.5", 14 | "react-native-image-picker": "^4.10.0", 15 | "react-native-mlkit-ocr": "link:../" 16 | }, 17 | "devDependencies": { 18 | "@babel/core": "^7.12.9", 19 | "@babel/runtime": "^7.12.5", 20 | "babel-plugin-module-resolver": "^4.1.0", 21 | "metro-react-native-babel-preset": "^0.72.1", 22 | "pod-install": "^0.1.38" 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /example/src/App.tsx: -------------------------------------------------------------------------------- 1 | /* eslint-disable react-native/no-inline-styles */ 2 | import * as React from 'react'; 3 | import { 4 | StyleSheet, 5 | View, 6 | Button, 7 | SafeAreaView, 8 | ScrollView, 9 | Text, 10 | Dimensions, 11 | ActivityIndicator, 12 | } from 'react-native'; 13 | import { Asset, launchImageLibrary } from 'react-native-image-picker'; 14 | import MlkitOcr, { MlkitOcrResult } from 'react-native-mlkit-ocr'; 15 | 16 | export default function App() { 17 | const [loading, setLoading] = React.useState(false); 18 | const [result, setResult] = React.useState(); 19 | const [image, setImage] = React.useState(); 20 | 21 | if (loading) { 22 | return ( 23 | 24 | 25 | 26 | ); 27 | } 28 | return ( 29 | 30 | {!!result?.length && ( 31 | 40 | {result?.map((block) => { 41 | return block.lines.map((line) => { 42 | return ( 43 | 54 | {line.text} 55 | 56 | ); 57 | }); 58 | })} 59 | 60 | )} 61 | 62 |