0

Possible duplicate this question but I can't find the answer
My project is used Objective C, and I create ui test in swift. Then I create a bridging header MyApp_Bridging_Header.h file like this:

 #ifndef MyApp_Bridging_Header_h
 #define MyApp_Bridging_Header_h
 #import "MyService.h"

 #endif /* MyApp_Bridging_Header_h */

And call the class in Swift test:

 func testApp() {
   // singleton
   var service = MyService.shared()
 }

Xcode can regconize MyService class, but when I run test, I get this error:

Undefined symbols for architecture x86_64:
 "_OBJC_CLASS_$_MyService", referenced from:
  objc-class-ref 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)

Is there any idea to fix this error?

ductran
  • 10,043
  • 19
  • 82
  • 165
  • Maybe quit xcode, then deleting Derived Data, cleaning build folder and then clean project. and try building. – Pranav Kasetti May 20 '18 at 14:52
  • Possible duplicate : https://stackoverflow.com/questions/18408531/xcode-build-failure-undefined-symbols-for-architecture-x86-64?rq=1 – Pranav Kasetti May 20 '18 at 15:00
  • @PranavKasetti Tried all, still not work. And I don't use any framework, it's only ui test, and it refers to MyApp – ductran May 20 '18 at 15:10
  • This one: https://stackoverflow.com/questions/30935640/xcode-unittest-build-failed-with-error-undefined-symbols-for-architecture-x86-6?utm_medium=organic&utm_source=google_rich_qa&utm_campaign=google_rich_qa? – Pranav Kasetti May 20 '18 at 15:19
  • @PranavKasetti still not work. I already search for them – ductran May 20 '18 at 15:51
  • Could you share code for MyService class? – Pranav Kasetti May 20 '18 at 16:32
  • Hmm, could you explain also which steps you have tried as well, would help me to better understand. – Pranav Kasetti May 21 '18 at 18:19
  • 1
    @PranavKasetti sorry for late response, I finally fix it. The reason is that I didn't add `MyService` class into UITest target's build source. It's fixed in Xcode->Targets->Build Phases->Compile Sources Thanks for your help btw :) – ductran May 22 '18 at 03:28
  • @ductran my issue was the same. You may want to write an answer and accept it for visibility! – Joel Fischer Apr 11 '23 at 18:36

0 Answers0