Feature Request: Xcode Needs a "Configure Phase" Scheme
Feature Request: Xcode Needs a "Configure Phase" Scheme
- Subject: Feature Request: Xcode Needs a "Configure Phase" Scheme
- From: Andreas Grosam <email@hidden>
- Date: Fri, 02 Dec 2011 12:09:10 +0100
If you have ever installed an open source package you already know the typical "configure & make & make install" procedure.
And this "configure" step makes sense, really.
In Xcode there is no such thing like a "configure" step. Rather than running a configure script, we just setup the build settings manually. Xcode's Build Configuration Files may help a bit. However IMHO, they are simply too restricted in order to be used in a more complex, more dynamic setup. For instance, in a configure file you can't modify Xcode's build setting variables - you are just allowed to "redefine" them. That is, for instance, accumulating preprocessor macros which are defined in several config files does not work. Furthermore, it's not possible to declare a simple conditional, not to mention to run scripts. To be honest, Xcode's "Build Configuration File" feature is too dump.
In order to search for a solution, I desperately tried whether it were possible to use a "Run Script" Build Phase to setup build settings. Unfortunately, this doesn't work well. This step happens to late and there might arise conflicts in the build settings displayed by Xcode's build settings panel and the one actually used. This is at least confusing. And Xcode's dependency evaluation may become confused, too. So, this is no solution.
To better illustrate the "configure issue", which should not be confused with setting up build settings in Xcode's build settings panel, here's an example:
Suppose I develop an open source framework "MyFramework" which shall be available for download from some of the source code hosting sites.
In order to build this framework I require another open source package, lets name it "ToolKit". This package is publicly available and can be conveniently obtained as well from one of the source code hosting sites. As the developer of the framework "MyFramework" I don't include the "ToolKit package" in the MyFramework sources, rather I tell the users (other developers) to download it themselves.
In order to build the MyFramework project I need to define a few build settings regarding the "ToolKit" package. In addition to the header and library search paths which I need to know, I also want to let the user to define individual macro definitions for ToolKit sources as part of the build process for the whole framework "MyFramework". These settings shall be individually set by the user of the MyFramework when it will be compiled.
Here, the problem is how do I setup the build settings for my project MyFramework? It requires the path to the public headers of ToolKit, the framework or library path and possibly some specific macro definitions in order to compile successfully. However, as the MyFramework developer I don't know this upfront since these settings depend on the individual environment of the user. And, in order to make the build process as convenient as possible, I don't want our framework users to have to change build settings in my project "MyFramework" before she can compile it at all. Also, suppose the Xcode project is available through a revision control system - how could this *shared* project include individual settings which indirectly change the build settings of my MyFramework project? Well, it can't.
A "Configure" Phase in Xcode's Schemes could solve this dilemma. The "Config Phase" would just appear above of the Build phase in Xcode's Scheme editor, just to indicate that it will be executed before the Build Phase.
This Configure process would read a specific input file which is individually set up by the user and then Xcode executes the "configure phase" which produces *build settings* which can be read in by Xcode. These evaluated build settings shall be immediately available - that is, when opening an Xcode project or when the config input file has been changed these settings need to be "compiled" on the fly by Xcode so that Xcode's Build Settings panel is always up to date.
I could imagine, the configure phase just runs a (user) script. Its output are just build settings. Xcode could evaluate this configure script whenever it is required. More technically, Xcode's build settings would depend on a configure phase and this in turn depends on a "config input file" which can be a script. So, before Xcode uses build settings, it checks the dependency and possibly evaluates the configure phase.
A configure script could virtually perform anything complex - for instance running the C compiler to check for certain features on the platform and then defining a corresponding build setting (aka environment variable) depending on the result. A more simple task would be to change/accumulate build settings (strings), like preprocessor macros, header search paths, etc., which effectively would be evaluated like this in a config script:
// File: boost.config.in
export HEADER_SEARCH_PATHS="${HEADER_SEARCH_PATHS} ${HOME}/Develop/boost_1_48_0"
export GCC_PREPROCESSOR_DEFINITIONS="${GCC_PREPROCESSOR_DEFINITIONS} BOOST_STRICT_CONFIG"
This above is a simple bash script. We were able to "source" (aka include) many of such self-contained config files, and still get the desired results. Note: modifying variables doesn't work with current Xcode config files!
If you don't like bash (me, too) you might use Ruby, or whatever script language you prefer. IMHO, this would be a great feature in Xcode simplifying the setup of more complex projects.
I appreciate your comments!
Regards
Andreas
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden