0

I am writing UITest for my app. In some parts of the UITest, I should call functions from Main target. When I create an Object from the Class(that has the implementation of the function), I get the error "use of undeclared of type CLASSNAME". I added the Class to the Compile Source of the test target.Then I get the same error but this time for the super class. I added Classes to the compile source again and again, till I get this error "use of undeclared of UITextField, UIColor." UITextField and UIColor are part of UIkit, then I import UIkit to my test Class , but did not work. Any idea how to solve it? In generell, How should we call functions in main target from test target? Thanks a lot.

FaFa
  • 11
  • 2
  • 1
    Add @Testable in front of your main Class/Method in your main target. See also https://developer.apple.com/library/content/documentation/DeveloperTools/Conceptual/testing_with_xcode/chapters/04-writing_tests.html –  Nov 15 '17 at 15:46
  • I did use testable. But also get error Mach O linker. I also tried this https://stackoverflow.com/questions/32008403/no-such-module-when-using-testable-in-xcode-unit-tests/32844977#32844977 , but could not fix it. – FaFa Nov 16 '17 at 11:09
  • Can you add your error message log ? –  Nov 17 '17 at 09:55

1 Answers1

0

import your target with @testable import

import XCTest
@testable import MyProject
Daniel Carlos
  • 268
  • 4
  • 6
  • I did use testable. But also get error Mach O linker.i also tried this https://stackoverflow.com/questions/32008403/no-such-module-when-using-testable-in-xcode-unit-tests/32844977#32844977 , but could not fix it. – FaFa Nov 16 '17 at 11:07