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

Closed source is best source

Closed source is best source

Releasing a private Swift framework using Cocoapods, Fastlane and some command line tools.

Romain Pouclet

November 19, 2016

Transcript

47 slides
  1. Hi, I'm Romain · @Palleas on Github, Twitter... · iOS

    developer at Mirego · I love Continuous Integration (it's a disease)
  2. Context · Currently working on a project for a super

    secret client I can't tell you about but OMG it's cool · Working on reusable components for other teams in the company · Unable to give them access to the sources (for now)
  3. Creating the framework let emojis = ["!", """, "#", "$"]

    public func nicify(_ string: String) -> String { let emoji = emojis[Int(arc4random_uniform(UInt32(emojis.count)))] return "\(string) \(emoji)" }
  4. Cocoapods-packager · Does not seem to play well with Swi!

    · Not actively maintained by the community https://github.com/CocoaPods/cocoapods- packager
  5. Carthage · Carthage is cool · Carthage is slow ·

    Carthage mostly-only works with Github https://github.com/Carthage/Carthage
  6. Sweat, tears and command line · Customize the whole process

    · Learn a lot about frameworks · Still rely on cocoapods
  7. The goal · Build a framework · Put it on

    a server somewhere · Make it available via Cocoapods over HTTPS
  8. Switching to the command line with lipo Lipo is a

    command line tool to interact with The lipo command creates or operates on universal files.
  9. Switching to the command line with lipo lipo -info BeingNiceIsNice.framework/BeingNiceIsNice

    Architectures are: i386 x86_64 Architectures are: * i386 * x86_64
  10. Building the framework (iphone) xcodebuild -scheme BeingNiceIsNice -arch armv7 -arch

    armv7s -arch armv64 -sdk iphoneos only_active_arch=no
  11. Merging the frameworks? Lipo is a command line tool to

    interact with universal files. So let's interact. lipo -create -output "BeingNiceIsNice.framework/BeingNiceIsNice" \ "build/Release-iphoneos/BeingNiceIsNice.framework/BeingNiceIsNice" \ "build/Release-iphonesimulator/BeingNiceIsNice.framework/BeingNiceIsNice"
  12. Add the missing slices · Copy the *.swiftmodule file from

    the simulator framework to the new one cp -r "BeingNiceIsNice.framework/Modules/BeingNiceIsNice.swiftmodule/" "BeingNiceIsNice.framework/Modules/BeingNiceIsNice.swiftmodule"
  13. What did we do? · Built the framework for the

    simulator architectures · Built the framework for the devices architectures · Merged two frameworks into a single one
  14. Fastlane · Fastlane is the easiest way to automate building

    and releasing apps (seriously) · Written in ruby · 500+ contributors · Great documentation · Great community
  15. Fastfile platform :ios do # ... desc "Deploy a new

    version to the App Store" lane :release do # release the framework end end
  16. Packaging with fastlane · Bump the version number · Build

    the project · Zip the framework · Make it available via cocoapods
  17. Make it available via cocoapods Pod::Spec.new do |s| s.name =

    "BeingNiceIsNice" s.version = "0.4.6" # ... s.source = { :http => "http://some-server.com/BeingNiceIsNice-#{s.version}.zip" } s.vendored_frameworks = "BeingNiceIsNice.framework" end
  18. Using the framework source 'secret-podspecs' # ⚠ target 'BeingNiceIsHard' do

    # Comment the next line if you're not using Swift and don't want to use dynamic frameworks use_frameworks! pod 'BeingNiceIsNice' end

More Decks by Romain Pouclet

Other Decks in Programming