#!/bin/bash VERSION="1.0.0" APP_NAME="Nex" BUNDLE_ID="io.nex.gateway" SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)" PROJECT_ROOT="$(cd "${SCRIPT_DIR}/../.." && pwd)" BUILD_DIR="${PROJECT_ROOT}/build" ASSETS_DIR="${PROJECT_ROOT}/assets" echo "打包 macOS .app..." mkdir -p "${BUILD_DIR}/${APP_NAME}.app/Contents/MacOS" mkdir -p "${BUILD_DIR}/${APP_NAME}.app/Contents/Resources" if [ -f "${BUILD_DIR}/nex-darwin-arm64" ]; then cp "${BUILD_DIR}/nex-darwin-arm64" "${BUILD_DIR}/${APP_NAME}.app/Contents/MacOS/nex" elif [ -f "${BUILD_DIR}/nex-darwin-amd64" ]; then cp "${BUILD_DIR}/nex-darwin-amd64" "${BUILD_DIR}/${APP_NAME}.app/Contents/MacOS/nex" else echo "错误: 未找到 macOS 二进制文件,请先运行 make desktop-darwin" exit 1 fi if [ -f "${ASSETS_DIR}/AppIcon.icns" ]; then cp "${ASSETS_DIR}/AppIcon.icns" "${BUILD_DIR}/${APP_NAME}.app/Contents/Resources/" else echo "警告: 未找到 AppIcon.icns" fi cat > "${BUILD_DIR}/${APP_NAME}.app/Contents/Info.plist" << EOF CFBundleDevelopmentRegion zh_CN CFBundleExecutable nex CFBundleIconFile AppIcon CFBundleIdentifier ${BUNDLE_ID} CFBundleInfoDictionaryVersion 6.0 CFBundleName ${APP_NAME} Gateway CFBundleDisplayName ${APP_NAME} Gateway CFBundlePackageType APPL CFBundleShortVersionString ${VERSION} CFBundleVersion ${VERSION} LSMinimumSystemVersion 10.13 LSUIElement NSHighResolutionCapable EOF chmod +x "${BUILD_DIR}/${APP_NAME}.app/Contents/MacOS/nex" echo "打包完成: ${BUILD_DIR}/${APP_NAME}.app"