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

xcconfig pitfalls

E2c86baa99178b8400a2ef49ef861a6c?s=47 toshi0383
September 17, 2017

xcconfig pitfalls

presented at iOSDC Japan 2017

E2c86baa99178b8400a2ef49ef861a6c?s=128

toshi0383

September 17, 2017
Tweet

Transcript

  1. xcconfig pitfalls (LT) iOSDC 2017 Sep 17, 2017 Toshihiro Suzuki

    © Toshihiro Suzuki 2017 1
  2. whoami — ླ໦ ढ़༟ (@toshi0383) Toshihiro Suzuki — iOS/tvOS Dev

    at AbemaTV — Father (5 month) — F1, GT SPORT © Toshihiro Suzuki 2017 2
  3. tools and apps https://toshi0383.github.io/LGTM © Toshihiro Suzuki 2017 3

  4. Agenda — What's xcconfig and Why would you use it?

    — Common Pitfails © Toshihiro Suzuki 2017 4
  5. What's xcconfig? where you put your build se!ings © Toshihiro

    Suzuki 2017 5
  6. How it looks on Xcode © Toshihiro Suzuki 2017 6

  7. How it looks inside xcconfig © Toshihiro Suzuki 2017 7

  8. Why? — Easier to review in Pull requests — Refactor

    using #include — Reusable © Toshihiro Suzuki 2017 8
  9. Recommended way to extract — Extract using toshi0383/xcconfig-extractor — Validate

    using xcodebuild -showBuildSettings © Toshihiro Suzuki 2017 9
  10. Let's Do it ! CONFIGURATION =-configuration Debug WORKSPACE =-workspace iOSSingleViewApp.xcworkspace

    SCHEME =-scheme iOSSingleViewApp OPTIONS=$(CONFIGURATION) $(WORKSPACE) $(SCHEME) xcodebuild -showBuildSettings $(OPTIONS) > before xcconfig-extractor --no-trim-duplicates *.xcodeproj Config/xcconfigs xcodebuild -showBuildSettings $(OPTIONS) > after diff before after © Toshihiro Suzuki 2017 10
  11. Sample App © Toshihiro Suzuki 2017 11

  12. Result © Toshihiro Suzuki 2017 12

  13. $(inherited) is ignored ! — ./Config/xcconfigs/iOSSingleViewApp-Debug.xcconfig FRAMEWORK_SEARCH_PATHS = $(inherited) $

    (PROJECT_DIR)/Carthage/Build/iOS — ./Pods/Target Support Files/Pods-iOSSingleViewApp/ Pods-iOSSingleViewApp.debug.xcconfig FRAMEWORK_SEARCH_PATHS = $(inherited) "$ {PODS_ROOT}/TwitterCore/iOS" "${PODS_ROOT}/ TwitterKit/iOS" © Toshihiro Suzuki 2017 13
  14. On CI.. e.g. fastlane's increment_version_number depends on agvtool © Toshihiro

    Suzuki 2017 14
  15. Migration failed! — Unwanted FRAMEWORK_SEACH_PATHS diff ! — Failed to

    increment version using agvtool © Toshihiro Suzuki 2017 15
  16. How $(inherited) works? — Inherites from parent LEVEL's value in

    Build Settings — Does NOT work for #include © Toshihiro Suzuki 2017 16
  17. App's FRAMEWORK_SEACH_PATHS overwri!en CocoaPods's © Toshihiro Suzuki 2017 17

  18. Fix ✅ Set FRAMEWORK_SEACH_PATHS in rootObject's xcconfig © Toshihiro Suzuki

    2017 18
  19. Why agvtool failed to update version? — Answer: agvtool is

    not clever enough — It does NOT search for INFOPLIST_FILE value in xcconfig. © Toshihiro Suzuki 2017 19
  20. Workaround #1 Restore INFOPLIST_FILE in Xcode's buildSettings section © Toshihiro

    Suzuki 2017 20
  21. Workaround #2 Use /usr/libexec/PlistBuddy instead of agvtool e.g. APP_VERSION=$(git describe

    --tags --abbrev=0) BUILD_VERSION=$BITRISE_BUILD_NUMBER /usr/libexec/PlistBuddy -c "Set :CFBundleShortVersionString ${APP_VERSION}" AbemaTV/Info.plist /usr/libexec/PlistBuddy -c "Set :CFBundleVersion ${BUILD_VERSION}" AbemaTV/Info.plist © Toshihiro Suzuki 2017 21
  22. Summary © Toshihiro Suzuki 2017 22

  23. $(inherited) — works btw LEVELs but not for #include INFOPLIST_FILE

    — agvtool compatibility © Toshihiro Suzuki 2017 23
  24. xcconfig-extractor Options: --no-trim-duplicates [default: false] --no-edit-pbxproj [default: false] --include-existing [default:

    true] --no-set-configurations [default: false] © Toshihiro Suzuki 2017 24
  25. End © Toshihiro Suzuki 2017 25

  26. Toshihiro Suzuki Feel free to reach out! Twitter: @toshi0383 GitHub:

    @toshi0383 Qiita: @toshi0383 Email: t.suzuki326@gmail.com © Toshihiro Suzuki 2017 26