Modify Podfile using managed workflow & expo-dev-client

SDK Version: 42
Platforms(Android/iOS/web/all): IOS

I’m trying to implement react-native-camera which requires MLKit, (changes to Podfile), for managed workflow 42.

This is my dev process:

  1. EAS for building dev build
  2. Install the dev build build on device
  3. Start dev client and scan QR code on device

How do I add the following code snippet to the Podfile so I can enable text recognition?

pod 'react-native-camera', path: '../node_modules/react-native-camera', subspecs: [
  'TextDetector',
  'FaceDetectorMLKit',
  'BarcodeDetectorMLKit'
]

I’ve found this in the documentation:

… But I’m not sure how you’re supposed to implement this…

All help appreciated

@reft

Making that change “dangerously with regex” should be possible, but I am a bit confused by the “or statically via JSON” comment. The code below that shows the actual Podfile which you don’t have access to in a managed app, so I’m not sure what that part of the docs is trying to say.

If I were you I’d look into Autolinking to see how it works.

If you run expo prebuild and then do a manual npx react-native link react-native-camera (which is of course not recommended), it makes the following change to the Podfile:

diff --git ios/Podfile ios/Podfile
index c3d8c29..a92e8e2 100644
--- ios/Podfile
+++ ios/Podfile
@@ -24,6 +24,8 @@ target 'flagsecure' do
   #   use_flipper!('Flipper' => '0.75.1', 'Flipper-Folly' => '2.5.3', 'Flipper-RSocket' => '1.3.1')
   # end
 
+  pod 'react-native-camera', :path => '../node_modules/react-native-camera'
+
   post_install do |installer|
     react_native_post_install(installer)
 

So if you can figure out how Autolinking works, I think you ought to be able to get it to put your modified version of the above into the Podfile instead.

Hi,

I forgot to tell you I’m on windows :smiley: But I’ve forked react-native-camera and have made the necessary changes myself…

s.default_subspecs = “RN”, “RCT”, “TextDetector”

1 Like

Great! No need to fork it. You could use patch-package for this.