xingyun/scripts/add-iap-to-xcode.sh

66 lines
1.7 KiB
Bash
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
cd "$(dirname "$0")/.."
APP_ROOT=$(pwd)
PROJECT_FILE="$APP_ROOT/ios/Xingyun.xcodeproj/project.pbxproj"
SWIFT_FILE="$APP_ROOT/ios/Xingyun/IAPBridge.swift"
OBJC_FILE="$APP_ROOT/ios/Xingyun/IAPBridge.m"
echo "=== iOS 内购模块文件添加工具 ==="
echo ""
# 检查文件是否存在
if [ ! -f "$PROJECT_FILE" ]; then
echo "❌ 错误: Xcode 项目文件不存在"
echo " 路径: $PROJECT_FILE"
exit 1
fi
if [ ! -f "$SWIFT_FILE" ]; then
echo "❌ 错误: Swift 文件不存在"
echo " 路径: $SWIFT_FILE"
exit 1
fi
if [ ! -f "$OBJC_FILE" ]; then
echo "❌ 错误: Objective-C 文件不存在"
echo " 路径: $OBJC_FILE"
exit 1
fi
echo "✅ 文件检查通过"
echo ""
# 检查是否已经添加
if grep -q "IAPBridge.swift" "$PROJECT_FILE" && grep -q "IAPBridge.m" "$PROJECT_FILE"; then
echo "✅ 文件已在 Xcode 项目中"
echo ""
echo "请执行以下步骤重新构建:"
echo "1. cd ios && rm -rf build Pods && pod install"
echo "2. cd .. && yarn run-ios"
exit 0
fi
echo "⚠️ 文件尚未添加到 Xcode 项目"
echo ""
echo "请按以下步骤手动添加:"
echo ""
echo "1. 打开 Xcode"
echo " open $APP_ROOT/ios/Xingyun.xcworkspace"
echo ""
echo "2. 在 Xcode 中添加文件:"
echo " - 右键点击 'Xingyun' 文件夹(黄色图标)"
echo " - 选择 'Add Files to Xingyun...'"
echo " - 依次选择以下文件:"
echo "$SWIFT_FILE"
echo "$OBJC_FILE"
echo " - 确保勾选 'Copy items if needed' 和 'Xingyun' target"
echo " - 点击 'Add'"
echo ""
echo "3. 清理并重新构建:"
echo " cd $APP_ROOT/ios"
echo " rm -rf build Pods"
echo " pod install"
echo " cd .."
echo " yarn run-ios"