Skip to content

Commit f21d415

Browse files
chrfalchreact-native-bot
authored andcommitted
aligned symbol folders with RNdeps (#53354)
Summary: After fixing an isssue with ReactnativeDependencies and how it built symbols (#53353) this commit will align the output of the Symbols folder for the two frameworks. Previously we had an output in the Symbols folder that looked like this (from a local build on my machine) - catalyst - iphone - iphonesimulator After this we now have the more correct arcitecture names on these folders: - ios-arm64 - ios-arm64_x86_64-simulator - ios-arm64_x86_64-maccatalyst This is in line with how the ReactNativeDependencies Symbol folder is set up. ## Changelog: [IOS] [FIXED] - Aligned Symbols folder in React.xcframework symbols with ReactNativeDependencies.xcframework symbols. Pull Request resolved: #53354 Test Plan: Nightlies Reviewed By: cortinico Differential Revision: D80692098 Pulled By: cipolleschi fbshipit-source-id: e952b087d5dbdeb929b45d9e6d3d7e077c9d05cc
1 parent fcb86cc commit f21d415

File tree

1 file changed

+66
-27
lines changed

1 file changed

+66
-27
lines changed

packages/react-native/scripts/ios-prebuild/xcframework.js

Lines changed: 66 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -185,24 +185,68 @@ function buildXCFrameworks(
185185
);
186186

187187
// Copy Symbols to symbols folder
188-
const symbolPaths = frameworkFolders.map(framework =>
189-
path.join(framework, `..`, `..`, `React.framework.dSYM`),
190-
);
191-
192-
frameworkLog('Copying symbols to symbols folder...');
193-
const symbolOutput = path.join(outputPath, '..', 'Symbols');
194-
symbolPaths.forEach(symbol => {
195-
const destination = extractDestinationFromPath(symbol);
196-
const outputFolder = path.join(symbolOutput, destination);
197-
fs.mkdirSync(outputFolder, {recursive: true});
198-
execSync(`cp -r ${symbol} ${outputFolder}`);
199-
});
188+
copySymbols(outputPath, frameworkFolders);
200189

201190
if (identity) {
202191
signXCFramework(identity, outputPath);
203192
}
204193
}
205194

195+
function copySymbols(
196+
outputPath /*:string*/,
197+
frameworkFolders /*:Array<string>*/,
198+
) {
199+
frameworkLog('Copying symbols to symbols folder...');
200+
const targetArchFolders = fs
201+
.readdirSync(outputPath)
202+
.map(p => path.join(outputPath, p))
203+
.filter(folder => {
204+
return (
205+
fs.statSync(folder).isDirectory() &&
206+
!folder.endsWith('Headers') &&
207+
!folder.endsWith('Modules')
208+
);
209+
});
210+
211+
const symbolOutput = path.join(outputPath, '..', 'Symbols');
212+
frameworkFolders.forEach(frameworkFolder => {
213+
// Get archs for current symbol slice
214+
const frameworkPlatforms = getArchsFromFramework(
215+
path.join(frameworkFolder, 'React'),
216+
);
217+
if (frameworkPlatforms) {
218+
const targetFolder = targetArchFolders.find(
219+
targetArchFolder =>
220+
getArchsFromFramework(
221+
path.join(targetArchFolder, 'React.framework', 'React'),
222+
) === frameworkPlatforms,
223+
);
224+
if (!targetFolder) {
225+
frameworkLog(
226+
`No target folder found for symbol slice: ${frameworkFolder}`,
227+
'error',
228+
);
229+
return;
230+
}
231+
const targetSymbolPath = path.join(
232+
symbolOutput,
233+
path.basename(targetFolder),
234+
);
235+
const sourceSymbolPath = path.join(
236+
frameworkFolder,
237+
'..',
238+
'..',
239+
'React.framework.dSYM',
240+
);
241+
console.log(
242+
` ${path.relative(outputPath, sourceSymbolPath)}${path.basename(targetFolder)}`,
243+
);
244+
fs.mkdirSync(targetSymbolPath, {recursive: true});
245+
execSync(`cp -r ${sourceSymbolPath} ${targetSymbolPath}`);
246+
}
247+
});
248+
}
249+
206250
function linkArchFolders(
207251
outputPath /*:string*/,
208252
moduleMapFile /*:string*/,
@@ -319,22 +363,17 @@ function createModuleMapFile(outputPath /*: string */) {
319363
}
320364
}
321365

322-
function extractDestinationFromPath(symbolPath /*: string */) /*: string */ {
323-
if (symbolPath.includes('iphoneos')) {
324-
return 'iphoneos';
325-
}
326-
327-
if (symbolPath.includes('iphonesimulator')) {
328-
return 'iphonesimulator';
329-
}
330-
331-
if (symbolPath.includes('maccatalyst')) {
332-
return 'catalyst';
366+
function getArchsFromFramework(frameworkPath /*:string*/) {
367+
try {
368+
return execSync(`vtool -show-build ${frameworkPath}|grep platform`)
369+
.toString()
370+
.split('\n')
371+
.map(p => p.trim().split(' ')[1])
372+
.sort((a, b) => a.localeCompare(b))
373+
.join(' ');
374+
} catch (error) {
375+
return '';
333376
}
334-
335-
throw new Error(
336-
`Impossible to extract destination from ${symbolPath}. Valid destinations are iphoneos, iphonesimulator and catalyst.`,
337-
);
338377
}
339378

340379
function signXCFramework(

0 commit comments

Comments
 (0)