swiftobjective-cunit-testingprivate-membersprivate-methods

Obj C codebase and unit test cases in Swift


I have an objective c code base and I am writing snapshot test cases in swift. I have certain functions and variable which are declared in .m class. How I can access those variables from swift test class.


Solution

  • Use a bridging header to expose the Objective-C entities that you want to use in your Swift tests. You may already have one set up (as explained in the link, Xcode offers to create one when you add a Swift file to an Objective-C project); if so, you may just need to update the file to add headers that aren't currently included. If you don't have one, the link I provided will show you how to create one.