Podfile
Also called Podfile.lock
- Part of
- React Native Glossary
- Updated
What is Podfile in React Native?
The Podfile is the Ruby file in ios/ that tells CocoaPods which native iOS dependencies to install; Podfile.lock records the exact versions it resolved.
The Podfile is a Ruby file at ios/Podfile that tells CocoaPods what to install into your iOS app. In a React Native project you rarely list libraries in it yourself: a few helper calls do the work.
target 'MyApp' do
config = use_native_modules!
use_react_native!(
:path => config[:reactNativePath]
)
end
use_native_modules! runs autolinking, adding every native library found in node_modules, and use_react_native! adds React Native’s own pods. Expo projects call use_expo_modules! for Expo modules as well. The surrounding code sets the minimum iOS version, applies post-install fixes and passes build flags.
Podfile.lock is the iOS equivalent of your JavaScript lockfile: it pins the exact version of every pod, including transitive ones. Commit it. Without it, two developers running pod install on the same commit can end up with different native code, and CI can break on a dependency nobody touched.
When does a React Native developer edit the Podfile directly?
- Raising the iOS deployment target a library requires.
- Adding a
post_installtweak to work around a build error in a dependency. - Enabling options a library documents, such as static frameworks.
The main gotcha is Expo’s Continuous Native Generation. If ios/ is generated by npx expo prebuild and not committed, hand edits to the Podfile disappear on the next prebuild. Make those changes through a config plugin or the expo-build-properties plugin instead.
A merge conflict in Podfile.lock is usually safest to resolve by taking either side and re-running pod install, then committing what it produces.