Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sharing classes between existing iPhone project and Watch Kit extension

I would like to share a class "MyClass" that I added as target to an iPhone project to which I then added a Watch Kit extension target.

Whenever I import the "MyClass" in the Watch Kit extension source code I get:

Undefined symbols for architecture arm64: "_OBJC_CLASS_$_MyClass", referenced from: objc-class-ref in WKMyInterfaceController.o ld: symbol(s) not found for architecture arm64 clang: error: linker command failed with exit code 1 (use -v to see invocation)

Any idea on how to solve this? It seems a linker problem so I guess I have to add the source code of the class MyClass to the linked libraries/headers of the WatchKit Extension app but I am not sure if there is a better way to do it.

like image 233
mm24 Avatar asked Feb 11 '23 04:02

mm24


1 Answers

You need to select both target for you MyClass.

If you are using objective c then go to your MyClass's .m file and select the target as your watch kit also.

Check out the screenshot here

Hope this will help you.

like image 158
Malav Soni Avatar answered Feb 13 '23 05:02

Malav Soni