Carthage: Best practice for adding a Carthage dependency to my Carthage Framework

Created on 19 Sep 2018  路  7Comments  路  Source: Carthage/Carthage

I'm developing a Framework named "MyFramework" which compatible with Carthage but I need "Alamofire" as dependency to my "MyFramework".

1) What are all options to include "Alamofire" to my "MyFramework" ?

2) What is the most recommended way ?

3) Any real life example ?

Thank you

question stale

Most helpful comment

hi @tunidev

  • Add a Cartfile file in the root directory of your project.
  • Write all your dependencies in the Cartfile as usual
  • In the Terminal, exec carthage update to resolve dependencies
    This will create the resolution file Cartfile.resolved and a Carthage directory where it will checkout and build dependencies
  • Add Carthage/ to .gitignore file (if it doesn't exist, create one in the root directory of your project).
  • Add Cartfile and Cartfile.resolved to git: git add Cartfile Cartfile.resolved
  • In Xcode, add all frameworks to the application's target In General under Linked Frameworks and Libraries
    You can do it by dragging the Frameworks files or with the + button.
    Check that this last action added the frameworks path to the Build Settings in Framework Search Paths line.
    If not, you'll need to add the relative path to frameworks.
    As an example this looks like this for iOS:
    $(PROJECT_DIR)/Carthage/Build/iOS

All 7 comments

In "MyFramework" use a Cartfile and add Alamofire as a dependency. This dependency will be passed on to whatever project depends on "MyFramework"

hi @tunidev

  • Add a Cartfile file in the root directory of your project.
  • Write all your dependencies in the Cartfile as usual
  • In the Terminal, exec carthage update to resolve dependencies
    This will create the resolution file Cartfile.resolved and a Carthage directory where it will checkout and build dependencies
  • Add Carthage/ to .gitignore file (if it doesn't exist, create one in the root directory of your project).
  • Add Cartfile and Cartfile.resolved to git: git add Cartfile Cartfile.resolved
  • In Xcode, add all frameworks to the application's target In General under Linked Frameworks and Libraries
    You can do it by dragging the Frameworks files or with the + button.
    Check that this last action added the frameworks path to the Build Settings in Framework Search Paths line.
    If not, you'll need to add the relative path to frameworks.
    As an example this looks like this for iOS:
    $(PROJECT_DIR)/Carthage/Build/iOS

hi @blender
can u confirm if we can use the copy-frameworks script on the added dependencies so that final framework can be used for app store submission as well?
I was trying to do the following steps in order to use custom framework for app-store submission:
1) Generate framework with normal approach as mentioned in Readme on carthage homepage
2) Tried running copy-framework script step to do the needful with output folder set to other than the default expected folder (was trying this as hit and trial)
intention of step 2 was to see if i can still use the script to do needful on the added dependencies.
3) copy the frameworks from step 2 location to the actual framework parth in the final target.
4) run the strip symbol script (copied from net) before archiving or so on the final custom framework.
I am currently using XCode 10 with carthage v0.30.1

You just need to add carthage copy-frameworks to a custom run script phase with the list of inout and output file as specified in the quick start guide at point 8.

You just need to add carthage copy-frameworks to a custom run script phase with the list of inout and output file as specified in the quick start guide at point 8.

so carthage copy-frameworks this would take care of doing the needful for the main framework as well the other embedded frameworks, recursively?

You have to specify the list of frameworks on which it will act. Please follow the instructions in the Readme.

Specifically: https://github.com/Carthage/Carthage/blob/master/README.md#if-youre-building-for-ios-tvos-or-watchos

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

faustperic picture faustperic  路  3Comments

justinmakaila picture justinmakaila  路  4Comments

itinance picture itinance  路  3Comments

willhains picture willhains  路  3Comments

3lvis picture 3lvis  路  3Comments