The Lister app is one of Apple's only Apple Watch sample projects. It was first written to support the watchOS 1, and later updated on 9/16/15 to support watchOS 2. Because of this, there are many targets, groups, etc. that aren't consistently named, making it hard to understand what is what.
I want to create a similar project, where I have an iOS and watchOS 2 with shared code/frameworks. I'm having a hard time understanding how to set up such a project due to the complexity of the Lister app.
How should I set up my project so that I can share code between my watchOS 2 and iOS app? (Note: support for watchOS 1 is not a requirement.)
For reference, here is a list of the targets, schemes, and groups from the Lister app:
The project is so complex because it supports both watchOS 1 and watchOS 2.
If all you want is a to support watchOS 2 and share code between iOS and watchOS 2, you will need to create two frameworks, one for each platform.
Lister WatchKit Extension
, and Lister Watch Extension
). (See the Shared Lister WatchKit Code group.)ListerKit
).Lister WatchKit Extension
, and Lister Watch Extension
). (See the Shared Lister WatchKit Code group.)Code is shared between watchOS 2 and iOS by including shared files (e.g. List.swift
) in both the Lister iOS Framework (ListerKit
) and Lister watchOS 2 Framework (ListerKit (watchOS)
). (See the Shared ListerKit Framework Code group.)
In the Sharing Code Between an iOS App and a watchOS App section of the watchOS 2 Transition Guide, they confirm this kind of set up for watchOS 2:
In watchOS 2, 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.
[...]
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.
Note: In this project, wherever you see WatchKit this usually refers to watchOS 1, while Watch refers to watchOS 2.
Lister
):ListerKit
)Lister Today
)Lister Watch App
)Lister WatchKit Extension
)ListerKit.framework
)ListerKit.framework
)Lister WatchKit Extension.appex
)Lister.appex
)Lister Watch App.app
)Lister Today
or Lister
):ListerKit
)ListerKit.framework
)Lister
)ListerKit
):Lister
)Lister Today
)Lister WatchKit Extension
)Lister WatchKit Extension
):ListerKit
)Lister WatchKit App
)Lister
)Lister WatchKit App
):Lister WatchKit Extension
)Lister Watch Extension
):ListerKit (watchOS)
)ListerWatchKit.framework
)ListerWatchKit.framework
)Lister Watch App
):Lister
)ListerKit (watchOS)
or ListerWatchKit
):Lister Watch Extension
)Shared Lister WatchKit Code
group contains code that is shared by both the watchOS 1 and watchOS 2 extensions.Lister Watch App/ListerKit Framework (watchOS)
group implies that it should be a part of the ListerKit (watchOS)
target, but it is a part of the Lister Watch Extension
target instead.Shared ListerKit Framework Code
is primarily meant to share code between the iOS, watchOS and OS X ListerKit frameworks. However, there are some files omitted from the ListerKit (watchOS)
target: SegueHandlerType.swift
, CheckBoxLayer.swift
WatchKit
is primary used to refer to watchOS 1 in this project, the Lister watchOS 2 Framework's product name is ListerWatchKit
, yet it is only used in watchOS 2. Note: watchOS 1 does not use a framework.If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With