`@testable import` in UI Tests fail to link to app

Hi,


Is functional testing supported in UI Test ?


I'd like to check the state of my application is correct in a UI Test function (like I have done in my functional tests in the Unit Test target), however adding `@testable import MyApp` causes a link time error:


Undefined symbols for architecture x86_64:
  "type metadata accessor for MyApp.MainViewController", referenced from:
      MyAppUITests.MyAppUITests.setUp (MyAppUITests.MyAppUITests)() -> () in MyAppUITests.o
      type metadata accessor for MyApp.MainViewController? in MyAppUITests.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)


I noticed that `UIApplication.sharedApplication().windows` also returns an empty array.


Has access to the app been removed from UI Test targets?


Cheers,


Daniel

Post not yet marked as solved Up vote post of DanielAsher Down vote post of DanielAsher
2.9k views

Replies

Daniel. I don't have an answer. But I wanted to let you know, that 7 years later... I see you. And I stand with you.

In Xcode, UI tests run in a separate process from your app, so they are not designed to import your app's code. If you want to run code that lives inside your app bundle, you can import it inside a Unit test and execute it there.