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

Bringing CocoaPods to Linux

Bringing CocoaPods to Linux

Talk on build systems and abstracting them inside CocoaPods. Given at NSSpain 2015. 🍷

9d2ea021919ff81e02d48530aae191bd?s=128

Boris Bügling

September 16, 2015
Tweet

Transcript

  1. Bringing CocoaPods to Linux NSSpain, September 2015 Boris Bügling -

    @NeoNacho
  2. CocoaPods dependency management ✅

  3. Contentful content management ✅

  4. Xcode?

  5. Agenda 4 Why? 4 Xcode's build system 4 How does

    CocoaPods interact with it? 4 Alternatives 4 Plan
  6. None
  7. None
  8. None
  9. No Xcode on Linux

  10. Xcode is broken

  11. ya tu sabes

  12. Quora Post from early 2014

  13. Just two examples 4 Archiving watchOS 2.0 apps 4 CLANG_ENABLE_MODULES

  14. [Xcode 7 beta] Linking dual (iphoneos and watchos) frameworks with

    same product name causes archive to fail http://openradar.appspot.com/22392501
  15. None
  16. CLANG_ENABLE_MODULES

  17. Enables the use of modules for system APIs. System headers

    are imported as semantic modules instead of raw headers.
  18. "system APIs" == any framework outside your target !

  19. None
  20. Bring back CocoaPods to its core and move rest (e.g.

    Xcode integration) into plugins. #2729 From October 2014 https://github.com/CocoaPods/CocoaPods/issues/ 2729
  21. Solve everyday problems for Cocoa and Xcode developers.

  22. Let's face it, programming sucks.

  23. Xcode's build system

  24. 4 Fairly old (Xcode3Core.ideplugin) 4 Entirely based on mtimes 4

    Poorly documented
  25. De-facto documentation 4 http://pewpewthespells.com/blog/ managing_xcode.html 4 http://pewpewthespells.com/blog/ buildsettings.html

  26. Xcode project files !"#

  27. Tomorrow 16:30 - 17:00 Grant Paul - Making Sense of

    Xcode
  28. How does CocoaPods interact with it?

  29. 4 Pods project 4 Integration into the user project 4

    Linting
  30. Pods project 4 Generated by our Xcodeproj gem 4 Targets

    for all Pods 4 XCConfig files
  31. Private XCConfig #include "ContentfulDeliveryAPI.xcconfig" GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 HEADER_SEARCH_PATHS =

    "${PODS_ROOT}/Headers/Private" "${PODS_ROOT}/Headers/Private/ContentfulDeliveryAPI" "${PODS_ROOT}/Headers/Public" "${PODS_ROOT}/Headers/Public/AFNetworking" "${PODS_ROOT}/Headers/Public/Bypass" "${PODS_ROOT}/Headers/Public/CGLMail" "${PODS_ROOT}/Headers/Public/ContentfulDeliveryAPI" "${PODS_ROOT}/Headers/Public/ContentfulDialogs" "${PODS_ROOT}/Headers/Public/ContentfulPersistence" "${PODS_ROOT}/Headers/Public/ContentfulStyle" "${PODS_ROOT}/Headers/Public/DDPageControl" "${PODS_ROOT}/Headers/Public/EDColor" "${PODS_ROOT}/Headers/Public/FBSnapshotTestCase" "${PODS_ROOT}/Headers/Public/ISO8601DateFormatter" "${PODS_ROOT}/Headers/Public/LatoFont" "${PODS_ROOT}/Headers/Public/TSMiniWebBrowser@dblock" OTHER_LDFLAGS = ${CONTENTFULDELIVERYAPI_OTHER_LDFLAGS} -ObjC PODS_ROOT = ${SRCROOT} SKIP_INSTALL = YES
  32. Build settings 4 GCC_PREPROCESSOR_DEFINITIONS 4 HEADER_SEARCH_PATHS 4 OTHER_LDFLAGS

  33. None
  34. User project 4 Optional integration (--no-integrate) 4 Implicit target dependencies

    4 XCConfig files
  35. Public XCConfig CONTENTFULDELIVERYAPI_OTHER_LDFLAGS = -framework "MapKit" -framework "UIKit"

  36. If you edit OTHER_LDFLAGS in your project, settings will be

    copied.
  37. Build phases

  38. Linting 4 Shells out to xcodebuild

  39. Alternatives

  40. Makefiles

  41. package: $(EXECUTABLE_NAME) $(INFO_PLIST) mkdir -p "$(PRODUCT_NAME).app" @/bin/echo -n 'AAPL' >

    "$(PRODUCT_NAME).app/PkgInfo" @$(PLBUDDY) -c 'Print CFBundleSignature' $(INFO_PLIST) \ >> "$(PRODUCT_NAME).app/PkgInfo" cp $(EXECUTABLE_NAME) "$(PRODUCT_NAME).app" $(BASE_DIR)/sh/build_plist $(INFO_PLIST) "$(PRODUCT_NAME).app/Info.plist" $(BASE_DIR)/sh/build_ipa "$(PRODUCT_NAME).app" $(EXECUTABLE_NAME): $(OBJS) $(LD) $(CFLAGS) $(LDFLAGS) -o $@ $^
  42. Makefiles 4 Build rules to transform files (e.g. .m =>

    .o) 4 Based on mtimes 4 "Phony" rules which run unconditionally 4 Dependencies to files or other rules 4 Exists everywhere
  43. Rules target: dependencies build step(s)

  44. Execution make [options] [target1 target2 ...]

  45. Buck

  46. None
  47. None
  48. None
  49. None
  50. None
  51. => no more DerivedData nonsense !

  52. Installation $ brew update $ brew tap facebook/fb $ brew

    install --HEAD buck
  53. Quickstart $ buck quickstart --type ios --dest-dir . [...] $

    buck build demo_app_ios [...] $ ls buck-out/gen/ios/BuckDemoApp BuckDemoApp.app BuckDemoApp.dSYM
  54. Initial build $ buck build demo_app_ios [...] [-] BUILDING...FINISHED 2.4s

    (8/8 JOBS, 8 UPDATED, 0.0% CACHE HITS) Subsequent builds $ buck build demo_app_ios [...] [-] BUILDING...FINISHED 0.0s (1/8 JOBS, 0 UPDATED)
  55. Faster iterations

  56. BUCK apple_binary( [...] ) xcode_project_config( name = 'Hello', src_target =

    ':Hello', action_config_names={'profile': 'Profile'} )
  57. Source files srcs = [ 'Code/AppDelegate.m' 'Code/ViewController.m', 'Code/main.m', ],

  58. Headers headers = [ 'Code/AppDelegate.h' 'Code/ViewController.h', ],

  59. Linked frameworks frameworks = [ '$SDKROOT/System/Library/Frameworks/Foundation.framework', '$SDKROOT/System/Library/Frameworks/UIKit.framework', ],

  60. Dependencies deps = [ '//Libraries/EXExample:EXExample', ],

  61. Buck does not support Swift !

  62. Plan

  63. Plan 4 Prototype with plugins ! 4 Abstraction for the

    build system 4 Mapping for build settings (*_xcconfig attributes) 4 ??? 4 Profit!
  64. Add a new platform

  65. Adding a new platform (tvos)

  66. Gemfile source 'https://rubygems.org' gem 'cocoapods', :git => 'https://github.com/CocoaPods/CocoaPods.git', :branch =>

    'tvos' gem 'cocoapods-core', :git => 'https://github.com/CocoaPods/Core.git', :branch => 'tvos-support' gem 'xcodeproj', :git => 'https://github.com/CocoaPods/Xcodeproj.git', :branch => 'tvos-support' Usage: $ bundle exec pod install
  67. Xcode is a leaky abstraction, try to learn what's underneath

    it.
  68. Thanks!

  69. https://www.facebook.com/events/ 1495505997428211/ _ @NeoNacho boris@contentful.com http://buegling.com/talks