For unit test files, there is also a file called "MyProjectTests-Bridging-Header.h" as well but I do not see a corresponding "MyProjectTests-Swift.h" file. Therefore, I am not able to access Objective-C classes within unit test files that are written in swift. Any suggestions?
Huh? There’s two directions to consider here:
Using Objective-C from Swift — To do this you include the relevant headers in your bridging header (
xxx-Bridging-Header.h) and Swift will pick things up from there.
Using Swift from Objective-C — To do this, you include the
xxx-Swift.hheader in your Objective-C code.
So, if you want to do the former you only need
It sounds like you’ve added the relevant includes to your app target bridging header (
MyProject-Bridging-Header.h) but not to your test target bridging header (
Share and Enjoy
Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware
let myEmail = "eskimo" + "1" + "@apple.com"
I'm having a similar problem.
Scenario: Swift UI test of Objective-C project.
This is what I'm getting in the Unit Test file:
The following Objective-C target is in the Pods project:
... so I'm using a Unit Test from within YahooSearchSDK to access YSKBossDataSource in Pods:
Here are the targets:
I created TWO (2) bridge files for the Swift code to access the target Objective-C code:
...still doesn't work.
How do I make my Swift test file 'see' an Objective-C file within the second project, 'Pods'?