Overview
Thepods.rb file allows you to customize CocoaPods configuration for specific targets. This is particularly useful when you need to enable React Native in targets like App Clips or Share Extensions.
Creating a pods.rb File
Add apods.rb file to the root of your repository. This file will be evaluated with global access to the podfile_properties variable.
Enabling React Native in Targets
The most common use case forpods.rb is enabling React Native in App Clip targets. Here’s a complete example:
How It Works
Podfile Block Structure
Podfile Block Structure
The The target name must exactly match the name of the target directory in your
pods.rb file executes at the end of the Podfile in a target-specific block:/targets folder.Available Variables
Available Variables
Your
pods.rb file has access to:podfile_properties- A hash containing properties from your Expo configios.useFrameworks- Framework linkage settingexpo.jsEngine- JavaScript engine (hermes/jsc)apple.privacyManifestAggregationEnabled- Privacy manifest setting
- Environment variables - Standard ENV hash
EXPO_USE_COMMUNITY_AUTOLINKING- Autolinking modeUSE_FRAMEWORKS- Framework override
Common Use Cases
App Clips with React Native
For App Clips that need React Native, use the full example above. This enables:- React Native core dependencies
- Expo modules autolinking
- Hermes JavaScript engine
- Privacy manifest aggregation
Share Extensions with React Native
The samepods.rb configuration works for Share Extensions:
Custom Pod Dependencies
You can also add custom pod dependencies:Target Matching
Troubleshooting
Pod install fails
Pod install fails
Ensure you have CocoaPods 1.16.2 or later:Also verify Ruby 3.2.0 or later:
React Native not found in target
React Native not found in target
Verify that:
- Your
pods.rbfile is in the repository root - The target name matches the directory name exactly
- You’ve run
npx expo prebuild --cleanafter creating the file
Autolinking issues
Autolinking issues
If modules aren’t linking correctly:
- Check the
config_commandarray in yourpods.rb - Try setting
EXPO_USE_COMMUNITY_AUTOLINKING=1environment variable - Clear your Pods cache:
rm -rf ios/Pods && rm ios/Podfile.lock
Next Steps
- Learn about sharing files between targets
- Set up JavaScript bundling with exportJs
- Configure custom frameworks