开发者

Post script target build phase in Xcode how to embed a build version?

开发者 https://www.devze.com 2022-12-21 04:20 出处:网络
In Xcode, I\'ve added a script target build phase so I can run an arbitrary script upon a successful build of my project. Where I\'m stuck is, I\'m trying to get the version of our build passed into t

In Xcode, I've added a script target build phase so I can run an arbitrary script upon a successful build of my project. Where I'm stuck is, I'm trying to get the version of our build passed into the script by any means.. it looks like the only way is to parse Settings.app/Root.plist and retrieve a hard coded build version that I have embedded in there. Is there any other way to go about this in a way that makes sense? I'm open for using any scripting environment, particularly Python since if I have to end up doing XML parsing, it's straight forward d开发者_运维问答oing it there.


If you're looking to include a Subversion build number into your project, something like my answer to this question might do the trick.


I have solved it by moving the build action to first in the series of actions. Feel free to read about it here.

I just added the time for the "extra" number added to "1.0". Think you should easily be able to insert your svn command.

The plist must also be converted binary back and forth.

Then you should be able to get this version string from the app itself when running with this

    NSBundle *bundle = [NSBundle mainBundle];
    NSDictionary *info = [bundle infoDictionary];
    NSString *prodName = [info objectForKey:@"CFBundleVersion"];
0

精彩评论

暂无评论...
验证码 换一张
取 消