react-native-vision-camera icon indicating copy to clipboard operation
react-native-vision-camera copied to clipboard

🐛 Build 'react-native-vision-camera' failed in v0.68.2

Open jhongyi opened this issue 3 years ago • 10 comments

What were you trying to do?

I get the build error in iOS, and still can't resolve it.

  • "react": "17.0.2"
  • "react-native": "0.68.2"
  • "react-native-vision-camera": "^2.13.5"

Things I have done

I deleted my node_modules folder rm -rf package-lock.json && rm -rf yarn.lock && rm -rf node_modules rm -rf ios/Podfile.lock && rm -rf ios/Pods yarn cd ios && pod repo update && pod update && pod install

截圖 2022-07-07 11 46 45

Reproduceable Code

Undefined symbols for architecture x86_64:
  "typeinfo for reanimated::Scheduler", referenced from:
      typeinfo for vision::VisionCameraScheduler in VisionCameraScheduler.o
  "facebook::react::LongLivedObject::LongLivedObject()", referenced from:
      facebook::react::CallbackWrapper::CallbackWrapper(facebook::jsi::Function&&, facebook::jsi::Runtime&, std::__1::shared_ptr<facebook::react::CallInvoker>) in JSIUtils.o
  "facebook::react::LongLivedObject::~LongLivedObject()", referenced from:
      facebook::react::CallbackWrapper::CallbackWrapper(facebook::jsi::Function&&, facebook::jsi::Runtime&, std::__1::shared_ptr<facebook::react::CallInvoker>) in JSIUtils.o
      facebook::react::CallbackWrapper::~CallbackWrapper() in JSIUtils.o
  "facebook::react::LongLivedObjectCollection::get()", referenced from:
      facebook::react::CallbackWrapper::createWeak(facebook::jsi::Function&&, facebook::jsi::Runtime&, std::__1::shared_ptr<facebook::react::CallInvoker>) in JSIUtils.o
  "typeinfo for facebook::react::LongLivedObject", referenced from:
      typeinfo for facebook::react::CallbackWrapper in JSIUtils.o
  "facebook::react::LongLivedObjectCollection::add(std::__1::shared_ptr<facebook::react::LongLivedObject>) const", referenced from:
      facebook::react::CallbackWrapper::createWeak(facebook::jsi::Function&&, facebook::jsi::Runtime&, std::__1::shared_ptr<facebook::react::CallInvoker>) in JSIUtils.o
  "facebook::jsi::detail::throwJSError(facebook::jsi::Runtime&, char const*)", referenced from:
      std::__1::shared_ptr<facebook::jsi::HostObject> facebook::jsi::Object::asHostObject<facebook::jsi::HostObject>(facebook::jsi::Runtime&) const in JSIUtils.o
  "vtable for reanimated::Scheduler", referenced from:
      reanimated::Scheduler::Scheduler() in VisionCameraScheduler.o
      reanimated::Scheduler::~Scheduler() in VisionCameraScheduler.o
  NOTE: a missing vtable usually means the first non-inline virtual member function has no definition.
  "facebook::jsi::Object::getPropertyAsObject(facebook::jsi::Runtime&, char const*) const", referenced from:
      ___43+[JSConsoleHelper getLogFunctionForBridge:]_block_invoke_2 in JSConsoleHelper.o
  "vtable for facebook::jsi::HostObject", referenced from:
      facebook::jsi::HostObject::HostObject() in FrameProcessorUtils.o
  NOTE: a missing vtable usually means the first non-inline virtual member function has no definition.
  "typeinfo for facebook::jsi::HostObject", referenced from:
      typeinfo for FrameHostObject in FrameHostObject.o
      convertJSIValueToObjCObject(facebook::jsi::Runtime&, facebook::jsi::Value const&, std::__1::shared_ptr<facebook::react::CallInvoker>) in JSIUtils.o
  "typeinfo for facebook::jsi::JSError", referenced from:
      FrameHostObject::assertIsFrameStrong(facebook::jsi::Runtime&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) in FrameHostObject.o
      FrameHostObject::get(facebook::jsi::Runtime&, facebook::jsi::PropNameID const&)::$_1::operator()(facebook::jsi::Runtime&, facebook::jsi::Value const&, facebook::jsi::Value const*, unsigned long) const in FrameHostObject.o
      GCC_except_table6 in FrameProcessorUtils.o
      GCC_except_table3 in JSConsoleHelper.o
  "facebook::jsi::HostObject::set(facebook::jsi::Runtime&, facebook::jsi::PropNameID const&, facebook::jsi::Value const&)", referenced from:
      vtable for FrameHostObject in FrameHostObject.o
  "facebook::jsi::HostObject::~HostObject()", referenced from:
      FrameHostObject::~FrameHostObject() in FrameHostObject.o
  "facebook::jsi::JSError::~JSError()", referenced from:
      FrameHostObject::assertIsFrameStrong(facebook::jsi::Runtime&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) in FrameHostObject.o
      FrameHostObject::get(facebook::jsi::Runtime&, facebook::jsi::PropNameID const&)::$_1::operator()(facebook::jsi::Runtime&, facebook::jsi::Value const&, facebook::jsi::Value const*, unsigned long) const in FrameHostObject.o
  "facebook::react::LongLivedObject::allowRelease()", referenced from:
      facebook::react::CallbackWrapper::allowRelease() in JSIUtils.o
  "facebook::jsi::JSError::JSError(facebook::jsi::Runtime&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >)", referenced from:
      facebook::jsi::JSError::JSError(facebook::jsi::Runtime&, char const*) in FrameHostObject.o
  "facebook::react::LongLivedObjectCollection::remove(facebook::react::LongLivedObject const*) const", referenced from:
      facebook::react::CallbackWrapper::allowRelease() in JSIUtils.o
  "facebook::jsi::Value::Value(facebook::jsi::Value&&)", referenced from:
      facebook::jsi::Value::operator=(facebook::jsi::Value&&) in JSIUtils.o
  "facebook::jsi::Object::getPropertyAsFunction(facebook::jsi::Runtime&, char const*) const", referenced from:
      ___43+[JSConsoleHelper getLogFunctionForBridge:]_block_invoke_2 in JSConsoleHelper.o
  "facebook::jsi::Value::~Value()", referenced from:
      facebook::jsi::Value::Value<facebook::jsi::Function>(facebook::jsi::Function&&) in FrameHostObject.o
      facebook::jsi::Value::Value<facebook::jsi::String>(facebook::jsi::String&&) in FrameHostObject.o
      ____Z42convertJSIFunctionToFrameProcessorCallbackRN8facebook3jsi7RuntimeERKNS0_8FunctionE_block_invoke in FrameProcessorUtils.o
      facebook::jsi::Value facebook::jsi::Function::callWithThis<facebook::jsi::Object>(facebook::jsi::Runtime&, facebook::jsi::Object const&, facebook::jsi::Object&&) const in FrameProcessorUtils.o
      facebook::jsi::Function::callWithThis(facebook::jsi::Runtime&, facebook::jsi::Object const&, facebook::jsi::Value const*, unsigned long) const in FrameProcessorUtils.o
      facebook::jsi::Value::Value(facebook::jsi::Runtime&, facebook::jsi::Object const&) in FrameProcessorUtils.o
      ___43+[JSConsoleHelper getLogFunctionForBridge:]_block_invoke_2 in JSConsoleHelper.o
      ...
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

