0

I need to share my entities (CoreData) of the main app with WatchOS2.

There are two ways to share code between targets - frameworks, and just including the .m or .swift file in multiple targets using Xcode's inspector.

WatchOS2 can create a dynamic framework and the main app too.

I have tried to create a dynamic framework in the main app and share code with WatchOS 2 : `Not such module TestFrameworkKit'.

Framework isn't going to work with a watchOS 2 extension because that extension runs on a completely different device.

Any idea ?

Hobbes
  • 119
  • 9
  • Why didn't the dynamic framework work? That sounds like the best way as you don't duplicate code at runtime. – Droppy Jun 24 '15 at 08:06
  • I have got this error : " `Not such module TestFrameworkKit'.`. I added the framework in `Librairies Frameworks and Libraries` in Settings of my watchOS Extension. – Hobbes Jun 24 '15 at 08:09
  • They are very fiddly to get right and not at all trivial. – Droppy Jun 24 '15 at 08:10

1 Answers1

0

I just add the .swift and .m files to both targets and this works great. Since the iOS and watch app need to be in the same project anyways, this is a very appropriate solution. I would only look into adding frameworks if you need to share code between projects.

lehn0058
  • 19,977
  • 15
  • 69
  • 109