[ios] Resolve `use_react_native!(path)` param in `reacft_native_pods.rb` from `Pathname.pwd`
Summary:
[!NOTE] This is a bit of a speculative fix that's based on trying to get a bare project with
react-native-macosto link directly against it in an isolated installation, which makes passingpathset torequire.resolve('react-native-macos/package.json')more convenient than constructing a relative path first.
The path argument in react_native_pods.rb is not resolved but instead later joined using File.join(relative_path_from_current, path). This doesn't actually resolve the path, meaning, if path is absolute it's appended to this first relative path.
Instead, we should use Pathname#join and join the path to the pathname, guaranteeing it to be absolute, then construct relative paths (for the prefix) using relative_path_from against the installation root.
If we don't do this, the absolute path gets treated as a relative path (e.g. ./Users), which leads to errors such as:
[!] Invalid Podfile file: Couldn't find the React Native package.json file at ./Users/phil/git/expo/expo-pnpm/packages/expo/package.json.
Since absolute paths are unambiguous the change should be safe.
Changelog:
[IOS] Allow absolute react-native paths to be passed to use_react_native! in project podfiles
Test Plan:
This can be replicated by replacing path in the use_react_native call with an absolute resolution and running pod install after, for example:
use_react_native!(
:path => File.dirname(`node --print "require.resolve('react-native/package.json')"`),
:hermes_enabled => podfile_properties['expo.jsEngine'] == nil || podfile_properties['expo.jsEngine'] == 'hermes',
# An absolute path to your application root.
:app_path => "#{Pod::Config.instance.installation_root}/..",
)
Usually, the path argument gets resolved from the react-native-config via config[:reactNativePath]. However, this makes the implicit assumption that use_native_modules! has already converted this to a relative path.