37
Women Who Code iOS Meetup 2016 AUG 21

Dependent things dependency management for apple sw - slideshare

Embed Size (px)

Citation preview

Women Who CodeiOS Meetup

2016 AUG 21

While on your journey of introducing a new experience for your amazing app you hit a decision point.

Do you develop write your own code or do you use something someone has written?

If you want to DIY, turn to page 57

If you want to use something someone has written, turn to page 154

What this talk IS covering

Dependency Management Options Pros and Cons of each

My personal bias

What this talk IS NOT covering

Application Architecture (kind of) Project Structure (sort of)

System Configuration (just a little)

154

Cocoapods in 5 “easy” steps$ sudo gem install cocoapods && pod setup —-verbose

$ pod init

$ pod install

$ nano Podfile

1

2

3

4

// sudo because it’s a global install // gem because it’s written in Ruby // Run setup… go take a break // if setup breaks… there’s a fix

// creates a ‘Podfile’ with defaults // Assumes you already are at the top level of your project

// (personal choice) use linux text editor for initial changes to Podfile

// select your platform // select the libraries you want to use // exit from the editor

// install libraries

5 $ open MyApp.xcworkspace // open workspace in XCode. W T H is a workspace?

# Uncomment this line to define a global platform for your project # platform :ios, '9.0'

target 'PrettyRandom' do # Comment this line if you're not using Swift and don't want to use dynamic frameworks use_frameworks!

# Pods for PrettyRandom pod 'CocoaLumberjack/Swift'

target 'PrettyRandomTests' do inherit! :search_paths # Pods for testing end

target 'PrettyRandomUITests' do inherit! :search_paths # Pods for testing end

end

# Uncomment this line to define a global platform for your project # platform :ios, '9.0'

target 'PrettyRandom' do # Comment this line if you're not using Swift and don't want to use dynamic frameworks use_frameworks!

# Pods for PrettyRandom pod 'CocoaLumberjack/Swift'

target 'PrettyRandomTests' do inherit! :search_paths # Pods for testing end

target 'PrettyRandomUITests' do inherit! :search_paths # Pods for testing end

end

I love homebrew

http://brew.sh

Carthage in 5 “easy”-ish steps $ brew install carthage

$ nano Cartfile

$ carthage update —-platform iOS

1

2

3

4

// shouldn’t take long

// it’s easier to start a Cartfile from here

// install libraries for the type of app you are building for

// extremely minimalistic

// This is platform dependent // you must manually link your libraries // It has to be done through the XCode UI

4?

github "CocoaLumberjack/CocoaLumberjack"

Carthage Step 4 (a) … (c)macOS

iOS, watchOS, tvOS

• On your application targets’ “General” settings tab, in the “Embedded Binaries” section, drag and drop each framework you want to use from the Carthage/Build folder on disk.

• On your application target’s “Build Phases” settings tab, click the “+” icon and choose “New Copy Files Phase”. • For each framework you’re using, drag and drop its corresponding dSYM file.

• On your application targets’ “General” settings tab, in the “Linked Frameworks and Libraries” section, drag and drop each framework you want to use from the Carthage/Build folder on disk.

• On your application targets’ “Build Phases” settings tab, click the “+” icon and choose “New Run Script Phase”. Create a Run Script in which you specify your shell (ex: bin/sh), add the following contents to the script area below the shell:

• and add the paths to the frameworks you want to use under “Input Files”, e.g.:

/usr/local/bin/carthage copy-frameworks

$(SRCROOT)/Carthage/Build/iOS/Box.framework $(SRCROOT)/Carthage/Build/iOS/Result.framework $(SRCROOT)/Carthage/Build/iOS/ReactiveCocoa.framework

Swift PM in 5

$ swift package init --type executable

$ swift package generate-xcodeproj

1

2

3

5

// creates a ‘Package.swift’ with defaults // Assumes you already are at the top level of your project

// depending on your internets, this could take a while

// add dependencies

// generates PrettyRandom.xcodeproj file

Install Xcode 8.0 (beta)

$ open PrettyRandom.xcodeproj

4

import PackageDescription

let package = Package(

name: "PrettyRandom",

dependencies: [ .Package(url: "https://github.com/thecb4/SwiftyJSON.git", versions: Version(3,0,2)..<Version(3,0,34)), ]

)

$ nano Package.swift

// open Xcode (beta) and realize nothing works because the library isn’t Swift 3 compatible

Swift PM in 5… Nevermind

$ swift package init --type executable

$ swift package generate-xcodeproj

1

2

3

5

// creates a ‘Package.swift’ with defaults // Assumes you already are at the top level of your project

// depending on your internets, this could take a while

// add dependencies

// generates PrettyRandom.xcodeproj file

Install Xcode 8.0 (beta)

$ open PrettyRandom.xcodeproj

4

import PackageDescription

let package = Package(

name: "PrettyRandom",

dependencies: [ .Package(url: "https://github.com/thecb4/SwiftyJSON.git", versions: Version(3,0,2)..<Version(3,0,34)), ]

)

$ nano Package.swift

// open Xcode (beta) and realize nothing works because the library isn’t Swift 3 compatible

side by side comparison

Written In Ruby Swift Swift

Current Version 1.0.1 0.16.2 swiftpm-18

Control File Podfile Cartfile Package.swift

Repository Cocoapods Trunk git git

Libraries 3000+ 3000+1 ???

Search Index website, command line

If it’s on github you can use it1

IBM Catalog

Version support Semantic Semantic Semantic

Target Support Yes What target? On Roadmap

Integration Type Source Source or Binary Source

Platform Support macOS, iOS, watchOS, tvOS

macOS, iOS, watchOS, tvOS

Linux, macOS2, iOS2, watchOS2, tvOS2

Swift Support 2.2.3 2.2.3 3.01. The library has to have a Shared Scheme to work 2. If you are building a library you are fine. Anything with a UI is a lot of work

I love carthage

https://github.com/Carthage/Carthage

Written In Ruby Swift Swift

Current Version 1.0.1 0.16.2 swiftpm-18

Control File Podfile Cartfile Package.swift

Repository Cocoapods Trunk git git

Libraries 3000+ 3000+1 ???

Search Index website, command line

If it’s on github you can use it1

IBM Catalog

Version support Semantic Semantic Semantic

Target Support Yes What target? On Roadmap

Integration Type Source Source or Binary Source

Platform Support macOS, iOS, watchOS, tvOS

macOS, iOS, watchOS, tvOS

Linux, macOS2, iOS2, watchOS2, tvOS2

Swift Support 2.2.3 2.2.3 3.01. The library has to have a Shared Scheme to work 2. If you are building a library you are fine. Anything with a UI is a lot of work

Any Questions?

referencesThese slides… http://goo.gl/oJM5Pf

Homebrew… http://brew.sh

Carthage… https://github.com/Carthage/Carthage

Cocoapods… https://cocoapods.org

Swift Package Manager… https://swift.org/package-manager

Libraries vs. Frameworks… http://www.knowstack.com/framework-vs-library-cocoa-ios/