Reputation: 32804
Let's say I have framework that defines a protocol which depends on symbols exported by a 3rd framework:
import CoreLocation
public protocol BarsAPIClient {
func getBars(around location: CLLocation, completion: @escaping (Result<[String], Error>) -> Void)
}
Now, in my app I want to add a concrete implementation of the protocol:
import MyFramework
class BarsAPIClientImpl: BarsAPIClient {
func getBars(around location: CLLocation, completion: @escaping (Result<[String], Error>) -> Void) {
// actual implementation goes here
}
}
However, the above code won't compile due to CLLocation
not being visible:
I can easily address this particular error by also importing CoreLocation
. However for more complex cases, with multiple dependencies, this might become tedious.
So, question is if it's possible for the module to declare all its public dependencies, so consumers of that module are automatically linked to those dependencies?
Upvotes: 7
Views: 619
Reputation: 1460
There are currently 2 ways to do this
Add this to a swift file in MyFramework
.
@_exported import CoreLocation
Create MyFramework.h
public umbrella header in MyFramework
with the following contents.
#import <CoreLocation/CoreLocation.h>
Upvotes: 6