简体   繁体   中英

How sharing the model of the main app with WatchOS2?

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 ?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM