What is quickest way to add dependencies in Xcode project using Carthage.
How to add or edit dependencies later.
Installing Carthage
//Homebrew
brew install carthage
Create Cartfile
file at the project(.xcodeproj
)/workspace(.xcworkspace
) directory
Modify Cartfile
. Add necessary dependency == repo
github "/" ==
Run carthage update
. High level logic:
`carthage update [dependency]` {
- reads `Cartfile`, resolves dependency graph and generates `Cartfile.resolved` to store a list of versions that will be actually built
//--no-use-binaries - this flag force a Carthage to not use a `Prebuilt framework`
//--no-build - this flag skip a building step - `carthage build`
`carthage bootstrap [dependency]` {
- reads `Cartfile.resolved`
`carthage checkout [dependency]` {
`carthage fetch ` {
- fetch dependency from `Cartfile.resolved` into `~/Library/Caches/org.carthage.CarthageKit/` folder
}
- checkout/move a dependency from `~/Library/Caches/org.carthage.CarthageKit/` to generated `Carthage/Checkouts` folder
}
`carthage build [dependency]` {
- builds all `shared frameworks schemes` from `Carthage/Checkouts` into generated `Carthage/Build` folder
//--no-skip-current - this flag also builds all `shared frameworks schemes` of a consumer workspace/project(in addition to `Carthage/Checkouts` folder)
}
}
}
Drag and drop builded frameworks to General -> Frameworks and Libraries
Run the next script. This step is important because carthage build process a fat
binary(arm64... + x86_64) using lipo
[About]. Apple reject application which uses it. That is why you should add this extra step to cut architecture for simulator(x86_64)
Build Phases -> + -> New Run Script phase ->
// /usr/local/bin/carthage - path to Carthage, copy-frameworks - command which sets a necessary architecture and copies framework to an application bundle
Shell -> /usr/local/bin/carthage copy-frameworks
//path to a generated Carthage/Build
Input files -> + -> $(SRCROOT)/Carthage/Build//.framework
*Any carthage
command should be called from Cartfile
folder
[Fast Carthage build]
[Vocabulary]
[CocoaPods vs Carthage]