What happened instead?

Build failed

Relevant log output

No response

Device

iPhone 8 (iOS 14.3)

VisionCamera Version

2.13.5

Additional information

jhongyi avatar Jul 07 '22 03:07 jhongyi

Im having the same issue 🙏

somiasHtec avatar Jul 12 '22 08:07 somiasHtec

I have the same issue in RN 0.66.1. Since i upgraded RN to version 69 and because of other packages incompatibility i downgraded again to my previous version 0.66.1

RahulMore-Codes avatar Jul 18 '22 13:07 RahulMore-Codes

Same issue

caferyukseloglu avatar Jul 24 '22 22:07 caferyukseloglu

Guys, I managed to find a solution. When I implemented firebase into my project, it requested from me to have use_frameworks! in Podfile. That was the time I started getting this error. So I deleted use_frameworks! and added use_modular_headers!.

After doing this, I didn't had any errors except some glog issue, so I had to add this in Podfile next to pods: pod 'glog', :podspec => '../node_modules/react-native/third-party-podspecs/glog.podspec', :modular_headers => false

The app is finally working now!

somiasHtec avatar Jul 25 '22 09:07 somiasHtec

Guys, I managed to find a solution. When I implemented firebase into my project, it requested from me to have use_frameworks! in Podfile. That was the time I started getting this error. So I deleted use_frameworks! and added use_modular_headers!.

