Best Practices for Expo / React Native development with devenv

For anyone that ends up here, I ended up using xcrun from Xcode/command-line tools instead of the Nix version that uses the xcrun from the deprecated xcbuild.

Before sharing how, a quick note: This breaks hermiticity as you’ll be using a tool not managed by Nix. While this might not be the recommended approach, I personally prefer using Apple’s version since many ecosystem tools are built around it (Expo, for example, relies on specific messages going to stdout/stderr - that’s fixed in xcbuild: fix interactive applications run by xcrun by midchildan · Pull Request #359721 · NixOS/nixpkgs · GitHub, but who knows what other deviations we might have). Again, this might not be the community recommended way, this is what worked for me and I’m happy with it.

To implement this, add the following to your devshell shellHook (or enterShell in devenv):

export PATH=$(echo $PATH | sd "${pkgs.xcbuild.xcrun}/bin" "")
unset DEVELOPER_DIR

Special thanks to @reckenrode for all the help in arriving at this solution!

2 Likes