react-native-vision-camera: 🐛 Build Failed in new app created with react-native init

What were you trying to do?

run the app on ios simulator/device after installing react-native-vision-camera

Reproduceable Code

No response

What happened instead?

Build failed with “Cannot convert value of type ‘[AnyHashable : Any]’ to expected argument type ‘[String : Any]’”

Relevant log output

npx react-native info
info Fetching system and libraries information...
System:
    OS: macOS 11.6.2
    CPU: (8) arm64 Apple M1
    Memory: 142.83 MB / 8.00 GB
    Shell: 5.8 - /bin/zsh
  Binaries:
    Node: 17.0.1 - /opt/homebrew/bin/node
    Yarn: 1.22.17 - /opt/homebrew/bin/yarn
    npm: 8.1.0 - /opt/homebrew/bin/npm
    Watchman: 2021.11.15.00 - /opt/homebrew/bin/watchman
  Managers:
    CocoaPods: 1.11.2 - /opt/homebrew/bin/pod
  SDKs:
    iOS SDK:
      Platforms: iOS 14.4, DriverKit 20.2, macOS 11.1, tvOS 14.3, watchOS 7.2
    Android SDK:
      API Levels: 29, 31
      Build Tools: 29.0.2, 31.0.0
      System Images: android-29 | Intel x86 Atom_64, android-31 | Google APIs ARM 64 v8a
      Android NDK: Not Found
  IDEs:
    Android Studio: 2020.3 AI-203.7717.56.2031.7784292
    Xcode: 12.4/12D4e - /usr/bin/xcodebuild
  Languages:
    Java: 1.8.0_292 - /usr/bin/javac
  npmPackages:
    @react-native-community/cli: Not Found
    react: 17.0.2 => 17.0.2 
    react-native: 0.66.4 => 0.66.4 
    react-native-macos: Not Found
  npmGlobalPackages:
    *react-native*: Not Found

Device

iPhone 12 (iOS 14.4)

VisionCamera Version

2.11.2

Additional information

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 4
  • Comments: 32 (7 by maintainers)

Most upvoted comments

If you encounter this issue and cannot upgrade to Xcode 13, you can try version 2.10.0, which, during my tests, is the latest version currently that doesn’t have this issue in Xcode 12. It’s not quite a solution but 2.10.0 may already suit your needs.

Can @mrousavy tell me what to change in my code? I have two errors when building like @firofame faced.

  1. “Cannot convert value of type ‘[AnyHashable : Any]’ to expected argument type ‘[String : Any]’”
  2. “Type of expression is ambiguous without more context” Can you tell what are the changes to be made build it successfully?

vision-camera works fine with XCode 13. unfortunately, I am stuck with XCode 12.4 since I have some dependency on Swift 5.3.

@mrousavy is there an older version that works with XCode 12.4?

Thanks! Yeah, I guess we could add an additional point to the TROUBLESHOOTING guide that states “Make sure you’re using Xcode 13 or higher”. just to be sure

This needs to be changed to XCode 13

Wrong, it does not need to be changed to XCode 13. I was using XCode 12 back when I originally created VisionCamera.

so that people with older version do not waste their time

That’s what the TROUBLESHOOTING guide is for. If you run into any issues, I have specifically created a document that helps you troubleshoot any common issues I can think of. It’s your responsibility to look there, and not waste your time.

Great!

I propose that I fix the issue once I also get this issue. For me, on Xcode 13, everything builds fine so far. I also mentioned all of the versions (e.g. Swift) in the Troubleshooting section.

there is one more build error. just an fyi

/Users/firozahmed/Desktop/MyApp/node_modules/react-native-vision-camera/ios/CameraView+RecordVideo.swift:267:26: Type of expression is ambiguous without more context

Okay looks like they changed the type of that value. If I cast it, it breaks for other users 😅

I dont understand what’s probblem. But i do some steps and it can run successfully. Delete node module and remove yarn.lock ( use yarn instead of npm, i used npm before ). And change “react-native-vision-camera”: “2.9.4”, ( delete ^ in front 2.9.4). Then run: yarn to install library, after that delete Podfile.lock then npx pod-install Rerun and it worked for me. Xcode Version 12.5 “react-native”: “0.64.2”

here is folder react-native-vision-camera in node_module. You can try to extract it and put in your node_module. Hope this help. https://drive.google.com/file/d/1VUlXvxxownyQnvgbnEOxppCWc_Htrm-D/view?usp=sharing

@mrousavy “Troubleshooting” page says “VisionCamera requires a minimum Swift version of 5.2”, This needs to be changed to XCode 13.

many repositories have a minimum requirement section in the readme so that people with older version do not waste their time.

Same issue: Xcode 12.5, Swift 5.3

same error here. Any prevision on fixing?

Having the same issue on xcode 12.5