tethering-hider/build_dmg.sh

82 lines
2.6 KiB
Shell
Executable file
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/bin/bash
set -e
APP_NAME="TetheringHider"
BUILD_DIR="build"
echo "🔍 Obteniendo automáticamente la versión del proyecto desde Xcode..."
VERSION=$(xcodebuild -project "${APP_NAME}.xcodeproj" -scheme "${APP_NAME}" -configuration Release -showBuildSettings 2>/dev/null | grep -m1 "MARKETING_VERSION" | awk -F '=' '{print $2}' | xargs)
if [ -z "${VERSION}" ]; then
echo "⚠️ No se pudo obtener MARKETING_VERSION automáticamente de Xcode."
exit 1
fi
ARCHIVE_PATH="${BUILD_DIR}/${APP_NAME}.xcarchive"
EXPORT_PATH="${BUILD_DIR}/Exported"
EXPORT_OPTIONS_PLIST="ExportOptions.plist"
DMG_DIR="${BUILD_DIR}/dmg"
DMG_NAME="${APP_NAME}-${VERSION}.dmg"
echo "📌 Versión de la app detectada: ${VERSION}"
echo "📦 1. Creando ExportOptions.plist para exportación de macOS..."
cat << 'EOF' > "${EXPORT_OPTIONS_PLIST}"
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>method</key>
<string>mac-application</string>
<key>destination</key>
<string>export</string>
</dict>
</plist>
EOF
echo "📦 2. Ejecutando Product > Archive (${APP_NAME}.xcarchive)..."
rm -rf "${BUILD_DIR}"
xcodebuild -project "${APP_NAME}.xcodeproj" \
-scheme "${APP_NAME}" \
-configuration Release \
-archivePath "${ARCHIVE_PATH}" \
archive
echo "📦 3. Exportando aplicación distribuible..."
if ! xcodebuild -exportArchive \
-archivePath "${ARCHIVE_PATH}" \
-exportOptionsPlist "${EXPORT_OPTIONS_PLIST}" \
-exportPath "${EXPORT_PATH}" 2>/dev/null; then
echo " Copiando binario distribuible directamente desde el paquete .xcarchive..."
mkdir -p "${EXPORT_PATH}"
cp -R "${ARCHIVE_PATH}/Products/Applications/${APP_NAME}.app" "${EXPORT_PATH}/"
fi
APP_PATH="${EXPORT_PATH}/${APP_NAME}.app"
if [ ! -d "${APP_PATH}" ]; then
echo "❌ Error: No se encontró la aplicación exportada en ${APP_PATH}"
exit 1
fi
echo "📦 4. Preparando estructura para el archivo DMG..."
rm -rf "${DMG_DIR}" "${DMG_NAME}"
mkdir -p "${DMG_DIR}"
# Copiar la app exportada a la carpeta del DMG
cp -R "${APP_PATH}" "${DMG_DIR}/"
# Crear enlace simbólico a /Applications
ln -s /Applications "${DMG_DIR}/Applications"
echo "💿 5. Creando imagen de disco DMG: ${DMG_NAME}..."
hdiutil create -volname "${APP_NAME} ${VERSION}" \
-srcfolder "${DMG_DIR}" \
-ov \
-format UDZO \
"${DMG_NAME}"
# Limpieza de temporales
rm -rf "${DMG_DIR}" "${EXPORT_OPTIONS_PLIST}"
echo "✅ ¡DMG distribuible v${VERSION} creado exitosamente en: ${DMG_NAME}!"