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: null is not an object evaluating TfliteReactNative.loadmodel #1

Closed
ojiofong opened this issue Feb 17, 2019 · 11 comments
Closed

iOS: null is not an object evaluating TfliteReactNative.loadmodel #1

ojiofong opened this issue Feb 17, 2019 · 11 comments

Comments

@ojiofong
Copy link
Contributor

First of all, thanks for this awesome project. Had this working on Android but not quite on iOS. The home screen with the buttons shows up. However, clicking on a button results in error: null is not an object evaluating TfliteReactNative.loadmodel

The only change I made was in the Pod file to get the build to succeed.

Pod file:

platform :ios, '9.0'

target 'example' do
  pod 'TensorFlowLite', '1.12.0'
  pod 'react-native-image-picker', :path => '../node_modules/react-native-image-picker'

  pod 'React', :path => '../node_modules/react-native'
  pod 'yoga', :path => '../node_modules/react-native/ReactCommon/yoga'

end

My npm version is 6.5.0

Need help with resolving this. Thanks.

@shaqian
Copy link
Owner

shaqian commented Feb 18, 2019

Hi,

Can you please try to manually link the library to your project?
https://github.com/shaqian/tflite-react-native#ios

Thanks,
Qian

@ojiofong
Copy link
Contributor Author

Thank you, Qian. I was finally able to resolve the issue by making some additional changes to the Pod file. However, I'll manually link the library later as well. Maybe it could fix this, but I had previously checked to make sure that all the files were added correctly via automatic linking.

@techgig17
Copy link

Thank you, Qian. I was finally able to resolve the issue by making some additional changes to the Pod file. However, I'll manually link the library later as well. Maybe it could fix this, but I had previously checked to make sure that all the files were added correctly via automatic linking.

Can you provide me the podfile changes you made to make it work?

@ojiofong
Copy link
Contributor Author

ojiofong commented May 8, 2019

Thank you, Qian. I was finally able to resolve the issue by making some additional changes to the Pod file. However, I'll manually link the library later as well. Maybe it could fix this, but I had previously checked to make sure that all the files were added correctly via automatic linking.

Can you provide me the podfile changes you made to make it work?

Here you go.

# Uncomment the next line to define a global platform for your project
platform :ios, '9.0'

target 'TurdsWithFriends' do
  pod 'TensorFlowLite', '1.12.0'
  pod 'react-native-image-picker', :path => '../node_modules/react-native-image-picker'
  pod 'React', :path => '../node_modules/react-native'
  pod 'yoga', :path => '../node_modules/react-native/ReactCommon/yoga'
  pod 'TfliteReactNative', :path => '../node_modules/tflite-react-native/ios'


end

# Workaround for RN upgrade issues: https://github.com/facebook/react-native/issues/24192
post_install do |installer|
  installer.pods_project.targets.each do |target|
    if target.name == "React"
      target.remove_from_project
    end
  end
end

@kashifsulaiman
Copy link

kashifsulaiman commented Sep 2, 2019

@ojiofong since you're using POD, so you didn't had done the manual linking except the Podfile part, right? I did the same, but I'm getting
image

Actually in TfliteReactNative.loadModel, TfliteReactNative is undefined which is destructed from NativeModules

@hokaiyipFS
Copy link

Manually linking with iOS fixed my issue

@Tayyaba3317
Copy link

@hokaiyipFS which react native version are you using?

@hokaiyipFS
Copy link

@Tayyaba3317 0.63.2

@lucidprojects
Copy link

lucidprojects commented Aug 20, 2021

Sorry to rehash an old thread but I'm having this same issue. And have tried the above fixes with no luck.

It does work if I build it to Android, which makes me think I have the model files in the wrong place.

This is where I have them currently: /ios/AppName/models

Any help appreciated.

@BILLXZY1215
Copy link

BILLXZY1215 commented Sep 2, 2021

Sorry to rehash an old thread but I'm having this same issue. And have tried the above fixes with no luck.

It does work if I build it to Android, which makes me think I have the model files in the wrong place.

This is where I have them currently: /ios/AppName/models

Any help appreciated.

Same issue. I tried manual link, however, when I try to build model in XCode, I get this:

截屏2021-09-02 下午10 46 12

https://stackoverflow.com/questions/41663002/react-rctbridgemodule-h-file-not-found#comment76499068_43340802

The link above mentioned some possible solutions. I think this is related to the version of React Native (>0.61).

Well, I fixed it by adding conditional import in RCTBridgeModule.h (after manual link, and follow the instruction in stackoverflow above):

#if __has_include("RCTDefines.h")
#import "RCTDefines.h"
#else
#import <React/RCTDefines.h>
#endif

@lucidprojects
Copy link

Same issue. I tried manual link, however, when I try to build model in XCode, I get this:

This comment helped me sort a similar RCTBridge issue.

Then just make sure you build it from Xcode from the xcworkspace not the xcodeproj

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

No branches or pull requests

8 participants