1

I am currently working to add Apple Watch app in my current App. I added the required profiles and got it to working without any issues.

Now, I want to use some of the class files from iphone app in my apple watch app. I did add the .m file in the target membership to the watchkit extension target. Since the file which I want to use is in Objective C class, I went ahead and created the bridging header file for apple watch extension target.

Each time when I run the application; I get $(SWIFT_MODULE_NAME)-Swift.h file not found. I did try to follow steps from this link but to no avail. I did clean build folder; removed the derived data but it still gives me the same error.

Am I missing anything in particular which others have tried and can share with me ? I am using Xcode 8 and Swift 3.

lifemoveson
  • 1,661
  • 8
  • 28
  • 55
  • Have you tried this? https://stackoverflow.com/q/31557345/8402042 – Ivan Golikov Aug 01 '17 at 21:48
  • The issue started occurring after I added Watch App in my project. It seems Xcode is getting confused between the header files. I did try the link you suggested and is working for me. If I remove the iphone class from the watch app the project runs fine. – lifemoveson Aug 01 '17 at 22:37

1 Answers1

0

So I figured out the answer and thought of posting it here.

There are couple of ways in which you can fix this but it depends on what you want to do.

1) Using #IF TARGET_OS_IOS will allow you to use the class from iphone to watch.

2) You can also use WatchConnectivity framework to send and/or receive messages, send data also. This is the new framework Apple has recommended to use for connectivity between the devices.

Hope this will help someone else trying to figure out this problem.

lifemoveson
  • 1,661
  • 8
  • 28
  • 55