Imagine this scenario when your App
project uses two custom libraries
.xcworkspace
|- App.xcodeproj
|- LibraryA.xcodeproj
|- LibraryB.xcodeproj
And since in this case we are working with Xcode frameworks one could add the following to the LibraryB
header file:
#import <LibraryA/MyLibraryA.h>
and now not only there is no need to import LibraryA
in the source od LibraryB
, but also every time you import LibraryB
inside your App
source files, the LibraryA
gets imported along with it, which can be very convenient.
The same applies to the default Foundation import one can find in an Xcode framework header:
#import <Foundation/Foundation.h>
Now with SPM, I need to manually import Foundation everywhere I use it.
Q: Is this possible to achieve the same result when using SPM packages exclusively?
I haven't found any resources on this matter. Thanks!
To expose import to your whole package you can use @_exported
attribute inside of any of your swift file:
@_exported import Foundation
More info about this in next discussion: https://forums.swift.org/t/package-manager-exported-dependencies/11615
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With