carthage

下面介绍的是carthage基本使用方式, 具体详细的使用方式请参考Carthage官方教程。

  1. Get Carthage by running brew install carthage or choose another installation method

  2. Create a Cartfile in the same directory where your .xcodeproj or .xcworkspace is

  3. List the desired dependencies in the Cartfile, for example:

  4. github “Alamofire/Alamofire” ~> 4.7.2 Run carthage update

  5. A Cartfile.resolved file and a Carthage directory will appear in the same directory where your .xcodeproj or .xcworkspace is

  6. Drag the built .framework binaries from Carthage/Build/ into your application’s Xcode project.

  7. If you are using Carthage for an application, follow the remaining steps, otherwise stop here.

  8. 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:

  9. /usr/local/bin/carthage copy-frameworks Add the paths to the frameworks you want to use under “Input Files”. For example:

$(SRCROOT)/Carthage/Build/iOS/Alamofire.framework Add the paths to the copied frameworks to the “Output Files”. For example: $(BUILT_PRODUCTS_DIR)/$(FRAMEWORKS_FOLDER_PATH)/Alamofire.framework Another approach when having multiple dependencies is to use .xcfilelists. This is covered in If you´re building for iOS, tvOS ot WatchOS

For an in depth guide, read on from Adding frameworks to an application