Search code examples
iosswiftios-frameworkscarthage

iOS Dependency manager in Cocoa Touch Framework


I have been researching a while and with no success on how I can build a cocoa touch framework, add dependency manger for 3rd party libraries and finally add the framework in an app project.

First, I would like to say that the framework I am planning to work with will be developed and tested while I write the app, it will be a git submodule of the main git project and.

Ideally, The structure of my the whole project looks like that

Finder: enter image description here

Project

enter image description here

Is that a good way to work?

Secondly, the main issue I am facing is how to add dependency manager in my framework

I have tried "Carthage" and "Cocoapods"

With Carthage The main project crashes as It can't find the frameworks and with "Cocoapods", because it creates a workspaces, I can't import the the framework or, at least, I don't know how to do it.

Does anyone know a way for integrating dependency manager in a cocoa touch framework with no app project configuration?

Thank you.

Removed edited part due unfair downvotes


Solution

  • Open to edit and suggestions! To be continued when Swift Package Manager is released for iOS

    Also, I want to apologise if something is not quite right.

    ANSWER:

    After a while trying different ways and methods and with drekka answer, I have figured out how to use Carthage as a dependency manager for my cocoa touch framework.

    My Framework has all the Carthage files and folders, includes the Frameworks but it doesn't have the run script.

    enter image description here

    Because my framework contains public variables that depends on the frameworks imported, when I use them in App project Xcode can find them.

    enter image description here

    So in my App target "TheApp - General - Linked frameworks and libraries" i drag an drop the carthage framework reference:

    enter image description here

    And, indeed, the location is added into "TheApp - Build settings - Search path - Framework search path"

    enter image description here

    At this point the app compiles an runs in a simulator but crashes when runs in a real device as it is shown in the question. For solving this issue I add the Carthage scrips in "TheApp - Build phases"

    enter image description here

    And job done!

    I was expecting an easier integration like the one you get with gradle in android but, by now, I think this is the best approach.