2025-03-27 16:47:31 -05:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
# Get the user's home directory
|
|
|
|
USER_HOME="$HOME"
|
|
|
|
|
|
|
|
# Set up Unreal Engine paths
|
|
|
|
UE_ROOT="/Users/Shared/Epic Games/UE_5.5"
|
|
|
|
UE_EDITOR="$UE_ROOT/Engine/Binaries/Mac/UnrealEditor.app/Contents/MacOS/UnrealEditor"
|
|
|
|
UE_UAT="$UE_ROOT/Engine/Build/BatchFiles/RunUAT.command"
|
|
|
|
|
|
|
|
# Set up project paths
|
|
|
|
PROJECT_ROOT="$(pwd)"
|
2025-04-10 07:17:18 -05:00
|
|
|
PROJECT_FILE="$PROJECT_ROOT/LuckyWorld.uproject"
|
2025-03-27 16:47:31 -05:00
|
|
|
ARCHIVE_DIR="$PROJECT_ROOT/Builds"
|
|
|
|
|
2025-04-13 20:54:08 +02:00
|
|
|
# Check for entitlements file
|
|
|
|
if [ -f "$PROJECT_ROOT/LuckyWorld.entitlements" ]; then
|
|
|
|
ENTITLEMENTS_FILE="$PROJECT_ROOT/LuckyWorld.entitlements"
|
|
|
|
else
|
|
|
|
echo "Warning: No entitlements file found. This might affect notarization."
|
|
|
|
ENTITLEMENTS_FILE=""
|
|
|
|
fi
|
|
|
|
|
|
|
|
# For debugging: print paths and config
|
|
|
|
echo "Project root: $PROJECT_ROOT"
|
|
|
|
echo "Project file: $PROJECT_FILE"
|
|
|
|
echo "Archive directory: $ARCHIVE_DIR"
|
|
|
|
echo "Entitlements file: $ENTITLEMENTS_FILE"
|
|
|
|
|
|
|
|
# Clean up previous build artifacts
|
2025-04-10 07:17:18 -05:00
|
|
|
rm -rf DerivedDataCache Intermediate Binaries Saved
|
|
|
|
|
2025-04-13 20:54:08 +02:00
|
|
|
# Generate project files
|
2025-04-10 07:17:18 -05:00
|
|
|
"$UE_ROOT/Engine/Build/BatchFiles/Mac/GenerateProjectFiles.sh" -project="$PROJECT_FILE" -game -engine
|
2025-04-13 20:54:08 +02:00
|
|
|
|
2025-03-27 16:47:31 -05:00
|
|
|
# Run the build command
|
|
|
|
"$UE_UAT" -ScriptsForProject="$PROJECT_FILE" Turnkey \
|
|
|
|
-command=VerifySdk \
|
|
|
|
-platform=Mac \
|
|
|
|
-UpdateIfNeeded \
|
|
|
|
-EditorIO \
|
|
|
|
-EditorIOPort=59484 \
|
|
|
|
-project="$PROJECT_FILE" \
|
|
|
|
BuildCookRun \
|
|
|
|
-nop4 \
|
|
|
|
-utf8output \
|
|
|
|
-cook \
|
|
|
|
-project="$PROJECT_FILE" \
|
2025-04-10 07:17:18 -05:00
|
|
|
-target=LuckyWorld \
|
2025-03-27 16:47:31 -05:00
|
|
|
-unrealexe="$UE_EDITOR" \
|
|
|
|
-platform=Mac \
|
|
|
|
-installed \
|
|
|
|
-stage \
|
|
|
|
-archive \
|
|
|
|
-package \
|
|
|
|
-build \
|
|
|
|
-iterativecooking \
|
|
|
|
-pak \
|
|
|
|
-iostore \
|
|
|
|
-compressed \
|
|
|
|
-prereqs \
|
|
|
|
-archivedirectory="$ARCHIVE_DIR" \
|
|
|
|
-CrashReporter \
|
|
|
|
-clientconfig=Shipping \
|
|
|
|
# -nocompile \
|
|
|
|
# -nocompileuat \
|
|
|
|
# -nocompileeditor \
|
|
|
|
# -skipbuildeditor \
|
|
|
|
|
2025-04-15 01:46:06 +02:00
|
|
|
BUILD_EXIT_CODE=$?
|
2025-04-13 20:54:08 +02:00
|
|
|
|
|
|
|
echo ""
|
2025-04-15 01:46:06 +02:00
|
|
|
echo "🦾 Build process completed with exit code: $BUILD_EXIT_CODE"
|
2025-04-13 20:54:08 +02:00
|
|
|
|
2025-04-15 01:46:06 +02:00
|
|
|
# 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"
|
|
|
|
|
2025-04-13 20:54:08 +02:00
|
|
|
echo ""
|
|
|
|
echo "🔍 Binary files that will need signing:"
|
|
|
|
DYLIB_COUNT=$(find "$APP_PATH" -name "*.dylib" | wc -l)
|
|
|
|
SO_COUNT=$(find "$APP_PATH" -name "*.so" | wc -l)
|
|
|
|
FRAMEWORKS=$(find "$APP_PATH" -path "*.framework/*" -type f -perm +111 | wc -l)
|
|
|
|
EXECUTABLES=$(find "$APP_PATH" -type f -perm +111 -not -path "*.framework/*" -not -name "*.dylib" -not -name "*.so" | wc -l)
|
|
|
|
|
|
|
|
echo "- $DYLIB_COUNT .dylib libraries"
|
|
|
|
echo "- $SO_COUNT .so libraries"
|
|
|
|
echo "- $FRAMEWORKS framework executables"
|
|
|
|
echo "- $EXECUTABLES other executables"
|
|
|
|
echo "Total binary files: $((DYLIB_COUNT + SO_COUNT + FRAMEWORKS + EXECUTABLES))"
|
|
|
|
|
|
|
|
echo ""
|
|
|
|
echo "🔍 Checking for PhysX and other special libraries (often need special handling):"
|
|
|
|
find "$APP_PATH" -name "*PhysX*" -o -name "*APEX*"
|
|
|
|
fi
|
2025-04-14 19:53:37 +02:00
|
|
|
|
2025-04-14 21:20:13 +02:00
|
|
|
# Update bundle ID in project settings
|
2025-04-14 19:53:37 +02:00
|
|
|
echo ""
|
2025-04-15 00:00:28 +02:00
|
|
|
echo "🔧 Checking for bundle ID in UE config..."
|
2025-04-14 19:53:37 +02:00
|
|
|
CONFIG_FILE="$PROJECT_ROOT/Config/DefaultGame.ini"
|
|
|
|
if [ -f "$CONFIG_FILE" ]; then
|
2025-04-15 00:00:28 +02:00
|
|
|
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 ✅"
|
2025-04-14 19:53:37 +02:00
|
|
|
else
|
2025-04-15 00:00:28 +02:00
|
|
|
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"
|
2025-04-14 19:53:37 +02:00
|
|
|
fi
|
2025-04-14 21:41:02 +02:00
|
|
|
else
|
|
|
|
echo "⚠️ Config file not found at $CONFIG_FILE"
|
2025-04-14 19:53:37 +02:00
|
|
|
fi
|
|
|
|
|
2025-04-14 21:20:13 +02:00
|
|
|
# Post-build process - set bundle ID
|
2025-04-14 19:53:37 +02:00
|
|
|
echo ""
|
|
|
|
echo "🔧 Performing post-build fix for bundle ID..."
|
2025-04-15 01:46:06 +02:00
|
|
|
|
|
|
|
# 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
|
2025-04-14 19:53:37 +02:00
|
|
|
INFO_PLIST="$APP_PATH/Contents/Info.plist"
|
|
|
|
if [ -f "$INFO_PLIST" ]; then
|
2025-04-15 01:46:06 +02:00
|
|
|
CURRENT_BUNDLE_ID=$(/usr/libexec/PlistBuddy -c "Print :CFBundleIdentifier" "$INFO_PLIST" 2>/dev/null)
|
2025-04-15 01:22:42 +02:00
|
|
|
echo "Current bundle ID: $CURRENT_BUNDLE_ID"
|
|
|
|
|
2025-04-15 01:46:06 +02:00
|
|
|
if [ $? -ne 0 ] || [ "$CURRENT_BUNDLE_ID" != "com.luckyrobots.luckyworld" ]; then
|
|
|
|
echo "Bundle ID mismatch or not set - fixing it!"
|
2025-04-15 01:22:42 +02:00
|
|
|
echo "Setting bundle identifier to com.luckyrobots.luckyworld"
|
|
|
|
/usr/libexec/PlistBuddy -c "Set :CFBundleIdentifier com.luckyrobots.luckyworld" "$INFO_PLIST"
|
2025-04-15 01:46:06 +02:00
|
|
|
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
|
2025-04-15 01:22:42 +02:00
|
|
|
else
|
|
|
|
echo "Bundle ID is already correct: com.luckyrobots.luckyworld"
|
|
|
|
fi
|
|
|
|
|
2025-04-15 01:46:06 +02:00
|
|
|
# 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
|
|
|
|
|
2025-04-15 01:22:42 +02:00
|
|
|
# Find and repair nested app bundles as well (like CrashReportClient.app)
|
|
|
|
echo "Checking for nested app bundles..."
|
2025-04-15 01:46:06 +02:00
|
|
|
NESTED_APPS=$(find "$APP_PATH" -name "*.app" -type d 2>/dev/null)
|
2025-04-15 01:22:42 +02:00
|
|
|
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
|
2025-04-15 01:46:06 +02:00
|
|
|
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
|
2025-04-15 01:22:42 +02:00
|
|
|
fi
|
|
|
|
done
|
|
|
|
else
|
|
|
|
echo "No nested app bundles found."
|
|
|
|
fi
|
2025-04-14 19:53:37 +02:00
|
|
|
else
|
|
|
|
echo "⚠️ Info.plist not found at $INFO_PLIST"
|
|
|
|
fi
|
2025-04-15 01:46:06 +02:00
|
|
|
else
|
|
|
|
echo "⚠️ App bundle not found or APP_PATH is not valid. Skipping bundle ID fix."
|
2025-04-14 19:53:37 +02:00
|
|
|
fi
|