Swift: dependency API export

Suppose we have 2 frames written in Swift: A.framework and B.framework , A depends on B I want each project depending on A be able to access the api framework B without the need for import B in the project source files. How can this be achieved?

EDIT . In particular, I am interested in how this can be done using Cocoapods.

OTHER IMAGE . I think it will be useful if I explain the context in which this question arises, because I still have not received a suitable answer, despite its length and generosity.

So, I have a pod Freestyler ( https://github.com/cayugasoft/Freestyler ), which itself depends on the pod FreestylerCore ( https://github.com/cayugasoft/FreestylerCore ). Works great, but I have to import FreestylerCore in the project, even if import Freestyler . This looks a little annoying to me because I see this dependency ( Freestyler -> FreestylerCore ) as an implementation detail, and I would like library users to work automatically without importing anything other than the main unit, Freestyler . So I asked this question. Are there any ways to implement this?

+5
source share
1 answer

It turns out that in Swift this is the default behavior.

If Pod.A depends on Pod.B, then your project, which depends on Pod.A (by including Pod.A in your subfile), will really have visibility for Pod.B.

To see an example Pod.A setup that has a dependency, and then a draft example that consumes Pod.A (and also has visibility for Pod.B), see my Public GitHub Repo demo for this:

https://github.com/ericwastaken/CocoaPod-Dependency-Demo

I added comments to the App (ViewController) example, which shows that this works. The repo has additional clarifications.

0
source

Source: https://habr.com/ru/post/1259737/


All Articles