From ddb29a8c38f7115785660d0eeb6b0c85e3f7e5bc Mon Sep 17 00:00:00 2001 From: Ozgur Ersoy Date: Tue, 15 Apr 2025 00:00:28 +0200 Subject: [PATCH] fix(actions): improve macOS build workflow with bundle ID verification and enhanced logging --- .gitea/workflows/test-macos-build.yml | 71 ++++++++++++++++++--------- Config/DefaultGame.ini | 3 ++ scripts/mac_build.sh | 15 ++---- 3 files changed, 57 insertions(+), 32 deletions(-) diff --git a/.gitea/workflows/test-macos-build.yml b/.gitea/workflows/test-macos-build.yml index dbd4b8ad..f35a0d67 100644 --- a/.gitea/workflows/test-macos-build.yml +++ b/.gitea/workflows/test-macos-build.yml @@ -33,29 +33,43 @@ jobs: echo "Environment setup complete" shell: bash - # Set correct bundle identifier before build - - name: Set bundle identifier + # Verify bundle identifier is correctly set + - name: Verify bundle identifier run: | - # Set the correct bundle identifier in DefaultGame.ini if it exists - CONFIG_FILE="Config/DefaultGame.ini" - if [ -f "$CONFIG_FILE" ]; then - # Check if section exists or add it - if grep -q "\[/Script/MacTargetPlatform\.MacTargetSettings\]" "$CONFIG_FILE"; then - # Section exists, update the setting - sed -i '' 's/BundleIdentifier=.*/BundleIdentifier=com.luckyrobots.luckyworld/g' "$CONFIG_FILE" - else - # Section doesn't exist, add it - echo "" >> "$CONFIG_FILE" - echo "[/Script/MacTargetPlatform.MacTargetSettings]" >> "$CONFIG_FILE" - echo "BundleIdentifier=com.luckyrobots.luckyworld" >> "$CONFIG_FILE" - fi - echo "Updated bundle ID in project config" - fi - # Set the constant bundle ID for the workflow echo "BUNDLE_ID=com.luckyrobots.luckyworld" >> "$GITHUB_ENV" + + # Verify the bundle ID is correctly set in DefaultGame.ini + CONFIG_FILE="Config/DefaultGame.ini" + if [ -f "$CONFIG_FILE" ]; then + if grep -q "\[/Script/MacTargetPlatform\.MacTargetSettings\]" "$CONFIG_FILE" && grep -q "BundleIdentifier=com.luckyrobots.luckyworld" "$CONFIG_FILE"; then + echo "✅ Bundle ID correctly set in DefaultGame.ini" + else + echo "⚠️ Warning: Bundle ID may not be correctly set in DefaultGame.ini" + echo "Please make sure the following section exists:" + echo "[/Script/MacTargetPlatform.MacTargetSettings]" + echo "BundleIdentifier=com.luckyrobots.luckyworld" + fi + else + echo "⚠️ DefaultGame.ini not found!" + fi shell: bash - + + # Check Unreal Engine Project settings + - name: Inspect Unreal Settings + run: | + # Check for any potential issues in UE project settings + if [ -f "Config/DefaultEngine.ini" ]; then + echo "Checking DefaultEngine.ini for settings that might affect bundle ID..." + grep -i "bundle\|identifier\|package" Config/DefaultEngine.ini || echo "No relevant settings found" + fi + + if [ -f "Config/DefaultGame.ini" ]; then + echo "Checking DefaultGame.ini for settings that might affect bundle ID..." + grep -i "bundle\|identifier\|package" Config/DefaultGame.ini || echo "No relevant settings found" + fi + shell: bash + # Build for macOS - use your own build script or create a test app if needed - name: Build for macOS run: | @@ -116,9 +130,18 @@ jobs: # Fix bundle ID in Info.plist before signing if [ -f "$MAIN_APP_PATH/Contents/Info.plist" ]; then - echo "Setting bundle identifier to $BUNDLE_ID" - /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")" + echo "Checking current bundle identifier..." + CURRENT_BUNDLE_ID=$(/usr/libexec/PlistBuddy -c "Print :CFBundleIdentifier" "$MAIN_APP_PATH/Contents/Info.plist") + echo "Current bundle ID: $CURRENT_BUNDLE_ID" + + if [ "$CURRENT_BUNDLE_ID" != "$BUNDLE_ID" ]; then + echo "Bundle ID mismatch - fixing it!" + echo "Setting bundle identifier to $BUNDLE_ID" + /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" + fi else echo "WARNING: Could not find Info.plist in app bundle." fi @@ -133,6 +156,10 @@ jobs: 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" + + # 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 fi diff --git a/Config/DefaultGame.ini b/Config/DefaultGame.ini index 96915495..7cae8a2f 100644 --- a/Config/DefaultGame.ini +++ b/Config/DefaultGame.ini @@ -7,6 +7,9 @@ ProjectVersion=0.1 ;bAddPacks=True ;InsertPack=(PackSource="StarterContent.upack",PackName="StarterContent") +[/Script/MacTargetPlatform.MacTargetSettings] +BundleIdentifier=com.luckyrobots.luckyworld + [/Script/UnrealEd.ProjectPackagingSettings] Build=IfProjectHasCode BuildConfiguration=PPBC_Shipping diff --git a/scripts/mac_build.sh b/scripts/mac_build.sh index 8b1ba0c4..b0a661b1 100755 --- a/scripts/mac_build.sh +++ b/scripts/mac_build.sh @@ -97,20 +97,15 @@ fi # Update bundle ID in project settings echo "" -echo "🔧 Updating bundle ID in UE config..." +echo "🔧 Checking for bundle ID in UE config..." CONFIG_FILE="$PROJECT_ROOT/Config/DefaultGame.ini" if [ -f "$CONFIG_FILE" ]; then - # Check if section exists or add it - if grep -q "\[/Script/MacTargetPlatform\.MacTargetSettings\]" "$CONFIG_FILE"; then - # Section exists, update the setting - sed -i '' 's/BundleIdentifier=.*/BundleIdentifier=com.luckyrobots.luckyworld/g' "$CONFIG_FILE" + if grep -q "\[/Script/MacTargetPlatform\.MacTargetSettings\]" "$CONFIG_FILE" && grep -q "BundleIdentifier=com.luckyrobots.luckyworld" "$CONFIG_FILE"; then + echo "Bundle ID already correctly set in project config ✅" else - # Section doesn't exist, add it - echo "" >> "$CONFIG_FILE" - echo "[/Script/MacTargetPlatform.MacTargetSettings]" >> "$CONFIG_FILE" - echo "BundleIdentifier=com.luckyrobots.luckyworld" >> "$CONFIG_FILE" + echo "⚠️ Warning: Bundle ID may not be correctly set in DefaultGame.ini" + echo "Please ensure [/Script/MacTargetPlatform.MacTargetSettings] section exists with BundleIdentifier=com.luckyrobots.luckyworld" fi - echo "Updated bundle ID in project config" else echo "⚠️ Config file not found at $CONFIG_FILE" fi