Babul Prabhakar
Babul Prabhakar

Reputation: 2403

Whats the alternative of @testable import in Objective C

I am working with Unit Testing in Xcode using XCTest provided by Xcode in objective C. I know how to import Module in Swift like below.


@testable import  AppName

Whats the alternative in objective C.

Upvotes: 20

Views: 11263

Answers (2)

Sulthan
Sulthan

Reputation: 130122

@testable overrides access rights in Swift, allowing you to test internal methods in unit tests.

Objective-C has no such access modifiers, therefore you don't need @testable and you just import the module normally.

If you need to unit test internal Swift methods, you will have to write your tests in Swift.

Upvotes: 10

Tomer
Tomer

Reputation: 3297

In Objective C you can simply #import them, as there are no such "internal" method access limitations as in Swift.

Also, On Xcode 6 your main target should be already linked to the test target. If not, try to check the "Allow testing Host Application APIs" checkbox inside Your Test Target > General > Testing. Take a look at this question for more information.

Upvotes: 7

Related Questions