哪些工具支持编辑project.pbxproj文件? [英] What tools support editing project.pbxproj files?

查看:194
本文介绍了哪些工具支持编辑project.pbxproj文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用命令行直接编辑project.pbxproj(用于CI服务器脚本)

I want to edit project.pbxproj straight up using command line (for CI server script)

什么工具可以让我做到这一点?

what tools can allow me to do this?

我以前使用PlistBuddy编辑输出Info.plist;但是,我真正想做的是编辑此用户定义的字段,该字段已在多个地方使用,而且我真的不想在每个plist位置都查找该字段

I used to use PlistBuddy to edit the output Info.plist; however, what i really want to do is to edit this user defined field, which is used in multiple places, and i really don't want to have to hunt that down in every plist location

推荐答案

也许您走错了路.如果您有一个经常更改的参数,则可以更容易地在* .plist中将其作为设置来执行.与编辑项目文件或传递用户定义的字段相比,替换* .plist中的值要容易得多.在我的项目中,将server_address设置为放置在configuration.plist中.

Maybe you went the wrong way. If you have a frequently changing parameter, it is easier to carry out it in * .plist as a setting. Replacement a value in the * .plist much easier than editing the project file or pass the user defined field. In my project I have the setting server_address which placed in the configuration.plist.

1)应用启动后,只需加载一次配置并分发设置:

1) When the app starts, just load the configuration once and distribute a settings:

- (NSDictionary *)loadConfigFromPlist:(NSString *)plistName {
    NSURL *plistUrl = [[NSBundle bundleForClass:[self class]] URLForResource:plistName withExtension:@"plist"];

    if (!plistUrl) {
        @throw [NSException exceptionWithName:@"InaccessibleFileException"
                                       reason:[NSString stringWithFormat:@"Unable to read config from '%@'", plistName]
                                     userInfo:nil];
    }

    NSDictionary *config = [NSDictionary dictionaryWithContentsOfURL:plistUrl];
    return config;
}

2)在配置CI时,需要添加自定义脚本的构建步骤(从git/svn更新源代码之后),例如对于teamcity CI:

2) When configuring the CI need to add a build step for custom script (after updating sources from the git/svn), e.g. for teamcity CI:

echo "Check a condition - change server address"

if [ "true" = "%env.is_change_serveraddress%" ]; then
  echo "env.is_change_serveraddress = %env.is_change_serveraddress%"
  echo "Setup a custom server address: %env.server_address%"
  /usr/libexec/plistbuddy -c "Set :WebClient:Constants:WebServerAddress %env.server_address%" "configuration.plist"
else
  echo "env.is_change_serveraddress = %env.is_change_serveraddress%"
fi

这篇关于哪些工具支持编辑project.pbxproj文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