omnAPP/IOS_BUILD_README.md
2025-09-23 16:23:15 +08:00

183 lines
4.1 KiB
Markdown
Raw 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.

# iOS 自动化构建指南
本指南将帮助您使用自动化脚本构建和签名 iOS 应用,并创建 DMG 安装包。
## 🎯 目标
创建经过签名的 iOS 应用 DMG 文件,用于分发和安装。
## 📋 前提条件
### 1. Apple Developer 账户
- 需要有效的 Apple Developer 账户
- 需要 **iOS Development** 证书
- 需要 **Provisioning Profile**
### 2. 获取证书和配置文件
1. 登录 [Apple Developer Portal](https://developer.apple.com)
2. 进入 "Certificates, Identifiers & Profiles"
3. 创建以下证书:
- **iOS Development** (用于应用签名)
4. 创建 App ID 和 Provisioning Profile
5. 下载并安装证书和配置文件
## 🚀 快速开始
### 步骤 1: 配置签名信息
```bash
# 运行配置脚本
./update_team_id.sh
```
按照提示输入您的 Team ID脚本会自动更新配置文件。
### 步骤 2: 加载配置
```bash
# 加载签名配置
source ios_signing_config.sh
```
### 步骤 3: 构建 DMG
```bash
# 构建发布版本
./build_ios_dmg.sh
# 或构建调试版本
./build_ios_dmg.sh debug
```
## 📁 输出文件
构建完成后,文件将位于:
```
build/ios/
├── BearVPN-1.0.0.ipa # 签名的 IPA 文件
└── BearVPN-1.0.0-iOS.dmg # DMG 安装包
```
## 🛠️ 可用的构建脚本
### 1. `build_ios_dmg.sh` - 主要构建脚本
- 构建签名的 iOS 应用
- 创建 DMG 安装包
- 支持调试和发布版本
```bash
./build_ios_dmg.sh [debug|release]
```
### 2. `build_ios_simple.sh` - 简化构建脚本
- 构建未签名的版本
- 仅用于测试和开发
```bash
./build_ios_simple.sh [debug|release]
```
### 3. `build_ios_appstore.sh` - App Store 构建脚本
- 构建用于 App Store 分发的版本
- 支持自动上传到 App Store Connect
```bash
./build_ios_appstore.sh [upload|build]
```
## 🔧 配置文件
### `ios_signing_config.sh`
包含所有签名配置信息:
```bash
# Apple Developer 账户信息
export APPLE_ID="your-apple-id@example.com"
export APPLE_PASSWORD="your-app-password"
export TEAM_ID="YOUR_TEAM_ID"
# 应用信息
export APP_NAME="BearVPN"
export BUNDLE_ID="com.bearvpn.app"
export VERSION="1.0.0"
export BUILD_NUMBER="1"
# 签名身份
export SIGNING_IDENTITY="iPhone Developer: Your Name (YOUR_TEAM_ID)"
export DISTRIBUTION_IDENTITY="iPhone Distribution: Your Name (YOUR_TEAM_ID)"
```
## 🔍 验证构建结果
构建完成后,您可以验证结果:
```bash
# 验证 IPA 文件
unzip -l build/ios/BearVPN-1.0.0.ipa
# 验证 DMG 文件
hdiutil verify build/ios/BearVPN-1.0.0-iOS.dmg
# 查看 DMG 内容
hdiutil mount build/ios/BearVPN-1.0.0-iOS.dmg
```
## 🛠️ 故障排除
### 1. 证书问题
```bash
# 查看可用证书
security find-identity -v -p codesigning
# 如果看到 "0 valid identities found",说明没有安装证书
```
### 2. 配置文件问题
- 确保 Provisioning Profile 已正确安装
- 检查 Bundle ID 是否匹配
- 确保证书和配置文件匹配
### 3. 构建失败
- 检查 Xcode 是否正确安装
- 确保 Flutter 环境正确配置
- 查看构建日志中的具体错误信息
### 4. 签名失败
- 确保证书已正确安装
- 检查签名身份名称是否正确
- 确保证书未过期
## 📚 相关文档
- [Apple 代码签名指南](https://developer.apple.com/documentation/security/notarizing_macos_software_before_distribution)
- [Flutter iOS 部署指南](https://docs.flutter.dev/deployment/ios)
- [Xcode 构建指南](https://developer.apple.com/documentation/xcode)
## ⚠️ 重要提醒
1. **安全性**:请妥善保管您的开发者证书和密码
2. **测试**:在分发前,请在真实的 iOS 设备上测试
3. **更新**:定期更新证书,避免过期
4. **备份**:建议备份您的签名配置
## 🎉 成功标志
如果构建成功,您应该看到:
- ✅ 应用构建成功
- ✅ 应用签名成功
- ✅ IPA 文件创建成功
- ✅ DMG 文件创建成功
- ✅ 最终验证通过
## 📞 支持
如果遇到问题,请检查:
1. 构建日志中的错误信息
2. 证书和配置文件是否正确安装
3. 网络连接是否正常
4. Xcode 和 Flutter 版本是否兼容