Skip to content

Commit d28fa43

Browse files
committed
Fix macOS app bundle path - find .app directory dynamically
The previous fix used the wrong path for macOS app bundles. It was missing the .app directory name in the path construction. Problem: - Was looking for: <outputPath>/Contents/Resources/sitl - Actual location: <outputPath>/<AppName>.app/Contents/Resources/sitl Fix: - Dynamically find the .app bundle in outputPath - Construct correct path with .app directory included This should now properly remove non-native SITL binaries from macOS builds.
1 parent 204c082 commit d28fa43

1 file changed

Lines changed: 15 additions & 5 deletions

File tree

forge.config.js

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,21 @@ export default {
4949
// Remove SITL binaries for other platforms/architectures to reduce package size
5050
postPackage: async (forgeConfig, options) => {
5151
for (const outputPath of options.outputPaths) {
52-
// macOS has different app bundle structure: <app>/Contents/Resources/sitl
53-
// Windows/Linux: <outputPath>/resources/sitl
54-
const sitlPath = options.platform === 'darwin'
55-
? path.join(outputPath, 'Contents', 'Resources', 'sitl')
56-
: path.join(outputPath, 'resources', 'sitl');
52+
let sitlPath;
53+
54+
if (options.platform === 'darwin') {
55+
// macOS app bundle structure: <outputDir>/<AppName>.app/Contents/Resources/sitl
56+
// Find the .app directory
57+
const appBundles = fs.readdirSync(outputPath).filter(f => f.endsWith('.app'));
58+
if (appBundles.length === 0) {
59+
console.log(`postPackage: No .app bundle found in ${outputPath}`);
60+
continue;
61+
}
62+
sitlPath = path.join(outputPath, appBundles[0], 'Contents', 'Resources', 'sitl');
63+
} else {
64+
// Windows/Linux: <outputPath>/resources/sitl
65+
sitlPath = path.join(outputPath, 'resources', 'sitl');
66+
}
5767

5868
console.log(`postPackage: Checking SITL path for ${options.platform}: ${sitlPath}`);
5969
if (!fs.existsSync(sitlPath)) {

0 commit comments

Comments
 (0)