What is quickest way to add dependencies in Xcode project using Carthage.
How to add or edit dependencies later.
Install Carthage
Open terminal
Terminal: cd ~/Path/To/Folder Containing Project
Create Carthage file as:
Terminal: touch Cartfile
Open Cartfile file from project folder and add required dependency
Example Cartfile file
github "Alamofire/Alamofire" == 4.5
github "Alamofire/AlamofireImage"
After Editing Cartfile file save it.
Run following command from terminal
Terminal: carthage update --platform iOS
xCode > Build phases
/usr/local/bin/carthage copy-frameworks
$(SRCROOT)/Carthage/Build/iOS/DependencyName.framework
Done
 
    
    Using Carthage flow
TL;DR:
Download dependency -> build fat binary -> it should  be imported -> slice for release
Long version:
Installing Carthage
//Homebrew
brew install carthage
Create Cartfile file at the project(.xcodeproj)/workspace(.xcworkspace) directory
Modify Cartfile. Add necessary dependency == repo
github "<owner>/<repo>" == <version>
Run carthage update under Cartfile location. 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 <path>` {
                - 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 - (+current consumer)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
//framework location
<cartfile_path>/Carthage/Build/
Run the next script. This step is important because carthage build 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/<platform>/<name>.framework
*Any carthage command should be called from Cartfile folder
If you run into some error
This usually indicates that project itself failed to compile. Please check the xcodebuild log for more details: /var/folders/2q/jhrcxkmx49g21lydqfrf26ph0000gn/T/carthage-xcodebuild.AySUH3.log
//you can use open command to review the log
open /var/folders/2q/jhrcxkmx49g21lydqfrf26ph0000gn/T/carthage-xcodebuild.AySUH3.log
Crear Carthage cache
rm -rf ~/Library/Caches/org.carthage.CarthageKit
Get stuck on update
carthage update --platform ios --verbose --new-resolver
//e.g.
//The dependency graph contained a cycle
Use XCFramework[About] --use-xcframeworks
//error
Building universal frameworks with common architectures is not possible. The device and simulator slices for "<schema_name>" both build for: arm64
Rebuild with --use-xcframeworks to create an xcframework bundle instead.
//solution
carthage update --platform ios --verbose --new-resolver --use-xcframeworks
 
    
    brew install carthageCartfile in the project root directory, e.g. vim Cartfile and paste:
github "AFNetworking/AFNetworking" ~> 4.0
carthage update --platform iOS
carthage update command to run specifically. You may need to run e.g. carthage update --use-xcframeworks --platform iOS --no-use-binaries instead. Check their readme.$project_dir/Carthage/Build. You will find a FrameworkName.framework or FrameworkName.xcframework. Drag the .framework/ .xcframework into your Xcode Project (in the project navigator).