Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[iOS]: "RNTfliteSpec.h" not found in RN 0.75 with new arch #87

Open
mbpictures opened this issue Sep 2, 2024 · 22 comments · May be fixed by #126
Open

[iOS]: "RNTfliteSpec.h" not found in RN 0.75 with new arch #87

mbpictures opened this issue Sep 2, 2024 · 22 comments · May be fixed by #126

Comments

@mbpictures
Copy link

Hi!

I'm using react-native 0.75 with the new architecture enabled and I'm getting an XCode compile error, that the file "RNTfliteSpec.h" could not be found in this line:

#import "RNTfliteSpec.h"

There was an issue regarding this problem but it has been closed without solving, so I'm creating a new one. Any help in addressing this problem would be highly appreciated! Thanks already!

Copy link

Guten Tag, Hans here! 🍻

Thanks for your report! It looks like you're having trouble with the file "RNTfliteSpec.h" not being found. Please make sure you have followed all installation instructions and double-check your project setup with the documentation.

Also, could you please provide more information regarding your environment? Specifically, we need to know if there are any relevant logs from Xcode. You can find them in the Xcode logs window during the build process. This would greatly help mrousavy in diagnosing ze problem.

If you feel like this issue might be caused by something else, please feel free to update your post and we can take another look!

Danke!

Note: If you think I made a mistake, please ping @mrousavy to take a look.

@lucksp
Copy link

lucksp commented Sep 24, 2024

I get this error building for Android also.

  • expo : ~50.0.19
  • react-native : 0.73.6
  • react-native-vision-camera: 4.5.1
  • react-native-fast-tflite: 1.3.0

@liontariai
Copy link

I think this happens, because there's no codegenConfig in the package.json for @react-native/codegen to generate the turbomodule header file.

#14 (comment)

@mrousavy as you mentioned here, the file is missing, correct. But it's not that you would create it by hand. It seems it would be generated, if the config is set up properly. I found a tutorial here: https://medium.com/@sanchitsrivastava247/creating-turbo-module-in-react-native-0-74-73c6cae6a945

I'll try to fix this somehow and report back. Perhaps we can come up with a PR

@liontariai
Copy link

You can try my fork: https://github.com/liontariai/react-native-fast-tflite

  1. Install from github with "react-native-fast-tflite": "liontariai/react-native-fast-tflite",
  2. Copy the dir https://github.com/liontariai/react-native-fast-tflite/tree/main/src/expo-plugin into your root project
  3. In withFastTFLite.ts replace const pkg = require('../../../package.json') with const pkg = require("react-native-fast-tflite/package.json");
  4. Use the plugin from your root project in your expo config. The reason for this is, that otherwise you'd be importing Typescript from a node_modules location which doesn't work. The correct fix for this would be to publish an updated package, but this is WIP.

@mSenad
Copy link

mSenad commented Nov 12, 2024

@liontariai do you have any information when it comes to bare workflow in react-native? I have the sam issue and this is my package.json file:

{
  "name": "PoseDetection",
  "version": "0.0.1",
  "private": true,
  "scripts": {
    "android": "react-native run-android",
    "ios": "react-native run-ios",
    "lint": "eslint .",
    "start": "react-native start",
    "test": "jest"
  },
  "dependencies": {
    "react": "18.3.1",
    "react-native": "0.76.1",
    "react-native-fast-tflite": "^1.5.0",
    "react-native-vision-camera": "^4.6.1",
    "react-native-worklets-core": "^1.5.0"
  },
  "devDependencies": {
    "@babel/core": "^7.25.2",
    "@babel/preset-env": "^7.25.3",
    "@babel/runtime": "^7.25.0",
    "@react-native-community/cli": "15.0.0",
    "@react-native-community/cli-platform-android": "15.0.0",
    "@react-native-community/cli-platform-ios": "15.0.0",
    "@react-native/babel-preset": "0.76.1",
    "@react-native/eslint-config": "0.76.1",
    "@react-native/metro-config": "0.76.1",
    "@react-native/typescript-config": "0.76.1",
    "@types/react": "^18.2.6",
    "@types/react-test-renderer": "^18.0.0",
    "babel-jest": "^29.6.3",
    "eslint": "^8.19.0",
    "jest": "^29.6.3",
    "prettier": "2.8.8",
    "react-test-renderer": "18.3.1",
    "typescript": "5.0.4"
  },
  "engines": {
    "node": ">=18"
  }
}

I've got nothing much happening here yet but my build is failing just because I have "react-native-fast-tflite" installed. Thanks!

@lucksp
Copy link

lucksp commented Nov 12, 2024

