Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Building an embedded framework for WatchOS and iOS in Xcode 8 with Swift 3

I am in the process of porting an all iOS + WatchOS 1 app written originally in Swift 1, to the latest Xcode 8, WatchOS 3, Swift 3.

My app has an embedded framework with some common functionality that used to compile and run file for both the watchkit extension target and the ios app target.

With Xcode 8 I can no longer seem to get this to work. When I try to import the framework in the watchkit extension code, I get the module not found error.

Is it still possible to compile and use one single embedded framework package on both the target iOS and WatchKit extension targets? In my framework I have the target platforms set to watchos, watchsimulator, iphoneos, iphonesimulator.

My gut says it's not possible anymore. Where originally all the code really ran on the phone itself, not that codes runs on the actual watch and the phone, you'd need to compile an embedded framework specifically for each.

like image 426
cpjolicoeur Avatar asked Nov 17 '16 15:11

cpjolicoeur


People also ask

How do I create an Apple Watch app with Xcode?

To build a watch-only app, start a new project in Xcode, select the Watch App template, and click Next. Provide a name, and choose the interface, life cycle, and language for your watch app. Select the options to include a notification scene template or unit and user interface tests, and click Next.

How do I make apps for watchOS?

To create a watchOS app, start by adding a watchOS target to the project. Xcode adds groups and files for the watchOS app to your project, along with the schemes needed to build and run the app. Choose File > New > Target.

What is umbrella framework?

An umbrella framework simply includes and links with constituent subframeworks and other public frameworks. An umbrella framework encompasses all the technologies and APIs that define an application environment or a layer of system software.


1 Answers

Short version: You can't. Create a duplicate target and set it to use the watch SDK.

Longer version from Apple's docs: https://developer.apple.com/library/content/documentation/General/Conceptual/WatchKitProgrammingGuide/iOSSupport.html#//apple_ref/doc/uid/TP40014969-CH21-SW1

including:

NOTE

After you create a separate framework target for your WatchKit extension, you must manage the contents of that framework separately for both iOS and watchOS. If you add files to the iOS version of the framework, remember to add them to the watchOS version.

like image 108
Joseph Lord Avatar answered Oct 13 '22 11:10

Joseph Lord