Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sharing classes between iphone and the apple watch

Tags:

I was hoping someone could shed some light on this. I've tried researching but couldn't really find anything...

Is there a way to share a class between the iPhone application and the apple watch extension?

Let's say in the watch extension I have a class myClass; I am unable to use this class within the phone application. Is there anyway to get around this?

like image 920
prawn Avatar asked Feb 04 '15 23:02

prawn


People also ask

Can you communicate between Apple Watch and iPhone?

To enjoy every feature on your Apple Watch, you need to turn on Wi-Fi and Bluetooth on your paired iPhone. Open Control Centre on your iPhone, then make sure that Wi-Fi and Bluetooth are turned on. Your Apple Watch uses Wi-Fi and Bluetooth to communicate with your paired iPhone.

How do iPhone and Apple Watch work together?

Your Apple Watch uses Wi-Fi and Bluetooth to communicate with your paired iPhone. If you have cellular, your watch can also stay connected through a cellular network. Your watch switches between these intelligently to choose the most power-efficient connection.

How do I add a class to my Apple Watch?

Touch and hold the bottom of the Apple Watch screen, then swipe up to see Control Center. Scroll to the bottom, then tap Edit. Tap the add button on the Schooltime button , then tap Done.


1 Answers

iPhone application and the apple watch extension are basally different targets in your project. For each file (except the .h file), you can specify which target you want to include it to.

There are at least two ways to do this.

1) From the top menu select View -> Utilities -> File Inspector. The right panel will show up and you should find the Target Membership section with checkboxes next to the available targets for you project. Check the targets you want to include this file to. In this case, the iPhone app and the WatchKit extension.

2) You can also click on the project to go to the project settings. Select the target you want. (i.e. iPhone app or WatchKit extension), click on the Build Phases tab. In the Compile sources, you can click on the "+" icon to add more files to build for the target. (i.e. myClass.m in your case)

Hope this helps!

like image 104
j-techsha Avatar answered Oct 20 '22 17:10

j-techsha