After doing this, I didn't had any errors except some glog issue, so I had to add this in Podfile next to pods: pod 'glog', :podspec => '../node_modules/react-native/third-party-podspecs/glog.podspec', :modular_headers => false

The app is finally working now!

When I did that FirebaseStore gave error for me even with custom headers :/. Clean build folder Pods and re-instaal

caferyukseloglu avatar Jul 25 '22 09:07 caferyukseloglu

Guys, I managed to find a solution. When I implemented firebase into my project, it requested from me to have use_frameworks! in Podfile. That was the time I started getting this error. So I deleted use_frameworks! and added use_modular_headers!. After doing this, I didn't had any errors except some glog issue, so I had to add this in Podfile next to pods: pod 'glog', :podspec => '../node_modules/react-native/third-party-podspecs/glog.podspec', :modular_headers => false The app is finally working now!

When I did that FirebaseStore gave error for me even with custom headers :/. Clean build folder Pods and re-instaal

Could you write your error here?

somiasHtec avatar Jul 25 '22 09:07 somiasHtec

Guys, I managed to find a solution. When I implemented firebase into my project, it requested from me to have use_frameworks! in Podfile. That was the time I started getting this error. So I deleted use_frameworks! and added use_modular_headers!.

After doing this, I didn't had any errors except some glog issue, so I had to add this in Podfile next to pods: pod 'glog', :podspec => '../node_modules/react-native/third-party-podspecs/glog.podspec', :modular_headers => false

The app is finally working now!

Worked for me also. Thanks 👍🏻

RahulMore-Codes avatar Jul 28 '22 09:07 RahulMore-Codes

Guys, I managed to find a solution. When I implemented firebase into my project, it requested from me to have use_frameworks! in Podfile. That was the time I started getting this error. So I deleted use_frameworks! and added use_modular_headers!.

After doing this, I didn't had any errors except some glog issue, so I had to add this in Podfile next to pods: pod 'glog', :podspec => '../node_modules/react-native/third-party-podspecs/glog.podspec', :modular_headers => false

The app is finally working now!

What a lovely solution. I've been struggling with this for nearly a day! Thank you.

cashcount avatar Aug 15 '22 13:08 cashcount

@RahulMore-Codes

Hello Rahul,

Could you kindly post your PodFile? I am attempting your solution, however, after removing use_frameworks! and adding use_modular_headers! I still get the glog error so I suspecting I am not putting pod 'glog', :podspec => '../node_modules/react-native/third-party-podspecs/glog.podspec', :modular_headers => false in its proper place

Edit Works now, thank you for the solution.

I had to place these two lines first in the target do section. At first, I had pod 'glog', :podspec => '../node_modules/react-native/third-party-podspecs/glog.podspec', :modular_headers => false at the bottom

Podfile Snippet

target 'MyProject' do
  pod 'glog', :podspec => '../node_modules/react-native/third-party-podspecs/glog.podspec', :modular_headers => false
  use_modular_headers!
  ...

Thanks in advance

BMwanza avatar Sep 08 '22 02:09 BMwanza

I had the same issue, fixed by upgrade to the latest React Native verison as suggested in #1159

LazyAfternoons avatar Sep 20 '22 08:09 LazyAfternoons

