diff --git a/.gitea/workflows/test-macos-build.yml b/.gitea/workflows/test-macos-build.yml index f321b1ec..db51ccd7 100644 --- a/.gitea/workflows/test-macos-build.yml +++ b/.gitea/workflows/test-macos-build.yml @@ -109,56 +109,127 @@ jobs: # Build for macOS - use your own build script or create a test app if needed - name: Build for macOS + id: build-app + continue-on-error: true # Continue even if build fails, to collect debug info run: | if [ -f "./scripts/mac_build.sh" ]; then + echo "🔨 Running mac_build.sh and capturing output to build_log.txt..." chmod +x ./scripts/mac_build.sh # Set CI environment variable explicitly before running export CI=true - ./scripts/mac_build.sh + # Run build script and capture all output to a log file + ./scripts/mac_build.sh 2>&1 | tee build_log.txt + + # Check if build succeeded based on exit code + if [ ${PIPESTATUS[0]} -ne 0 ]; then + echo "❌ Build script failed with exit code ${PIPESTATUS[0]}" + echo "See build_log.txt for details" + # Set output to indicate failure + echo "::set-output name=build_success::false" + else + echo "✅ Build script completed successfully" + echo "::set-output name=build_success::true" + fi else - echo "ERROR: Build script not found at ./scripts/mac_build.sh" + echo "❌ ERROR: Build script not found at ./scripts/mac_build.sh" + echo "::set-output name=build_success::false" exit 1 fi shell: bash - # Find the app bundle + # Upload build logs regardless of success + - name: Upload Build Logs + uses: actions/upload-artifact@v3 + with: + name: build-logs + path: | + build_log.txt + ./Saved/Logs/*.log + retention-days: 7 + if-no-files-found: warn + + # Find the app bundle - this may fail if build failed - name: Find app bundle + id: find-app + continue-on-error: ${{ steps.build-app.outputs.build_success != 'true' }} # Only stop if build succeeded but app not found run: | + # Debug: Show directory structure to help diagnose issues + echo "📂 Current directory structure:" + ls -la ./ + + # Debug: Show if the build directory exists + echo "📂 Checking if Builds directory exists:" + ls -la ./ | grep Builds || echo "Builds directory not found!" + + # Debug: Show if Saved directory exists + echo "📂 Checking if Saved directory exists:" + ls -la ./ | grep Saved || echo "Saved directory not found!" + # First check Saved/StagedBuilds directory - where Unreal often places built apps - echo "Checking Saved/StagedBuilds directory..." - APP_PATHS=$(find ./Saved/StagedBuilds -type d -name "*.app" 2>/dev/null) + echo "📂 Checking Saved/StagedBuilds directory..." + if [ -d "./Saved/StagedBuilds" ]; then + echo "Saved/StagedBuilds exists, checking content:" + ls -la ./Saved/StagedBuilds + APP_PATHS=$(find ./Saved/StagedBuilds -type d -name "*.app" 2>/dev/null) + else + echo "⚠️ Saved/StagedBuilds directory doesn't exist!" + APP_PATHS="" + fi + + # If not found, check Saved directory + if [ -z "$APP_PATHS" ]; then + echo "📂 Checking Saved directory..." + if [ -d "./Saved" ]; then + echo "Saved exists, looking for app bundles:" + ls -la ./Saved + APP_PATHS=$(find ./Saved -type d -name "*.app" 2>/dev/null) + else + echo "⚠️ Saved directory doesn't exist!" + fi + fi # If not found, check Builds directory if [ -z "$APP_PATHS" ]; then - echo "Checking Builds directory..." - APP_PATHS=$(find ./Builds -type d -name "*.app" 2>/dev/null) + echo "📂 Checking Builds directory..." + if [ -d "./Builds" ]; then + echo "Builds exists, looking for app bundles:" + ls -la ./Builds + ls -la ./Builds/Mac 2>/dev/null || echo "No Builds/Mac directory found" + APP_PATHS=$(find ./Builds -type d -name "*.app" 2>/dev/null) + else + echo "⚠️ Builds directory doesn't exist!" + fi fi # If still not found, check the whole workspace if [ -z "$APP_PATHS" ]; then - echo "Checking entire workspace..." + echo "📂 Checking entire workspace for .app bundles..." APP_PATHS=$(find . -type d -name "*.app" -not -path "*/\.*" 2>/dev/null) fi if [ -z "$APP_PATHS" ]; then - echo "ERROR: Could not find any app bundles!" + echo "❌ ERROR: Could not find any app bundles!" echo "Listing all directories to help debug:" find . -type d -maxdepth 3 | sort + + echo "Build process likely failed. Checking mac_build.sh log:" + cat build_log.txt 2>/dev/null || echo "No build log found" + exit 1 fi - echo "Found potential app bundles:" + echo "📦 Found potential app bundles:" echo "$APP_PATHS" # Use the first app path found (preferably the main app, not a child app) MAIN_APP_PATH=$(echo "$APP_PATHS" | grep -v "CrashReportClient" | head -1 || echo "$APP_PATHS" | head -1) - echo "Using app bundle: $MAIN_APP_PATH" + echo "🚀 Using app bundle: $MAIN_APP_PATH" echo "APP_PATH=$MAIN_APP_PATH" >> "$GITHUB_ENV" # Make sure app exists - using local variable if [ ! -d "$MAIN_APP_PATH" ]; then - echo "ERROR: App bundle not found at $MAIN_APP_PATH!" + echo "❌ ERROR: App bundle not found at $MAIN_APP_PATH!" exit 1 fi @@ -179,6 +250,11 @@ jobs: else echo "Bundle ID is already correct: $BUNDLE_ID" fi + + # Set the application name to "LuckyWorld" instead of "LuckyWorld-Mac-Shipping" + echo "Setting application display name to LuckyWorld..." + /usr/libexec/PlistBuddy -c "Set :CFBundleName LuckyWorld" "$MAIN_APP_PATH/Contents/Info.plist" + echo "Updated app name: $(/usr/libexec/PlistBuddy -c "Print :CFBundleName" "$MAIN_APP_PATH/Contents/Info.plist")" else echo "WARNING: Could not find Info.plist in app bundle." fi diff --git a/Config/DefaultEngine.ini b/Config/DefaultEngine.ini index 761b6da7..e701c9f9 100644 --- a/Config/DefaultEngine.ini +++ b/Config/DefaultEngine.ini @@ -338,3 +338,27 @@ NearClipPlane=0.100000 bFinalUsesRDO=True FinalRDOLambda=100 +[/Script/MacTargetPlatform.MacTargetSettings] +TargetedRHIs=SF_METAL_SM5 +MetalLanguageVersion=5 +MaxShaderLanguageVersion=4 +MinimumOSVersion=11 +BundleName=LuckyWorld +BundleDisplayName=LuckyWorld +bEnableMathOptimizations=True +UseFastIntrinsics=True +EnableMipGenOption=Default +FrameRateLock=PUFRL_None +AudioSampleRate=48000 +AudioMaxChannels=32 +bUseCustomIcon=False +bUseMiniUPnP=False +MetalDynamicLibraries=() +MetalRuntimeLibrary=1 +OutputRealFPS=False +bBuildEmbeddedFrameworksForGame=False +EnableCodeCoverage=False +EnableCodeCoveragePath=(Path="") +ForwardShading=False +UseFastCopyToResolve=True + diff --git a/Source/LuckyWorld.Target.cs b/Source/LuckyWorld.Target.cs index 54e0d30d..17d49d9a 100644 --- a/Source/LuckyWorld.Target.cs +++ b/Source/LuckyWorld.Target.cs @@ -24,6 +24,8 @@ public class LuckyWorldTarget : TargetRules { // Force use the bundle ID from DefaultGame.ini GlobalDefinitions.Add("APP_BUNDLE_IDENTIFIER=com.luckyrobots.luckyworld"); + GlobalDefinitions.Add("APP_BUNDLE_NAME=LuckyWorld"); + GlobalDefinitions.Add("APP_BUNDLE_DISPLAY_NAME=LuckyWorld"); } } } diff --git a/Source/LuckyWorld/LuckyWorld.Build.cs b/Source/LuckyWorld/LuckyWorld.Build.cs index 4cca39f2..fb42121f 100644 --- a/Source/LuckyWorld/LuckyWorld.Build.cs +++ b/Source/LuckyWorld/LuckyWorld.Build.cs @@ -24,6 +24,8 @@ public class LuckyWorld : ModuleRules if (Target.Platform == UnrealTargetPlatform.Mac) { PublicDefinitions.Add("APP_BUNDLE_IDENTIFIER=com.luckyrobots.luckyworld"); + PublicDefinitions.Add("APP_BUNDLE_NAME=LuckyWorld"); + PublicDefinitions.Add("APP_BUNDLE_DISPLAY_NAME=LuckyWorld"); } } } diff --git a/scripts/mac_build.sh b/scripts/mac_build.sh index e1a7b6f3..7c35780c 100755 --- a/scripts/mac_build.sh +++ b/scripts/mac_build.sh @@ -67,16 +67,54 @@ rm -rf DerivedDataCache Intermediate Binaries Saved # -nocompileeditor \ # -skipbuildeditor \ - # enable these if you want to test build without pak and iostore (you're just testing the build) - # -skipiostore \ - # -skippak \ (disable -pak and -iostore) +BUILD_EXIT_CODE=$? echo "" -echo "🦾 Build completed. Application path:" -APP_PATH=$(find "$ARCHIVE_DIR" -name "*.app" -type d | head -n 1) -echo "$APP_PATH" +echo "🦾 Build process completed with exit code: $BUILD_EXIT_CODE" -if [ -n "$APP_PATH" ]; then +# Debug check for where the app might be +echo "📂 Checking potential build output locations:" +echo "Saved directory contents (if exists):" +ls -la Saved 2>/dev/null || echo "Saved directory not found" + +echo "Saved/StagedBuilds directory contents (if exists):" +ls -la Saved/StagedBuilds 2>/dev/null || echo "Saved/StagedBuilds directory not found" + +echo "Builds directory contents:" +ls -la "$ARCHIVE_DIR" 2>/dev/null || echo "Builds directory not found" + +echo "Builds/Mac directory contents (if exists):" +ls -la "$ARCHIVE_DIR/Mac" 2>/dev/null || echo "Builds/Mac directory not found" + +# Find the app, regardless of build success +echo "🔍 Searching for .app bundles in Saved and Builds directories:" +APP_PATH="" +for search_dir in "$ARCHIVE_DIR" "$ARCHIVE_DIR/Mac" "Saved/StagedBuilds" "Saved/StagedBuilds/Mac" "Saved"; do + if [ -d "$search_dir" ]; then + echo "Searching in $search_dir" + APP_FOUND=$(find "$search_dir" -name "*.app" -type d | head -n 1) + if [ -n "$APP_FOUND" ]; then + APP_PATH="$APP_FOUND" + echo "Found app bundle at: $APP_PATH" + break + fi + fi +done + +if [ -z "$APP_PATH" ]; then + echo "❌ No app bundle found. Build may have failed or output location is unexpected." + + # Set a fake path for debug tests + if [ -n "$CI" ]; then + echo "This is a CI environment, continuing with error checks..." + else + echo "Exiting with error code from build" + exit $BUILD_EXIT_CODE + fi +else + echo "🦾 Build completed. Application path:" + echo "$APP_PATH" + echo "" echo "🔍 Binary files that will need signing:" DYLIB_COUNT=$(find "$APP_PATH" -name "*.dylib" | wc -l) @@ -113,24 +151,62 @@ fi # Post-build process - set bundle ID echo "" echo "🔧 Performing post-build fix for bundle ID..." -if [ -n "$APP_PATH" ]; then + +# First verify that APP_PATH is defined and exists +if [ -z "$APP_PATH" ]; then + echo "⚠️ APP_PATH is not defined, trying to find the app bundle again..." + # Try to find the app bundle in common locations + for search_dir in "$ARCHIVE_DIR" "$ARCHIVE_DIR/Mac" "Saved/StagedBuilds" "Saved/StagedBuilds/Mac" "Saved"; do + if [ -d "$search_dir" ]; then + APP_FOUND=$(find "$search_dir" -name "*.app" -type d | head -n 1) + if [ -n "$APP_FOUND" ]; then + APP_PATH="$APP_FOUND" + echo "✅ Found app bundle at: $APP_PATH" + break + fi + fi + done + + if [ -z "$APP_PATH" ]; then + echo "❌ ERROR: Could not find any app bundle. Skipping bundle ID fix." + # Don't exit, just skip this part + APP_PATH="" + fi +fi + +if [ -n "$APP_PATH" ] && [ -d "$APP_PATH" ]; then INFO_PLIST="$APP_PATH/Contents/Info.plist" if [ -f "$INFO_PLIST" ]; then - CURRENT_BUNDLE_ID=$(/usr/libexec/PlistBuddy -c "Print :CFBundleIdentifier" "$INFO_PLIST") + CURRENT_BUNDLE_ID=$(/usr/libexec/PlistBuddy -c "Print :CFBundleIdentifier" "$INFO_PLIST" 2>/dev/null) echo "Current bundle ID: $CURRENT_BUNDLE_ID" - if [ "$CURRENT_BUNDLE_ID" != "com.luckyrobots.luckyworld" ]; then - echo "Bundle ID mismatch - fixing it!" + if [ $? -ne 0 ] || [ "$CURRENT_BUNDLE_ID" != "com.luckyrobots.luckyworld" ]; then + echo "Bundle ID mismatch or not set - 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")" + UPDATED_ID=$(/usr/libexec/PlistBuddy -c "Print :CFBundleIdentifier" "$INFO_PLIST" 2>/dev/null) + if [ $? -eq 0 ]; then + echo "Updated bundle ID: $UPDATED_ID" + else + echo "⚠️ Failed to update bundle ID" + fi else echo "Bundle ID is already correct: com.luckyrobots.luckyworld" fi + # Set the application name to "LuckyWorld" instead of "LuckyWorld-Mac-Shipping" + echo "Setting application name to LuckyWorld..." + /usr/libexec/PlistBuddy -c "Set :CFBundleName LuckyWorld" "$INFO_PLIST" + UPDATED_NAME=$(/usr/libexec/PlistBuddy -c "Print :CFBundleName" "$INFO_PLIST" 2>/dev/null) + if [ $? -eq 0 ]; then + echo "Updated app name: $UPDATED_NAME" + else + echo "⚠️ Failed to update app name" + 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) + NESTED_APPS=$(find "$APP_PATH" -name "*.app" -type d 2>/dev/null) if [ -n "$NESTED_APPS" ]; then echo "Found nested app bundles, fixing their bundle IDs:" echo "$NESTED_APPS" | while read -r NESTED_APP; do @@ -141,8 +217,12 @@ if [ -n "$APP_PATH" ]; then /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" + UPDATED_ID=$(/usr/libexec/PlistBuddy -c "Print :CFBundleIdentifier" "$NESTED_APP/Contents/Info.plist" 2>/dev/null) + if [ $? -eq 0 ]; then + echo "Updated nested app bundle ID: $UPDATED_ID" + else + echo "⚠️ Failed to update nested app bundle ID for $NESTED_APP" + fi fi done else @@ -151,4 +231,6 @@ if [ -n "$APP_PATH" ]; then else echo "⚠️ Info.plist not found at $INFO_PLIST" fi +else + echo "⚠️ App bundle not found or APP_PATH is not valid. Skipping bundle ID fix." fi