随笔 - 91,  文章 - 0,  评论 - 4,  阅读 - 13万
这里只记录修改文件名称,不是修改项目名称
 
  1. 修改xcodeproj

  1. 选择旧name.xcodeproj

  1. 右键显示包内容

  1. 双击打开project.pbxproj

  1. command+F全局搜索旧name进行替换。

 
  1. 批量更改前缀

  1. 下载python3

  • 下载地址:https://www.python.org/downloads/macos/
  • 安装
  • 检测是否安装成功
$ python3 -V
Python 3.10.6
  1. 编写脚本

#!/usr/bin/env python
import os
for dirpath, _, filenames in os.walk('.'):
    for filename in filenames:
        if filename.startswith('oldName'):
            oldFile = os.path.join(dirpath, filename)
            newFile = os.path.join(dirpath, filename.replace('oldName', 'newName', 2))
            print(newFile)
            inFile = open(oldFile)
            outFile = open(newFile, 'w')
            replacements = {'oldName':'newName'}
            for line in inFile:
                for src, target in replacements.items():
                    line = line.replace(src, target)
                outFile.write(line)
            inFile.close()
            outFile.close()
            os.remove(oldFile)
  • oldName为替换前的前缀如TZ1
  • newName为替换后的前缀AAA
  • 保存文件名字为:app.py
  • 将文件放到xxx.xcodeproj 同级目录下
 
  1. 运行脚本

  • 执行命令
python3 app.py
  • 打印如下,即为成功
 
  1. 项目中替换

  1. 全局搜索替换

  1. 编译,如果有报错,再根据警告替换

 
posted on   xiao孛  阅读(16)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· CSnakes vs Python.NET:高效嵌入与灵活互通的跨语言方案对比
· DeepSeek “源神”启动!「GitHub 热点速览」
· 我与微信审核的“相爱相杀”看个人小程序副业
· Plotly.NET 一个为 .NET 打造的强大开源交互式图表库
· 上周热点回顾(2.17-2.23)

< 2025年2月 >
26 27 28 29 30 31 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 1
2 3 4 5 6 7 8
点击右上角即可分享
微信分享提示