Skip to content

Combine two macOS installers into one universal binary #39339

@jclarkeSTFC

Description

@jclarkeSTFC

Describe the outcome that is desired.

Currently we have a DMG installer for x86_64, and one for ARM, but I think we can combine these into one universal DMG with both architectures included.

Describe any solutions you are considering

Here's what Copilot had to say for itself:

#!/bin/bash

set -e

# Input DMG paths
DMG_X86="$1"
DMG_ARM="$2"
APP_NAME="YourApp.app"
BINARY_NAME="YourApp"

# Mount DMGs
echo "Mounting DMGs..."
MOUNT_X86=$(hdiutil attach "$DMG_X86" | grep Volumes | awk '{print $3}')
MOUNT_ARM=$(hdiutil attach "$DMG_ARM" | grep Volumes | awk '{print $3}')

# Extract binaries
echo "Extracting binaries..."
cp "$MOUNT_X86/$APP_NAME/Contents/MacOS/$BINARY_NAME" ./binary_x86_64
cp "$MOUNT_ARM/$APP_NAME/Contents/MacOS/$BINARY_NAME" ./binary_arm64

# Create universal binary
echo "Creating universal binary..."
lipo -create -output "$BINARY_NAME"_universal binary_x86_64 binary_arm64

# Copy one of the app bundles to modify
echo "Preparing app bundle..."
cp -R "$MOUNT_ARM/$APP_NAME" "./$APP_NAME"
cp "$BINARY_NAME"_universal "./$APP_NAME/Contents/MacOS/$BINARY_NAME"

# Unmount DMGs
echo "Unmounting DMGs..."
hdiutil detach "$MOUNT_X86"
hdiutil detach "$MOUNT_ARM"

# Create new DMG
echo "Creating new DMG..."
hdiutil create -volname "$APP_NAME" -srcfolder "./$APP_NAME" -ov -format UDZO "${APP_NAME%.app}_Universal.dmg"

echo "✅ Universal DMG created: ${APP_NAME%.app}_Universal.dmg"

Additional context

See #38990

Metadata

Metadata

Assignees

No one assigned

    Labels

    ISIS: CoreIssue and pull requests at ISIS that relate to Core features and functionsMaintenanceUnassigned issues to be addressed in the next maintenance period.macOS OnlyThe issues related to macOS only. Currently could be x64 or ARM.

    Type

    No type

    Projects

    Status

    No status

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions