styler1972 styler1972 - 6 months ago 73
Swift Question

Unit testing Swift 2.0, @testable import, and scheme targeting issues

I have recently converted my app, and unit tests over to Swift 2.0. I am using

@testable import AppName
in my Tests.swift files.

Due to an issue with not being able to execute subclasses in multiple targets (see here for the issue), my class
EntityName
can only be of Target Membership
AppName
, and NOT
AppNameTests
.

The problem is, once I switch over to the
AppNameTests
schema to run unit tests, code in the module
AppName
can't find the class
EntityName
and I get


Use of undeclared type 'EntityName'


How do I get
AppName
to compile when running tests from the
AppNameTests
scheme without that entity class not a member of the scheme?

Answer

I had to stop targeting my entire apps .swift files to be have membership of MyAppTests, and rely solely on @testable import MyApp

Comments