Using images in the main Xcode project for Watch app

235 views Asked by At

I have a watch application and I will display images in it. Those images are already included in IOS application so I don't want to copy them into watch app as well. How to use images in IOS side (not in asset catalog) in watch app?

1

There are 1 answers

0
Dávid Pásztor On

With the introduction of watchOS2, WatckKit apps became native apps and not just extensions of their iOS counterpart. Due to this, the iOS and watchOS apps can no longer share a common AppGroup.

The only way to share data between apps is using the WatchConnectivity framework. However, for static images, you shouldn't use the WatchConnectivity framework. If you don't want to add the pictures to the asset catalog, you don't actually need to copy them. All you need to do is add them to your WatckKit app or app extension target, depending on whether you want to use them from Storyboard or code.

Keep in mind that the system will actually copy those images to your Watch target as well, since storage is not shared between the iOS and watchOS apps so you don't actually gain any storage advantages by not adding those images to both apps' asset catalogs.