Skip to content

Commit cfd06d8

Browse files
chrfalchreact-native-bot
authored andcommitted
fixed copying bundles correctly (#53325)
Summary: When copying bundle files from the platform folders in the .build output, the script had a bug where all bundles were copied - meaning that only the last one would be in the resulting xcframework output. This caused an issue when we tried to publish an app built with precompiled binaries to AppStore where the field `CFBundleSupportedPlatforms` was wrong and caused the submission to be rejected. This was caused by the script copying the wrong bundle file into the final xcframework outputs. This issue is described here: react-native-community/discussions-and-proposals#923 (comment) This commit fixes the above error by using the iOS 15 `vtool` to show the actual platform for a given framework and then making sure we don't copy bundles in the wrong way. Testing this on my local machine for iOS/iOS-simulator/MacOS/catalyst yields the following results (before/after this fix): **Before:** ```bash Copying bundles to the framework... ../.build/Build/Products/Debug/ReactNativeDependencies_glog.bundle → ios-arm64 ../.build/Build/Products/Debug/ReactNativeDependencies_glog.bundle → ios-arm64_x86_64-maccatalyst ../.build/Build/Products/Debug/ReactNativeDependencies_glog.bundle → ios-arm64_x86_64-simulator ../.build/Build/Products/Debug/ReactNativeDependencies_glog.bundle → macos-arm64_x86_64 ../.build/Build/Products/Debug/ReactNativeDependencies_boost.bundle → ios-arm64 ../.build/Build/Products/Debug/ReactNativeDependencies_boost.bundle → ios-arm64_x86_64-maccatalyst ../.build/Build/Products/Debug/ReactNativeDependencies_boost.bundle → ios-arm64_x86_64-simulator ../.build/Build/Products/Debug/ReactNativeDependencies_boost.bundle → macos-arm64_x86_64 ../.build/Build/Products/Debug/ReactNativeDependencies_folly.bundle → ios-arm64 ../.build/Build/Products/Debug/ReactNativeDependencies_folly.bundle → ios-arm64_x86_64-maccatalyst ../.build/Build/Products/Debug/ReactNativeDependencies_folly.bundle → ios-arm64_x86_64-simulator ../.build/Build/Products/Debug/ReactNativeDependencies_folly.bundle → macos-arm64_x86_64 ../.build/Build/Products/Debug-iphoneos/ReactNativeDependencies_glog.bundle → ios-arm64 ../.build/Build/Products/Debug-iphoneos/ReactNativeDependencies_glog.bundle → ios-arm64_x86_64-maccatalyst ../.build/Build/Products/Debug-iphoneos/ReactNativeDependencies_glog.bundle → ios-arm64_x86_64-simulator ../.build/Build/Products/Debug-iphoneos/ReactNativeDependencies_glog.bundle → macos-arm64_x86_64 ../.build/Build/Products/Debug-iphoneos/ReactNativeDependencies_boost.bundle → ios-arm64 ../.build/Build/Products/Debug-iphoneos/ReactNativeDependencies_boost.bundle → ios-arm64_x86_64-maccatalyst ../.build/Build/Products/Debug-iphoneos/ReactNativeDependencies_boost.bundle → ios-arm64_x86_64-simulator ../.build/Build/Products/Debug-iphoneos/ReactNativeDependencies_boost.bundle → macos-arm64_x86_64 ../.build/Build/Products/Debug-iphoneos/ReactNativeDependencies_folly.bundle → ios-arm64 ../.build/Build/Products/Debug-iphoneos/ReactNativeDependencies_folly.bundle → ios-arm64_x86_64-maccatalyst ../.build/Build/Products/Debug-iphoneos/ReactNativeDependencies_folly.bundle → ios-arm64_x86_64-simulator ../.build/Build/Products/Debug-iphoneos/ReactNativeDependencies_folly.bundle → macos-arm64_x86_64 ../.build/Build/Products/Debug-iphonesimulator/ReactNativeDependencies_glog.bundle → ios-arm64 ../.build/Build/Products/Debug-iphonesimulator/ReactNativeDependencies_glog.bundle → ios-arm64_x86_64-maccatalyst ../.build/Build/Products/Debug-iphonesimulator/ReactNativeDependencies_glog.bundle → ios-arm64_x86_64-simulator ../.build/Build/Products/Debug-iphonesimulator/ReactNativeDependencies_glog.bundle → macos-arm64_x86_64 ../.build/Build/Products/Debug-iphonesimulator/ReactNativeDependencies_boost.bundle → ios-arm64 ../.build/Build/Products/Debug-iphonesimulator/ReactNativeDependencies_boost.bundle → ios-arm64_x86_64-maccatalyst ../.build/Build/Products/Debug-iphonesimulator/ReactNativeDependencies_boost.bundle → ios-arm64_x86_64-simulator ../.build/Build/Products/Debug-iphonesimulator/ReactNativeDependencies_boost.bundle → macos-arm64_x86_64 ../.build/Build/Products/Debug-iphonesimulator/ReactNativeDependencies_folly.bundle → ios-arm64 ../.build/Build/Products/Debug-iphonesimulator/ReactNativeDependencies_folly.bundle → ios-arm64_x86_64-maccatalyst ../.build/Build/Products/Debug-iphonesimulator/ReactNativeDependencies_folly.bundle → ios-arm64_x86_64-simulator ../.build/Build/Products/Debug-iphonesimulator/ReactNativeDependencies_folly.bundle → macos-arm64_x86_64 ../.build/Build/Products/Debug-maccatalyst/ReactNativeDependencies_glog.bundle → ios-arm64 ../.build/Build/Products/Debug-maccatalyst/ReactNativeDependencies_glog.bundle → ios-arm64_x86_64-maccatalyst ../.build/Build/Products/Debug-maccatalyst/ReactNativeDependencies_glog.bundle → ios-arm64_x86_64-simulator ../.build/Build/Products/Debug-maccatalyst/ReactNativeDependencies_glog.bundle → macos-arm64_x86_64 ../.build/Build/Products/Debug-maccatalyst/ReactNativeDependencies_boost.bundle → ios-arm64 ../.build/Build/Products/Debug-maccatalyst/ReactNativeDependencies_boost.bundle → ios-arm64_x86_64-maccatalyst ../.build/Build/Products/Debug-maccatalyst/ReactNativeDependencies_boost.bundle → ios-arm64_x86_64-simulator ../.build/Build/Products/Debug-maccatalyst/ReactNativeDependencies_boost.bundle → macos-arm64_x86_64 ../.build/Build/Products/Debug-maccatalyst/ReactNativeDependencies_folly.bundle → ios-arm64 ../.build/Build/Products/Debug-maccatalyst/ReactNativeDependencies_folly.bundle → ios-arm64_x86_64-maccatalyst ../.build/Build/Products/Debug-maccatalyst/ReactNativeDependencies_folly.bundle → ios-arm64_x86_64-simulator ../.build/Build/Products/Debug-maccatalyst/ReactNativeDependencies_folly.bundle → macos-arm64_x86_64 ``` **After:** ```bash Copying bundles to the framework... ../.build/Build/Products/Debug/ReactNativeDependencies_glog.bundle → macos-arm64_x86_64 ../.build/Build/Products/Debug/ReactNativeDependencies_boost.bundle → macos-arm64_x86_64 ../.build/Build/Products/Debug/ReactNativeDependencies_folly.bundle → macos-arm64_x86_64 ../.build/Build/Products/Debug-iphoneos/ReactNativeDependencies_glog.bundle → ios-arm64 ../.build/Build/Products/Debug-iphoneos/ReactNativeDependencies_boost.bundle → ios-arm64 ../.build/Build/Products/Debug-iphoneos/ReactNativeDependencies_folly.bundle → ios-arm64 ../.build/Build/Products/Debug-iphonesimulator/ReactNativeDependencies_glog.bundle → ios-arm64_x86_64-simulator ../.build/Build/Products/Debug-iphonesimulator/ReactNativeDependencies_boost.bundle → ios-arm64_x86_64-simulator ../.build/Build/Products/Debug-iphonesimulator/ReactNativeDependencies_folly.bundle → ios-arm64_x86_64-simulator ../.build/Build/Products/Debug-maccatalyst/ReactNativeDependencies_glog.bundle → ios-arm64_x86_64-maccatalyst ../.build/Build/Products/Debug-maccatalyst/ReactNativeDependencies_boost.bundle → ios-arm64_x86_64-maccatalyst ../.build/Build/Products/Debug-maccatalyst/ReactNativeDependencies_folly.bundle → ios-arm64_x86_64-maccatalyst ``` ## Changelog: [IOS] [FIXED] - Fixed copying bundles correctly to xcframeworks when precompiling ReactNativeDependencies.xcframework Pull Request resolved: #53325 Test Plan: Ensure that the info.plist files in the nightlies for the ReactNativeDepdendencies.xcframework has the correct bundles for its targets. Reviewed By: andrewdacenko Differential Revision: D80457335 Pulled By: cipolleschi fbshipit-source-id: aeb4166f66218f72bdd29b6fc579fcc7b6d12844
1 parent f21d415 commit cfd06d8

File tree

1 file changed

+28
-8
lines changed

1 file changed

+28
-8
lines changed

scripts/releases/ios-prebuild/compose-framework.js

Lines changed: 28 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,9 @@ function copyBundles(
134134
// A bundle is the name of the framework + _ + target name + .bundle. We can
135135
// check if the target has a bundle by checking if it defines one or more resources.
136136
frameworkPaths.forEach(frameworkPath => {
137+
const frameworkPlatforms = execSync(
138+
`vtool -show-build ${path.join(frameworkPath, 'PackageFrameworks', scheme + '.framework', scheme)}|grep platform`,
139+
).toString();
137140
dependencies.forEach(dep => {
138141
const resources = dep.files.resources;
139142
if (!resources || resources.length === 0) {
@@ -144,16 +147,33 @@ function copyBundles(
144147
const sourceBundlePath = path.join(frameworkPath, bundleName);
145148
if (fs.existsSync(sourceBundlePath)) {
146149
// Target folder - needs to be copied to the resulting framework
150+
let targetArchFolderFound = false;
147151
targetArchFolders.forEach(targetArchFolder => {
148-
const targetBundlePath = path.join(
149-
targetArchFolder,
150-
`${scheme}.framework`,
151-
bundleName,
152-
);
153-
154-
// A bundle is a directory, so we need to copy the whole directory
155-
execSync(`cp -r "${sourceBundlePath}/" "${targetBundlePath}"`);
152+
const targetPlatforms = execSync(
153+
`vtool -show-build ${path.join(targetArchFolder, scheme + '.framework', scheme)}|grep platform`,
154+
).toString();
155+
156+
if (targetPlatforms === frameworkPlatforms) {
157+
console.log(
158+
` ${path.relative(outputFolder, sourceBundlePath)}${path.basename(targetArchFolder)}`,
159+
);
160+
const targetBundlePath = path.join(
161+
targetArchFolder,
162+
`${scheme}.framework`,
163+
bundleName,
164+
);
165+
166+
// A bundle is a directory, so we need to copy the whole directory
167+
execSync(`cp -r "${sourceBundlePath}/" "${targetBundlePath}"`);
168+
targetArchFolderFound = true;
169+
}
156170
});
171+
172+
if (!targetArchFolderFound) {
173+
throw Error(
174+
`Could not find target architecture for folder ${path.relative(outputFolder, frameworkPath)}. Expected to find ${frameworkPlatforms}`,
175+
);
176+
}
157177
} else {
158178
console.warn(`Bundle ${sourceBundlePath} not found`);
159179
}

0 commit comments

Comments
 (0)