Reputation: 906
I have an XCWorkspace that contains separate framework projects, project structure as follows
AFramework project (static framework project, AFramework project links BFramework and adds it to its target dependencies)
BFramework project (static framework project, contains public BClass.swift file)
AFramework project can access BClass.swift file as expected but I also want to expose BClass.swift file to the outside of AFramework, assume that an application project links just AFramework and on that app I want to access to BClass.swift file, what should I do to achieve that, using custom module map can be useful?
Here is the screenshot from the demo app, the app just links AFramework and tries to access to BClass.swift file, but that file is not accessible.
Thanks in advance for your helps
Upvotes: 3
Views: 548
Reputation: 906
Finally, I found the answer. To be able to expose sub-module's public apis you can use @_explored import attribute.
For my case using "@_exported import BFramework" on AClass.swift file, it causes BFramework's public apis are accessible from also application side which just links the AFramework.
Note that it is not officially released.
Some discussions about that can be found here and here.
Upvotes: 2
Reputation: 218
You should be able to import only the BClass like so
import class BFramework.BClass
That should work as long as the classes in the framework are public. This should also work for func, var, protocol, struct and enum (eg. import struct BFramework.BStruct
)
Upvotes: 0
Reputation: 926
I think you either you add B framework as a dependency or create a class on A framework that exposes the functionality that you want.
Upvotes: 0