From 9c21445b68312e52825ab53d58a1b96076644a69 Mon Sep 17 00:00:00 2001 From: ldindu Date: Sun, 8 Dec 2019 18:53:59 +0000 Subject: [PATCH] Add fixture tests for ios app with xcframework --- Sources/TuistCore/Graph/TargetNode.swift | 143 ----------------------- features/generate.feature | 8 ++ fixtures/README.md | 10 +- 3 files changed, 17 insertions(+), 144 deletions(-) delete mode 100644 Sources/TuistCore/Graph/TargetNode.swift diff --git a/Sources/TuistCore/Graph/TargetNode.swift b/Sources/TuistCore/Graph/TargetNode.swift deleted file mode 100644 index e5da287eab0..00000000000 --- a/Sources/TuistCore/Graph/TargetNode.swift +++ /dev/null @@ -1,143 +0,0 @@ -import Basic -import Foundation -import TuistSupport - -public class TargetNode: GraphNode { - // MARK: - Attributes - - public let project: Project - public let target: Target - public var dependencies: [GraphNode] - - enum CodingKeys: String, CodingKey { - case path - case name - case platform - case product - case bundleId = "bundle_id" - case dependencies - case type - } - - // MARK: - Init - - public init(project: Project, - target: Target, - dependencies: [GraphNode]) { - self.project = project - self.target = target - self.dependencies = dependencies - super.init(path: project.path, name: target.name) - } - - public override func hash(into hasher: inout Hasher) { - super.hash(into: &hasher) - hasher.combine(target.name) - } - - static func == (lhs: TargetNode, rhs: TargetNode) -> Bool { - lhs.isEqual(to: rhs) && rhs.isEqual(to: lhs) - } - - override func isEqual(to otherNode: GraphNode) -> Bool { - guard let otherTagetNode = otherNode as? TargetNode else { - return false - } - return path == otherTagetNode.path - && target == otherTagetNode.target - } - - static func read(name: String, - path: AbsolutePath, - cache: GraphLoaderCaching, - circularDetector: GraphCircularDetecting, - modelLoader: GeneratorModelLoading) throws -> TargetNode { - if let targetNode = cache.targetNode(path, name: name) { return targetNode } - let project = try Project.at(path, cache: cache, circularDetector: circularDetector, modelLoader: modelLoader) - - guard let target = project.targets.first(where: { $0.name == name }) else { - throw GraphLoadingError.targetNotFound(name, path) - } - - let targetNode = TargetNode(project: project, target: target, dependencies: []) - cache.add(targetNode: targetNode) - - let dependencies: [GraphNode] = try target.dependencies.map { - try node(for: $0, - path: path, - name: name, - platform: target.platform, - cache: cache, - circularDetector: circularDetector, - modelLoader: modelLoader) - } - - targetNode.dependencies = dependencies - - try circularDetector.complete() - - return targetNode - } - - public override func encode(to encoder: Encoder) throws { - var container = encoder.container(keyedBy: CodingKeys.self) - try container.encode(path.pathString, forKey: .path) - try container.encode(target.name, forKey: .name) - try container.encode(target.platform.rawValue, forKey: .platform) - try container.encode(target.product.rawValue, forKey: .product) - try container.encode(target.bundleId, forKey: .bundleId) - try container.encode("source", forKey: .type) - - let dependencies = self.dependencies.compactMap { (dependency) -> String? in - if let targetDependency = dependency as? TargetNode { - return targetDependency.target.name - } else if let precompiledDependency = dependency as? PrecompiledNode { - return precompiledDependency.name - } else if let cocoapodsDependency = dependency as? CocoaPodsNode { - return cocoapodsDependency.name - } else { - return nil - } - } - try container.encode(dependencies, forKey: .dependencies) - } - - static func node(for dependency: Dependency, - path: AbsolutePath, - name: String, - platform: Platform, - cache: GraphLoaderCaching, - circularDetector: GraphCircularDetecting, - modelLoader: GeneratorModelLoading) throws -> GraphNode { - switch dependency { - case let .target(target): - let circularFrom = GraphCircularDetectorNode(path: path, name: name) - let circularTo = GraphCircularDetectorNode(path: path, name: target) - circularDetector.start(from: circularFrom, to: circularTo) - return try TargetNode.read(name: target, path: path, cache: cache, circularDetector: circularDetector, modelLoader: modelLoader) - case let .project(target, projectPath): - let circularFrom = GraphCircularDetectorNode(path: path, name: name) - let circularTo = GraphCircularDetectorNode(path: projectPath, name: target) - circularDetector.start(from: circularFrom, to: circularTo) - return try TargetNode.read(name: target, path: projectPath, cache: cache, circularDetector: circularDetector, modelLoader: modelLoader) - case let .framework(frameworkPath): - return try FrameworkNode.parse(path: frameworkPath, cache: cache) - case let .xcFramework(frameworkPath): - return try XCFrameworkParser.parse(path: frameworkPath, cache: cache) - case let .library(libraryPath, publicHeaders, swiftModuleMap): - return try LibraryNode.parse(publicHeaders: publicHeaders, - swiftModuleMap: swiftModuleMap, - path: libraryPath, - cache: cache) - case let .sdk(name, status): - return try SDKNode(name: name, platform: platform, status: status) - case let .cocoapods(podsPath): - return CocoaPodsNode.read(path: podsPath, cache: cache) - case let .package(product): - return PackageProductNode( - product: product, - path: path - ) - } - } -} diff --git a/features/generate.feature b/features/generate.feature index 6f28fa07427..0ea28457cde 100644 --- a/features/generate.feature +++ b/features/generate.feature @@ -230,3 +230,11 @@ Scenario: The project is an iOS application with watch app (ios_app_with_watchap Then I should be able to build for watchOS the scheme App Then the product 'App.app' with destination 'Debug-iphoneos' contains resource 'Watch/WatchApp.app' Then the product 'WatchApp.app' with destination 'Debug-watchos' contains extension 'WatchAppExtension' + +Scenario: The project is an iOS application with Xcframeworks (ios_app_with_xcframeworks) + Given that tuist is available + And I have a working directory + Then I copy the fixture ios_app_with_xcframeworks into the working directory + Then tuist generates the project + Then I should be able to build for iOS the scheme App + Then the product 'App.app' with destination 'Debug-iphoneos' contains the framework 'MyFramework' with architecture 'arm64' diff --git a/fixtures/README.md b/fixtures/README.md index dc05ecad43c..0b1c73451bd 100644 --- a/fixtures/README.md +++ b/fixtures/README.md @@ -271,4 +271,12 @@ An example of an iOS app that contains Carthage frameworks \*(fat frameworks wit ## ios_app_with_helpers -A basic iOS app that has some manifest bits extracted into helpers. \ No newline at end of file +A basic iOS app that has some manifest bits extracted into helpers. + +## ios_app_with_xcframeworks + +An example of an application which depends on prebuilt `.xcframework`s. + +The `.xcframework` can be obtained by running the `build.sh` script within the each of the framework directories. + +e.g. `ios_app_with_xcframeworks/Frameworks/MyFramework/build.sh`