Why "Cannot find interface declaration for XCTestCase" in Swift unit test? -


i added swift class objc project , wanted write unit tests it. when go build, xcode complains can't find interface declaration xctestcase, though @import of xctest above. doing wrong?

here relevant part of generated -footests-swift.h file, annotations:

#if defined(__has_feature) && __has_feature(modules) @import objectivec; @import xctest;                <<<< note import #endif  #pragma clang diagnostic ignored "-wproperty-attribute-mismatch" #pragma clang diagnostic ignored "-wduplicate-method-arg"  swift_class("_ttc12play611tests14weightedsumin2") @interface weightedsumin2 : nsobject   <<<< error here: cannot find                                        <<<< interface declaration 'xctestcase' - (swift_nullability(nonnull) instancetype)initwithinitvalue:(double)initvalue objc_designated_initializer; - (double)push:(double)e; @end  @class nsinvocation;  swift_class("_ttc12play611tests18weightedsumin2test") @interface weightedsumin2test : xctestcase - (void)test1; - (swift_nullability(null_unspecified) instancetype)initwithinvocation:(nsinvocation * __null_unspecified)invocation objc_designated_initializer; - (swift_nullability(null_unspecified) instancetype)initwithselector:(sel __null_unspecified)selector objc_designated_initializer; - (swift_nullability(nonnull) instancetype)init objc_designated_initializer; @end 

here source test case:

import uikit import xctest  class weightedsumin2test : xctestcase {     func test1() {...} } 

and class:

import uikit  public class weightedsumin2 : nsobject {     init(initvalue: double = 0.0) {...}     func push(e: double) -> double {...} } 

both files have been added test target. also, can build/run objc unit tests, not swift one.

any idea what's wrong? if import of xctest being done (how can know whether #if condition true?), shouldn't interface xctestcase available?

one thing issue this:

does swift file weightedsumin2 declare target membership both you're test bundle , main bundle? if not, select swift file , in right menu, under target membership, select test bundle (it should checkmark).


Comments

Popular posts from this blog

jquery - How do you format the date used in the popover widget title of FullCalendar? -

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -