简体   繁体   English

如何从.h和.m文件中获取所有打开的字符串Xcode

[英]How to get all open strings from .h and .m files Xcode

I want to create excel of all open strings @"..." in .h and .m files throughout my project. 我希望在整个项目中在.h和.m文件中创建所有打开的字符串@“...”的excel。 To standardise strings across platform. 跨平台标准化字符串。 Is there any tool to get strings ? 有没有工具来获取字符串? I used genstrings but it only finds localized strings. 我使用genstrings但它只找到本地化的字符串。

One option can be using 'grep' command recursively on all files in ur project folder ending with .h and .m 一个选项可以递归地使用'grep'命令对ur项目文件夹中以.h和.m结尾的所有文件

Something like: 就像是:

grep -Po '@" \\K.*(?= ")' inputfilename.h > outfile.txt grep -Po'@“\\ K。*(?=”)'inputfilename.h> outfile.txt

The result will be saved in the file outfile.txt. 结果将保存在文件outfile.txt中。 I have not tested it personally but you can give it a try... 我没有亲自测试过,但你可以尝试一下......

You need to install BREW first and then GNU grep. 您需要先安装BREW然后再安装GNU grep。 -p no longer works with current grep in osx. -p不再适用于osx中的当前grep。 http://www.heystephenwood.com/2013/09/install-gnu-grep-on-mac-osx.html http://www.heystephenwood.com/2013/09/install-gnu-grep-on-mac-osx.html

I used following command after installing GNU grep 我在安装GNU grep后使用了以下命令

 grep -rPo --no-filename --include='*.m' '(?<=@")(.*)(?=")'  *  >> outfile.txt

regex is not proper but still manageable. 正则表达式不合适但仍然易于管理。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM