哪些工具支持编辑project.pbxproj文件? [英] What tools support editing project.pbxproj files?
问题描述
我想使用命令行直接编辑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屋!