Guys, I managed to find a solution. When I implemented firebase into my project, it requested from me to have use_frameworks! in Podfile. That was the time I started getting this error. So I deleted use_frameworks! and added use_modular_headers!.

After doing this, I didn't had any errors except some glog issue, so I had to add this in Podfile next to pods: pod 'glog', :podspec => '../node_modules/react-native/third-party-podspecs/glog.podspec', :modular_headers => false

The app is finally working now!

Can you please share your PodFile? I have the same issue with Firebase installed. Followed the setup example by @mikehardy https://github.com/mikehardy/rnfbdemo/blob/main/make-demo.sh . The app was ok, but Im not able to run the app anymore with Vision Camera in iOS

krisidmisso avatar Sep 30 '22 19:09 krisidmisso

It appears that react-native-vision-camera may not work with use_frameworks then, and that's a react-native-vision-camera issue.

Attempting to work around the issue by removing use_frameworks and adding modular_headers stuff is a temporary workaround at best

@mrousavy have you tried building any compile-test rig for react-native-vision-camera with use_frameworks! :linkage => :static in the Podfile? Seems it may have some symbol location (read as: header pathing...) issue ?

mikehardy avatar Sep 30 '22 19:09 mikehardy

@mikehardy thank you for the quick reply. Do you suggest any workaround for a specific library (i.e.: VisionCamera) to skip use_frameworks!?

Below is my Podfile:

require_relative '../node_modules/react-native/scripts/react_native_pods'
require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules'

platform :ios, '12.4'
install! 'cocoapods', :deterministic_uuids => false

production = ENV["PRODUCTION"] == "1"

target 'APPNAME' do

  config = use_native_modules!
  config = use_frameworks!
  $RNFirebaseAsStaticFramework = true

  # Flags change depending on the env values.
  flags = get_default_flags()

  use_react_native!(
    :path => config[:reactNativePath],
    # to enable hermes on iOS, change `false` to `true` and then install pods
    :production => production,
    :hermes_enabled => flags[:hermes_enabled],
    :fabric_enabled => flags[:fabric_enabled],
#    :flipper_configuration => FlipperConfiguration.enabled(["Debug"], { 'Flipper' => '0.159.0' }),
    :flipper_configuration => FlipperConfiguration.disabled,
    # An absolute path to your application root.
    :app_path => "#{Pod::Config.instance.installation_root}/.."
  )
  # Firebase BoM -> specify global firebase version
  # TODO: update firebase version here too
  $FirebaseSDKVersion = '9.4.0'

  target 'APPNAMETests' do
    inherit! :complete
    # Pods for testing
  end

  post_install do |installer|
    react_native_post_install(installer)
    installer.pods_project.targets.each do |target|
      if (target.name.eql?('FBReactNativeSpec'))
        target.build_phases.each do |build_phase|
          if (build_phase.respond_to?(:name) && build_phase.name.eql?('[CP-User] Generate Specs'))
            target.build_phases.move(build_phase, 0)
          end
        end
      end
    end

    installer.pods_project.targets.each do |target|
      target.build_configurations.each do |config|
        config.build_settings["ENABLE_BITCODE"] = "NO"
      end
    end
    __apply_Xcode_12_5_M1_post_install_workaround(installer)
  end
end

I tried:

  • removing use_framworks!
  • removing use_framworks! and adding use_modular_headers! in its place
  • adding the following code to skip the use of use_frameworks! for a specific library:
dynamic_frameworks = ['VisionCamera'] # <- swift libraries names

# Make all the other frameworks into static frameworks by overriding the static_framework function to return true
pre_install do |installer|
  installer.pod_targets.each do |pod|
    if !dynamic_frameworks.include?(pod.name)
      puts "Overriding the static_framework? method for #{pod.name}"
      def pod.static_framework?;
        true
      end
      def pod.build_type;
        Pod::BuildType.static_library
      end
    end
  end
end

Error: image

krisidmisso avatar Sep 30 '22 20:09 krisidmisso

Sorry, I do not propose workarounds to use_frameworks, I work with maintainers to fix use_frameworks compilation in their modules Avoiding it is not (I repeat not) a viable option for any users of react-native-firebase and that's my focus