but my build is failing just because I have "react-native-fast-tflite" installed

What is the build failure message?

@mSenad
Copy link

mSenad commented Nov 12, 2024

@lucksp Thanks for hopping in.

So, currently I uninstall 'react-native-fast-tflite' and tried to build my app and everything works as expected.

When I:

  • install react-native-fast-tflite
  • cd ios/
  • pod install ( which shows me : Installing TensorFlowLiteC (2.17.0) Installing react-native-fast-tflite (1.5.0 )

This is everything I do, than I go to build my app from the xcode and here is the error:

Screenshot 2024-11-12 at 4 23 52 PM

@liontariai
Copy link

Hey @mSenad , I'll try my best:

I think generally you need to do the exact same thing I did, the error you see is what I saw.
The problem is that the package is not fully implemented as TurboModule, which is required (?) for the new architecture.

So if you follow the steps I have outlined above, you should be able to fix it. The only thing that's different, is that you'll be doing the things that are done by the expo plugins manually.

If I see it right, the plugin only adds a variable to your Podfile and adds a Framework to the XCode project:
grafik

And this is also only done, if you want to use the CoreML Delegates (i'm no expert on what it is / why you'd need it... i think it's like GPU/NeuralEngine acceleration?)
grafik

So therefore, you might as well skip the expo plugins / Podfile modifications and might still work...
Give it a try and report back, so I might help you further if needed ;)

@mSenad
Copy link

mSenad commented Nov 12, 2024

@liontariai thanks man, I really appreciate it that you took your time to give me some insights.

Currently, when I run npm install liontariai/react-native-fast-tflite my terminal just stucks. Is there something that I need to do here in order to have this package installed or?

...and how I understood, I just need to have expo-plugin folder in my project root level and apply the changes you've mentioned, right?

@liontariai
Copy link

you're welcome! Well... I'm not 100% sure why it stucks. I have installed it by putting it in my package.json and running the install then, I'm not sure how you tell npm to look at github via the cli command, even though it might be correct the way you did it.

grafik

Also you could check if you have some logs for npm. I think it prints logs somewhere in the /tmp dir.
Could be that there's some post-install script running a pod install maybe? I'm not sure but if I remember correctly, the pod install can take some time...

Regarding the plugins... if you don't use expo, you shouldn't need to do anything other than installing the package from my repo.

@mSenad
Copy link

mSenad commented Nov 12, 2024

@liontariai for some reason I am not able to install your fork of the repo... I've tried with adding "react-native-fast-tflite": "liontariai/react-native-fast-tflite", to my package.json and by running npm install directly but it's just stucked.

I see your latest commit inside the forked repo so maybe I can just apply the same changes and try to use my own fork. That's the only thing that comes to my mind at the moment.

Appreciate your effort man!

@liontariai
Copy link

Yes, you can definitely do that.
You can try your own fork, or for the time being just apply the changes in your locally installed pkg.
I only made a fork so that it would be somewhat consistent and not vanish after a fresh install of packages... and also to have a starting point to make a contribution back to this package.

@babldev
Copy link

babldev commented Nov 18, 2024

I'm very new to React Native, but hit the same issue.

FWIW, I disabled the new architecture temporarily and that works fine.

diff --git a/react-native/app.json b/react-native/app.json
index 81ef5a8..056c4c4 100644
--- a/react-native/app.json
+++ b/react-native/app.json
@@ -7,7 +7,7 @@
     "icon": "./assets/images/icon.png",
     "scheme": "myapp",
     "userInterfaceStyle": "automatic",
-    "newArchEnabled": true,
+    "newArchEnabled": false,
     "ios": {
       "supportsTablet": true,
       "infoPlist": {

I then deleted the ios/ and android/ directories and re-built.

This was a default changed recently for new projects:

https://reactnative.dev/blog/2024/10/23/release-0.76-new-architecture#:~:text=React%20Native%20New%20Architecture%20by%20default%E2%80%8B,quality%20native%20applications%20using%20React.

Going to come back and try to get this working with the new architecture but sharing this info for now.

@fwcd
Copy link

fwcd commented Nov 27, 2024

Disabling the new arch fixed it for me too. I had to use

RCT_NEW_ARCH_ENABLED=0 pod install

to reinstall/regenerate the CocoaPods project.

@gpbaculio
Copy link

Is there workaround atm for with new Arch?

@liontariai
Copy link

Is there workaround atm for with new Arch?

#87 (comment)

try my guide

@lucksp
Copy link

lucksp commented Dec 14, 2024

done, if you want to use the CoreML Delegates (i'm no expert on what it is / why you'd need it... i think it's like GPU/NeuralEngine acceleration?)

Does any one else have issues with iOS GPU on packages 1.40 and up? It’s fine on 1.3.0

@boorad
Copy link

boorad commented Jan 5, 2025

You can try my fork: https://github.com/liontariai/react-native-fast-tflite

@liontariai I also have a fork now, updated for fast-tflite recent commits since yours. You should open a PR to get yours merged in, as I don't think there are any conflicts. It may only be a stop-gap until it can all use Nitro, but still, we should discuss it in a PR 🙂

@liontariai
Copy link

You can try my fork: https://github.com/liontariai/react-native-fast-tflite

@liontariai I also have a fork now, updated for fast-tflite recent commits since yours. You should open a PR to get yours merged in, as I don't think there are any conflicts. It may only be a stop-gap until it can all use Nitro, but still, we should discuss it in a PR 🙂

yes you're right... haven't really worked on the project I needed this for since then, but I'll open a PR as soon as I get back to it 👍

@rmscrlos
Copy link

rmscrlos commented Jan 19, 2025

I tried implementing the workaround but I can't no longer npm i. Doing step 1 where you just past "react-native-fast-tflite": "liontariai/react-native-fast-tflite" in the package.json breaks it for me.

npm error code 128
npm error git dep preparation failed
npm error command /Users/carlosramos/.nvm/versions/node/v22.11.0/bin/node /Users/carlosramos/.nvm/versions/node/v22.11.0/lib/node_modules/npm/bin/npm-cli.js install --force --cache=/Users/carlosramos/.npm --prefer-offline=false --prefer-online=false --offline=false --no-progress --no-save --no-audit --include=dev --include=peer --include=optional --no-package-lock-only --no-dry-run
npm error > [email protected] prepare
npm error > git submodule update --init --recursive
npm error npm warn using --force Recommended protections disabled.
npm error npm warn deprecated @types/[email protected]: This is a stub types definition. react-native provides its own type definitions, so you do not need this installed.
npm error npm warn deprecated [email protected]: This module is not supported, and leaks memory. Do not use it. Check out lru-cache if you want a good and tested way to coalesce async requests by a key value, which is much more comprehensive and powerful.
npm error npm warn deprecated @babel/[email protected]: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-numeric-separator instead.
npm error npm warn deprecated @babel/[email protected]: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-nullish-coalescing-operator instead.
npm error npm warn deprecated @babel/[email protected]: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-class-properties instead.
npm error npm warn deprecated @babel/[email protected]: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-optional-catch-binding instead.
npm error npm warn deprecated [email protected]: Rimraf versions prior to v4 are no longer supported
npm error npm warn deprecated @humanwhocodes/[email protected]: Use @eslint/config-array instead
npm error npm warn deprecated @babel/[email protected]: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-async-generator-functions instead.
npm error npm warn deprecated @babel/[email protected]: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-optional-chaining instead.
npm error npm warn deprecated [email protected]: Rimraf versions prior to v4 are no longer supported
npm error npm warn deprecated [email protected]: Glob versions prior to v9 are no longer supported
npm error npm warn deprecated @babel/[email protected]: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-object-rest-spread instead.
npm error npm warn deprecated [email protected]: Package no longer supported. Contact Support at https://www.npmjs.com/support for more info.
npm error npm warn deprecated [email protected]: Glob versions prior to v9 are no longer supported
npm error npm warn deprecated @humanwhocodes/[email protected]: Use @eslint/object-schema instead
npm error npm warn deprecated @xmldom/[email protected]: this version is no longer supported, please update to at least 0.8.*
npm error npm warn deprecated [email protected]: This version is no longer supported. Please see https://eslint.org/version-support for other options.
npm error fatal: not a git repository (or any of the parent directories): .git
npm error npm error code 128
npm error npm error path /Users/carlosramos/.npm/_cacache/tmp/git-clonebXTygH
npm error npm error command failed
npm error npm error command sh -c git submodule update --init --recursive
npm error npm error A complete log of this run can be found in: /Users/carlosramos/.npm/_logs/2025-01-19T05_25_18_505Z-debug-0.log
npm error A complete log of this run can be found in: /Users/carlosramos/.npm/_logs/2025-01-19T05_24_22_660Z-debug-0.log

@Jonatthu
Copy link

I guess this is stuck? This is happening to me on expo newest version and RN 0.76

@boorad
Copy link

boorad commented Jan 25, 2025

There are two forks you can point your package.json to in the comments above. Maybe @liontariai will submit the PR... he did the work 😉

@boorad boorad linked a pull request Jan 25, 2025 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

10 participants