Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,13 @@ function getInputFiles(appPath /*: string */, appPkgJson /*: $FlowFixMe */) {
return '[]';
}

// Normalize appPath so any "Pods/.." segment is collapsed before find runs.
// Otherwise every find result inherits the search-root prefix containing
// "/Pods/" and gets dropped by the exclusion filter below.
const resolvedAppPath = path.resolve(appPath);

const xcodeproj = String(
execSync(`find ${appPath} -type d -name "*.xcodeproj"`),
execSync(`find ${resolvedAppPath} -type d -name "*.xcodeproj"`),
)
.trim()
.split('\n')
Expand All @@ -61,12 +66,12 @@ function getInputFiles(appPath /*: string */, appPkgJson /*: $FlowFixMe */) {
)[0];
if (!xcodeproj) {
throw new Error(
`Cannot find .xcodeproj file inside ${appPath}. This is required to determine codegen spec paths relative to native project.`,
`Cannot find .xcodeproj file inside ${resolvedAppPath}. This is required to determine codegen spec paths relative to native project.`,
);
}
const jsFiles = '-name "Native*.js" -or -name "*NativeComponent.js"';
const tsFiles = '-name "Native*.ts" -or -name "*NativeComponent.ts"';
const findCommand = `find ${path.join(appPath, jsSrcsDir)} -type f -not -path "*/__mocks__/*" -and \\( ${jsFiles} -or ${tsFiles} \\)`;
const findCommand = `find ${path.join(resolvedAppPath, jsSrcsDir)} -type f -not -path "*/__mocks__/*" -and \\( ${jsFiles} -or ${tsFiles} \\)`;
const list = String(execSync(findCommand))
.trim()
.split('\n')
Expand Down
17 changes: 15 additions & 2 deletions packages/react-native/scripts/react_native_pods.rb
Original file line number Diff line number Diff line change
Expand Up @@ -539,8 +539,21 @@ def react_native_post_install(
rn_relative_to_pods = rn_real.relative_path_from(pods_dir_real)
ReactNativePodsUtils.set_build_setting(installer, build_setting: "REACT_NATIVE_PATH", value: File.join("${PODS_ROOT}", rn_relative_to_pods.to_s))
# Store the Podfile directory as a build setting so that shell scripts can
# locate it without relying on PODS_ROOT/.. (breaks when Pods/ is a symlink).
ReactNativePodsUtils.set_build_setting(installer, build_setting: "PODFILE_DIR", value: Pod::Config.instance.installation_root.to_s)
# locate it without hardcoding an absolute path. Use Xcode variable
# substitution per-project so the value persisted in project.pbxproj is
# portable across machines: $(SRCROOT) is the Podfile dir for user projects
# (also avoids the PODS_ROOT/.. traversal that breaks when Pods/ is a
# symlink), and $(SRCROOT)/.. for the Pods project.
installer.aggregate_targets.map(&:user_project).uniq(&:path).each do |user_project|
user_project.build_configurations.each do |config|
config.build_settings['PODFILE_DIR'] = '$(SRCROOT)'
end
user_project.save
end
installer.pods_project.build_configurations.each do |config|
config.build_settings['PODFILE_DIR'] = '$(SRCROOT)/..'
end
installer.pods_project.save
ReactNativePodsUtils.set_build_setting(installer, build_setting: "SWIFT_ACTIVE_COMPILATION_CONDITIONS", value: ['$(inherited)', 'DEBUG'], config_name: "Debug")

if (ENV['RCT_REMOVE_LEGACY_ARCH'] == '1')
Expand Down
Loading