Top Banner
Women Who Code iOS Meetup 2016 AUG 21
37

Dependent things dependency management for apple sw - slideshare

Apr 07, 2017

Download

Software

Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Dependent things   dependency management for apple sw - slideshare

Women Who CodeiOS Meetup

2016 AUG 21

Page 2: Dependent things   dependency management for apple sw - slideshare
Page 3: Dependent things   dependency management for apple sw - slideshare
Page 4: Dependent things   dependency management for apple sw - slideshare

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

Page 5: Dependent things   dependency management for apple sw - slideshare
Page 6: Dependent things   dependency management for apple sw - slideshare
Page 7: Dependent things   dependency management for apple sw - slideshare
Page 8: Dependent things   dependency management for apple sw - slideshare
Page 9: Dependent things   dependency management for apple sw - slideshare
Page 10: Dependent things   dependency management for apple sw - slideshare

What this talk IS covering

Dependency Management Options Pros and Cons of each

My personal bias

Page 11: Dependent things   dependency management for apple sw - slideshare

What this talk IS NOT covering

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

System Configuration (just a little)

Page 12: Dependent things   dependency management for apple sw - slideshare

154

Page 13: Dependent things   dependency management for apple sw - slideshare
Page 14: Dependent things   dependency management for apple sw - slideshare

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

Page 15: Dependent things   dependency management for apple sw - slideshare

# 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

Page 16: Dependent things   dependency management for apple sw - slideshare
Page 17: Dependent things   dependency management for apple sw - slideshare
Page 18: Dependent things   dependency management for apple sw - slideshare
Page 19: Dependent things   dependency management for apple sw - slideshare

I love homebrew

http://brew.sh

Page 20: Dependent things   dependency management for apple sw - slideshare
Page 21: Dependent things   dependency management for apple sw - slideshare

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"

Page 22: Dependent things   dependency management for apple sw - slideshare

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

Page 23: Dependent things   dependency management for apple sw - slideshare
Page 24: Dependent things   dependency management for apple sw - slideshare
Page 25: Dependent things   dependency management for apple sw - slideshare
Page 26: Dependent things   dependency management for apple sw - slideshare
Page 27: Dependent things   dependency management for apple sw - slideshare

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

Page 28: Dependent things   dependency management for apple sw - slideshare

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

Page 29: Dependent things   dependency management for apple sw - slideshare
Page 30: Dependent things   dependency management for apple sw - slideshare

side by side comparison

Page 31: Dependent things   dependency management for apple sw - slideshare

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

Page 32: Dependent things   dependency management for apple sw - slideshare

I love carthage

https://github.com/Carthage/Carthage

Page 33: Dependent things   dependency management for apple sw - slideshare

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

Page 34: Dependent things   dependency management for apple sw - slideshare
Page 35: Dependent things   dependency management for apple sw - slideshare

Any Questions?

Page 36: Dependent things   dependency management for apple sw - slideshare

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/