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

Secret History: xcconfig files

Secret History: xcconfig files

Slides from presentation given at CocoaHeads Hamburg January 2017 meet up.

Renzo Crisóstomo

January 05, 2017
Tweet

More Decks by Renzo Crisóstomo

Other Decks in Programming

Transcript

  1. XCCONFIG > No actual documentation provided by Apple WRONG! >

    Best docs provided by Samantha Marshall (holds true) > Supplemental file that replaces build settings in Xcode projects
  2. WHAT CAN IT DO? > Override build settings > Inherit

    values from existing settings: $(inherited) > Conditionally override > Import settings from other xcconfig files
  3. CONDITIONAL OVERRIDE > Conditions: sdk, arch, config, variant (?), dialect1

    (?) GCC_PREPROCESSOR_DEFINITIONS[config=OmnitureTest] = $(inherited) OMNITURE_ENABLED=1 1 *: Google this one, you'll have a good !
  4. INHERITANCE RULES 1. Platform defaults 2. Project file 3. xcconfig

    file for the Project file 4. Target 5. xcconfig file for the target file
  5. VALUE ASSIGNMENT RULES 1. Platform defaults 2. xcconfig file for

    the Project file 3. Project file 4. xcconfig file for the target file 5. Target
  6. VARIABLE SUBSTITUTION > String interpolation GCC_PREPROCESSOR_DEFINITIONS = $(inherited) CONFIGURATION_$(CONFIGURATION)=1 >

    Resolved for Debug configuration as: GCC_PREPROCESSOR_DEFINITIONS = $(inherited) CONFIGURATION_Debug=1
  7. RESULT #include "default.xcconfig" OTHER_LDFLAGS_Debug = $(inherited) -lz -framework "Reveal" OTHER_LDFLAGS_Release

    = $(inherited) OTHER_LDFLAGS = $(inherited) $(OTHER_LDFLAGS_$(CONFIGURATION))
  8. USE: VARIABLE SUBSTITUTION setting PRODUCT_NAME use WRAPPER_EXTENSION { for app

    { "My App" } for xctest { "Unit Test Bundle" } for bundle { "Generic Bundle" } }
  9. RESULT PRODUCT_NAME_app = "My App" PRODUCT_NAME_xctest = "Unit Test Bundle"

    PRODUCT_NAME_bundle = "Generic Bundle" PRODUCT_NAME = $(PRODUCT_NAME_$(WRAPPER_EXTENSION))
  10. IF: CONDITIONAL ASSIGNMENT setting PRODUCT_NAME { if arch=i386 { libIntel32

    } if arch=x86_64 { libIntel64 } if arch=armv7 { libArm32 } if arch=arm64 { libArm64 } }
  11. ADVANTAGES > DSL is more readable that legacy plist format

    > Less changes in xcodeproj file_size = targets * configuration
  12. DISADVANTAGES > Restart Xcode to apply xcconfig changes (! dup.)

    > Migration could be some effort xcodebuild -showBuildSettings