• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Access Build Settings in a User Script?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Access Build Settings in a User Script?


  • Subject: Re: Access Build Settings in a User Script?
  • From: Jerry Krinock <email@hidden>
  • Date: Thu, 20 Nov 2008 09:26:27 -0800

My conclusion to this thread is: The AppleScript kludge is the only way to access Build Settings in a User Script.

Maybe I can fire up some interest in User Scripts by posting my User Script for updating a project's Doxygen documentation on the fly (without having to Build). See below.

Jerry

#!/bin/sh

### This script builds doxygen documentation for the active project and loads this docset into Xcode. It is an adaptation of the script found at http://developer.apple.com/tools/creatingdocsetswithdoxygen.html , except that it works in User Scripts instead of in a Run Shell Script Build Phase. The idea is that you can update your documentation at any time. This is geared toward people who appreciate the increased quality they get by writing documentation, primarily for themselves, before writing implementation code. Xcode 3.1's documentation browser seems to load documentation revisions produced by this script immediately, although it will not refresh a page currently being viewed until you click to another page or two and then click back.

# Besides being installed in your ~/Library/Developer/Shared/ Documentation/DocSets for Xcode, a copy of the completed docset package will also be placed in your project folder -- that is, Build Setting SRCROOT.

# Limitations: Unfortunately, producing documentation can take several tens of seconds, and no progress is shown during the process. Therefore, I recommend installing this script with Output: Open in New Document and Errors: Merge with Script Output so that at least you'll be able to see when it is done.

### Customize variables. Since these are user-level settings, it does not make sense to read them out of either Target Settings or even Project Settings. So I just hard-code them here:

# All of the documentation you produce for any project will appear bundled under your COMPANY_NAME in Xcode's documentation browser:
COMPANY_NAME="My Company"
COMPANY_IDENTIFIER="com.company"
# Script needs to know where to find your doxygen tool:
DOXYGEN_PATH="/Applications/Doxygen.app/Contents/Resources/doxygen"


###  End of customized variables

# We'll need a couple of build settings. Unfortunately these are not available in the User Scripts environment, so we kludge it: Call out to AppleScript and then call back into Xcode.
SOURCE_ROOT=`osascript -e "tell application \"Xcode\" to return value of flattened build setting \"SRCROOT\" of build configuration \"Release \" of active target of item 1 of projects"`


# Note that "OBJROOT" is the symbolic name for Build Locations > Intermediate Build Files Path. In other words, I'm putting my Doxygen junk in the same place where Xcode puts its junk.
TEMP_DIR=`osascript -e "tell application \"Xcode\" to return value of flattened build setting \"OBJROOT\" of build configuration \"Release\" of active target of item 1 of projects"`


PROJECT_NAME=`osascript -e "tell application \"Xcode\" to return name of item 1 of projects"`

# We're going to create a temporary configuration file for Doxygen to use. We'll need a path.
CONFIG_PATH="$TEMP_DIR/doxygen.config"


#  Remove old configuration file, in case there already is one.
rm -f "$CONFIG_PATH"

#  Run Doxygen to create the default configuration file.
"$DOXYGEN_PATH" -g "$CONFIG_PATH"

# Append our settings to the default configuration file which is now at $CONFIG_PATH. Note that in the case of GENERATE_DOCSET, DOCSET_FEEDNAME and DOCSET_BUNDLE_ID, the default configuration file set has already set non-empty values for these (which are not the values we want) earlier in the file. Apparently, because this works, when Doxygen reads these later settings, it overwrites the incorrect default values with our values:
echo "#---------------------------------------------------------------------------" > > "$CONFIG_PATH"
echo "# Configuration additions by the Xcode User Script" >> "$CONFIG_PATH"
echo "#---------------------------------------------------------------------------" > > "$CONFIG_PATH"
echo "INPUT = $SOURCE_ROOT" >> "$CONFIG_PATH"
echo "OUTPUT_DIRECTORY = $SOURCE_ROOT/DoxygenDocs.docset" >> "$CONFIG_PATH"
echo "GENERATE_DOCSET = YES" >> "$CONFIG_PATH"
echo "DOCSET_FEEDNAME = \"$COMPANY_NAME\"" >> "$CONFIG_PATH"
echo "DOCSET_BUNDLE_ID = $COMPANY_IDENTIFIER.$PROJECT_NAME" >> "$CONFIG_PATH"
echo "PROJECT_NAME = $PROJECT_NAME" >> "$CONFIG_PATH"


# Run doxygen to generate documentation based on the updated config file.
# Note: doxygen creates a Makefile that does most of the heavy lifting.
"$DOXYGEN_PATH" "$CONFIG_PATH"


# make will invoke docsetutil. Take a look at the Makefile to see how this is done. Apparently, it installs the new docset into /Users/ $USER/Library/Developer/Shared/Documentation/DocSets
make -C $SOURCE_ROOT/DoxygenDocs.docset/html install


# Construct a temporary applescript file to tell Xcode to load the new docset.
LOAD_DOCSET_PATH="$TEMP_DIR/loadDocSet.scpt"


#  Remove old applescript file, in case there already is one.
rm -f "$LOAD_DOCSET_PATH"

# Echo three lines of text into the file
echo "tell application \"Xcode\"" >> "$LOAD_DOCSET_PATH"
echo "load documentation set with path \"/Users/$USER/Library/ Developer/Shared/Documentation/DocSets/\""
>> "$LOAD_DOCSET_PATH"
echo "end tell" >> "$LOAD_DOCSET_PATH"


#  Run the load-docset applescript command.
osascript "$LOAD_DOCSET_PATH"

echo
echo "*** This script is now done."
echo

exit 0
_______________________________________________
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


References: 
 >Re: Access Build Settings in a User Script? (From: Karl Moskowski <email@hidden>)

  • Prev by Date: Wrangling 3rd party libraries with xcconfig settings?
  • Next by Date: Re: get rid of warning "suggest parenthesis around assignment used as truth value"
  • Previous by thread: Re: Access Build Settings in a User Script?
  • Next by thread: break points in library not found
  • Index(es):
    • Date
    • Thread