Files
PowerBar/archive_export.sh

49 lines
1.2 KiB
Bash
Executable File
Raw Permalink Blame History

This file contains ambiguous Unicode characters
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
# PowerBar 构建脚本
# 使用 archive + export 方式构建应用
set -e
echo "=== PowerBar 构建脚本 ==="
echo "1. 清理之前的构建产物..."
# 清理之前的构建产物
rm -rf build
rm -rf archive
rm -rf PowerBar.app
rm -rf PowerBar-*.dmg
echo "2. 创建构建目录..."
mkdir -p build
mkdir -p archive
echo "3. 归档项目..."
xcodebuild archive \
-project PowerBar.xcodeproj \
-scheme PowerBar \
-archivePath archive/PowerBar.xcarchive \
-destination 'generic/platform=macOS' \
-configuration Release
echo "4. 导出归档..."
xcodebuild -exportArchive -archivePath archive/PowerBar.xcarchive -exportPath build -exportOptionsPlist ExportOptions.plist
echo "5. 复制应用到当前目录..."
cp -R build/PowerBar.app .
echo "6. 创建DMG安装包..."
# 获取当前版本号
VERSION=$(xcodebuild -project PowerBar.xcodeproj -showBuildSettings | grep MARKETING_VERSION | head -1 | awk -F'=' '{print $2}' | xargs)
# 创建DMG
hdiutil create -volname "PowerBar" \
-srcfolder PowerBar.app \
-ov \
-format UDZO \
PowerBar-$VERSION.dmg
echo "7. 构建完成!"
echo "应用:$(pwd)/PowerBar.app"
echo "DMG$(pwd)/PowerBar-$VERSION.dmg"
echo "=== 构建脚本执行结束 ==="