lundi 22 juin 2015

How to test internals of an Objective-C framework with Swift

I have a framework/module written in Objective-C and want to test its external interfaces and internals in Swift. For that I created a new test target in the same project, targeting the framework. In the Swift code I can import the module and use the public classes without a problem. However, I can't access the internal classes in my tests.

I tried the following:

  • I set the visibility of the internal sources to "Project". For what I understood that should make them available to code in the same project. It doesn't work, though. Or do I need to import them differently then?
  • I also tried the new @testable import feature of Swift 2 in Xcode 7, but that doesn't seem to work (yet) for Objective-C frameworks.

What I came up with is to manually import all privat sources I want to test in the bridging header of the test target. That works. However, it doesn't feel like it's the intended way of testing an Objective-C framework with Swift.

Any ideas on how to do that better?

Aucun commentaire:

Enregistrer un commentaire