From 8b3c9ca68983d4f5d55bfab8e8089607d50cef85 Mon Sep 17 00:00:00 2001 From: Roman Blum Date: Thu, 8 Apr 2021 09:53:11 +0200 Subject: [PATCH 01/12] Support for tvOS app extensions --- Sources/ProjectDescription/Product.swift | 2 +- .../ValueGraph/ModelExtensions/Product+Core.swift | 4 ++-- .../Generator/InfoPlistContentProvider.swift | 2 +- Sources/TuistGenerator/GraphViz/NodeStyling.swift | 2 +- Sources/TuistGenerator/Linter/GraphLinter.swift | 13 ++++++------- Sources/TuistGraph/Models/Product.swift | 12 ++++++------ .../Product+ManifestMapper.swift | 2 ++ Tests/TuistGraphTests/Models/ProductTests.swift | 2 +- 8 files changed, 20 insertions(+), 19 deletions(-) diff --git a/Sources/ProjectDescription/Product.swift b/Sources/ProjectDescription/Product.swift index 1034f82c652..2aa84f13d61 100644 --- a/Sources/ProjectDescription/Product.swift +++ b/Sources/ProjectDescription/Product.swift @@ -20,7 +20,7 @@ public enum Product: String, Codable, Equatable { case watch2App // case watchExtension case watch2Extension -// case tvExtension + case tvExtension // case messagesApplication case messagesExtension case stickerPackExtension = "sticker_pack_extension" diff --git a/Sources/TuistCore/ValueGraph/ModelExtensions/Product+Core.swift b/Sources/TuistCore/ValueGraph/ModelExtensions/Product+Core.swift index dc646a9a5f0..04bf34c8ff0 100644 --- a/Sources/TuistCore/ValueGraph/ModelExtensions/Product+Core.swift +++ b/Sources/TuistCore/ValueGraph/ModelExtensions/Product+Core.swift @@ -31,8 +31,8 @@ extension Product { // return .watchExtension case .watch2Extension: return .watch2Extension - // case .tvExtension: - // return .tvExtension + case .tvExtension: + return .tvExtension // case .messagesApplication: // return .messagesApplication case .messagesExtension: diff --git a/Sources/TuistGenerator/Generator/InfoPlistContentProvider.swift b/Sources/TuistGenerator/Generator/InfoPlistContentProvider.swift index 9d0eed74fcf..b11a1290c4f 100644 --- a/Sources/TuistGenerator/Generator/InfoPlistContentProvider.swift +++ b/Sources/TuistGenerator/Generator/InfoPlistContentProvider.swift @@ -111,7 +111,7 @@ final class InfoPlistContentProvider: InfoPlistContentProviding { packageType = "FMWK" case .watch2App, .watch2Extension: packageType = "$(PRODUCT_BUNDLE_PACKAGE_TYPE)" - case .appExtension, .stickerPackExtension, .messagesExtension: + case .appExtension, .stickerPackExtension, .messagesExtension, .tvExtension: packageType = "XPC!" case .commandLineTool: packageType = nil diff --git a/Sources/TuistGenerator/GraphViz/NodeStyling.swift b/Sources/TuistGenerator/GraphViz/NodeStyling.swift index 9f96fb163b8..b349fb686f2 100644 --- a/Sources/TuistGenerator/GraphViz/NodeStyling.swift +++ b/Sources/TuistGenerator/GraphViz/NodeStyling.swift @@ -38,7 +38,7 @@ extension ValueGraphTarget { switch target.product { case .app, .watch2App, .commandLineTool, .appClip: return .init(fillColorName: .deepskyblue, strokeWidth: 1.5, shape: .box3d) - case .appExtension, .watch2Extension: + case .appExtension, .watch2Extension, .tvExtension: return .init(fillColorName: .deepskyblue2, shape: .component) case .messagesExtension, .stickerPackExtension: return .init(fillColorName: .springgreen2, shape: .component) diff --git a/Sources/TuistGenerator/Linter/GraphLinter.swift b/Sources/TuistGenerator/Linter/GraphLinter.swift index cb04605e2b8..b7649e73726 100644 --- a/Sources/TuistGenerator/Linter/GraphLinter.swift +++ b/Sources/TuistGenerator/Linter/GraphLinter.swift @@ -426,14 +426,13 @@ public class GraphLinter: GraphLinting { LintableTarget(platform: .macOS, product: .dynamicLibrary), LintableTarget(platform: .macOS, product: .staticFramework), ], - // tvOS LintableTarget(platform: .tvOS, product: .app): [ LintableTarget(platform: .tvOS, product: .staticLibrary), LintableTarget(platform: .tvOS, product: .dynamicLibrary), LintableTarget(platform: .tvOS, product: .framework), LintableTarget(platform: .tvOS, product: .staticFramework), LintableTarget(platform: .tvOS, product: .bundle), -// LintableTarget(platform: .tvOS, product: .tvExtension), + LintableTarget(platform: .tvOS, product: .tvExtension), ], LintableTarget(platform: .tvOS, product: .staticLibrary): [ LintableTarget(platform: .tvOS, product: .staticLibrary), @@ -462,11 +461,11 @@ public class GraphLinter: GraphLinting { LintableTarget(platform: .tvOS, product: .framework), LintableTarget(platform: .tvOS, product: .staticFramework), ], - // LintableTarget(platform: .tvOS, product: .tvExtension): [ -// LintableTarget(platform: .tvOS, product: .staticLibrary), -// LintableTarget(platform: .tvOS, product: .dynamicLibrary), -// LintableTarget(platform: .tvOS, product: .framework), -// ], + LintableTarget(platform: .tvOS, product: .tvExtension): [ + LintableTarget(platform: .tvOS, product: .staticLibrary), + LintableTarget(platform: .tvOS, product: .dynamicLibrary), + LintableTarget(platform: .tvOS, product: .framework), + ], // watchOS // LintableTarget(platform: .watchOS, product: .watchApp): [ // LintableTarget(platform: .watchOS, product: .staticLibrary), diff --git a/Sources/TuistGraph/Models/Product.swift b/Sources/TuistGraph/Models/Product.swift index 6c0d3b4e20a..2f33922b40e 100644 --- a/Sources/TuistGraph/Models/Product.swift +++ b/Sources/TuistGraph/Models/Product.swift @@ -15,7 +15,7 @@ public enum Product: String, CustomStringConvertible, CaseIterable, Encodable { case watch2App = "watch_2_app" // case watchExtension = "watch_extension" case watch2Extension = "watch_2_extension" - // case tvExtension = "tv_extension" + case tvExtension = "tv_extension" // case messagesApplication = "messages_application" case messagesExtension = "messages_extension" case stickerPackExtension = "sticker_pack_extension" @@ -49,8 +49,8 @@ public enum Product: String, CustomStringConvertible, CaseIterable, Encodable { // return "watchExtension" case .watch2Extension: return "watch2Extension" - // case .tvExtension: - // return "tvExtension" + case .tvExtension: + return "tvExtension" // case .messagesApplication: // return "messagesApplication" case .messagesExtension: @@ -92,8 +92,8 @@ public enum Product: String, CustomStringConvertible, CaseIterable, Encodable { // return "watch extension" case .watch2Extension: return "watch 2 extension" - // case .tvExtension: - // return "tv extension" + case .tvExtension: + return "tv extension" // case .messagesApplication: // return "iMessage application" case .messagesExtension: @@ -139,7 +139,7 @@ public enum Product: String, CustomStringConvertible, CaseIterable, Encodable { } if platform == .tvOS { - // base.append(.tvExtension) + base.append(.tvExtension) } if platform == .macOS || diff --git a/Sources/TuistLoader/Models+ManifestMappers/Product+ManifestMapper.swift b/Sources/TuistLoader/Models+ManifestMappers/Product+ManifestMapper.swift index 417a648c6e2..48274800b52 100644 --- a/Sources/TuistLoader/Models+ManifestMappers/Product+ManifestMapper.swift +++ b/Sources/TuistLoader/Models+ManifestMappers/Product+ManifestMapper.swift @@ -27,6 +27,8 @@ extension TuistGraph.Product { return .bundle case .appExtension: return .appExtension + case .tvExtension: + return .tvExtension case .stickerPackExtension: return .stickerPackExtension case .watch2App: diff --git a/Tests/TuistGraphTests/Models/ProductTests.swift b/Tests/TuistGraphTests/Models/ProductTests.swift index 50d3b5cfb09..2451dd6a660 100644 --- a/Tests/TuistGraphTests/Models/ProductTests.swift +++ b/Tests/TuistGraphTests/Models/ProductTests.swift @@ -67,7 +67,7 @@ final class ProductTests: XCTestCase { .staticLibrary, .dynamicLibrary, .framework, - // .tvExtension, + .tvExtension, .unitTests, .uiTests, ] From 5f1f9214c57ab521ebca083ab2458434f2583470 Mon Sep 17 00:00:00 2001 From: Roman Blum Date: Wed, 5 May 2021 16:58:38 +0200 Subject: [PATCH 02/12] Make tv extension being added to targets --- Sources/TuistCore/ValueGraph/ValueGraphTraverser.swift | 3 ++- Sources/TuistGenerator/Linter/TargetLinter.swift | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/Sources/TuistCore/ValueGraph/ValueGraphTraverser.swift b/Sources/TuistCore/ValueGraph/ValueGraphTraverser.swift index d1ea861ed99..a02a5da3187 100644 --- a/Sources/TuistCore/ValueGraph/ValueGraphTraverser.swift +++ b/Sources/TuistCore/ValueGraph/ValueGraphTraverser.swift @@ -182,7 +182,7 @@ public class ValueGraphTraverser: GraphTraversing { public func appExtensionDependencies(path: AbsolutePath, name: String) -> Set { let validProducts: [Product] = [ - .appExtension, .stickerPackExtension, .watch2Extension, .messagesExtension, + .appExtension, .stickerPackExtension, .watch2Extension, .tvExtension, .messagesExtension, ] return Set(directLocalTargetDependencies(path: path, name: name) .filter { validProducts.contains($0.target.product) }) @@ -625,6 +625,7 @@ public class ValueGraphTraverser: GraphTraversing { .unitTests, .uiTests, .watch2Extension, + .tvExtension, ] return validProducts.contains(target.product) } diff --git a/Sources/TuistGenerator/Linter/TargetLinter.swift b/Sources/TuistGenerator/Linter/TargetLinter.swift index d86514d32e5..1a7b9098811 100644 --- a/Sources/TuistGenerator/Linter/TargetLinter.swift +++ b/Sources/TuistGenerator/Linter/TargetLinter.swift @@ -199,7 +199,7 @@ class TargetLinter: TargetLinting { private func lintValidPlatformProductCombinations(target: Target) -> [LintingIssue] { let invalidProductsForPlatforms: [Platform: [Product]] = [ - .iOS: [.watch2App, .watch2Extension], + .iOS: [.watch2App, .watch2Extension, .tvExtension], ] if let invalidProducts = invalidProductsForPlatforms[target.platform], From 551b067122a68dcfca47b500d2a4a360f2ae0d6c Mon Sep 17 00:00:00 2001 From: Roman Blum Date: Wed, 5 May 2021 17:16:22 +0200 Subject: [PATCH 03/12] Update CHANGELOG --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index fe168dfe43e..76bdd9f427e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ Please, check out guidelines: https://keepachangelog.com/en/1.0.0/ ### Added - Add `tuist dependencies update` command. [#2819](https://github.com/tuist/tuist/pull/2819) by [@laxmorek](https://github.com/laxmorek) +- Add `tvExtension` target product. [#2793](https://github.com/tuist/tuist/pull/2793) by [@rmnblm](https://github.com/rmnblm) ### Changed From ee9445886f0b56386f4c1c8db49f5a208755af2b Mon Sep 17 00:00:00 2001 From: Roman Blum Date: Wed, 5 May 2021 17:53:42 +0200 Subject: [PATCH 04/12] Add tvOS Fixture --- projects/tuist/features/generate-4.feature | 9 +++++ .../tvos_app_with_extensions/Info.plist | 26 ++++++++++++++ .../tvos_app_with_extensions/Project.swift | 36 +++++++++++++++++++ .../Sources/AppDelegate.swift | 20 +++++++++++ .../Sources/StaticFramework.swift | 7 ++++ .../TopShelfExtension/ContentProvider.swift | 7 ++++ 6 files changed, 105 insertions(+) create mode 100644 projects/tuist/fixtures/tvos_app_with_extensions/Info.plist create mode 100644 projects/tuist/fixtures/tvos_app_with_extensions/Project.swift create mode 100644 projects/tuist/fixtures/tvos_app_with_extensions/Sources/AppDelegate.swift create mode 100644 projects/tuist/fixtures/tvos_app_with_extensions/StaticFramework/Sources/StaticFramework.swift create mode 100644 projects/tuist/fixtures/tvos_app_with_extensions/TopShelfExtension/ContentProvider.swift diff --git a/projects/tuist/features/generate-4.feature b/projects/tuist/features/generate-4.feature index d88d08214bd..14c67323cc1 100644 --- a/projects/tuist/features/generate-4.feature +++ b/projects/tuist/features/generate-4.feature @@ -43,3 +43,12 @@ Scenario: The project is an iOS application with extensions (ios_app_with_extens Then the product 'App.app' with destination 'Debug-iphonesimulator' contains extension 'NotificationServiceExtension' Then the product 'App.app' with destination 'Debug-iphonesimulator' contains extension 'NotificationServiceExtension' Then the product 'App.app' with destination 'Debug-iphonesimulator' does not contain headers + +Scenario: The project is a tvOS application with extensions (tvos_app_with_extensions) + Given that tuist is available + And I have a working directory + Then I copy the fixture tvos_app_with_extensions into the working directory + Then tuist generates the project + Then I should be able to build for tvOS the scheme App + Then the product 'App.app' with destination 'Debug-appletvsimulator' contains extension 'TopShelfExtension' + Then the product 'App.app' with destination 'Debug-appletvsimulator' does not contain headers diff --git a/projects/tuist/fixtures/tvos_app_with_extensions/Info.plist b/projects/tuist/fixtures/tvos_app_with_extensions/Info.plist new file mode 100644 index 00000000000..df420550dda --- /dev/null +++ b/projects/tuist/fixtures/tvos_app_with_extensions/Info.plist @@ -0,0 +1,26 @@ + + + + + CFBundleDevelopmentRegion + $(DEVELOPMENT_LANGUAGE) + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + $(PRODUCT_NAME) + CFBundlePackageType + $(PRODUCT_BUNDLE_PACKAGE_TYPE) + CFBundleShortVersionString + 1.0 + CFBundleVersion + 1 + LSRequiresIPhoneOS + + UIUserInterfaceStyle + Automatic + + diff --git a/projects/tuist/fixtures/tvos_app_with_extensions/Project.swift b/projects/tuist/fixtures/tvos_app_with_extensions/Project.swift new file mode 100644 index 00000000000..3e7a75656bf --- /dev/null +++ b/projects/tuist/fixtures/tvos_app_with_extensions/Project.swift @@ -0,0 +1,36 @@ +import ProjectDescription + +let project = Project(name: "App", + targets: [ + Target(name: "App", + platform: .tvOS, + product: .app, + bundleId: "io.tuist.App", + infoPlist: "Info.plist", + sources: ["Sources/**"], + dependencies: [ + .target(name: "TopShelfExtension") + ]), + Target(name: "TopShelfExtension", + platform: .tvOS, + product: .tvExtension, + bundleId: "io.tuist.App.TopShelfExtension", + infoPlist: .extendingDefault(with: [ + "CFBundleDisplayName": "$(PRODUCT_NAME)", + "NSExtension": [ + "NSExtensionPointIdentifier": "com.apple.tv-top-shelf", + "NSExtensionPrincipalClass": "$(PRODUCT_MODULE_NAME).ContentProvider" + ] + ]), + sources: "TopShelfExtension/**", + dependencies: [ + + ]), + Target(name: "StaticFramework", + platform: .iOS, + product: .staticFramework, + bundleId: "io.tuist.App.StaticFramework", + infoPlist: .default, + sources: "StaticFramework/Sources/**" + ) + ]) \ No newline at end of file diff --git a/projects/tuist/fixtures/tvos_app_with_extensions/Sources/AppDelegate.swift b/projects/tuist/fixtures/tvos_app_with_extensions/Sources/AppDelegate.swift new file mode 100644 index 00000000000..99d5a9570f3 --- /dev/null +++ b/projects/tuist/fixtures/tvos_app_with_extensions/Sources/AppDelegate.swift @@ -0,0 +1,20 @@ +import UIKit + +@UIApplicationMain +class AppDelegate: UIResponder, UIApplicationDelegate { + + var window: UIWindow? + + func application( + _ application: UIApplication, + didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil + ) -> Bool { + window = UIWindow(frame: UIScreen.main.bounds) + let viewController = UIViewController() + viewController.view.backgroundColor = .white + window?.rootViewController = viewController + window?.makeKeyAndVisible() + return true + } + +} \ No newline at end of file diff --git a/projects/tuist/fixtures/tvos_app_with_extensions/StaticFramework/Sources/StaticFramework.swift b/projects/tuist/fixtures/tvos_app_with_extensions/StaticFramework/Sources/StaticFramework.swift new file mode 100644 index 00000000000..d7a748e1588 --- /dev/null +++ b/projects/tuist/fixtures/tvos_app_with_extensions/StaticFramework/Sources/StaticFramework.swift @@ -0,0 +1,7 @@ +import Foundation + +public struct StaticFramework { + public init() { + + } +} \ No newline at end of file diff --git a/projects/tuist/fixtures/tvos_app_with_extensions/TopShelfExtension/ContentProvider.swift b/projects/tuist/fixtures/tvos_app_with_extensions/TopShelfExtension/ContentProvider.swift new file mode 100644 index 00000000000..fc9d78e39a6 --- /dev/null +++ b/projects/tuist/fixtures/tvos_app_with_extensions/TopShelfExtension/ContentProvider.swift @@ -0,0 +1,7 @@ +import TVServices + +class ContentProvider: TVTopShelfContentProvider { + override func loadTopShelfContent(completionHandler: @escaping (TVTopShelfContent?) -> Void) { + + } +} \ No newline at end of file From 41524f0ac9c4bde9e219e2b5a943447b0ea8017b Mon Sep 17 00:00:00 2001 From: Roman Blum Date: Tue, 1 Jun 2021 17:06:41 +0200 Subject: [PATCH 05/12] Add `tvTopShelfExtension` and `tvIntentsExtension` according to https://github.com/tuist/XcodeProj/pull/609 --- CHANGELOG.md | 2 +- Sources/ProjectDescription/Product.swift | 2 +- .../ModelExtensions/Product+Core.swift | 4 +++- .../ValueGraph/ValueGraphTraverser.swift | 4 ++-- .../Generator/InfoPlistContentProvider.swift | 2 +- .../TuistGenerator/GraphViz/NodeStyling.swift | 2 +- Sources/TuistGenerator/Linter/GraphLinter.swift | 4 ++-- .../TuistGenerator/Linter/TargetLinter.swift | 2 +- Sources/TuistGraph/Models/Product.swift | 17 +++++++++++------ .../Product+ManifestMapper.swift | 4 ++-- Tests/TuistGraphTests/Models/ProductTests.swift | 2 +- 11 files changed, 26 insertions(+), 19 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7be56076526..3ccb2c03b8d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,7 +10,7 @@ Please, check out guidelines: https://keepachangelog.com/en/1.0.0/ - Add option to `Scaffolding` for copy folder with option `.directory(path: "destinationContainerFolder", sourcePath: "sourceFolder")`. [#2985](https://github.com/tuist/tuist/pull/2985) by [@santi-d](https://github.com/santi-d) - Add possibility to specify version of Swift in the `Config.swift` manifest file. [#2998](https://github.com/tuist/tuist/pull/2998) by [@laxmorek](https://github.com/laxmorek) - Add `tuist run` command which allows running schemes of a project. [#2917](https://github.com/tuist/tuist/pull/2917) by [@luispadron](https://github.com/luispadron) -- Add `tvExtension` target product. [#2793](https://github.com/tuist/tuist/pull/2793) by [@rmnblm](https://github.com/rmnblm) +- Add `tvTopShelfExtension` and `tvIntentsExtension` target product. [#2793](https://github.com/tuist/tuist/pull/2793) by [@rmnblm](https://github.com/rmnblm) ### Changed diff --git a/Sources/ProjectDescription/Product.swift b/Sources/ProjectDescription/Product.swift index 2aa84f13d61..3760d26f061 100644 --- a/Sources/ProjectDescription/Product.swift +++ b/Sources/ProjectDescription/Product.swift @@ -20,7 +20,7 @@ public enum Product: String, Codable, Equatable { case watch2App // case watchExtension case watch2Extension - case tvExtension + case tvTopShelfExtension // case messagesApplication case messagesExtension case stickerPackExtension = "sticker_pack_extension" diff --git a/Sources/TuistCore/ValueGraph/ModelExtensions/Product+Core.swift b/Sources/TuistCore/ValueGraph/ModelExtensions/Product+Core.swift index 04bf34c8ff0..6fc4548632a 100644 --- a/Sources/TuistCore/ValueGraph/ModelExtensions/Product+Core.swift +++ b/Sources/TuistCore/ValueGraph/ModelExtensions/Product+Core.swift @@ -31,7 +31,9 @@ extension Product { // return .watchExtension case .watch2Extension: return .watch2Extension - case .tvExtension: + case .tvTopShelfExtension: // Important Note: https://github.com/tuist/XcodeProj/pull/609 + return .appExtension + case .tvIntentsExtension: // Important Note: https://github.com/tuist/XcodeProj/pull/609 return .tvExtension // case .messagesApplication: // return .messagesApplication diff --git a/Sources/TuistCore/ValueGraph/ValueGraphTraverser.swift b/Sources/TuistCore/ValueGraph/ValueGraphTraverser.swift index a02a5da3187..c74a81f120a 100644 --- a/Sources/TuistCore/ValueGraph/ValueGraphTraverser.swift +++ b/Sources/TuistCore/ValueGraph/ValueGraphTraverser.swift @@ -182,7 +182,7 @@ public class ValueGraphTraverser: GraphTraversing { public func appExtensionDependencies(path: AbsolutePath, name: String) -> Set { let validProducts: [Product] = [ - .appExtension, .stickerPackExtension, .watch2Extension, .tvExtension, .messagesExtension, + .appExtension, .stickerPackExtension, .watch2Extension, .tvTopShelfExtension, .messagesExtension, ] return Set(directLocalTargetDependencies(path: path, name: name) .filter { validProducts.contains($0.target.product) }) @@ -625,7 +625,7 @@ public class ValueGraphTraverser: GraphTraversing { .unitTests, .uiTests, .watch2Extension, - .tvExtension, + .tvTopShelfExtension, ] return validProducts.contains(target.product) } diff --git a/Sources/TuistGenerator/Generator/InfoPlistContentProvider.swift b/Sources/TuistGenerator/Generator/InfoPlistContentProvider.swift index b11a1290c4f..efb93fd2d58 100644 --- a/Sources/TuistGenerator/Generator/InfoPlistContentProvider.swift +++ b/Sources/TuistGenerator/Generator/InfoPlistContentProvider.swift @@ -111,7 +111,7 @@ final class InfoPlistContentProvider: InfoPlistContentProviding { packageType = "FMWK" case .watch2App, .watch2Extension: packageType = "$(PRODUCT_BUNDLE_PACKAGE_TYPE)" - case .appExtension, .stickerPackExtension, .messagesExtension, .tvExtension: + case .appExtension, .stickerPackExtension, .messagesExtension, .tvTopShelfExtension, .tvIntentsExtension: packageType = "XPC!" case .commandLineTool: packageType = nil diff --git a/Sources/TuistGenerator/GraphViz/NodeStyling.swift b/Sources/TuistGenerator/GraphViz/NodeStyling.swift index b349fb686f2..fa011bea908 100644 --- a/Sources/TuistGenerator/GraphViz/NodeStyling.swift +++ b/Sources/TuistGenerator/GraphViz/NodeStyling.swift @@ -38,7 +38,7 @@ extension ValueGraphTarget { switch target.product { case .app, .watch2App, .commandLineTool, .appClip: return .init(fillColorName: .deepskyblue, strokeWidth: 1.5, shape: .box3d) - case .appExtension, .watch2Extension, .tvExtension: + case .appExtension, .watch2Extension, .tvTopShelfExtension, .tvIntentsExtension: return .init(fillColorName: .deepskyblue2, shape: .component) case .messagesExtension, .stickerPackExtension: return .init(fillColorName: .springgreen2, shape: .component) diff --git a/Sources/TuistGenerator/Linter/GraphLinter.swift b/Sources/TuistGenerator/Linter/GraphLinter.swift index b7649e73726..977a9c2c165 100644 --- a/Sources/TuistGenerator/Linter/GraphLinter.swift +++ b/Sources/TuistGenerator/Linter/GraphLinter.swift @@ -432,7 +432,7 @@ public class GraphLinter: GraphLinting { LintableTarget(platform: .tvOS, product: .framework), LintableTarget(platform: .tvOS, product: .staticFramework), LintableTarget(platform: .tvOS, product: .bundle), - LintableTarget(platform: .tvOS, product: .tvExtension), + LintableTarget(platform: .tvOS, product: .tvTopShelfExtension), ], LintableTarget(platform: .tvOS, product: .staticLibrary): [ LintableTarget(platform: .tvOS, product: .staticLibrary), @@ -461,7 +461,7 @@ public class GraphLinter: GraphLinting { LintableTarget(platform: .tvOS, product: .framework), LintableTarget(platform: .tvOS, product: .staticFramework), ], - LintableTarget(platform: .tvOS, product: .tvExtension): [ + LintableTarget(platform: .tvOS, product: .tvTopShelfExtension): [ LintableTarget(platform: .tvOS, product: .staticLibrary), LintableTarget(platform: .tvOS, product: .dynamicLibrary), LintableTarget(platform: .tvOS, product: .framework), diff --git a/Sources/TuistGenerator/Linter/TargetLinter.swift b/Sources/TuistGenerator/Linter/TargetLinter.swift index afb00ae3f6d..5600c06781d 100644 --- a/Sources/TuistGenerator/Linter/TargetLinter.swift +++ b/Sources/TuistGenerator/Linter/TargetLinter.swift @@ -203,7 +203,7 @@ class TargetLinter: TargetLinting { private func lintValidPlatformProductCombinations(target: Target) -> [LintingIssue] { let invalidProductsForPlatforms: [Platform: [Product]] = [ - .iOS: [.watch2App, .watch2Extension, .tvExtension], + .iOS: [.watch2App, .watch2Extension, .tvTopShelfExtension], ] if let invalidProducts = invalidProductsForPlatforms[target.platform], diff --git a/Sources/TuistGraph/Models/Product.swift b/Sources/TuistGraph/Models/Product.swift index b8870b1ba6d..f7f104a4d18 100644 --- a/Sources/TuistGraph/Models/Product.swift +++ b/Sources/TuistGraph/Models/Product.swift @@ -15,7 +15,8 @@ public enum Product: String, CustomStringConvertible, CaseIterable, Codable { case watch2App = "watch_2_app" // case watchExtension = "watch_extension" case watch2Extension = "watch_2_extension" - case tvExtension = "tv_extension" + case tvTopShelfExtension = "tv_top_shelf_extension" + case tvIntentsExtension = "tv_intents_extension" // case messagesApplication = "messages_application" case messagesExtension = "messages_extension" case stickerPackExtension = "sticker_pack_extension" @@ -49,8 +50,10 @@ public enum Product: String, CustomStringConvertible, CaseIterable, Codable { // return "watchExtension" case .watch2Extension: return "watch2Extension" - case .tvExtension: - return "tvExtension" + case .tvTopShelfExtension: + return "tvTopShelfExtension" + case .tvIntentsExtension: + return "tvIntentsExtension" // case .messagesApplication: // return "messagesApplication" case .messagesExtension: @@ -92,8 +95,10 @@ public enum Product: String, CustomStringConvertible, CaseIterable, Codable { // return "watch extension" case .watch2Extension: return "watch 2 extension" - case .tvExtension: - return "tv extension" + case .tvTopShelfExtension: + return "tv top shelf extension" + case .tvIntentsExtension: + return "tv intents extension" // case .messagesApplication: // return "iMessage application" case .messagesExtension: @@ -139,7 +144,7 @@ public enum Product: String, CustomStringConvertible, CaseIterable, Codable { } if platform == .tvOS { - base.append(.tvExtension) + base.append(.tvTopShelfExtension) } if platform == .macOS || diff --git a/Sources/TuistLoader/Models+ManifestMappers/Product+ManifestMapper.swift b/Sources/TuistLoader/Models+ManifestMappers/Product+ManifestMapper.swift index 48274800b52..4d5a2907bb2 100644 --- a/Sources/TuistLoader/Models+ManifestMappers/Product+ManifestMapper.swift +++ b/Sources/TuistLoader/Models+ManifestMappers/Product+ManifestMapper.swift @@ -27,8 +27,8 @@ extension TuistGraph.Product { return .bundle case .appExtension: return .appExtension - case .tvExtension: - return .tvExtension + case .tvTopShelfExtension: + return .tvTopShelfExtension case .stickerPackExtension: return .stickerPackExtension case .watch2App: diff --git a/Tests/TuistGraphTests/Models/ProductTests.swift b/Tests/TuistGraphTests/Models/ProductTests.swift index 44051aabede..bdc99152145 100644 --- a/Tests/TuistGraphTests/Models/ProductTests.swift +++ b/Tests/TuistGraphTests/Models/ProductTests.swift @@ -83,7 +83,7 @@ final class ProductTests: XCTestCase { .staticLibrary, .dynamicLibrary, .framework, - .tvExtension, + .tvTopShelfExtension, .unitTests, .uiTests, ] From 3ae9d0eb24f7a8e8dff4289dd1d775b50bf44d84 Mon Sep 17 00:00:00 2001 From: Roman Blum Date: Tue, 1 Jun 2021 17:08:45 +0200 Subject: [PATCH 06/12] Only make `tvTopShelfExtension` available, for the moment --- .../ValueGraph/ModelExtensions/Product+Core.swift | 4 ++-- Sources/TuistGraph/Models/Product.swift | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Sources/TuistCore/ValueGraph/ModelExtensions/Product+Core.swift b/Sources/TuistCore/ValueGraph/ModelExtensions/Product+Core.swift index 6fc4548632a..eea5b1d55eb 100644 --- a/Sources/TuistCore/ValueGraph/ModelExtensions/Product+Core.swift +++ b/Sources/TuistCore/ValueGraph/ModelExtensions/Product+Core.swift @@ -33,8 +33,8 @@ extension Product { return .watch2Extension case .tvTopShelfExtension: // Important Note: https://github.com/tuist/XcodeProj/pull/609 return .appExtension - case .tvIntentsExtension: // Important Note: https://github.com/tuist/XcodeProj/pull/609 - return .tvExtension + // case .tvIntentsExtension: // Important Note: https://github.com/tuist/XcodeProj/pull/609 + // return .tvExtension // case .messagesApplication: // return .messagesApplication case .messagesExtension: diff --git a/Sources/TuistGraph/Models/Product.swift b/Sources/TuistGraph/Models/Product.swift index f7f104a4d18..17f52779ce0 100644 --- a/Sources/TuistGraph/Models/Product.swift +++ b/Sources/TuistGraph/Models/Product.swift @@ -16,7 +16,7 @@ public enum Product: String, CustomStringConvertible, CaseIterable, Codable { // case watchExtension = "watch_extension" case watch2Extension = "watch_2_extension" case tvTopShelfExtension = "tv_top_shelf_extension" - case tvIntentsExtension = "tv_intents_extension" + // case tvIntentsExtension = "tv_intents_extension" // case messagesApplication = "messages_application" case messagesExtension = "messages_extension" case stickerPackExtension = "sticker_pack_extension" @@ -52,8 +52,8 @@ public enum Product: String, CustomStringConvertible, CaseIterable, Codable { return "watch2Extension" case .tvTopShelfExtension: return "tvTopShelfExtension" - case .tvIntentsExtension: - return "tvIntentsExtension" + // case .tvIntentsExtension: + // return "tvIntentsExtension" // case .messagesApplication: // return "messagesApplication" case .messagesExtension: @@ -97,8 +97,8 @@ public enum Product: String, CustomStringConvertible, CaseIterable, Codable { return "watch 2 extension" case .tvTopShelfExtension: return "tv top shelf extension" - case .tvIntentsExtension: - return "tv intents extension" + // case .tvIntentsExtension: + // return "tv intents extension" // case .messagesApplication: // return "iMessage application" case .messagesExtension: From 80e3691c648d1469cfffba08de3e665d4afb8e0e Mon Sep 17 00:00:00 2001 From: Roman Blum Date: Tue, 1 Jun 2021 17:10:20 +0200 Subject: [PATCH 07/12] Fix fixture --- .../tuist/fixtures/tvos_app_with_extensions/Project.swift | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/projects/tuist/fixtures/tvos_app_with_extensions/Project.swift b/projects/tuist/fixtures/tvos_app_with_extensions/Project.swift index 3e7a75656bf..572453f37b2 100644 --- a/projects/tuist/fixtures/tvos_app_with_extensions/Project.swift +++ b/projects/tuist/fixtures/tvos_app_with_extensions/Project.swift @@ -13,7 +13,7 @@ let project = Project(name: "App", ]), Target(name: "TopShelfExtension", platform: .tvOS, - product: .tvExtension, + product: .tvTopShelfExtension, bundleId: "io.tuist.App.TopShelfExtension", infoPlist: .extendingDefault(with: [ "CFBundleDisplayName": "$(PRODUCT_NAME)", @@ -33,4 +33,4 @@ let project = Project(name: "App", infoPlist: .default, sources: "StaticFramework/Sources/**" ) - ]) \ No newline at end of file + ]) From a1f3a2cbe0733732d02ca2cda1f823f2ef313897 Mon Sep 17 00:00:00 2001 From: Roman Blum Date: Tue, 1 Jun 2021 18:51:50 +0200 Subject: [PATCH 08/12] Fix compiler errors --- Sources/TuistGenerator/Generator/InfoPlistContentProvider.swift | 2 +- Sources/TuistGenerator/GraphViz/NodeStyling.swift | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Sources/TuistGenerator/Generator/InfoPlistContentProvider.swift b/Sources/TuistGenerator/Generator/InfoPlistContentProvider.swift index efb93fd2d58..7f443a350fc 100644 --- a/Sources/TuistGenerator/Generator/InfoPlistContentProvider.swift +++ b/Sources/TuistGenerator/Generator/InfoPlistContentProvider.swift @@ -111,7 +111,7 @@ final class InfoPlistContentProvider: InfoPlistContentProviding { packageType = "FMWK" case .watch2App, .watch2Extension: packageType = "$(PRODUCT_BUNDLE_PACKAGE_TYPE)" - case .appExtension, .stickerPackExtension, .messagesExtension, .tvTopShelfExtension, .tvIntentsExtension: + case .appExtension, .stickerPackExtension, .messagesExtension, .tvTopShelfExtension: packageType = "XPC!" case .commandLineTool: packageType = nil diff --git a/Sources/TuistGenerator/GraphViz/NodeStyling.swift b/Sources/TuistGenerator/GraphViz/NodeStyling.swift index fa011bea908..c97572aaffe 100644 --- a/Sources/TuistGenerator/GraphViz/NodeStyling.swift +++ b/Sources/TuistGenerator/GraphViz/NodeStyling.swift @@ -38,7 +38,7 @@ extension ValueGraphTarget { switch target.product { case .app, .watch2App, .commandLineTool, .appClip: return .init(fillColorName: .deepskyblue, strokeWidth: 1.5, shape: .box3d) - case .appExtension, .watch2Extension, .tvTopShelfExtension, .tvIntentsExtension: + case .appExtension, .watch2Extension, .tvTopShelfExtension: return .init(fillColorName: .deepskyblue2, shape: .component) case .messagesExtension, .stickerPackExtension: return .init(fillColorName: .springgreen2, shape: .component) From b0f9fb1f54e6227cc85d7c1b1011e75879a8e991 Mon Sep 17 00:00:00 2001 From: Roman Blum Date: Wed, 2 Jun 2021 08:05:33 +0200 Subject: [PATCH 09/12] Add (commented out) .tvIntentsExtension case --- Sources/ProjectDescription/Product.swift | 1 + Sources/TuistGraph/Models/Product.swift | 1 + 2 files changed, 2 insertions(+) diff --git a/Sources/ProjectDescription/Product.swift b/Sources/ProjectDescription/Product.swift index 3760d26f061..86b85d7a356 100644 --- a/Sources/ProjectDescription/Product.swift +++ b/Sources/ProjectDescription/Product.swift @@ -21,6 +21,7 @@ public enum Product: String, Codable, Equatable { // case watchExtension case watch2Extension case tvTopShelfExtension +// case tvIntentsExtension // case messagesApplication case messagesExtension case stickerPackExtension = "sticker_pack_extension" diff --git a/Sources/TuistGraph/Models/Product.swift b/Sources/TuistGraph/Models/Product.swift index 17f52779ce0..90b5d4db5c6 100644 --- a/Sources/TuistGraph/Models/Product.swift +++ b/Sources/TuistGraph/Models/Product.swift @@ -145,6 +145,7 @@ public enum Product: String, CustomStringConvertible, CaseIterable, Codable { if platform == .tvOS { base.append(.tvTopShelfExtension) + // base.append(.tvIntentsExtension) } if platform == .macOS || From 81f91767fee1adec9bc6a1bdc6452dfba6f62c58 Mon Sep 17 00:00:00 2001 From: Roman Blum Date: Mon, 7 Jun 2021 10:12:10 +0200 Subject: [PATCH 10/12] Add suggestions from @kwridan --- CHANGELOG.md | 3 ++- .../TuistCore/ValueGraph/ValueGraphTraverser.swift | 1 - Sources/TuistGenerator/Linter/GraphLinter.swift | 1 + .../TopShelfExtension/ContentProvider.swift | 14 ++++++++++++-- 4 files changed, 15 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 189a91bdf8c..47bea82a906 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,8 @@ Please, check out guidelines: https://keepachangelog.com/en/1.0.0/ ## Next +- Add `tvTopShelfExtension` and `tvIntentsExtension` target product. [#2793](https://github.com/tuist/tuist/pull/2793) by [@rmnblm](https://github.com/rmnblm) + ## 1.44.0 ### Added @@ -12,7 +14,6 @@ Please, check out guidelines: https://keepachangelog.com/en/1.0.0/ - Add option to `Scaffolding` for copy folder with option `.directory(path: "destinationContainerFolder", sourcePath: "sourceFolder")`. [#2985](https://github.com/tuist/tuist/pull/2985) by [@santi-d](https://github.com/santi-d) - Add possibility to specify version of Swift in the `Config.swift` manifest file. [#2998](https://github.com/tuist/tuist/pull/2998) by [@laxmorek](https://github.com/laxmorek) - Add `tuist run` command which allows running schemes of a project. [#2917](https://github.com/tuist/tuist/pull/2917) by [@luispadron](https://github.com/luispadron) -- Add `tvTopShelfExtension` and `tvIntentsExtension` target product. [#2793](https://github.com/tuist/tuist/pull/2793) by [@rmnblm](https://github.com/rmnblm) ### Changed diff --git a/Sources/TuistCore/ValueGraph/ValueGraphTraverser.swift b/Sources/TuistCore/ValueGraph/ValueGraphTraverser.swift index c74a81f120a..3cbaf65c69d 100644 --- a/Sources/TuistCore/ValueGraph/ValueGraphTraverser.swift +++ b/Sources/TuistCore/ValueGraph/ValueGraphTraverser.swift @@ -625,7 +625,6 @@ public class ValueGraphTraverser: GraphTraversing { .unitTests, .uiTests, .watch2Extension, - .tvTopShelfExtension, ] return validProducts.contains(target.product) } diff --git a/Sources/TuistGenerator/Linter/GraphLinter.swift b/Sources/TuistGenerator/Linter/GraphLinter.swift index 977a9c2c165..f21ea8f6dd7 100644 --- a/Sources/TuistGenerator/Linter/GraphLinter.swift +++ b/Sources/TuistGenerator/Linter/GraphLinter.swift @@ -465,6 +465,7 @@ public class GraphLinter: GraphLinting { LintableTarget(platform: .tvOS, product: .staticLibrary), LintableTarget(platform: .tvOS, product: .dynamicLibrary), LintableTarget(platform: .tvOS, product: .framework), + LintableTarget(platform: .tvOS, product: .staticFramework) ], // watchOS // LintableTarget(platform: .watchOS, product: .watchApp): [ diff --git a/projects/tuist/fixtures/tvos_app_with_extensions/TopShelfExtension/ContentProvider.swift b/projects/tuist/fixtures/tvos_app_with_extensions/TopShelfExtension/ContentProvider.swift index fc9d78e39a6..0343e84a196 100644 --- a/projects/tuist/fixtures/tvos_app_with_extensions/TopShelfExtension/ContentProvider.swift +++ b/projects/tuist/fixtures/tvos_app_with_extensions/TopShelfExtension/ContentProvider.swift @@ -2,6 +2,16 @@ import TVServices class ContentProvider: TVTopShelfContentProvider { override func loadTopShelfContent(completionHandler: @escaping (TVTopShelfContent?) -> Void) { - + completionHandler(TVTopShelfSectionedContent(sections: [ + TVTopShelfItemCollection(items: [ + makeItem() + ]) + ])) } -} \ No newline at end of file + + private func makeItem() -> TVTopShelfSectionedItem { + let item = TVTopShelfSectionedItem(identifier: "tuist") + item.title = "Test" + return item + } +} From 9273b385cc39bb061e8462e41f735560890e9113 Mon Sep 17 00:00:00 2001 From: Roman Blum Date: Mon, 7 Jun 2021 10:21:10 +0200 Subject: [PATCH 11/12] Fix package type --- .../TuistGenerator/Generator/InfoPlistContentProvider.swift | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Sources/TuistGenerator/Generator/InfoPlistContentProvider.swift b/Sources/TuistGenerator/Generator/InfoPlistContentProvider.swift index 7f443a350fc..af0854063fe 100644 --- a/Sources/TuistGenerator/Generator/InfoPlistContentProvider.swift +++ b/Sources/TuistGenerator/Generator/InfoPlistContentProvider.swift @@ -109,9 +109,9 @@ final class InfoPlistContentProvider: InfoPlistContentProviding { packageType = "BNDL" case .staticFramework, .framework: packageType = "FMWK" - case .watch2App, .watch2Extension: + case .watch2App, .watch2Extension, .tvTopShelfExtension: packageType = "$(PRODUCT_BUNDLE_PACKAGE_TYPE)" - case .appExtension, .stickerPackExtension, .messagesExtension, .tvTopShelfExtension: + case .appExtension, .stickerPackExtension, .messagesExtension: packageType = "XPC!" case .commandLineTool: packageType = nil From 782bf6147ffca4cb1d47eeb6ca32d0bc0851e6a4 Mon Sep 17 00:00:00 2001 From: Kas Date: Tue, 8 Jun 2021 07:42:43 +0100 Subject: [PATCH 12/12] Run swiftformat --- Sources/TuistGenerator/Linter/GraphLinter.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sources/TuistGenerator/Linter/GraphLinter.swift b/Sources/TuistGenerator/Linter/GraphLinter.swift index f21ea8f6dd7..0be2396ebf6 100644 --- a/Sources/TuistGenerator/Linter/GraphLinter.swift +++ b/Sources/TuistGenerator/Linter/GraphLinter.swift @@ -465,7 +465,7 @@ public class GraphLinter: GraphLinting { LintableTarget(platform: .tvOS, product: .staticLibrary), LintableTarget(platform: .tvOS, product: .dynamicLibrary), LintableTarget(platform: .tvOS, product: .framework), - LintableTarget(platform: .tvOS, product: .staticFramework) + LintableTarget(platform: .tvOS, product: .staticFramework), ], // watchOS // LintableTarget(platform: .watchOS, product: .watchApp): [