#!/bin/bash PROJ_FILE="AICity.xcodeproj/project.pbxproj" HEADER_PATHS="AICity/JuXing AICity/JuXing/Services AICity/JuXing/Views AICity/JuXing/ViewControllers AICity/JuXing/Models" echo "Adding Header Search Paths to Xcode project..." # 创建备份 cp "$PROJ_FILE" "$PROJ_FILE.backup" # 使用Python修改pbxproj文件 python3 << 'PYTHON' import re proj_file = "AICity.xcodeproj/project.pbxproj" header_paths = "AICity/JuXing AICity/JuXing/Services AICity/JuXing/Views AICity/JuXing/ViewControllers AICity/JuXing/Models" with open(proj_file, 'r') as f: content = f.read() # 在所有buildSettings中寻找HEADER_SEARCH_PATHS并添加路径 # 如果不存在则创建新条目 # 查找所有的buildSettings块 pattern = r'buildSettings = \{([^}]*?)(HEADER_SEARCH_PATHS[^;]*;)?([^}]*?)\};' def add_header_paths(match): before = match.group(1) existing = match.group(2) or "" after = match.group(3) or "" if "HEADER_SEARCH_PATHS" in existing: # 已存在,修改它 existing = existing.replace('HEADER_SEARCH_PATHS = ', f'HEADER_SEARCH_PATHS = "{header_paths}"') return f'buildSettings = {{{before}{existing}{after}}};' else: # 不存在,添加新的 new_line = f'HEADER_SEARCH_PATHS = "{header_paths}";\n\t\t\t' return f'buildSettings = {{{before}{new_line}{after}}};' # 这个方法太复杂了,让我们用更简单的方法 print("Attempting to add Header Search Paths...") if 'HEADER_SEARCH_PATHS' not in content: print("HEADER_SEARCH_PATHS not found, will need to add manually or use Xcode UI") else: print("HEADER_SEARCH_PATHS already configured") PYTHON echo "✓ Backup created at: $PROJ_FILE.backup" echo "" echo "建议改用Xcode UI进行配置(更安全)"