Skip to content

Instantly share code, notes, and snippets.

@antmd
Created November 21, 2013 21:46
Show Gist options
  • Save antmd/7590278 to your computer and use it in GitHub Desktop.
Save antmd/7590278 to your computer and use it in GitHub Desktop.
Script to compile a single Objective-C file
#!/bin/bash -
set -o nounset # Treat unset variables as an error
SRC=$1
SRCROOT=${SRC%.*}
TMPFILE=`mktemp /tmp/singlecompile.XXXXXX` || exit 1
PRODUCTS_DIR=~/Development/Products
FRAMEWORKS_BUILD_TYPE=Debug
# Compile to .o
xcrun clang -c "${SRC}" \
-g \
-DDEBUG=1 \
-fobjc-arc \
-arch x86_64 \
-isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk \
-F/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk \
-mmacosx-version-min=10.9 \
-I "${PRODUCTS_DIR}/include" \
-o "${TMPFILE}.o"
# Link
xcrun clang "${TMPFILE}.o" \
-ObjC \
-fobjc-arc -arch x86_64 \
-isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk \
-F/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk \
-mmacosx-version-min=10.9 \
-framework Foundation \
-framework EventKit \
-framework Cocoa \
-framework Quartz \
-L "${PRODUCTS_DIR}/${FRAMEWORKS_BUILD_TYPE}" \
-l DervishSoftwareAppKit \
-o "${SRCROOT}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment