From 63ca0d48830ec60460bc9ee8b8493087fc42e802 Mon Sep 17 00:00:00 2001 From: Ozgur Ersoy Date: Tue, 15 Apr 2025 14:07:53 +0200 Subject: [PATCH] fix(actions): improve bundle ID verification process in macOS build workflow --- .gitea/workflows/test-macos-build.yml | 36 ++++++++++++++++++++------- scripts/mac_build.sh | 20 ++++++++++++--- 2 files changed, 43 insertions(+), 13 deletions(-) diff --git a/.gitea/workflows/test-macos-build.yml b/.gitea/workflows/test-macos-build.yml index 4ca6fd31..4376bbb8 100644 --- a/.gitea/workflows/test-macos-build.yml +++ b/.gitea/workflows/test-macos-build.yml @@ -141,6 +141,11 @@ jobs: # Export APP_PATH for next steps to use echo "APP_PATH=$MAIN_APP_PATH" >> "$GITHUB_ENV" + # Note: While bundle ID should be set by Unreal Engine build system based on DefaultGame.ini + # and LuckyWorld.Build.cs settings, we still check and fix if needed as a safety measure, + # since UE builds can sometimes have issues with bundle ID propagation + echo "Checking bundle IDs (fallback fix in case UE didn't properly apply settings)..." + # Fix bundle ID in Info.plist before signing if [ -f "$MAIN_APP_PATH/Contents/Info.plist" ]; then echo "Checking current bundle identifier..." @@ -153,7 +158,7 @@ jobs: /usr/libexec/PlistBuddy -c "Set :CFBundleIdentifier $BUNDLE_ID" "$MAIN_APP_PATH/Contents/Info.plist" echo "Updated bundle ID in Info.plist: $(/usr/libexec/PlistBuddy -c "Print :CFBundleIdentifier" "$MAIN_APP_PATH/Contents/Info.plist")" else - echo "Bundle ID is already correct: $BUNDLE_ID" + echo "✅ Bundle ID is already correct: $BUNDLE_ID" fi else echo "WARNING: Could not find Info.plist in app bundle." @@ -162,17 +167,23 @@ jobs: # Find and repair nested app bundles as well (like CrashReportClient.app) NESTED_APPS=$(find "$MAIN_APP_PATH" -name "*.app" -type d) if [ -n "$NESTED_APPS" ]; then - echo "Found nested app bundles, fixing their bundle IDs:" + echo "Found nested app bundles, checking their bundle IDs:" echo "$NESTED_APPS" | while read -r NESTED_APP; do if [ -f "$NESTED_APP/Contents/Info.plist" ]; then NESTED_NAME=$(basename "$NESTED_APP" .app) NESTED_BUNDLE_ID="$BUNDLE_ID.$NESTED_NAME" - echo "Setting nested bundle ID to $NESTED_BUNDLE_ID for $NESTED_APP" - /usr/libexec/PlistBuddy -c "Set :CFBundleIdentifier $NESTED_BUNDLE_ID" "$NESTED_APP/Contents/Info.plist" + CURRENT_NESTED_ID=$(/usr/libexec/PlistBuddy -c "Print :CFBundleIdentifier" "$NESTED_APP/Contents/Info.plist") - # Verify the change - UPDATED_ID=$(/usr/libexec/PlistBuddy -c "Print :CFBundleIdentifier" "$NESTED_APP/Contents/Info.plist") - echo "Updated nested app bundle ID: $UPDATED_ID" + if [ "$CURRENT_NESTED_ID" != "$NESTED_BUNDLE_ID" ]; then + echo "Setting nested bundle ID to $NESTED_BUNDLE_ID for $NESTED_APP" + /usr/libexec/PlistBuddy -c "Set :CFBundleIdentifier $NESTED_BUNDLE_ID" "$NESTED_APP/Contents/Info.plist" + + # Verify the change + UPDATED_ID=$(/usr/libexec/PlistBuddy -c "Print :CFBundleIdentifier" "$NESTED_APP/Contents/Info.plist") + echo "Updated nested app bundle ID: $UPDATED_ID" + else + echo "✅ Nested app $NESTED_NAME already has correct bundle ID: $CURRENT_NESTED_ID" + fi fi done fi @@ -210,8 +221,15 @@ jobs: if [ -f "$CRASH_REPORTER/Contents/Info.plist" ]; then # Ensure it has the correct bundle ID format CRASH_BUNDLE_ID="$BUNDLE_ID.CrashReportClient" - echo "Setting CrashReportClient bundle ID to $CRASH_BUNDLE_ID" - /usr/libexec/PlistBuddy -c "Set :CFBundleIdentifier $CRASH_BUNDLE_ID" "$CRASH_REPORTER/Contents/Info.plist" + CURRENT_CRASH_ID=$(/usr/libexec/PlistBuddy -c "Print :CFBundleIdentifier" "$CRASH_REPORTER/Contents/Info.plist") + + if [ "$CURRENT_CRASH_ID" != "$CRASH_BUNDLE_ID" ]; then + echo "Setting CrashReportClient bundle ID to $CRASH_BUNDLE_ID" + /usr/libexec/PlistBuddy -c "Set :CFBundleIdentifier $CRASH_BUNDLE_ID" "$CRASH_REPORTER/Contents/Info.plist" + echo "Updated CrashReportClient bundle ID: $(/usr/libexec/PlistBuddy -c "Print :CFBundleIdentifier" "$CRASH_REPORTER/Contents/Info.plist")" + else + echo "✅ CrashReportClient already has correct bundle ID: $CURRENT_CRASH_ID" + fi fi fi shell: bash diff --git a/scripts/mac_build.sh b/scripts/mac_build.sh index b0a661b1..478f3281 100755 --- a/scripts/mac_build.sh +++ b/scripts/mac_build.sh @@ -112,13 +112,25 @@ fi # Post-build process - set bundle ID echo "" -echo "🔧 Performing post-build fix for bundle ID..." +echo "🔍 Checking bundle ID in built app..." +echo "Note: Bundle ID should be automatically set by Unreal Engine based on DefaultGame.ini and" +echo "LuckyWorld.Build.cs settings, but UE sometimes fails to apply it correctly." +echo "Therefore, we keep this check and fix as a safety measure." + if [ -n "$APP_PATH" ]; then INFO_PLIST="$APP_PATH/Contents/Info.plist" if [ -f "$INFO_PLIST" ]; then - echo "Setting bundle identifier to com.luckyrobots.luckyworld" - /usr/libexec/PlistBuddy -c "Set :CFBundleIdentifier com.luckyrobots.luckyworld" "$INFO_PLIST" - echo "Updated bundle ID: $(/usr/libexec/PlistBuddy -c "Print :CFBundleIdentifier" "$INFO_PLIST")" + CURRENT_BUNDLE_ID=$(/usr/libexec/PlistBuddy -c "Print :CFBundleIdentifier" "$INFO_PLIST") + echo "Current bundle ID: $CURRENT_BUNDLE_ID" + + if [ "$CURRENT_BUNDLE_ID" != "com.luckyrobots.luckyworld" ]; then + echo "Bundle ID mismatch - fixing it!" + echo "Setting bundle identifier to com.luckyrobots.luckyworld" + /usr/libexec/PlistBuddy -c "Set :CFBundleIdentifier com.luckyrobots.luckyworld" "$INFO_PLIST" + echo "Updated bundle ID: $(/usr/libexec/PlistBuddy -c "Print :CFBundleIdentifier" "$INFO_PLIST")" + else + echo "✅ Bundle ID is already correct: com.luckyrobots.luckyworld" + fi else echo "⚠️ Info.plist not found at $INFO_PLIST" fi