-
-
Notifications
You must be signed in to change notification settings - Fork 508
/
ManifestTargetGenerator.swift
45 lines (40 loc) · 1.97 KB
/
ManifestTargetGenerator.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import Basic
import Foundation
import TuistCore
import TuistGenerator
protocol ManifestTargetGenerating {
func generateManifestTarget(for project: String, at path: AbsolutePath) throws -> Target
}
class ManifestTargetGenerator: ManifestTargetGenerating {
private let manifestLoader: GraphManifestLoading
private let resourceLocator: ResourceLocating
init(manifestLoader: GraphManifestLoading,
resourceLocator: ResourceLocating) {
self.manifestLoader = manifestLoader
self.resourceLocator = resourceLocator
}
func generateManifestTarget(for project: String,
at path: AbsolutePath) throws -> Target {
let settings = Settings(base: try manifestTargetBuildSettings(),
configurations: Settings.default.configurations,
defaultSettings: .recommended)
let manifest = try manifestLoader.manifestPath(at: path, manifest: .project)
return Target(name: "\(project)-Manifest",
platform: .macOS,
product: .staticFramework,
productName: "\(project)-Manifest",
bundleId: "io.tuist.manifests.${PRODUCT_NAME:rfc1034identifier}",
settings: settings,
sources: [(path: manifest, compilerFlags: nil)],
filesGroup: .group(name: "Manifest"))
}
func manifestTargetBuildSettings() throws -> [String: String] {
let frameworkParentDirectory = try resourceLocator.projectDescription().parentDirectory
var buildSettings = [String: String]()
buildSettings["FRAMEWORK_SEARCH_PATHS"] = frameworkParentDirectory.pathString
buildSettings["LIBRARY_SEARCH_PATHS"] = frameworkParentDirectory.pathString
buildSettings["SWIFT_INCLUDE_PATHS"] = frameworkParentDirectory.pathString
buildSettings["SWIFT_VERSION"] = Constants.swiftVersion
return buildSettings
}
}