CocoaPods          More than you need to know.         @CocoaPods • cocoapods.org • github.com/CocoaPods                  ...
What is it?It’s a... [DRUMROLL] ... dependency manager. Boring, I know :)
CocoaPods is like a combination of the RubyGems and Bundler projects. For those not familiarwith them (which I highly doub...
How is it used in             Objective-C projects?The average CocoaPods user will be a Objective-C user, so first let me d...
TODO Add video that         shows manual process.Video showing the ‘normal’ way of including third-party code. See https:/...
Video showing the same process, but handled by CocoaPods. See https://vimeo.com/63891716.
RubyMotion greatly  simplifies the build process.There are no pesky platform or deployment target specific build settings or...
Can’t we just Rubyify               ALL THE LIBS?!There are good reasons to use battle-tested objective-c libraries vs cre...
Too much dependencies             will kill you.Some feel that dependency managers are bad for communities/produced produc...
Minimal Dependency Policy.For instance, at Fingertips we have a ‘minimal dependency policy’. It’s surprisingly easy tofoll...
1. Second guess yourself.Do I really, really need this? Or is my object-oriented-abstract-away-all-the-details mindplaying...
1. Second guess yourself.  2. Will it solve my problem?Does the library I want to use fit my problem really well or am I be...
1. Second guess yourself.  2. Will it solve my problem?  3. Should I use this library?Sometimes using another library allo...
1. Second guess yourself. 2. Will it solve my problem? 3. Should I use this library? 4. Check child dependencies   and wei...
Details, details, details…
“Bundler has                 destroyed my life”                   – Carl LercheThis quote has been my guide to staying san...
Git ‘spec repo’ architecture        versus hosted like          rubygems.org?It has allowed us to focus on the important w...
Using the filesystem as the ‘database’ and distributing it through Git has proven to be anextremely flexible way to deal wit...
The future is out there.
Centralized specification          authority serviceThis is primarily meant to have access-control. This will work exactly ...
Download count                      web-applicationSomething that has been asked for by the community on many occasions, i...
CocoaDocs.orgCocoaDocs is a side project created by one of our spec maintainers, namely Orta Therox.If you’re familiar to ...
Magic is hard work.
1. Resolve dependenciesFind child dependencies and fail in case of a conflict.CocoaPods does do dependency resolution, but ...
1. Resolve dependencies       2. Fetch library sourcesFrom git/svn/mercurial, http tarballs/zipballs, or a local developme...
1. Resolve dependencies        2. Fetch library sources        3. Collect build-settingsPer Pods target.
1. Resolve dependencies       2. Fetch library sources       3. Collect build-settings       4. Create Xcode projectAh yes...
1. Resolve dependencies     2. Fetch library sources     3. Collect build-settings     4. Create Xcode project    5. User ...
1. Resolve dependencies    2. Fetch library sources     3. Collect build-settings     4. Create Xcode project   5. User pr...
Available Libraries      1250      1000       750       500       250         0        Sep 2011 Nov Jan 2012 Mar       May...
CocoaPods Downloads Over All Minor Versions    105000     78750     52500     26250          0               .0   .1   .2 ...
It needs a lot more attention.
Improve command-line          interface experience.With objc projects, people run `pod install` only when they need it. Ru...
Support multiple targets.In objc projects it is quite common to build multiple ‘targets’, e.g. apps, from one project.Ruby...
Support different                    configurations.E.g. within one target, configure dependencies differently based on debu...
Translate API                  documentation for                     RubyMotionAs we saw before, CocoaPods already generat...
We Need Yougithub.com/HipByte/motion-cocoapods
63 contributors to the CocoaPods tool repo and 100 contributors on the specs repo.For all of these people, and companies t...
One More Thing
Version 0.17 NOW!    $ gem install cocoapods$ gem install motion-cocoapods
@CocoaPods    cocoapods.orggithub.com/CocoaPods      @alloy   @fabiopelosin   @SmileyKeith      @orta
Upcoming SlideShare
Loading in...5
×

RubyMotion Inspect Conference - 2013. (With speaker notes.)

612

Published on

CocoaPods talk given at the RubyMotion Inspect 2013 conference.

There is another version that does not include speaker notes available at: https://www.slideshare.net/alloy020/ruby-motion-inspect-2013-without-notes-18676749

The videos that were shown on slide 5 and 6 are available at: https://vimeo.com/63891717 & https://vimeo.com/63891716.

Published in: Technology, Education
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
612
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
16
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

Transcript of "RubyMotion Inspect Conference - 2013. (With speaker notes.)"

  1. 1. CocoaPods More than you need to know. @CocoaPods • cocoapods.org • github.com/CocoaPods Eloy Durán • @alloyI will not be speaking about testing today, but please feel free to ask me anything on thesubject. After the talk, of course ;)So, CocoaPods, what is it?
  2. 2. What is it?It’s a... [DRUMROLL] ... dependency manager. Boring, I know :)
  3. 3. CocoaPods is like a combination of the RubyGems and Bundler projects. For those not familiarwith them (which I highly doubt); RubyGems is a Ruby source package manager. It takes careof fetching and installing a package, _plus_ its dependencies, into a central location on thesystem. Bundler uses RubyGems to retrieve packages, but instead installs these locally on aper-project basis.In addition, RubyGems provides an ‘ecosystem’ where open-source libraries can more easilybe discovered.So like I said before, CocoaPods is a combination of these projects. That is, it provides thetools to manage dependencies on a per-project basis and it provides an ‘ecosystem’ foropen-source libraries to be found and flourish in the form of a repository of specifications foropen-source libraries, which are searchable through cocoapods.org or from the command-line.The complete ‘CocoaPods’ project encompasses the tools – ‘Xcodeproj’ and ‘CocoaPods’ –and the library specifications. These are all written in Ruby. In fact, CocoaPods re-uses someclasses from RubyGems.So how does working with CocoaPods work?
  4. 4. How is it used in Objective-C projects?The average CocoaPods user will be a Objective-C user, so first let me do a quick rundown ofwhat that looks like.‘Normal’ usage:* DRAG THE SOURCES, LUKE!* Add subproject* Then apply all the required settings.Doing it the ‘normal’ way leads to issues with for instance shared dependencies. This willlead to duplicated symbols, which can be solved manually, but if you’re using for instancesubmodules, then you have local changes, so you need a fork, yada yada yada. It’s a pain.[Show AFNetworking example movie 1]
  5. 5. TODO Add video that shows manual process.Video showing the ‘normal’ way of including third-party code. See https://vimeo.com/63891717.
  6. 6. Video showing the same process, but handled by CocoaPods. See https://vimeo.com/63891716.
  7. 7. RubyMotion greatly simplifies the build process.There are no pesky platform or deployment target specific build settings or any compilerflags.[Show Pods.xcconfig in Terminal]
  8. 8. Can’t we just Rubyify ALL THE LIBS?!There are good reasons to use battle-tested objective-c libraries vs creating new ones.* In general, it’s often a good idea to use a lib that others use as well, because there is morechance that others will be contributing to make the lib better. And since there are in generalmore Objective-C devs than RubyMotion devs (which I totally pull out of thin air, I have noempirical data to back this up), this makes sense.But more importantly... [Next slide!]
  9. 9. Too much dependencies will kill you.Some feel that dependency managers are bad for communities/produced products, becauseit makes it too easy to fall for ‘widget shopping’.There are all sorts of philosophical debates we could have about this, but for now let’s keep itat that it’s the users that need to be responsible, not the tool.In this context, it is of the utmost importance to remember that deploying updates on iOSthrough the AppStore is very expensive. By which I mean, releasing a bug-fix update canquickly take around a week to be available. Given this, it’s very important to keep beingresponsible in mind.
  10. 10. Minimal Dependency Policy.For instance, at Fingertips we have a ‘minimal dependency policy’. It’s surprisingly easy tofollow; when you work on a new feature and want to add a dependency you ask yourself ifyou really need it.Minimal dependency is not just about the number of libraries you use, but also about thetotal amount of code you pull into your project. Less code means less bugs.Finally, less dependencies makes long-term maintenance easier because there is less that cango wrong when it’s time to upgrade to a new major iOS version.So, with that all in mind:
  11. 11. 1. Second guess yourself.Do I really, really need this? Or is my object-oriented-abstract-away-all-the-details mindplaying tricks on me?
  12. 12. 1. Second guess yourself. 2. Will it solve my problem?Does the library I want to use fit my problem really well or am I better off writing 20 lines ofcode myself? For example: pull in AFNetworking or use plain NSURLConnection?
  13. 13. 1. Second guess yourself. 2. Will it solve my problem? 3. Should I use this library?Sometimes using another library allows you to drop one you were using for another feature.For example: use AFNetworking for both networking and JSON serialization/de-serializationand drop JSONKit. (AFNetworking will use NSJSONSerialization when available.)[Actually I think they dropped any other support than NSJSONSerialization, but the generalidea still holds.]
  14. 14. 1. Second guess yourself. 2. Will it solve my problem? 3. Should I use this library? 4. Check child dependencies and weigh it against the benefit of using it.For example: add your own UIAlertView block delegate custom class instead of usingBlocksKit, which pulls in libffi.
  15. 15. Details, details, details…
  16. 16. “Bundler has destroyed my life” – Carl LercheThis quote has been my guide to staying sane. There is only so much that we can, but moreimportantly, *want* to do in our spare-time. So we took a conservative naive approach andfollowed it religiously.
  17. 17. Git ‘spec repo’ architecture versus hosted like rubygems.org?It has allowed us to focus on the important work first, which is obviously the actualdependency resolving and installation, instead of having to first create a specification serveras well.The thing is, we take a very agile approach to this whole thing, meaning that until CP 1.0, wereserve the right to add/update/remove any of the spec DSL at will. (We do generallydeprecate, but we won’t allow ourselves to be restricted by this.) So given this, it would havebeen very hard to keep the specs themselves up-to-date and the server features mightinfluence the design process in a limiting fashion.We don’t want that, so we ‘keep it simple, silly’.
  18. 18. Using the filesystem as the ‘database’ and distributing it through Git has proven to be anextremely flexible way to deal with these types of spec changes.That is, when we add, remove, or update an attribute, we can very easily go back and updateall of the specifications or even merge those changes back into to the ‘master’ branch onlyonce a new version is released.Finally, in order to push adoption, it is **very** important to recognize that Objective-C hasbeen used in commercial settings for a very long time already. Companies already tend tohave _private_ internal frameworks and not catering to those would make it hard for them toadopt CocoaPods for all of their open-source needs and in turn wouldn’t push them to open-source more of their internal code. With CocoaPods, these companies only need to add anextra Git repository in `~/.cocoapods/` that contains specifications for their _private_frameworks and **BOOM**, they’re in business.
  19. 19. The future is out there.
  20. 20. Centralized specification authority serviceThis is primarily meant to have access-control. This will work exactly the same as RubyGemscurrently does: first pusher is owner and owners can add other owners.This has a very high priority, because the number of spec contributors has grown too large torely purely on a trust based system. For instance, not too long ago, someone pushed a specfor AFNetworking for an non-existing version, this is obviously NOT cool when the author ofthe lib actually maintains the lib specs.The way it will work is roughly like follows:* Person creates spec and lints it locally.* CP creates a serialized version of the spec (YAML/JSON) and posts it together with theactual spec to the ‘push’ service.* The ‘push’ service checks if a previous version of the lib has been pushed and if so checkswether the person is authorized to push a new version.* The ‘push’ service creates a pull-request on the spec repo, which in turn notifies Travis toperform a full-lint. (Yes, Travis has mac workers in beta.) Once Travis notifies the ‘push’service that the spec has passed, it will automatically merge the pull-request.* If for some reason the build doesn’t finish (e.g. network outage), we can easily trigger a newbuild or even perform the lint checks ourselves.This process means we can add a control layer, while still keeping the flexibility of dealingwith the specs through Git and GitHub.
  21. 21. Download count web-applicationSomething that has been asked for by the community on many occasions, is stats on thingslike download-count of libs.Since in our architecture we don’t actually serve any packages, we aren’t able to countdownloads this way. Together with Mattt (of Heroku), we’ve been thinking about this andconcluded that the best way to go about it is to, again, be naive. The app will have a ‘counter’endpoint, to which CP will post the libraries that it has downloaded during installation.One problem with this was that we don’t want to count libs that we don’t actually hostthrough the ‘master’ spec repo (e.g. private libs), but with the ‘push’ service on the horizonthis will no longer be an issue, as we already have a DB in the cloud that contains a list of allthe libs it knows of.In short, sometime in the near future, our website will not only provide info on the availablelibs, but also how many times they have been downloaded.Now to be clear, this stat is only really meant for the owners. For end-users this metric is niceto have, but it doesn’t say anything about the quality of a lib.Moreover, since we count by accepting count POSTs, we will not show overall ranks, becausewe do not want people to try and game the system.
  22. 22. CocoaDocs.orgCocoaDocs is a side project created by one of our spec maintainers, namely Orta Therox.If you’re familiar to rubydoc.info, this is essentially the same kind of service. So everytime anew spec is pushed to the spec repo, this application receives a notification and will builddocumentation for the lib by using the appledoc tool.It’s still very much in development and currently only has docs for the most recent libs. Thenagain, this is not yet officially released, but it’s a great example of how we can help thecommunity, even if they wouldn’t use CocoaPods.Actually, he at some point generated docs for ALL OF THE LIBRARIES an it works, butobviously this takes at least a whole night, so it’s not very helpful while he’s still working onit.
  23. 23. Magic is hard work.
  24. 24. 1. Resolve dependenciesFind child dependencies and fail in case of a conflict.CocoaPods does do dependency resolution, but it does not automatically resolve conflicts.This means that, when a conflict occurs, CocoaPods will raise an error and leave conflictresolving up to the user. (The user can do this by depending on a specific version of acommon dependency before requiring the dependencies that lead to the conflict.)If you’re familiar with Ruby then you can compare the former (the current CocoaPods style) toRubyGems’ style resolution and the latter (with conflict resolving) to Bundler’s.Adding conflict resolution to CocoaPods is on our TODO list and we will try to work with theBundler team to see if we can share their algorithm, but this will be one of the last thingswe’ll work on. A feature like this will require a stable basis and since we’re not there yet,working on it now would only make working on the basis more complex than necessary.
  25. 25. 1. Resolve dependencies 2. Fetch library sourcesFrom git/svn/mercurial, http tarballs/zipballs, or a local development repo.
  26. 26. 1. Resolve dependencies 2. Fetch library sources 3. Collect build-settingsPer Pods target.
  27. 27. 1. Resolve dependencies 2. Fetch library sources 3. Collect build-settings 4. Create Xcode projectAh yes, the Xcode document format.
  28. 28. 1. Resolve dependencies 2. Fetch library sources 3. Collect build-settings 4. Create Xcode project 5. User project integrationAh yes, the Xcode document format, again.
  29. 29. 1. Resolve dependencies 2. Fetch library sources 3. Collect build-settings 4. Create Xcode project 5. User project integration 6. Create API documentionLike RubyGems does, we generate API documentation for each library by using the appledoctool and we install that into the Xcode documentation viewer. (This also works with Dash.appin case you do not love Xcode, for some reason…)[SHOW example of AFNetworking docs in Xcode]The appledoc tool is unfortunately not complete yet and misses some information likeconstants, but hopefully work on CocoaDocs.org will eventually lead to completing appledoccoverage.
  30. 30. Available Libraries 1250 1000 750 500 250 0 Sep 2011 Nov Jan 2012 Mar May Jul Sep Nov Jan 2013 MarYou can definitely see that people have better things to do in the summer than creatingspecs. (June/July)
  31. 31. CocoaPods Downloads Over All Minor Versions 105000 78750 52500 26250 0 .0 .1 .2 .3 .4 .5 .6 .7 .8 .9 .10 .11 .12 .13 .14 .15 .16The only version range that had 0 downloads was 0.4.x, because I accidentally skipped it :)
  32. 32. It needs a lot more attention.
  33. 33. Improve command-line interface experience.With objc projects, people run `pod install` only when they need it. RubyMotion’s buildprocess runs every time a build has to be made, so it needs better heuristics on when to doany work at all. As CocoaPods becomes smarter itself, this becomes less of an issue duringnormal usage, but things like updating the spec repos when there is no internet connectionavailable should be avoided.Actually, we have improved this a lot in the upcoming 0.17 version and it should already be alot nicer. But there is probably still room for improvement.
  34. 34. Support multiple targets.In objc projects it is quite common to build multiple ‘targets’, e.g. apps, from one project.RubyMotion does this too, but is normally limited to an ‘app’ target and a ‘test’ target.Currently the CocoaPods integration is limited to just the ‘app’ target, though. While I think itmight be uncessary to open up full multiple target support, there should be standard supportfor including dependencies specific to the RubyMotion test target.
  35. 35. Support different configurations.E.g. within one target, configure dependencies differently based on debug / release / deploy.This is still lacking form CocoaPods itself and should really be fixed there. Having said that, Ican imagine that with RubyMotion’s build system and handling of configurations it might bevery simple to already implement this in motion-cocoapods.
  36. 36. Translate API documentation for RubyMotionAs we saw before, CocoaPods already generates API docs for each library, however, these areof course all in Objective-C. What would be great is to integrate the RubyMotion doc tool totranslate these generated docs for RubyMotion.[Where does the tool actually live? Is it on GitHub?]
  37. 37. We Need Yougithub.com/HipByte/motion-cocoapods
  38. 38. 63 contributors to the CocoaPods tool repo and 100 contributors on the specs repo.For all of these people, and companies that have sponsored work on CocoaPods or provideservices, I’d like a big applause, for this would never have been possible without all of theirlove and care.[MAKE HEART LOVE SIGN]Oh, and one more thing…
  39. 39. One More Thing
  40. 40. Version 0.17 NOW! $ gem install cocoapods$ gem install motion-cocoapods
  41. 41. @CocoaPods cocoapods.orggithub.com/CocoaPods @alloy @fabiopelosin @SmileyKeith @orta

×