From c57938c995d919632b5b65c7aebfd1c67a0b00c5 Mon Sep 17 00:00:00 2001 From: Ozgur Ersoy Date: Tue, 15 Apr 2025 01:22:42 +0200 Subject: [PATCH] fix(actions): add bundle ID verification and nested app bundle handling in macOS build workflow --- .gitea/workflows/test-macos-build.yml | 24 ++++++++++++++++++ Source/LuckyWorld.Target.cs | 7 ++++++ Source/LuckyWorld/LuckyWorld.Build.cs | 6 +++++ scripts/mac_build.sh | 35 ++++++++++++++++++++++++--- 4 files changed, 69 insertions(+), 3 deletions(-) diff --git a/.gitea/workflows/test-macos-build.yml b/.gitea/workflows/test-macos-build.yml index 4ca6fd31..f321b1ec 100644 --- a/.gitea/workflows/test-macos-build.yml +++ b/.gitea/workflows/test-macos-build.yml @@ -66,6 +66,30 @@ jobs: else echo "⚠️ DefaultGame.ini not found!" fi + + # Verify Build.cs and Target.cs files + BUILD_CS="Source/LuckyWorld/LuckyWorld.Build.cs" + TARGET_CS="Source/LuckyWorld.Target.cs" + + if [ -f "$BUILD_CS" ]; then + if grep -q "APP_BUNDLE_IDENTIFIER=com.luckyrobots.luckyworld" "$BUILD_CS"; then + echo "✅ Bundle ID correctly set in LuckyWorld.Build.cs" + else + echo "⚠️ Warning: Bundle ID may not be correctly set in LuckyWorld.Build.cs" + fi + else + echo "⚠️ LuckyWorld.Build.cs not found!" + fi + + if [ -f "$TARGET_CS" ]; then + if grep -q "APP_BUNDLE_IDENTIFIER=com.luckyrobots.luckyworld" "$TARGET_CS"; then + echo "✅ Bundle ID correctly set in LuckyWorld.Target.cs" + else + echo "⚠️ Warning: Bundle ID may not be correctly set in LuckyWorld.Target.cs" + fi + else + echo "⚠️ LuckyWorld.Target.cs not found!" + fi shell: bash # Check Unreal Engine Project settings diff --git a/Source/LuckyWorld.Target.cs b/Source/LuckyWorld.Target.cs index 25223105..54e0d30d 100644 --- a/Source/LuckyWorld.Target.cs +++ b/Source/LuckyWorld.Target.cs @@ -18,5 +18,12 @@ public class LuckyWorldTarget : TargetRules { this.bUseLoggingInShipping = true; } + + // macOS specific settings + if (Target.Platform == UnrealTargetPlatform.Mac) + { + // Force use the bundle ID from DefaultGame.ini + GlobalDefinitions.Add("APP_BUNDLE_IDENTIFIER=com.luckyrobots.luckyworld"); + } } } diff --git a/Source/LuckyWorld/LuckyWorld.Build.cs b/Source/LuckyWorld/LuckyWorld.Build.cs index d6c887a7..4cca39f2 100644 --- a/Source/LuckyWorld/LuckyWorld.Build.cs +++ b/Source/LuckyWorld/LuckyWorld.Build.cs @@ -19,5 +19,11 @@ public class LuckyWorld : ModuleRules // PrivateDependencyModuleNames.Add("OnlineSubsystem"); // To include OnlineSubsystemSteam, add it to the plugins section in your uproject file with the Enabled attribute set to true + + // Set the bundle identifier for macOS builds + if (Target.Platform == UnrealTargetPlatform.Mac) + { + PublicDefinitions.Add("APP_BUNDLE_IDENTIFIER=com.luckyrobots.luckyworld"); + } } } diff --git a/scripts/mac_build.sh b/scripts/mac_build.sh index b0a661b1..e1a7b6f3 100755 --- a/scripts/mac_build.sh +++ b/scripts/mac_build.sh @@ -116,9 +116,38 @@ echo "🔧 Performing post-build fix for bundle ID..." 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 + + # Find and repair nested app bundles as well (like CrashReportClient.app) + echo "Checking for nested app bundles..." + NESTED_APPS=$(find "$APP_PATH" -name "*.app" -type d) + if [ -n "$NESTED_APPS" ]; then + echo "Found nested app bundles, fixing 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="com.luckyrobots.luckyworld.$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" + + # Verify the change + UPDATED_ID=$(/usr/libexec/PlistBuddy -c "Print :CFBundleIdentifier" "$NESTED_APP/Contents/Info.plist") + echo "Updated nested app bundle ID: $UPDATED_ID" + fi + done + else + echo "No nested app bundles found." + fi else echo "⚠️ Info.plist not found at $INFO_PLIST" fi