Expo for React Native
I've built React Native apps for a while and explored Expo before. I didn’t like the idea of being tied to their ecosystem (I was sort of a RN purist). However, over the years, the enormous effort required to upgrade apps to new versions of React Native and countless hours spent debugging poorly documented issues made me rethink this stance.
Right now, we are in the process of upgrading our old apps. Most of the developers we have are JavaScript-proficient people. Setting up Xcode and building the apps was a huge turnoff for most. We needed a simpler way to onboard every developer on the team to build the app.
Expo felt like the right fit for this task. It has changed a lot since I initially tried it, having improved its ecosystem significantly. It now has much better support for remote updates, publishing to app stores, etc.
During testing, we figured we couldn't completely use the ecosystem only. We needed some native build processes as we used device APIs in the apps. To test them, expo publishing was not enough.
I wrote this note to document the issues I've faced while setting up the project with my colleague.
I was trying to build the app for Android and iOS using npx expo prebuild --clean
. I used the --clean
flag to ensure that we were removing the native libraries and recreating them. We never intended to update the native libraries, so cleaning them out before a build was better.
The first error I saw was an issue with pod install
during the pre-build process. The error is given below.
Something went wrong running `pod install` in the `ios` directory.
Command `pod install` failed.
└─ Cause: Invalid `Podfile` file: cannot load such file -- ./scripts/autolinking.
# from /Users/pranav/chatwoot/chatwoot-mobile-next/ios/Podfile:1
# -------------------------------------------
> require File.join(File.dirname(`node --print "require.resolve('expo/package.json')"`), "scripts/autolinking")
# require File.join(File.dirname(`node --print "require.resolve('react-native/package.json')"`), "scripts/react_native_pods")
# -------------------------------------------
pod install --repo-update --ansi exited with non-zero code: 1
This was surprising as we expected Expo to resolve the issues automatically. Running the pod install command directly from the iOS folder also didn't work and ended up with the same error. Removing the node_modules folder and reinstalling didn't work either. Finally, searching through their forums, we found that the latest Expo requires CocoaPods version > 1.15.2, while I had 1.5.x. Upgrading it resolved the issue.
Now, we encountered a second error. This one was more cryptic than the previous one.
⚠️ Something went wrong running `pod install` in the `ios` directory.
Command `pod install` failed.
└─ Cause: Failed to load 'glog' podspec:
[!] Invalid `glog.podspec` file: undefined method `[]' for nil.
# from /Users/pranav/chatwoot/chatwoot-mobile-next/node_modules/react-native/third-party-podspecs/glog.podspec:38
# -------------------------------------------
# match = xcode_path.match(/Xcode (\\d+)\\.(\\d+)/)
> major_version = match[1].to_i
# minor_version = match[2].to_i
# -------------------------------------------
pod install --repo-update --ansi exited with non-zero code: 1
Luckily, we found a thread that showed a similar error. The suggested solution was to switch the Xcode tools to using the Xcode app. Here is the comment we looked into. I suspect this to be a byproduct of upgrading the OS version to the latest macOS 15 (Sequoia).
To fix this, I installed the latest Xcode and switched to using the CLI with the Xcode app.
sudo xcode-select --switch /Applications/Xcode.app
Voilà! That worked and the build was complete. Running the app with npx expo run:ios -d
was a breeze. There were no further issues with the build steps.
Final thoughts
Despite facing some issues during setup, I found the subsequent development process was much easier compared to native React Native development. I'd recommend using Expo for future projects.