Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
224 views
in Technique[技术] by (71.8m points)

swift - 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

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Carthage is my favourite manager so I can speak to that more than Cocoapods.

When you are building a framework you want to link against any dependency managed by Carthage, but NOT include them in the framework. This is relatively simple to do. Just goto your framework target and add the Carthage built frameworks from <project-dir>/Carthage/Build/<platform>. The Carthage directory should end up in you frameworks search path as well.

In your main app project you need to do the same thing, ie. add the frames from the Carthage build directories and make sure that directories in the framework search path as well.

Then you need to do one extra step. You need to add a run script phases and tell it to execute carthage copy-frameworks and then add each of the Carthage built framework files to that phase. The reason for this is the way Apple builds frameworks requires some extra work before they are copied into your application's bundle.

I suspect the reason for your crash where it could not find the frame was that this phase was not added to your app target. So when the app ran it was not able to find the framework.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...