I asked the same question in Stackoverflow and no luck yet. So I post it here hoping my luck to change.
I created an SPM small. library with some Objective-C code. Some code is a category on NSURL class.
@interface NSURL (Additions)
@property (copy, readonly) NSDictionary<NSString *, NSString *> *queryParams;
@end
Then I import my library into a Swift project
import URLUtils
and I am able to do:
// Sigh: queryParams is available in NSURL as expected
let url = NSURL(string: "https://domain.com/path?a=123")!
let queryParams = url.queryParams
But I am NOT able to do this (It does not compile):
// Sigh I want to be able to use URL and have my category method automatically bridged. Is this possible?!
let url = URL(string: "https://domain.com/path?a=123")!
let queryParams = url.queryParams
// ^ error: value of type 'URL' has no member 'queryParams'
Sample code here just run the tests: swift test
.
Why is this? Is this the expected behaviour for SPM packages? I have an old app with lots of Objective-C code and want to move them into a few SPM packages rather than having a huge bridging header file in the app.