Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Session 404 - Building from the Command Line wi...

wwdcman
July 09, 2012
140

Session 404 - Building from the Command Line with Xcode

wwdcman

July 09, 2012
Tweet

Transcript

  1. These are confidential sessions—please refrain from streaming, blogging, or taking

    pictures Session 404 Building from the Command Line with Xcode Anders Bertelrud Xcode Architect
  2. Roadmap •Why use the command line? •Using xcodebuild •Customizing your

    project •Automating xcodebuild •Working outside Xcode
  3. Why Use the Command Line? •Automation ▪ Nightly release builds

    ▪ Continuous Integration systems • Make-based open source development ▪ Cross-platform code ▪ MacPorts, Fink, Homebrew…
  4. What Is xcodebuild? •Command line access to Xcode IDE •Works

    with projects and workspaces •Batch operations ▪ Build ▪ Archive ▪ Query
  5. What Is xcodebuild? •Command line access to Xcode IDE •Works

    with projects and workspaces •Batch operations ▪ Build ▪ Archive ▪ Query •Use man xcodebuild for the details
  6. Using xcodebuild > === BUILD NATIVE TARGET Baffle OSX OF

    PROJECT Baffle OSX WITH CONFIGURATION Debug === ProcessPCH build/Intermediates/PrecompiledHeaders/Baff leCocoa_Prefix-dkhujustkymhfqbdihrzilncxtxa/BaffleCoco a_Prefix.pch.pth OtherSources/BaffleCocoa_Prefix.pch n ormal x86_64 objective-c com.apple.compilers.llvm.clan g.1_0.compiler : cd ~/Documents/MyProjectDir xcodebuild >
  7. === BUILD NATIVE TARGET Baffle OSX OF PROJECT Baffle OSX

    CpResource ../SharedResources/BGShake.png build/Debug/Ba cd /Users/anders/WWDC2012/Baffle builtin-copy -exclude .DS_Store -exclude CVS -exclud CpResource ../SharedResources/BGCubeFace.png build/Debug cd /Users/anders/WWDC2012/Baffle builtin-copy -exclude .DS_Store -exclude CVS -exclud CpResource ../SharedResources/BGSwirl-Green.png build/De cd /Users/anders/WWDC2012/Baffle builtin-copy -exclude .DS_Store -exclude CVS -exclud CopyStringsFile build/Debug/Baffle\ OSX.app/Contents/Res cd /Users/anders/WWDC2012/Baffle builtin-copyStrings --validate --inputencoding utf-1 Build Logs in the Console
  8. === BUILD NATIVE TARGET Baffle OSX OF PROJECT Baffle OSX

    CpResource ../SharedResources/BGShake.png build/Debug/Ba cd /Users/anders/WWDC2012/Baffle builtin-copy -exclude .DS_Store -exclude CVS -exclud CpResource ../SharedResources/BGCubeFace.png build/Debug cd /Users/anders/WWDC2012/Baffle builtin-copy -exclude .DS_Store -exclude CVS -exclud CpResource ../SharedResources/BGSwirl-Green.png build/De cd /Users/anders/WWDC2012/Baffle builtin-copy -exclude .DS_Store -exclude CVS -exclud CopyStringsFile build/Debug/Baffle\ OSX.app/Contents/Res cd /Users/anders/WWDC2012/Baffle builtin-copyStrings --validate --inputencoding utf-1 Build Logs in the Console
  9. === BUILD NATIVE TARGET Baffle OSX OF PROJECT Baffle OSX

    CpResource ../SharedResources/BGShake.png build/Debug/Ba cd /Users/anders/WWDC2012/Baffle builtin-copy -exclude .DS_Store -exclude CVS -exclud CpResource ../SharedResources/BGCubeFace.png build/Debug cd /Users/anders/WWDC2012/Baffle builtin-copy -exclude .DS_Store -exclude CVS -exclud CpResource ../SharedResources/BGSwirl-Green.png build/De cd /Users/anders/WWDC2012/Baffle builtin-copy -exclude .DS_Store -exclude CVS -exclud CopyStringsFile build/Debug/Baffle\ OSX.app/Contents/Res cd /Users/anders/WWDC2012/Baffle builtin-copyStrings --validate --inputencoding utf-1 Build Logs in the Console
  10. === BUILD NATIVE TARGET Baffle OSX OF PROJECT Baffle OSX

    CpResource ../SharedResources/BGShake.png build/Debug/Ba cd /Users/anders/WWDC2012/Baffle builtin-copy -exclude .DS_Store -exclude CVS -exclud CpResource ../SharedResources/BGCubeFace.png build/Debug cd /Users/anders/WWDC2012/Baffle builtin-copy -exclude .DS_Store -exclude CVS -exclud CpResource ../SharedResources/BGSwirl-Green.png build/De cd /Users/anders/WWDC2012/Baffle builtin-copy -exclude .DS_Store -exclude CVS -exclud CopyStringsFile build/Debug/Baffle\ OSX.app/Contents/Res cd /Users/anders/WWDC2012/Baffle builtin-copyStrings --validate --inputencoding utf-1 Build Logs in the Console
  11. CpResource ../SharedResources/BGShake.png build/Debug/Ba cd /Users/anders/WWDC2012/Baffle builtin-copy -exclude .DS_Store -exclude CVS

    -exclud CpResource ../SharedResources/BGCubeFace.png build/Debug cd /Users/anders/WWDC2012/Baffle builtin-copy -exclude .DS_Store -exclude CVS -exclud CpResource ../SharedResources/BGSwirl-Green.png build/De cd /Users/anders/WWDC2012/Baffle builtin-copy -exclude .DS_Store -exclude CVS -exclud CopyStringsFile build/Debug/Baffle\ OSX.app/Contents/Res cd /Users/anders/WWDC2012/Baffle builtin-copyStrings --validate --inputencoding utf-1 CompileXIB Resources/English.lproj/MainMenu.xib cd /Users/anders/WWDC2012/Baffle setenv XCODE_DEVELOPER_USR_PATH /Applications/Xcode. /Applications/Xcode.app/Contents/Developer/usr/bin/i CpResource ../SharedResources/Countdown.caf build/Debug cd /Users/anders/WWDC2012/Baffle builtin-copy -exclude .DS_Store -exclude CVS -exclud : ProcessPCH build/Intermediates/PrecompiledHeaders/Baffle cd /Users/anders/WWDC2012/Baffle setenv LANG en_US.US-ASCII clang -x objective-c -arch x86_64 -std=c99 -O0 -Wswi Build Logs in the Console
  12. CpResource ../SharedResources/BGShake.png build/Debug/Ba cd /Users/anders/WWDC2012/Baffle builtin-copy -exclude .DS_Store -exclude CVS

    -exclud CpResource ../SharedResources/BGCubeFace.png build/Debug cd /Users/anders/WWDC2012/Baffle builtin-copy -exclude .DS_Store -exclude CVS -exclud CpResource ../SharedResources/BGSwirl-Green.png build/De cd /Users/anders/WWDC2012/Baffle builtin-copy -exclude .DS_Store -exclude CVS -exclud CopyStringsFile build/Debug/Baffle\ OSX.app/Contents/Res cd /Users/anders/WWDC2012/Baffle builtin-copyStrings --validate --inputencoding utf-1 CompileXIB Resources/English.lproj/MainMenu.xib cd /Users/anders/WWDC2012/Baffle setenv XCODE_DEVELOPER_USR_PATH /Applications/Xcode. /Applications/Xcode.app/Contents/Developer/usr/bin/i CpResource ../SharedResources/Countdown.caf build/Debug cd /Users/anders/WWDC2012/Baffle builtin-copy -exclude .DS_Store -exclude CVS -exclud : ProcessPCH build/Intermediates/PrecompiledHeaders/Baffle cd /Users/anders/WWDC2012/Baffle setenv LANG en_US.US-ASCII clang -x objective-c -arch x86_64 -std=c99 -O0 -Wswi Build Logs in the Console
  13. CpResource ../SharedResources/BGShake.png build/Debug/Ba cd /Users/anders/WWDC2012/Baffle builtin-copy -exclude .DS_Store -exclude CVS

    -exclud CpResource ../SharedResources/BGCubeFace.png build/Debug cd /Users/anders/WWDC2012/Baffle builtin-copy -exclude .DS_Store -exclude CVS -exclud CpResource ../SharedResources/BGSwirl-Green.png build/De cd /Users/anders/WWDC2012/Baffle builtin-copy -exclude .DS_Store -exclude CVS -exclud CopyStringsFile build/Debug/Baffle\ OSX.app/Contents/Res cd /Users/anders/WWDC2012/Baffle builtin-copyStrings --validate --inputencoding utf-1 CompileXIB Resources/English.lproj/MainMenu.xib cd /Users/anders/WWDC2012/Baffle setenv XCODE_DEVELOPER_USR_PATH /Applications/Xcode. /Applications/Xcode.app/Contents/Developer/usr/bin/i CpResource ../SharedResources/Countdown.caf build/Debug cd /Users/anders/WWDC2012/Baffle builtin-copy -exclude .DS_Store -exclude CVS -exclud : ProcessPCH build/Intermediates/PrecompiledHeaders/Baffle cd /Users/anders/WWDC2012/Baffle setenv LANG en_US.US-ASCII clang -x objective-c -arch x86_64 -std=c99 -O0 -Wswi Build Logs in the Console
  14. builtin-copyStrings --validate --inputencoding utf-1 CompileXIB Resources/English.lproj/MainMenu.xib cd /Users/anders/WWDC2012/Baffle setenv XCODE_DEVELOPER_USR_PATH

    /Applications/Xcode. /Applications/Xcode.app/Contents/Developer/usr/bin/i CpResource ../SharedResources/Countdown.caf build/Debug cd /Users/anders/WWDC2012/Baffle builtin-copy -exclude .DS_Store -exclude CVS -exclud : ProcessPCH build/Intermediates/PrecompiledHeaders/Baffle cd /Users/anders/WWDC2012/Baffle setenv LANG en_US.US-ASCII clang -x objective-c -arch x86_64 -std=c99 -O0 -Wswi CompileC ../SharedCode/BGBaffleWord.m normal x86_64 obje cd /Users/anders/WWDC2012/Baffle setenv LANG en_US.US-ASCII clang -x objective-c -arch x86_64 -std=c99 -O0 -Wswi CompileC ./OtherSources/main.m normal x86_64 objective-c cd /Users/anders/WWDC2012/Baffle setenv LANG en_US.US-ASCII clang -x objective-c -arch x86_64 -std=c99 -O0 -Wswi : Ld build/Debug/Baffle\ OSX.app/Contents/MacOS/Baffle\ OS Build Logs in the Console
  15. builtin-copyStrings --validate --inputencoding utf-1 CompileXIB Resources/English.lproj/MainMenu.xib cd /Users/anders/WWDC2012/Baffle setenv XCODE_DEVELOPER_USR_PATH

    /Applications/Xcode. /Applications/Xcode.app/Contents/Developer/usr/bin/i CpResource ../SharedResources/Countdown.caf build/Debug cd /Users/anders/WWDC2012/Baffle builtin-copy -exclude .DS_Store -exclude CVS -exclud : ProcessPCH build/Intermediates/PrecompiledHeaders/Baffle cd /Users/anders/WWDC2012/Baffle setenv LANG en_US.US-ASCII clang -x objective-c -arch x86_64 -std=c99 -O0 -Wswi CompileC ../SharedCode/BGBaffleWord.m normal x86_64 obje cd /Users/anders/WWDC2012/Baffle setenv LANG en_US.US-ASCII clang -x objective-c -arch x86_64 -std=c99 -O0 -Wswi CompileC ./OtherSources/main.m normal x86_64 objective-c cd /Users/anders/WWDC2012/Baffle setenv LANG en_US.US-ASCII clang -x objective-c -arch x86_64 -std=c99 -O0 -Wswi : Ld build/Debug/Baffle\ OSX.app/Contents/MacOS/Baffle\ OS Build Logs in the Console
  16. builtin-copyStrings --validate --inputencoding utf-1 CompileXIB Resources/English.lproj/MainMenu.xib cd /Users/anders/WWDC2012/Baffle setenv XCODE_DEVELOPER_USR_PATH

    /Applications/Xcode. /Applications/Xcode.app/Contents/Developer/usr/bin/i CpResource ../SharedResources/Countdown.caf build/Debug cd /Users/anders/WWDC2012/Baffle builtin-copy -exclude .DS_Store -exclude CVS -exclud : ProcessPCH build/Intermediates/PrecompiledHeaders/Baffle cd /Users/anders/WWDC2012/Baffle setenv LANG en_US.US-ASCII clang -x objective-c -arch x86_64 -std=c99 -O0 -Wswi CompileC ../SharedCode/BGBaffleWord.m normal x86_64 obje cd /Users/anders/WWDC2012/Baffle setenv LANG en_US.US-ASCII clang -x objective-c -arch x86_64 -std=c99 -O0 -Wswi CompileC ./OtherSources/main.m normal x86_64 objective-c cd /Users/anders/WWDC2012/Baffle setenv LANG en_US.US-ASCII clang -x objective-c -arch x86_64 -std=c99 -O0 -Wswi : Ld build/Debug/Baffle\ OSX.app/Contents/MacOS/Baffle\ OS Build Logs in the Console
  17. builtin-copyStrings --validate --inputencoding utf-1 CompileXIB Resources/English.lproj/MainMenu.xib cd /Users/anders/WWDC2012/Baffle setenv XCODE_DEVELOPER_USR_PATH

    /Applications/Xcode. /Applications/Xcode.app/Contents/Developer/usr/bin/i CpResource ../SharedResources/Countdown.caf build/Debug cd /Users/anders/WWDC2012/Baffle builtin-copy -exclude .DS_Store -exclude CVS -exclud : ProcessPCH build/Intermediates/PrecompiledHeaders/Baffle cd /Users/anders/WWDC2012/Baffle setenv LANG en_US.US-ASCII clang -x objective-c -arch x86_64 -std=c99 -O0 -Wswi CompileC ../SharedCode/BGBaffleWord.m normal x86_64 obje cd /Users/anders/WWDC2012/Baffle setenv LANG en_US.US-ASCII clang -x objective-c -arch x86_64 -std=c99 -O0 -Wswi CompileC ./OtherSources/main.m normal x86_64 objective-c cd /Users/anders/WWDC2012/Baffle setenv LANG en_US.US-ASCII clang -x objective-c -arch x86_64 -std=c99 -O0 -Wswi : Ld build/Debug/Baffle\ OSX.app/Contents/MacOS/Baffle\ OS Build Logs in the Console
  18. builtin-copyStrings --validate --inputencoding utf-1 CompileXIB Resources/English.lproj/MainMenu.xib cd /Users/anders/WWDC2012/Baffle setenv XCODE_DEVELOPER_USR_PATH

    /Applications/Xcode. /Applications/Xcode.app/Contents/Developer/usr/bin/i CpResource ../SharedResources/Countdown.caf build/Debug cd /Users/anders/WWDC2012/Baffle builtin-copy -exclude .DS_Store -exclude CVS -exclud : ProcessPCH build/Intermediates/PrecompiledHeaders/Baffle cd /Users/anders/WWDC2012/Baffle setenv LANG en_US.US-ASCII clang -x objective-c -arch x86_64 -std=c99 -O0 -Wswi CompileC ../SharedCode/BGBaffleWord.m normal x86_64 obje cd /Users/anders/WWDC2012/Baffle setenv LANG en_US.US-ASCII clang -x objective-c -arch x86_64 -std=c99 -O0 -Wswi CompileC ./OtherSources/main.m normal x86_64 objective-c cd /Users/anders/WWDC2012/Baffle setenv LANG en_US.US-ASCII clang -x objective-c -arch x86_64 -std=c99 -O0 -Wswi : Ld build/Debug/Baffle\ OSX.app/Contents/MacOS/Baffle\ OS Build Logs in the Console
  19. clang -x objective-c -arch x86_64 -std=c99 -O0 -Wswi CompileC ../SharedCode/BGBaffleWord.m

    normal x86_64 obje cd /Users/anders/WWDC2012/Baffle setenv LANG en_US.US-ASCII clang -x objective-c -arch x86_64 -std=c99 -O0 -Wswi CompileC ./OtherSources/main.m normal x86_64 objective-c cd /Users/anders/WWDC2012/Baffle setenv LANG en_US.US-ASCII clang -x objective-c -arch x86_64 -std=c99 -O0 -Wswi : Ld build/Debug/Baffle\ OSX.app/Contents/MacOS/Baffle\ OS cd /Users/anders/WWDC2012/Baffle setenv MACOSX_DEPLOYMENT_TARGET 10.8 clang -arch x86_64 -fobjc-link-runtime -mmacosx-vers ** BUILD SUCCEEDED ** Build Logs in the Console
  20. clang -x objective-c -arch x86_64 -std=c99 -O0 -Wswi CompileC ../SharedCode/BGBaffleWord.m

    normal x86_64 obje cd /Users/anders/WWDC2012/Baffle setenv LANG en_US.US-ASCII clang -x objective-c -arch x86_64 -std=c99 -O0 -Wswi CompileC ./OtherSources/main.m normal x86_64 objective-c cd /Users/anders/WWDC2012/Baffle setenv LANG en_US.US-ASCII clang -x objective-c -arch x86_64 -std=c99 -O0 -Wswi : Ld build/Debug/Baffle\ OSX.app/Contents/MacOS/Baffle\ OS cd /Users/anders/WWDC2012/Baffle setenv MACOSX_DEPLOYMENT_TARGET 10.8 clang -arch x86_64 -fobjc-link-runtime -mmacosx-vers ** BUILD SUCCEEDED ** Build Logs in the Console
  21. clang -x objective-c -arch x86_64 -std=c99 -O0 -Wswi CompileC ../SharedCode/BGBaffleWord.m

    normal x86_64 obje cd /Users/anders/WWDC2012/Baffle setenv LANG en_US.US-ASCII clang -x objective-c -arch x86_64 -std=c99 -O0 -Wswi CompileC ./OtherSources/main.m normal x86_64 objective-c cd /Users/anders/WWDC2012/Baffle setenv LANG en_US.US-ASCII clang -x objective-c -arch x86_64 -std=c99 -O0 -Wswi : Ld build/Debug/Baffle\ OSX.app/Contents/MacOS/Baffle\ OS cd /Users/anders/WWDC2012/Baffle setenv MACOSX_DEPLOYMENT_TARGET 10.8 clang -arch x86_64 -fobjc-link-runtime -mmacosx-vers ** BUILD SUCCEEDED ** Build Logs in the Console
  22. clang -x objective-c -arch x86_64 -std=c99 -O0 -Wswi CompileC ../SharedCode/BGBaffleWord.m

    normal x86_64 obje cd /Users/anders/WWDC2012/Baffle setenv LANG en_US.US-ASCII clang -x objective-c -arch x86_64 -std=c99 -O0 -Wswi CompileC ./OtherSources/main.m normal x86_64 objective-c cd /Users/anders/WWDC2012/Baffle setenv LANG en_US.US-ASCII clang -x objective-c -arch x86_64 -std=c99 -O0 -Wswi : Ld build/Debug/Baffle\ OSX.app/Contents/MacOS/Baffle\ OS cd /Users/anders/WWDC2012/Baffle setenv MACOSX_DEPLOYMENT_TARGET 10.8 clang -arch x86_64 -fobjc-link-runtime -mmacosx-vers ** BUILD SUCCEEDED ** Build Logs in the Console
  23. clang -x objective-c -arch x86_64 -std=c99 -O0 -Wswi CompileC ../SharedCode/BGBaffleWord.m

    normal x86_64 obje cd /Users/anders/WWDC2012/Baffle setenv LANG en_US.US-ASCII clang -x objective-c -arch x86_64 -std=c99 -O0 -Wswi CompileC ./OtherSources/main.m normal x86_64 objective-c cd /Users/anders/WWDC2012/Baffle setenv LANG en_US.US-ASCII clang -x objective-c -arch x86_64 -std=c99 -O0 -Wswi : Ld build/Debug/Baffle\ OSX.app/Contents/MacOS/Baffle\ OS cd /Users/anders/WWDC2012/Baffle setenv MACOSX_DEPLOYMENT_TARGET 10.8 clang -arch x86_64 -fobjc-link-runtime -mmacosx-vers ** BUILD SUCCEEDED ** Build Logs in the Console
  24. Where Do the Outputs Go? Kind Contents Controlling Build Setting

    Intermediates Intermediates Intermediates Debug Products Debug Products Release Products Compiled Code (“Objects”) OBJROOT Generated Sources OBJROOT Precompiled Headers SHARED_PRECOMPS_DIR Products, in debug locations SYMROOT Debug Symbols (.dSYMs) SYMROOT Products, in release locations DSTROOT
  25. Where Do the Outputs Go? Kind Contents Controlling Build Setting

    Intermediates Intermediates Intermediates Debug Products Debug Products Release Products Compiled Code (“Objects”) OBJROOT Generated Sources OBJROOT Precompiled Headers SHARED_PRECOMPS_DIR Products, in debug locations SYMROOT Debug Symbols (.dSYMs) SYMROOT Products, in release locations DSTROOT
  26. Where Do the Outputs Go? Kind Contents Controlling Build Setting

    Intermediates Intermediates Intermediates Debug Products Debug Products Release Products Compiled Code (“Objects”) OBJROOT Generated Sources OBJROOT Precompiled Headers SHARED_PRECOMPS_DIR Products, in debug locations SYMROOT Debug Symbols (.dSYMs) SYMROOT Products, in release locations DSTROOT
  27. Where Do the Outputs Go? Kind Contents Controlling Build Setting

    Intermediates Intermediates Intermediates Debug Products Debug Products Release Products Compiled Code (“Objects”) OBJROOT Generated Sources OBJROOT Precompiled Headers SHARED_PRECOMPS_DIR Products, in debug locations SYMROOT Debug Symbols (.dSYMs) SYMROOT Products, in release locations DSTROOT
  28. Schemes •A scheme defines: ▪ A collection of targets to

    build ▪ A configuration to use when building
  29. Schemes •A scheme defines: ▪ A collection of targets to

    build ▪ A configuration to use when building ▪ An optional collection of tests to execute
  30. Schemes •A scheme defines: ▪ A collection of targets to

    build ▪ A configuration to use when building ▪ An optional collection of tests to execute ▪ User-defined pre- and post-processing actions
  31. Listing the Schemes > Information about workspace "Baffle": Schemes: Baffle

    OSX Baffle iOS xcodebuild -workspace Baffle.xcworkspace -list >
  32. Using Schemes •Configure in Xcode ▪ Build configuration ▪ Scheme

    actions ▪ Other options •Use in xcodebuild ▪ Use -scheme flag to select scheme to use
  33. Listing the SDKs OS X SDKs: ! Mac OS X

    10.7 -sdk macosx10.7 ! OS X 10.8 -sdk macosx10.8 iOS SDKs: ! iOS 6.0 -sdk iphoneos6.0 iOS Simulator SDKs: ! Simulator - iOS 6.0 -sdk iphonesimulator6.0 > xcodebuild -showsdks >
  34. Build Settings •“Knobs and switches” of the build system •View

    and edit in Build Settings editor in IDE •Override by passing on xcodebuild command line
  35. Build Settings •“Knobs and switches” of the build system •View

    and edit in Build Settings editor in IDE •Override by passing on xcodebuild command line •Set in environment to provide defaults
  36. Build Settings •“Knobs and switches” of the build system •View

    and edit in Build Settings editor in IDE •Override by passing on xcodebuild command line •Set in environment to provide defaults •Use -showBuildSettings option to xcodebuild
  37. Seeing Values of Build Settings Build settings for action build

    & target "Baffle OSX" ACTION = build ALWAYS_SEARCH_USER_PATHS = NO APPLY_RULES_IN_COPY_FILES = NO ARCHS = i386 ARCHS_STANDARD_32_64_BIT = x86_64 i386 ARCHS_STANDARD_32_BIT = i386 ARCHS_STANDARD_64_BIT = x86_64 AVAILABLE_PLATFORMS = macosx iphoneos BUILD_DIR = ./build/Baffle/Build/Products CONFIGURATION = Debug COPYING_PRESERVES_HFS_DATA = NO : > xcodebuild -workspace Baffle -showBuildSettings
  38. Putting It All Together > xcodebuild \ -workspace Baffle.xcworkspace \

    -scheme "Baffle OSX" \ -sdk macosx10.8 \ OBJROOT=/tmp/objects \
  39. Putting It All Together > xcodebuild \ -workspace Baffle.xcworkspace \

    -scheme "Baffle OSX" \ -sdk macosx10.8 \ OBJROOT=/tmp/objects \ SYMROOT=/tmp/symbols \
  40. Putting It All Together > xcodebuild \ -workspace Baffle.xcworkspace \

    -scheme "Baffle OSX" \ -sdk macosx10.8 \ OBJROOT=/tmp/objects \ SYMROOT=/tmp/symbols \ DSTROOT=/tmp/distrib
  41. What Is xcode-select Really Doing? •Sets the Xcode.app that’s used

    by tools in /usr/bin ▪ xcodebuild ▪ xcrun
  42. What Is xcode-select Really Doing? •Sets the Xcode.app that’s used

    by tools in /usr/bin ▪ xcodebuild ▪ xcrun ▪ opendiff
  43. What Is xcode-select Really Doing? •Sets the Xcode.app that’s used

    by tools in /usr/bin ▪ xcodebuild ▪ xcrun ▪ opendiff ▪ instruments
  44. What Is xcode-select Really Doing? •Sets the Xcode.app that’s used

    by tools in /usr/bin ▪ xcodebuild ▪ xcrun ▪ opendiff ▪ instruments ▪ ibtool
  45. What Is xcode-select Really Doing? •Sets the Xcode.app that’s used

    by tools in /usr/bin ▪ xcodebuild ▪ xcrun ▪ opendiff ▪ instruments ▪ ibtool ▪ xed
  46. What Is xcode-select Really Doing? •Sets the Xcode.app that’s used

    by tools in /usr/bin ▪ xcodebuild ▪ xcrun ▪ opendiff ▪ instruments ▪ ibtool ▪ xed ▪ iprofiler
  47. What Is xcode-select Really Doing? •Sets the Xcode.app that’s used

    by tools in /usr/bin ▪ xcodebuild ▪ xcrun ▪ opendiff ▪ instruments ▪ ibtool ▪ xed ▪ iprofiler ▪ agvtool
  48. What Is xcode-select Really Doing? •Sets the Xcode.app that’s used

    by tools in /usr/bin ▪ xcodebuild ▪ xcrun ▪ opendiff ▪ instruments ▪ ibtool ▪ xed ▪ iprofiler ▪ agvtool
  49. What Is xcrun? •Find or run a tool inside Xcode.app

    ▪ Context-sensitive—depends on SDK, etc.
  50. What Is xcrun? •Find or run a tool inside Xcode.app

    ▪ Context-sensitive—depends on SDK, etc. ▪ Also searches standard $PATH as a fallback
  51. What Is xcrun? •Find or run a tool inside Xcode.app

    ▪ Context-sensitive—depends on SDK, etc. ▪ Also searches standard $PATH as a fallback •Mode 1: Print the path of the tool
  52. What Is xcrun? •Find or run a tool inside Xcode.app

    ▪ Context-sensitive—depends on SDK, etc. ▪ Also searches standard $PATH as a fallback •Mode 1: Print the path of the tool ▪ Usage: xcrun -find tool
  53. What Is xcrun? •Find or run a tool inside Xcode.app

    ▪ Context-sensitive—depends on SDK, etc. ▪ Also searches standard $PATH as a fallback •Mode 1: Print the path of the tool ▪ Usage: xcrun -find tool •Mode 2: Run the tool with a full command line
  54. What Is xcrun? •Find or run a tool inside Xcode.app

    ▪ Context-sensitive—depends on SDK, etc. ▪ Also searches standard $PATH as a fallback •Mode 1: Print the path of the tool ▪ Usage: xcrun -find tool •Mode 2: Run the tool with a full command line ▪ Usage: xcrun tool arg1 arg2 ...
  55. Using xcrun > /Applications/Xcode.app/Contents/Developer/Toolchains/ XcodeDefault.xctoolchain/usr/bin/cc xcrun -find cc > source.c:22:23:

    warning: unused parameter 'baz' int foo (int bar, int baz) ^ 1 warning generated. xcrun cc -c source.c -o source.o >
  56. Using xcrun > /Applications/Xcode45-DP1.app/Contents/Developer/ usr/bin/git xcrun -find git > git

    version 1.7.9.6 (Apple Git-31) xcrun git --version > alias git="xcrun git"
  57. Using xcrun > /Applications/Xcode45-DP1.app/Contents/Developer/ usr/bin/git xcrun -find git > git

    version 1.7.9.6 (Apple Git-31) xcrun git --version > alias git="xcrun git" >
  58. Using xcrun > /Applications/Xcode45-DP1.app/Contents/Developer/ usr/bin/git xcrun -find git > git

    version 1.7.9.6 (Apple Git-31) xcrun git --version > alias git="xcrun git" > git --version
  59. Using xcrun > /Applications/Xcode45-DP1.app/Contents/Developer/ usr/bin/git xcrun -find git > git

    version 1.7.9.6 (Apple Git-31) xcrun git --version > alias git="xcrun git" > git --version git version 1.7.9.6 (Apple Git-31) >
  60. Directly Invoking a Specific xcodebuild > export DEVELOPER_DIR=/Applications/Xcode45-DP1.app/ Contents/Developer >

    xcrun -find xcodebuild > /Applications/Xcode45-DP1.app/Contents/Developer/usr/ bin/xcodebuild
  61. Directly Invoking a Specific xcodebuild > export DEVELOPER_DIR=/Applications/Xcode45-DP1.app/ Contents/Developer >

    xcrun -find xcodebuild > xcodebuild /Applications/Xcode45-DP1.app/Contents/Developer/usr/ bin/xcodebuild
  62. Directly Invoking a Specific xcodebuild > export DEVELOPER_DIR=/Applications/Xcode45-DP1.app/ Contents/Developer >

    xcrun -find xcodebuild > xcodebuild /Applications/Xcode45-DP1.app/Contents/Developer/usr/ bin/xcodebuild === BUILD NATIVE TARGET Baffle OSX OF PROJECT Baffle OSX WITH CONFIGURATION Debug === ProcessPCH build/Intermediates/PrecompiledHeaders/Baff leCocoa_Prefix-dkhujustkymhfqbdihrzilncxtxa/BaffleCoco a_Prefix.pch.pth OtherSources/BaffleCocoa_Prefix.pch n ormal x86_64 objective-c com.apple.compilers.llvm.clan g.1_0.compiler
  63. What Is Continuous Integration? •Continuous Integration (CI) refers to a

    continuous process for integrating and applying quality checks to software development
  64. What Is Continuous Integration? •Continuous Integration (CI) refers to a

    continuous process for integrating and applying quality checks to software development Commit
  65. What Is Continuous Integration? •Continuous Integration (CI) refers to a

    continuous process for integrating and applying quality checks to software development Commit Build
  66. What Is Continuous Integration? •Continuous Integration (CI) refers to a

    continuous process for integrating and applying quality checks to software development Commit Build Test
  67. What Is Continuous Integration? •Continuous Integration (CI) refers to a

    continuous process for integrating and applying quality checks to software development Commit Build Test Publish
  68. Continuous Integration Example •Common problem ▪ Develop with Xcode GM

    and Xcode WWDC Preview tools ▪ Code shared between two products (e.g. OS X and iOS)
  69. Continuous Integration Example •Common problem ▪ Develop with Xcode GM

    and Xcode WWDC Preview tools ▪ Code shared between two products (e.g. OS X and iOS) ▪ Disruptive to switch between tools constantly
  70. Continuous Integration Example •Common problem ▪ Develop with Xcode GM

    and Xcode WWDC Preview tools ▪ Code shared between two products (e.g. OS X and iOS) ▪ Disruptive to switch between tools constantly •Solution
  71. Continuous Integration Example •Common problem ▪ Develop with Xcode GM

    and Xcode WWDC Preview tools ▪ Code shared between two products (e.g. OS X and iOS) ▪ Disruptive to switch between tools constantly •Solution ▪ Use xcodebuild and Continuous Integration
  72. Automating xcodebuild •Set DEVELOPER_DIR before running xcodebuild ▪ This ensures

    the Xcode tools you want are used, regardless of the tools currently chosen by xcode-select
  73. Automating xcodebuild •Set DEVELOPER_DIR before running xcodebuild ▪ This ensures

    the Xcode tools you want are used, regardless of the tools currently chosen by xcode-select •Use appropriate options to set the workspace, scheme, SDK
  74. Automating xcodebuild •Set DEVELOPER_DIR before running xcodebuild ▪ This ensures

    the Xcode tools you want are used, regardless of the tools currently chosen by xcode-select •Use appropriate options to set the workspace, scheme, SDK •Use build settings to control where output files go
  75. Automating xcodebuild •Set DEVELOPER_DIR before running xcodebuild ▪ This ensures

    the Xcode tools you want are used, regardless of the tools currently chosen by xcode-select •Use appropriate options to set the workspace, scheme, SDK •Use build settings to control where output files go DSTROOT, OBJROOT, SYMROOT, SHARED_PRECOMPS_DIR
  76. Automating xcodebuild •Make sure builds are run as a user

    who has accepted the license agreement; alternately, can accept for all users sudo xcodebuild -license
  77. Automating xcodebuild •Make sure builds are run as a user

    who has accepted the license agreement; alternately, can accept for all users sudo xcodebuild -license •Ensure access to appropriate development certificates
  78. Working Outside Xcode •Many projects may not supply native Xcode

    projects ▪ Legacy code base ▪ Traditional UNIX development
  79. Working Outside Xcode •Many projects may not supply native Xcode

    projects ▪ Legacy code base ▪ Traditional UNIX development ▪ Cross-platform open source projects
  80. Working Outside Xcode •Many projects may not supply native Xcode

    projects ▪ Legacy code base ▪ Traditional UNIX development ▪ Cross-platform open source projects •Tools for working outside Xcode
  81. Working Outside Xcode •Many projects may not supply native Xcode

    projects ▪ Legacy code base ▪ Traditional UNIX development ▪ Cross-platform open source projects •Tools for working outside Xcode ▪ Understanding the command line tools package
  82. The Command Line Tools Package •What is the command line

    tools package? •How to install the command line tools package?
  83. The Command Line Tools Package •What is the command line

    tools package? •How to install the command line tools package? •When should it be installed?
  84. •New in Xcode 4.3 •Separate package for doing extensive command

    line development •Supported mechanism for UNIX-style development What Is the Package?
  85. What Does It Contain? •Contains everything for command line development

    •Bundled at the standard UNIX location (/usr)
  86. When to Install the Package •Open source development ▪ Recommended

    practice for working with Fink, MacPorts, Homebrew
  87. When to Install the Package •Open source development ▪ Recommended

    practice for working with Fink, MacPorts, Homebrew $ fink install wget $ port install wget $ brew install wget
  88. When to Install the Package •Open source development ▪ Recommended

    practice for working with Fink, MacPorts, Homebrew Command Line Tools $ fink install wget $ port install wget $ brew install wget
  89. When to Install the Package •Extensive command line usage ▪

    Traditional UNIX-style workflow ▪ Legacy projects
  90. When to Install the Package •Extensive command line usage ▪

    Traditional UNIX-style workflow ▪ Legacy projects ▪ Non-Xcode IDE based development (e.g., Makefiles)
  91. When to Install the Package •Limited development, small download size

    ▪ Command line tools package is self-contained
  92. When to Install the Package •Limited development, small download size

    ▪ Command line tools package is self-contained ▪ Does not contain Xcode IDE or other packages
  93. When Not to Install the Package •Do not install just

    to get svn or git ▪ Instead, use xcrun and shell aliases
  94. When Not to Install the Package •Do not install just

    to get svn or git ▪ Instead, use xcrun and shell aliases •Do not install unless you need them
  95. When Not to Install the Package •Do not install just

    to get svn or git ▪ Instead, use xcrun and shell aliases •Do not install unless you need them ▪ Only one instance of command line tools
  96. When Not to Install the Package •Do not install just

    to get svn or git ▪ Instead, use xcrun and shell aliases •Do not install unless you need them ▪ Only one instance of command line tools ▪ Install is distinct from Xcode
  97. When Not to Install the Package •Do not install just

    to get svn or git ▪ Instead, use xcrun and shell aliases •Do not install unless you need them ▪ Only one instance of command line tools ▪ Install is distinct from Xcode ▪ Requires manual effort to keep up-to-date with new releases
  98. Primary Xcode Command Line Tools Tool Summary xcode-select xcodebuild xcrun

    man Choose the default Xcode.app to use Build, archive, and query Xcode projects and workspaces Find and execute command line tools that are inside Xcode Access to command line documentation
  99. Common xcode-select Options Option Usage -print-path -switch <path> Show the

    currently selected Xcode Developer directory Switch to the given Xcode (or Developer directory)
  100. Common xcodebuild Options Option Usage -workspace <name> -project <name> -scheme

    <name> -sdk <name> -showsdks -list -showBuildSettings NAME=VALUE Select a project or workspace to operate on Select a scheme to use Select an SDK to use List available SDKs List schemes or targets for active project or workspace List active build settings and their values Override a build setting with a particular value
  101. Common xcrun Options Option Usage -find <name> -sdk <name> <tool>

    ... args ... Find a tool in the active Xcode Select an SDK to perform lookups in Find and execute the tool with the provided arguments
  102. More Information Michael Jurewitz Developer Tools Evangelist [email protected] Documentation Xcode

    Build Setting Reference http://developer.apple.com man Pages http://developer.apple.com (or man <toolname> on the command line) Apple Developer Forums http://devforums.apple.com
  103. Related Sessions Working with Schemes and Projects in Xcode Marina

    Wednesday 4:30PM Building, Archiving, and Submitting Your App Pacific Heights Thursday 4:30PM
  104. Labs Xcode Lab Developer Tools Lab B Daily 9:00AM Xcode

    Lab Developer Tools Lab B Daily 2:00PM
  105. Summary •Xcode provides a number of tools for working on

    the command •Use xcodebuild to script and automate builds
  106. Summary •Xcode provides a number of tools for working on

    the command •Use xcodebuild to script and automate builds ▪ Use build settings and schemes to customize to your project
  107. Summary •Xcode provides a number of tools for working on

    the command •Use xcodebuild to script and automate builds ▪ Use build settings and schemes to customize to your project •Consider using continuous integration to improve development
  108. Summary •Xcode provides a number of tools for working on

    the command •Use xcodebuild to script and automate builds ▪ Use build settings and schemes to customize to your project •Consider using continuous integration to improve development •Use the Command Line Tools package when working outside Xcode