批量修改pbxproj文件中的UDID

直接在终端运行,批量修改pbxproj文件中类的UDID。

python3 - <<'PYCODE'
import os, re, secrets, shutil

root = "/Users/henry/Desktop/xxx-mobile-ios"
pattern = re.compile(r'\b[A-F0-9]{24}\b')
count_total = 0

for dirpath, dirnames, filenames in os.walk(root):
    if any(x in dirpath for x in ["Pods", "Vendor", "third_party"]):
        continue
    for name in filenames:
        if not name.endswith(".pbxproj"):
            continue
        path = os.path.join(dirpath, name)
        with open(path, "r", encoding="utf-8", errors="ignore") as f:
            content = f.read()
        matches = set(pattern.findall(content))
        if not matches:
            continue
        new_content = content
        for old in matches:
            new = secrets.token_hex(12).upper()  # 24位HEX
            new_content = new_content.replace(old, new)
            count_total += 1
        shutil.copy2(path, path + ".bak")
        with open(path, "w", encoding="utf-8") as f:
            f.write(new_content)
        print(f"✅ 已修改 {path} (共 {len(matches)} 个UUID)")

print(f"\n🎯 总计替换 {count_total} 处 UUID(Pods 等目录已跳过)")
PYCODE
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

友情链接更多精彩内容