How to compile a pre-made xcode project into a library

Discussion in 'Mac Programming' started by dancks, Oct 3, 2012.

  1. dancks, Oct 3, 2012
    Last edited: Oct 3, 2012

    dancks macrumors regular


    Nov 8, 2009
    I wanted to install superiotool to check on my super i/o chip as well... make sure everything is going smoothly. I need to install DirectHW first. the download is sent as an xcode project and I have no idea how to install it. It came with no directions that I saw.

    I'm using snow leopard 10.6.8 and xcode 3.2.6

    edit: nevermind I think I'm supposed to create a .dmg

    I'm reading a file to use a script called create-dmg and here is a sample command:

    ./create-dmg --window-size 500 300 --background ~/Projects/eclipse-osx-repackager/build/background.gif --icon-size 96 --volname "Hyper Foo" --icon "Applications" 380 205 --icon "Eclipse OS X Repackager" 110 205 test2.dmg /Users/andreyvit/Projects/eclipse-osx-repackager/temp/Eclipse\ OS\ X\ Repackager\ r10/
    the help option:
    on-danckss-macbook:create-dmg Jason$ ./create-dmg --help
    Creates a fancy DMG file.
    Usage:  create-dmg options... image.dmg source_folder
    All contents of source_folder will be copied into the disk image.
      --volname name
          set volume name (displayed in the Finder sidebar and window title)
      --background pic.png
          set folder background image (provide png, gif, jpg)
      --window-pos x y
          set position the folder window
      --window-size width height
          set size of the folder window
      --icon-size icon_size
          set window icons size (up to 128)
      --icon file_name x y
          set position of the file's icon
      --custom-icon file_name custom_icon_or_sample_file x y
          set position and custom icon
      --version         show tool version number
      -h, --help        display this help
    the script file itself:
    #! /bin/bash
    # Create a read-only disk image of the contents of a folder
    # Usage: make-diskimage <image_file>
    #                       <src_folder>
    #                       <volume_name>
    #                       <applescript>
    #                       <artpath>
    #                       <eula_resource_file>
    set -e;
    function pure_version() {
      echo ''
    function version() {
      echo "create-dmg $(pure_version)"
    function usage() {
      echo "Creates a fancy DMG file."
      echo "Usage:  $(basename $0) options... image.dmg source_folder"
      echo "All contents of source_folder will be copied into the disk image."
      echo "Options:"
      echo "  --volname name"
      echo "      set volume name (displayed in the Finder sidebar and window title)"
      echo "  --background pic.png"
      echo "      set folder background image (provide png, gif, jpg)"
      echo "  --window-pos x y"
      echo "      set position the folder window"
      echo "  --window-size width height"
      echo "      set size of the folder window"
      echo "  --icon-size icon_size"
      echo "      set window icons size (up to 128)"
      echo "  --icon file_name x y"
      echo "      set position of the file's icon"
      echo "  --custom-icon file_name custom_icon_or_sample_file x y"
      echo "      set position and custom icon"
      echo "  --version         show tool version number"
      echo "  -h, --help        display this help"
      exit 0
    while test "${1:0:1}" = "-"; do
      case $1 in
          shift; shift;;
          BACKGROUND_CLAUSE="set background picture of opts to file \".background:$BACKGROUND_FILE_NAME\""
          shift; shift;;
          shift; shift;;
          WINX=$2; WINY=$3
          shift; shift; shift;;
          WINW=$2; WINH=$3
          shift; shift; shift;;
          POSITION_CLAUSE="${POSITION_CLAUSE}set position of item \"$2\" to {$3, $4}
          echo $POSITION_CLAUSE
          shift; shift; shift; shift;;
          shift; shift; shift; shift; shift;;
        -h | --help)
          version; exit 0;;
          pure_version; exit 0;;
          echo "Unknown option $1. Run with --help for help."
          exit 1;;
    test -z "$2" && {
      echo "Not enough arguments. Invoke with --help for help."
      exit 1
    DMG_DIRNAME="$(dirname "$DMG_PATH")"
    DMG_DIR="$(cd $DMG_DIRNAME > /dev/null; pwd)"
    DMG_NAME="$(basename "$DMG_PATH")"
    SRC_FOLDER="$(cd "$2" > /dev/null; pwd)"
    test -z "$VOLUME_NAME" && VOLUME_NAME="$(basename "$DMG_PATH" .dmg)"
    AUX_PATH="$(cd "$(dirname $0)"; pwd)/support"
    test -d "$AUX_PATH" || {
      echo "Cannot find support directory: $AUX_PATH"
      exit 1
    # Create the image
    echo "Creating disk image..."
    test -f "${DMG_TEMP_NAME}" && rm -f "${DMG_TEMP_NAME}"
    hdiutil create -srcfolder "$SRC_FOLDER" -volname "${VOLUME_NAME}" -fs HFS+ -fsargs "-c c=64,a=16,e=16" -format UDRW -size 300m "${DMG_TEMP_NAME}"
    # mount it
    echo "Mounting disk image..."
    echo "Mount directory: $MOUNT_DIR"
    DEV_NAME=$(hdiutil attach -readwrite -noverify -noautoopen "${DMG_TEMP_NAME}" | egrep '^/dev/' | sed 1q | awk '{print $1}')
    echo "Device name:     $DEV_NAME"
    #cp RightDS_Store "/Volumes/${VOLUME_NAME}/.DS_Store"
    if ! test -z "$BACKGROUND_FILE"; then
      echo "Copying background file..."
      test -d "$MOUNT_DIR/.background" || mkdir "$MOUNT_DIR/.background"
    # run applescript
    APPLESCRIPT=$(mktemp -t createdmg)
    cat "$AUX_PATH/template.applescript" | sed -e "s/WINX/$WINX/g" -e "s/WINY/$WINY/g" -e "s/WINW/$WINW/g" -e "s/WINH/$WINH/g" -e "s/BACKGROUND_CLAUSE/$BACKGROUND_CLAUSE/g" -e "s/ICON_SIZE/$ICON_SIZE/g" | perl -pe  "s/POSITION_CLAUSE/$POSITION_CLAUSE/g" >"$APPLESCRIPT"
    echo "Running Applescript: ./AdiumApplescriptRunner \"${APPLESCRIPT}\" process_disk_image \"${VOLUME_NAME}\""
    "$AUX_PATH/AdiumApplescriptRunner" "${APPLESCRIPT}" process_disk_image "${VOLUME_NAME}" || true
    echo "Done running the applescript..."
    sleep 4
    # make sure it's not world writeable
    echo "Fixing permissions..."
    chmod -Rf go-w "${MOUNT_DIR}" || true
    echo "Done fixing permissions."
    # make the top window open itself on mount:
    if [ -x /usr/local/bin/openUp ]; then
        echo "Applying openUp..."
        /usr/local/bin/openUp "${MOUNT_DIR}"
    # unmount
    echo "Unmounting disk image..."
    hdiutil detach "${DEV_NAME}"
    # compress image
    echo "Compressing disk image..."
    hdiutil convert "${DMG_TEMP_NAME}" -format UDZO -imagekey zlib-level=9 -o "${DMG_DIR}/${DMG_NAME}"
    rm -f "${DMG_TEMP_NAME}"
    # adding EULA resources
    if [ ! -z "${EULA_RSRC}" -a "${EULA_RSRC}" != "-null-" ]; then
            echo "adding EULA resources"
            hdiutil unflatten "${DMG_DIR}/${DMG_NAME}"
            /Developer/Tools/ResMerger -a "${EULA_RSRC}" -o "${DMG_DIR}/${DMG_NAME}"
            hdiutil flatten "${DMG_DIR}/${DMG_NAME}"
    echo "Disk image done"
    exit 0
    I have no idea why creating a .dmg is important. I hope its going to create the necessary lib files and put them in the appropriate folders so I can move on to other stuff. If I wanted to skip alll this and just do that myself how would I go about it? the source files from what I see are:


    so yeah. Any suggestions are appreciated
  2. dancks thread starter macrumors regular


    Nov 8, 2009
    any suggestions at least? how about just making an installer?

Share This Page