Skip to content

Commit

Permalink
Add the write-build-setting action
Browse files Browse the repository at this point in the history
  • Loading branch information
0xced committed Oct 4, 2013
1 parent ebec5f4 commit 2aae55c
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
2 changes: 2 additions & 0 deletions DevToolsCore/PBXTarget.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@

- (NSString *) expandedValueForString:(NSString *)string forBuildParameters:(id)buildParameters;

- (void)setBuildSetting:(id)buildSetting forKeyPath:(NSString *)keyPath;

- (id<PBXBuildPhase>) buildPhaseOfClass:(Class)buildPhaseClass;
- (void) addBuildPhase:(id<PBXBuildPhase>)buildPhase;
- (id<PBXBuildPhase>) defaultFrameworksBuildPhase;
Expand Down
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ Actions:
* read-build-setting <build_setting>
Evaluate a build setting and print its value. If the build setting does not exist, nothing is printed
* write-build-setting <build_setting> <value>
Assign a value to a build setting. If the build setting does not exist, it is added to the target
* add-xcconfig <xcconfig_path>
Add an xcconfig file to the project and base all configurations on it
Expand Down
16 changes: 15 additions & 1 deletion Sources/Xcproj.m
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ - (int) application:(DDCliApplication *)app runWithArguments:(NSArray *)argument

- (NSArray *) allowedActions
{
return [NSArray arrayWithObjects:@"list-targets", @"list-headers", @"read-build-setting", @"add-xcconfig", @"add-resources-bundle", @"touch", nil];
return [NSArray arrayWithObjects:@"list-targets", @"list-headers", @"read-build-setting", @"write-build-setting", @"add-xcconfig", @"add-resources-bundle", @"touch", nil];
}

- (void) printUsage:(int)exitCode
Expand All @@ -292,6 +292,8 @@ - (void) printUsage:(int)exitCode
@" List headers from the `Copy Headers` build phase\n\n"
@" * read-build-setting <build_setting>\n"
@" Evaluate a build setting and print its value. If the build setting does not exist, nothing is printed\n\n"
@" * write-build-setting <build_setting> <value>\n"
@" Assign a value to a build setting. If the build setting does not exist, it is added to the target\n\n"
@" * add-xcconfig <xcconfig_path>\n"
@" Add an xcconfig file to the project and base all configurations on it\n\n"
@" * add-resources-bundle <bundle_path>\n"
Expand Down Expand Up @@ -350,6 +352,18 @@ - (int) readBuildSetting:(NSArray *)arguments
return EX_OK;
}

- (int) writeBuildSetting:(NSArray *)arguments
{
if ([arguments count] != 2)
[self printUsage:EX_USAGE];

NSString *buildSetting = arguments[0];
NSString *value = arguments[1];
[_target setBuildSetting:value forKeyPath:buildSetting];

return [self writeProject];
}

- (int) writeProject
{
BOOL written = [_project writeToFileSystemProjectFile:YES userFile:NO checkNeedsRevert:NO];
Expand Down

0 comments on commit 2aae55c

Please sign in to comment.