diff --git a/packages/rn-tester/Podfile b/packages/rn-tester/Podfile index 16af24be0cbff1..b2d0ff24c0420e 100644 --- a/packages/rn-tester/Podfile +++ b/packages/rn-tester/Podfile @@ -8,6 +8,7 @@ platform :ios, '12.4' install! 'cocoapods', :deterministic_uuids => false USE_FRAMEWORKS = ENV['USE_FRAMEWORKS'] == '1' +@prefix_path = "../.." if USE_FRAMEWORKS puts "Installing pods with use_frameworks!" @@ -21,25 +22,23 @@ def pods(options = {}) hermes_enabled = ENV['USE_HERMES'] == '1' puts "Building RNTester with Fabric #{fabric_enabled ? "enabled" : "disabled"}.#{hermes_enabled ? " Using Hermes engine." : ""}" - prefix_path = "../.." - if ENV['USE_CODEGEN_DISCOVERY'] == '1' # Custom fabric component is only supported when using codegen discovery. pod 'MyNativeView', :path => "NativeComponentExample" end use_react_native!( - path: prefix_path, + path: @prefix_path, fabric_enabled: fabric_enabled, hermes_enabled: hermes_enabled, app_path: "#{Dir.pwd}", config_file_dir: "#{Dir.pwd}/node_modules", ) - pod 'ReactCommon/turbomodule/samples', :path => "#{prefix_path}/ReactCommon" + pod 'ReactCommon/turbomodule/samples', :path => "#{@prefix_path}/ReactCommon" # Additional Pods which aren't included in the default Podfile - pod 'React-RCTPushNotification', :path => "#{prefix_path}/Libraries/PushNotificationIOS" - pod 'Yoga', :path => "#{prefix_path}/ReactCommon/yoga", :modular_headers => true + pod 'React-RCTPushNotification', :path => "#{@prefix_path}/Libraries/PushNotificationIOS" + pod 'Yoga', :path => "#{@prefix_path}/ReactCommon/yoga", :modular_headers => true # Additional Pods which are classed as unstable # RNTester native modules and components @@ -64,6 +63,6 @@ target 'RNTesterIntegrationTests' do end post_install do |installer| - react_native_post_install(installer) + react_native_post_install(installer, @prefix_path) __apply_Xcode_12_5_M1_post_install_workaround(installer) end diff --git a/scripts/react_native_pods.rb b/scripts/react_native_pods.rb index 37f63b6789c472..9a20e147c41e51 100644 --- a/scripts/react_native_pods.rb +++ b/scripts/react_native_pods.rb @@ -258,7 +258,23 @@ def fix_config(config) end end -def react_native_post_install(installer) +def set_node_modules_user_settings(installer, react_native_path) + puts "Setting REACT_NATIVE build settings" + projects = installer.aggregate_targets + .map{ |t| t.user_project } + .uniq{ |p| p.path } + .push(installer.pods_project) + + projects.each do |project| + project.build_configurations.each do |config| + config.build_settings["REACT_NATIVE_PATH"] = File.join("${PODS_ROOT}", "..", react_native_path) + end + + project.save() + end +end + +def react_native_post_install(installer, react_native_path = "../node_modules/react-native") if has_pod(installer, 'Flipper') flipper_post_install(installer) end @@ -272,6 +288,7 @@ def react_native_post_install(installer) end modify_flags_for_new_architecture(installer, cpp_flags) + set_node_modules_user_settings(installer, react_native_path) end def modify_flags_for_new_architecture(installer, cpp_flags) diff --git a/scripts/xcode/with-environment.sh b/scripts/xcode/with-environment.sh index 67446a8362ebaf..e4a8e42436e7bf 100755 --- a/scripts/xcode/with-environment.sh +++ b/scripts/xcode/with-environment.sh @@ -38,7 +38,7 @@ else "in the ios folder. This is needed by React Native to work correctly. " \ "We fallback to the DEPRECATED behavior of finding `node`. This will be REMOVED in a future version. " \ "You can read more about this here: https://reactnative.dev/docs/environment-setup#optional-configuring-your-environment" >&2 - source "../find-node-for-xcode.sh" + source "${REACT_NATIVE_PATH}/scripts/find-node-for-xcode.sh" fi # Execute argument, if present