When do app sources need to be included in test targets?

前端 未结 7 1626
别那么骄傲
别那么骄傲 2020-12-02 05:30

In a new project I have this simple test

#import 
#import \"ViewController.h\"

@interface ViewControllerTests : XCTestCase
@end

@imp         


        
7条回答
  •  栀梦
    栀梦 (楼主)
    2020-12-02 05:49

    When you create a Unit Testing Bundle(Unit Testing target) for testing application you have two options

    1. Enable Allow testing Host Application APIs
    General -> Host  Application  -> >check< Allow testing Host Application APIs 
    
    • slow build
    1. Add every app's tested file into Target Membership[About]
    • you should take care of classes dependencies which are used into testable class(they should be added too)

    When you write a test and no one option was not enabled you can get

    Undefined symbol: nominal type descriptor for 
    Undefined symbol: type metadata accessor for 
    

提交回复
热议问题