From 2aae55cb5f5cb12fc9788de26a5d264288f39b93 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ce=CC=81dric=20Luthi?= Date: Fri, 4 Oct 2013 11:33:39 +0200 Subject: [PATCH] Add the `write-build-setting` action --- DevToolsCore/PBXTarget.h | 2 ++ README.md | 3 +++ Sources/Xcproj.m | 16 +++++++++++++++- 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/DevToolsCore/PBXTarget.h b/DevToolsCore/PBXTarget.h index 4fb447a..4026b48 100644 --- a/DevToolsCore/PBXTarget.h +++ b/DevToolsCore/PBXTarget.h @@ -9,6 +9,8 @@ - (NSString *) expandedValueForString:(NSString *)string forBuildParameters:(id)buildParameters; +- (void)setBuildSetting:(id)buildSetting forKeyPath:(NSString *)keyPath; + - (id) buildPhaseOfClass:(Class)buildPhaseClass; - (void) addBuildPhase:(id)buildPhase; - (id) defaultFrameworksBuildPhase; diff --git a/README.md b/README.md index fd58fc2..871b1e7 100644 --- a/README.md +++ b/README.md @@ -45,6 +45,9 @@ Actions: * read-build-setting Evaluate a build setting and print its value. If the build setting does not exist, nothing is printed + * write-build-setting + Assign a value to a build setting. If the build setting does not exist, it is added to the target + * add-xcconfig Add an xcconfig file to the project and base all configurations on it diff --git a/Sources/Xcproj.m b/Sources/Xcproj.m index 31a2de5..b934083 100644 --- a/Sources/Xcproj.m +++ b/Sources/Xcproj.m @@ -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 @@ -292,6 +292,8 @@ - (void) printUsage:(int)exitCode @" List headers from the `Copy Headers` build phase\n\n" @" * read-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 \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 \n" @" Add an xcconfig file to the project and base all configurations on it\n\n" @" * add-resources-bundle \n" @@ -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];