1

I have a need for two pieces of functionality that I have not been able to find support for. The first is to alter the name of a Xcode configuration via a bash script. For this I have tried:

xcodebuild -target "target name" -configuration existingConfig CONFIGURATION=newConfigName

The command above executes successfully but does not change the configuration name. It simply compiles the source. This is probably to be expected though as I am using xcodebuild.

For altering the configuration name I have also looked into xcconfig files. For example, I would create one in Xcode with the name projectname-existingConfigName.xcconfig and I would add a new configuration name to it like so:

CONFIGURATION = NewConfigName

However, in the instance above I fear that I am not using xcconfig files correctly. Is there a good reference on this somewhere?

The second piece of functionality that I have not been able to find support for is adding a new configuration on the fly via bash or via xcconfig.

Ultimately, I would like to perform this using bash, but am open to other opinions too that do not include opening Xcode to do so. I am using git sub modules here and pulling them in and adding dynamic configurations during CI build time is where this problem stems from.

There may be an easier way to do this but I thought I would pose my question here first to see if I am on the right track.

AgnosticDev
  • 1,843
  • 2
  • 20
  • 36

1 Answers1

0

There is a ruby gem called Xcodeproj which is also used by CocoaPods. It basically allows you to see the project file as an object, to change and finally save it. The following code should answer the first part of your question about renaming:

#!/usr/bin/ruby
require 'xcodeproj'

project_path = '../folder/yourproject.xcodeproj'
project = Xcodeproj::Project.open(project_path)

project.build_configurations.each do |configuration|
    if configuration.name == "existingConfig"
        configuration.name = "NewConfigName"
    end
end

project.save()

Adding a new configuration should also be possible with Xcodeproj, but that is something I haven't done yet. Documentation is found here:

https://github.com/CocoaPods/Xcodeproj http://www.rubydoc.info/gems/xcodeproj/Xcodeproj/Project

Carsten
  • 137
  • 1
  • 6