mikehardy avatar Sep 30 '22 20:09 mikehardy

After bunch of debugging, I found out use_frameworks is also causing iOS runtime crash "Frame Processors are not enabled" when trying to use frame processors.

It seems even if the build succeeds (I'm on RN 0.69, without flipper & without hermes), use_frameworks usage required by react-native-firebase@15 will cause issues in runtime.

I also tried to set the related packages to be static in the podfile, but it did not help.

viljark avatar Oct 20 '22 19:10 viljark

@mrousavy not sure if you are aware of the use_frameworks issue or not? I wish I could wave a magic wand and remove the requirement for use_frameworks in react-native-firebase but I cannot. Would be great if this package supported it - usually it's just header + linkage location differences that need resolving

mikehardy avatar Oct 20 '22 22:10 mikehardy

any news here?

KonstantinZhukovskij avatar Oct 25 '22 07:10 KonstantinZhukovskij

Is this issue resolved? I just tried use_frameworks! with [email protected] but it failed. The error message was the same.

bglgwyng avatar Oct 29 '22 14:10 bglgwyng

@bglgwyng I saw it closed and looked for anything in recent commits that would indicate a change had been made that would effect it. I did not see anything so I was surprised it was closed, myself. But I'm not a maintainer here so I don't really know. I think it is likely still an issue.

mikehardy avatar Oct 29 '22 14:10 mikehardy

I tried a very similar workaround here https://github.com/ICoi/VisionCameraExample/blob/main/ios/Podfile#L10 with what @krisidmisso suggested. The build succeded, but I got the following error message

 ERROR  frame-processor/unavailable: Frame Processors are not enabled. See https://mrousavy.github.io/react-native-vision-camera/docs/guides/troubleshooting, js engine: hermes

So I commented frame processor things in the code and the app worked fine. If migration from static to dynamic library is a hard work, then to enhance this workaround to work well with frame processor seems the best option for now.

bglgwyng avatar Oct 31 '22 15:10 bglgwyng

After installing Firebase (requiring to add use_frameworks! to my Podfile), the camera no longer initializes--Just a blank white screen (but past the <LoadingScreen>).

@bglgwyng Are you saying you got React Native Vision Camera + Firebase to work together? You just commented yesterday, but your link is already 404. Can you please post your workaround?

@krisidmisso What do I need to change in my Podfile to get React Native Vision Camera to work with Firebase?

hb-webdev avatar Nov 01 '22 19:11 hb-webdev

@hb-webdev Sorry. I shared a private one. You can see this one https://github.com/bglgwyng/VisionCameraExample. The latest commit also solved the frame processor issue by setting RNReanimated as static.

I haven't tested with firebase yet. I think I'll do it today.

bglgwyng avatar Nov 02 '22 02:11 bglgwyng

yea RNReanimated pod is the issue here, it can't be used with frameworks afaik - maybe there's a workaround

mrousavy avatar Nov 02 '22 11:11 mrousavy

Oh interesting! Is there something specific - information-wise - that we could package up and chat with software-mansion about? They are certainly on the "amazing maintainers" list - perhaps they are unaware?

In my experience with an app that does use reanimated (raect-navigation depends on it transitively, and I use a tabbed navigator that does animate) reanimated does work with use_frameworks, so maybe it is just some section of it since parts of it do work? So perhaps that diagnosis is not accurate either, perhaps the issue is still here somehow?

mikehardy avatar Nov 02 '22 12:11 mikehardy

https://github.com/bglgwyng/FirebaseExample I tried firebase + vision camera + frame processor here. It works fine. Firestore client is ok and the camera is too. @mrousavy My workaround was just setting RNAnimated to be built as a static library and there seems no problem for now.

bglgwyng avatar Nov 02 '22 12:11 bglgwyng

Nice!

I see this block, doing the thing you mention:


  pre_install do |installer|
    installer.pod_targets.each do |pod|
      if pod.name.eql?('vision-camera-code-scanner') || pod.name.eql?('VisionCamera') || pod.name.eql?('RNReanimated')
        def pod.build_type
          Pod::BuildType.static_library
        end
      end
    end
  end

Could be similar to our workaround in react-native-firebase here, though they look a little different:

  if defined?($RNFirebaseAsStaticFramework)
    Pod::UI.puts "#{s.name}: Using overridden static_framework value of '#{$RNFirebaseAsStaticFramework}'"
    s.static_framework = $RNFirebaseAsStaticFramework
  else
    s.static_framework = false
  end

It is exactly the same as the workaround (which also works) documented in react-native-permissions: https://github.com/zoontek/react-native-permissions#workaround-for-use_frameworks-issues

So...possibly could be solved in podspec here (somehow, though not aware of an elegant way yet) or could be a documentation solution similar to react-native-permissions (though there is a little issue tracker traffic related to it when people aren't aware)...

mikehardy avatar Nov 02 '22 13:11 mikehardy

@hb-webdev thanks to @bglgwyng and @mikehardy I was able to run my application with Firebae and Camera libs today. Here is my final Podfile:

require_relative '../node_modules/react-native/scripts/react_native_pods'
require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules'

$FirebaseSDKVersion = '10.2.0'

platform :ios, '12.4'
install! 'cocoapods', :deterministic_uuids => false

production = ENV["PRODUCTION"] == "1"


use_frameworks! :linkage => :static

$RNFirebaseAsStaticFramework = true

# Convert all permission pods into static libraries
pre_install do |installer|
  Pod::Installer::Xcode::TargetValidator.send(:define_method, :verify_no_static_framework_transitive_dependencies) {}

  installer.pod_targets.each do |pod|
    if pod.name.eql?('RNPermissions') || pod.name.start_with?('Permission-') || pod.name.eql?('vision-camera-code-scanner') || pod.name.eql?('VisionCamera') || pod.name.eql?('RNReanimated')
      def pod.build_type;
        Pod::BuildType.static_library
      end
    end
  end
end

target 'MyApp' do

  config = use_native_modules!

    # Flags change depending on the env values.
    flags = get_default_flags()
    flags[:hermes_enabled] = false

    use_react_native!(
      :path => config[:reactNativePath],
      # to enable hermes on iOS, change `false` to `true` and then install pods
      :production => production,
      :hermes_enabled => flags[:hermes_enabled],
      :fabric_enabled => flags[:fabric_enabled],
      :flipper_configuration => FlipperConfiguration.disabled,
      # An absolute path to your application root.
      :app_path => "#{Pod::Config.instance.installation_root}/.."
    )

    permissions_path = '../node_modules/react-native-permissions/ios'
    pod 'Permission-Camera', :path => "#{permissions_path}/Camera"

  target 'MyAppTests' do
    inherit! :complete
    # Pods for testing
  end

  post_install do |installer|

  #disable bitcode as it will be depricated in Xcode14
    installer.pods_project.targets.each do |target|
      target.build_configurations.each do |config|
        config.build_settings['ENABLE_BITCODE'] = 'NO'
      end
    end

    react_native_post_install(installer)
    __apply_Xcode_12_5_M1_post_install_workaround(installer)
    installer.pods_project.build_configurations.each do |config|
      config.build_settings["EXCLUDED_ARCHS[sdk=iphonesimulator*]"] = "arm64"
    end
  end
end

Note the long condition:

...
if pod.name.eql?('RNPermissions') || pod.name.start_with?('Permission-') || pod.name.eql?('vision-camera-code-scanner') || pod.name.eql?('VisionCamera') || pod.name.eql?('RNReanimated')
...

Replace it with packages of your app that have issues with use_frameworks!

Hope this helps.

krisidmisso avatar Dec 17 '22 00:12 krisidmisso

@krisidmisso, Thanks Bro, your podfile example help me to make build sucessfull, i lost any hours with this. I runned before build starts too: src/ios $ pod clean && pod deintegrate && pod install

VictorThales avatar Dec 21 '22 07:12 VictorThales