Sharing code between iOS and tvOS

To share code between our iOS and tvOS app, we will need to let Xcode know the Swift files that need to be shared across different targets. This is easy to do by simply checking the targets a Swift file should be part of when compiling and building the product:

Select one of the Swift files inside the ShoppingList app folder, and you should see ShoppingList and ShoppingListTV under Target Membership inside File Inspector on the right side of the screen. Check the ShoppingListTV target. Now, go through the remaining Swift files inside the ShoppingList iOS app, except for AppDelegate.swift, and check the ShoppingListTV ...

Get Hands-On Full-Stack Development with Swift now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.