Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Accessing main App class from extension target - iOS

I have an ObjC project and I've added a WatchApp Extension target in Swift. It works fine, however I have a database handler class that I wanted to make accessible from the watch extension target in order to get some data from it. I've added the database class in the Bridging Header file in the extension target but when I instantiate the class in the app viewController I get an error of missing symbol. I've trying adding the path to the class in the Header Search Path but it still doesn't work. Does anyone have any idea of what I'm missing?

like image 990
Lucas Pereira Avatar asked Sep 13 '25 01:09

Lucas Pereira


1 Answers

You need to add the class to your WatchKit extension target. Alternately, you can build a framework with your shared code.

Edit

See this for more info Calling a Method on Watchkit

like image 159
Stephen Johnson Avatar answered Sep 15 '25 14:09

Stephen Johnson