Requirements
As far as I understand your requirements are:
- Download xcconfig files, e.g., Cocoapods, GitHub
- Set xcconfig files on the Xcodeproj for each configuration on project and target level
Potential solution
As far as I know it is impossible to run a script from a Cocoapod to manipulate the including Xcode project. Fortunately, the guys from Cocoapods provide a Ruby gem called xcodeproj to manipulate Xcode projects and workspaces including build settings.
I have been using this gem to develop a tool (phoenx) to automate the generation of Xcode projects and workspaces based on metadata files (much like Podfiles). I have extracted the relevant code parts into a new ruby gem called xcconfig.
Xcconfig
Xcconfig can download and configure the xcconfig files on any Xcode project file. A Configfile
specifies the source of the configuration files (optional) and how to apply those xcconfig files to your project. If the files are not part of the project it will add them (together with groups for the subfolders) and configure the project accordingly. If you change the xcconfig files in your global repository you just need to run xcconfig
again to sync your repositories.
The Configfile
should reside in the same folder as you xcodeproj
file (just like the Podfile).
# Specify where to download the config files (optional)
source "git@github.com:xyz/Configuration"
# Specify the name of the project, e.g., MyProject if your project file is MyProject.xcodeproj
Project.new "MyProject" do |project|
# Specify xcconfig files for each configuration on project level (paths are relative t
project.config_files["Release"] = "Configuration/project_release.xcconfig"
project.config_files["Debug"] = "Configuration/project_debug.xcconfig"
# Specify target and xcconfig files for each configuration
project.target "test" do |target|
target.config_files["Debug"] = "Configuration/debug.xcconfig"
end
end
You can integrate this gem with cocoapods or use it standalone. If you want to give it a try you can install it with sudo gem install xcconfig
and then run xcconfig
in your project directory with the Configfile
. The sources are available on my GitHub account.
Hope that helps.