C6Silver
C6Silver

Reputation: 3357

Combined Watch OS and iOS Framework

I have created a class that is shared between iOS and Watch OS. This works just fine. However, I wanted to turn that class into a Framework. Doing so though only allows it to be created as an iOS or Watch OS framework, but not both. Creating it for Watch OS prevents iOS from seeing it and vice versa.

How can I have a single framework that both iOS and Watch OS can use?

Upvotes: 4

Views: 2141

Answers (1)

C6Silver
C6Silver

Reputation: 3357

I wound up finding the answer buried in the documentation right after asking it... Rather than delete the question I will post the answer here for the interest of others:

According to Apple you cannot share frameworks between the watch and phone. Specifically:

Sharing Code Between an iOS App and a watchOS App

You can share code, but not frameworks, between your iOS app and Watch app. Because the apps run on separate platforms with different architectures, source files must be compiled separately for each platform. If you still want to use a framework to manage any shared source files, you must create separate framework targets for each platform and add your shared source files to each framework.

If you already have an iOS framework, you can duplicate the framework and modify it to support watchOS.

https://developer.apple.com/library/content/documentation/General/Conceptual/WatchKitProgrammingGuide/iOSSupport.html#//apple_ref/doc/uid/TP40014969-CH21-SW1

Upvotes: 5

Related Questions