Skip to content

Commit 537e3ad

Browse files
Revert "Use autolinking react-native-config output in iOS artifacts generator (#53503)"
This reverts commit a2eb29e.
1 parent 63619bc commit 537e3ad

File tree

4 files changed

+12
-53
lines changed

4 files changed

+12
-53
lines changed

packages/react-native/scripts/cocoapods/autolinking.rb

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,6 @@ def list_native_modules!(config_command)
4040
packages = config["dependencies"]
4141
ios_project_root = Pathname.new(config["project"]["ios"]["sourceDir"])
4242
react_native_path = Pathname.new(config["reactNativePath"])
43-
codegen_output_path = ios_project_root.join("build/generated/autolinking/autolinking.json")
44-
45-
# Write autolinking react-native-config output to codegen folder
46-
FileUtils.mkdir_p(File.dirname(codegen_output_path))
47-
File.write(codegen_output_path, json)
48-
4943
found_pods = []
5044

5145
packages.each do |package_name, package|

packages/react-native/scripts/cocoapods/codegen_utils.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ def self.clean_up_build_folder(rn_path, codegen_dir, dir_manager: Dir, file_mana
8787
codegen_path = file_manager.join(ios_folder, codegen_dir)
8888
return if !dir_manager.exist?(codegen_path)
8989

90-
FileUtils.rm_rf("#{codegen_path}")
90+
FileUtils.rm_rf(dir_manager.glob("#{codegen_path}/*"))
9191
base_provider_path = file_manager.join(rn_path, 'React', 'Fabric', 'RCTThirdPartyFabricComponentsProvider')
9292
FileUtils.rm_rf("#{base_provider_path}.h")
9393
FileUtils.rm_rf("#{base_provider_path}.mm")

packages/react-native/scripts/codegen/generate-artifacts-executor/index.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -86,14 +86,10 @@ function execute(
8686
buildCodegenIfNeeded();
8787
}
8888

89-
const reactNativeConfig = readReactNativeConfig(
90-
projectRoot,
91-
baseOutputPath,
92-
);
89+
const reactNativeConfig = readReactNativeConfig(projectRoot);
9390
const codegenEnabledLibraries = findCodegenEnabledLibraries(
9491
pkgJson,
9592
projectRoot,
96-
baseOutputPath,
9793
reactNativeConfig,
9894
);
9995

packages/react-native/scripts/codegen/generate-artifacts-executor/utils.js

Lines changed: 10 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -97,40 +97,15 @@ function cleanupEmptyFilesAndFolders(filepath /*: string */) {
9797
}
9898
}
9999

100-
function readGeneratedAutolinkingOutput(
101-
baseOutputPath /*: string */,
102-
) /*: $FlowFixMe */ {
103-
// NOTE: Generated by scripts/cocoapods/autolinking.rb in list_native_modules (called by use_native_modules)
104-
const autolinkingGeneratedPath = path.resolve(
105-
baseOutputPath,
106-
'build/generated/autolinking/autolinking.json',
107-
);
108-
if (fs.existsSync(autolinkingGeneratedPath)) {
109-
// $FlowFixMe[unsupported-syntax]
110-
return require(autolinkingGeneratedPath);
111-
} else {
112-
codegenLog(
113-
`Could not find generated autolinking output at: ${autolinkingGeneratedPath}`,
114-
);
115-
return null;
116-
}
117-
}
118-
119-
function readReactNativeConfig(
120-
projectRoot /*: string */,
121-
baseOutputPath /*: string */,
122-
) /*: $FlowFixMe */ {
123-
const autolinkingOutput = readGeneratedAutolinkingOutput(baseOutputPath);
100+
function readReactNativeConfig(projectRoot /*: string */) /*: $FlowFixMe */ {
124101
const rnConfigFilePath = path.resolve(projectRoot, 'react-native.config.js');
125-
if (autolinkingOutput) {
126-
return autolinkingOutput;
127-
} else if (fs.existsSync(rnConfigFilePath)) {
128-
// $FlowIgnore[unsupported-syntax]
129-
return require(rnConfigFilePath);
130-
} else {
131-
codegenLog(`Could not find React Native config at: ${rnConfigFilePath}`);
102+
103+
if (!fs.existsSync(rnConfigFilePath)) {
132104
return {};
133105
}
106+
107+
// $FlowIgnore[unsupported-syntax]
108+
return require(rnConfigFilePath);
134109
}
135110

136111
/**
@@ -139,23 +114,17 @@ function readReactNativeConfig(
139114
function findCodegenEnabledLibraries(
140115
pkgJson /*: $FlowFixMe */,
141116
projectRoot /*: string */,
142-
baseOutputPath /*: string */,
143117
reactNativeConfig /*: $FlowFixMe */,
144118
) /*: Array<$FlowFixMe> */ {
145119
const projectLibraries = findProjectRootLibraries(pkgJson, projectRoot);
146120
if (pkgJsonIncludesGeneratedCode(pkgJson)) {
147121
return projectLibraries;
148122
} else {
149-
const libraries = [...projectLibraries];
150-
// If we ran autolinking, we shouldn't try to run our own "autolinking-like"
151-
// library discovery
152-
if (!readGeneratedAutolinkingOutput(baseOutputPath)) {
153-
libraries.push(...findExternalLibraries(pkgJson, projectRoot));
154-
}
155-
libraries.push(
123+
return [
124+
...projectLibraries,
125+
...findExternalLibraries(pkgJson, projectRoot),
156126
...findLibrariesFromReactNativeConfig(projectRoot, reactNativeConfig),
157-
);
158-
return libraries;
127+
];
159128
}
160129
}
161130

0 commit comments

Comments
 (0)