$30 off During Our Annual Pro Sale. View Details »

Xcode Configuration Files

Xcode Configuration Files

What Xcode configuration (.xcconfig) files are, and why they might be useful to you.

Presented at the HelsinkiOS/CocoaHeads meetup on January 22, 2013.

Ali Rantakari

January 22, 2013
Tweet

More Decks by Ali Rantakari

Other Decks in Programming

Transcript

  1. Xcode configuration files
    Ali Rantakari
    HelsinkiOS / CocoaHeads • January 22, 2013

    View Slide

  2. Build Settings GUI

    View Slide

  3. [.xcconfig alloc]

    View Slide

  4. GUI vs Text
    GCC_PREPROCESSOR_DEFINITIONS = DEBUG=1 $(inherited)

    View Slide

  5. Unique pros
    Human readable names
    Comments
    Custom organization
    Better at avoiding repetition
    Discoverability

    View Slide

  6. Comments
    // I am disabling -Wunused-variable because goddamnit, I might
    // need those variables later! Who knows, right!
    //
    WARNING_CFLAGS = -Wall -Wno-unused-variable

    View Slide

  7. DRY to the max
    *_Common
    *_Debug *_Release
    #include
    #include

    View Slide

  8. DRY to the max
    LIBFOO_ROOT = $(SRCROOT)/MyApp/libfoo
    HEADER_SEARCH_PATHS = "$(LIBFOO_ROOT)/include"
    LIBRARY_SEARCH_PATHS = "$(LIBFOO_ROOT)/lib"
    (Yes, you can do this with the GUI as well, but this is nicer, no?)

    View Slide

  9. Inheritance
    WARNING_CFLAGS = -Wall
    Common.xcconfig
    #include "Common.xcconfig"
    WARNING_CFLAGS = $(inherited) -Wno-unused-variables
    Other.xcconfig
    (!!) does not do what you may think it does

    View Slide

  10. Inheritance
    WARNING_CFLAGS = $(inherited)
    App_Target_Debug.xcconfig
    inheritance
    project
    config
    target
    config
    Value of WARNING_CFLAGS in the project
    config

    View Slide

  11. If you must composite values…
    MY_COMMON_WARNING_CFLAGS = -Wall
    Common.xcconfig
    #include "Common.xcconfig"
    WARNING_CFLAGS = $(MY_COMMON_WARNING_CFLAGS) -Wno-unused-variables
    Other.xcconfig
    Set final composite value in “leaf” config
    file
    Use custom keys for intermediate values

    View Slide

  12. Resolved values
    = “first from the left”

    View Slide

  13. Demo

    View Slide