Refactor/move options (#4131)

* feat: rename `-Project` scheme to `-Workspace`

* docs: update changelog

* feat: rename BuildGraphInspecting.projectSchemes

* feat: add support for configuring code coverage and testing options at the project level

* refactor: move workspace scheme generation options to workspace manifest

* fix: fix fixture

* chore: formatting

* chore: formatting

* docs: documentation

* chore: remove empty Config

* feat: change automatic schemes generation to byName

* fix: remove schemes from Tuist project description helpers

* fix: fix test

* fix: fix test

* fix: test

* fix: fix cache-frameworks acceptance test

* fix: acceptance

* fix: fix acceptance test

* refactor: use struct for Project.Options

* docs: add changelog entry

* refactor: use static func instead of init for Project.Options

* fix: disable automatic Xcode schemes for project editor

* refactor: move Workspace.GenerationOptions to separate file

* chore: formatting

* fix: fix meta tuist

* fix: fix tuist meta

* fix: fix project manifest dump test

* fix: fix project manifest dump test

* fix: generate missing workspace intermediate folder if needed

* fix: fix lockfiles

* fix: fix fixtures

* chore: format

* fix: fix test compilation error

* refactor: make enableXcodeSchemes a Bool?

* fix: fix ios_app_with_custom_workspace fixture

* docs: update docs

* refactor: more Workspace.GenerationOptions to separate file

* fix: fix tests

* chore: formattings

* refactor: change Config.generationOptions to be a struct

* fix: fix fixtures

* fix: fix compilation error

* fix: compilation error

* docs: changelog

* docs: fix docs

* fix: test compilation error

* fix: fix generate-3 fixture

* fix: fix test

* fix: fix tuist dump config test

* fix: fix test

* docs: fix doc

Co-authored-by: Marek Fořt <marekfort@me.com>

* chore: fix warnings

* refactor: move xcodeProjectName from Config.options to Project.options

* Revert "refactor: move xcodeProjectName from Config.options to Project.options"

This reverts commit 067bb7a48e.

* refactor: move disableShowEnvironmentVarsInScriptPhases from Config.options to Project.options

* feat: move lastXcodeUpgradeCheck to Workspace.options

* refactor: remove xcodeProjectName, organizationName, and developmentRegion from Config.generationOptions

* docs: changelog

* refactor: remove Config where not needed

* chore: invalidate GitHub action .build cache

* Revert "chore: invalidate GitHub action .build cache"

This reverts commit 91d3b78c2b.

* Revert "chore: fix warnings"

This reverts commit 3021a7ba2f.

* fix: compilation error

* fix: fix fixtures

* fix: fix broken tests

* chore: remove unused templateMacros

* feat: add back `developmentRegion` and `xcodeProjectName`

* chore: format

* chore: format

* Use forcedCacheDirectory even without Config.swift

* fix: fix tests

* fix: fix fixture

Co-authored-by: Marek Fořt <marekfort@me.com>
This commit is contained in:
Daniele Formichelli 2022-02-12 19:09:57 +01:00 committed by GitHub
parent 111d41ed52
commit 3959b6cd39
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
73 changed files with 380 additions and 887 deletions

View File

@ -9,7 +9,7 @@ Please, check out guidelines: https://keepachangelog.com/en/1.0.0/
- **Breaking** Tuist plugins 2.0 [#3492](https://github.com/tuist/tuist/pull/3492) by [@fortmarek](https://github.com/fortmarek)
- **Breaking** `tuist generate` automatically opens the generated project. [#3912](https://github.com/tuist/tuist/pull/3912) by [@danyf90](https://github.com/danyf90):
- **Motivation:**: Most of the times you want to open the project after generating it.
- **Migration:** If you need to generate the project without openeing it, just pass `--no-open` to `tuist generate`.
- **Migration:** If you need to generate the project without opening it, just pass `--no-open` to `tuist generate`.
- **Breaking** add `type` parameter to `TargetDependency.sdk` [#3961](https://github.com/tuist/tuist/pull/3961) by [@danyf90](https://github.com/danyf90)
- **Migration:** Add the `type` parameter where defining `sdk` target dependencies and remove both the extension and the `lib` prefix from the name
- **Breaking** move `disableBundleAccessors` and `disableSynthesizedResourceAccessors` from `Config.swift` to `Project.ProjectOption` [#3963](https://github.com/tuist/tuist/pull/3963) by [@danyf90](https://github.com/danyf90).
@ -34,6 +34,14 @@ Please, check out guidelines: https://keepachangelog.com/en/1.0.0/
- **Motivation**: A struct better represents the semantic of the type
- **Breaking** refactor `Config.generationOptions` to be a `struct` instead of an `enum` [#4109](https://github.com/tuist/tuist/pull/4109) by [@danyf90](https://github.com/danyf90)
- **Motivation**: A struct better represents the semantic of the type
- **Breaking** remove `xcodeProjectName`, `organizationName`, and `developmentRegion` from `Config.GenerationOptions` [#4131](https://github.com/tuist/tuist/pull/4131) by [@danyf90](https://github.com/danyf90)
- **Migration**: Configure them in `Project` instead or define helpers to share the value across projects
- **Breaking** move `Config.GenerationOptions.disableShowEnvironmentVarsInScriptPhases` to `Project.Options` [#4131](https://github.com/tuist/tuist/pull/4131) by [@danyf90](https://github.com/danyf90)
- **Motivation**: It is related to the project generation
- **Migration**: Configure it in `Project.Options` instead
- **Breaking** move `Config.GenerationOptions.lastXcodeUpgradeCheck` to `Workspace.GenerationOptions` [#4131](https://github.com/tuist/tuist/pull/4131) by [@danyf90](https://github.com/danyf90)
- **Motivation**: It is related to the workspace generation
- **Migration**: Configure it in `Worksapace.GenerrationOptions` instead
- Add support for configuring code coverage and testing options at the project level [#4090](https://github.com/tuist/tuist/pull/4090) by [@danyf90](https://github.com/danyf90)
- Add more detailed messaging for errors during manifest loading [#4076](https://github.com/tuist/tuist/pull/4076) by [@luispadron](https://github.com/luispadron)
- Deprecate legacy SPM support via Project.packages [#4112](https://github.com/tuist/tuist/pull/4112) by [@danyf90](https://github.com/danyf90)
@ -57,6 +65,7 @@ Please, check out guidelines: https://keepachangelog.com/en/1.0.0/
- Fix `tuist graph --skip-external-dependencies` for `Dependencies.swift` dependencies [#4115](https://github.com/tuist/tuist/pull/4115) by [@danyf90](https://github.com/danyf90) & [#4124](https://github.com/tuist/tuist/pull/4124) by [@laxmorek](https://github.com/laxmorek)
- Fix `envversion` command not printing the tuist env version [#4126](https://github.com/tuist/tuist/pull/4126) by [@takinwande](https://github.com/takinwande)
- Fix warning when importing `ProjectDescription` during `tuist edit`. It was caused by `.swiftsourceinfo` files being added to the release artifact [#4132](https://github.com/tuist/tuist/pull/4132) by [@luispadron](https://github.com/luispadron)
- Remove default MacCatalyst support when framework deployment target is set to iOS and/or iPad [#4134](https://github.com/tuist/tuist/pull/4134) by [@TheInkedEngineer](https://github.com/TheInkedEngineer)
### Added
@ -74,9 +83,7 @@ Please, check out guidelines: https://keepachangelog.com/en/1.0.0/
### Changed
- Use GitHub tags (via `git ls-remote`) to determine the latest Tuist version when installing/updating Tuist [#3985](https://github.com/tuist/tuist/pull/3985) by [@ezraberch](https://github.com/ezraberch)
- Remove default MacCatalyst support when framework deployment target is set to iOS and/or iPad [#4134](https://github.com/tuist/tuist/pull/4134) by [@TheInkedEngineer](https://github.com/TheInkedEngineer)
- Use GitHub tags (via `git ls-remote`) to determine the latest Tuist version when installing/updating Tuist [#3985](https://github.com/tuist/tuist/pull/3985) by [@ezraberch](https://github.com/ezraberch)
### Added
@ -1603,7 +1610,7 @@ let baseSettings = SettingsDictionary()
- **Breaking** Allow specifying a deployment target within project manifests [#541](https://github.com/tuist/tuist/pull/541) [@mollyIV](https://github.com/mollyIV).
- Add support for sticker pack extension & app extension products [#489](https://github.com/tuist/tuist/pull/489) by @Rag0n
- Utility to locate the root directory of a project [#622](https://github.com/tuist/tuist/pull/622) by [@pepibumur](https://github.com/pepibumur).
- Adds `codeCoverageTargets` to `TestAction` to make XCode gather coverage info only for that targets [#619](https://github.com/tuist/tuist/pull/619) by @abbasmousavi
- Adds `codeCoverageTargets` to `TestAction` to make Xcode gather coverage info only for that targets [#619](https://github.com/tuist/tuist/pull/619) by @abbasmousavi
- Enable the library evololution for the ProjectDescription framework [#625](https://github.com/tuist/tuist/pull/625) by [@pepibumur](https://github.com/pepibumur).
- Add support for watchOS apps [#623](https://github.com/tuist/tuist/pull/623) by [@kwridan](https://github.com/kwridan)
- Add linting for duplicate dependencies [#629](https://github.com/tuist/tuist/pull/629) by @lakpa

View File

@ -1,18 +1,6 @@
extension Config {
/// Contains options related to the project generation.
public struct GenerationOptions: Codable, Equatable {
/// Tuist generates the project with the specific name on disk instead of using the project name.
public let xcodeProjectName: TemplateString?
/// Tuist generates the project with the specific organization name.
public let organizationName: String?
/// Tuist generates the project with the specific development region.
public let developmentRegion: String?
/// Tuist disables echoing the ENV in shell script build phases
public let disableShowEnvironmentVarsInScriptPhases: Bool
/// When passed, Xcode will resolve its Package Manager dependencies using the system-defined
/// accounts (for example, git) instead of the Xcode-defined accounts
public let resolveDependenciesWithSystemScm: Bool
@ -21,27 +9,13 @@ extension Config {
/// in their declarations.
public let disablePackageVersionLocking: Bool
/// Allows to suppress warnings in Xcode about updates to recommended settings added in or below the specified Xcode version. The warnings appear when Xcode version has been upgraded.
/// It is recommended to set the version option to Xcode's version that is used for development of a project, for example `.lastUpgradeCheck(Version(13, 0, 0))` for Xcode 13.0.0.
public let lastXcodeUpgradeCheck: Version?
public static func options(
xcodeProjectName: TemplateString? = nil,
organizationName: String? = nil,
developmentRegion: String? = nil,
disableShowEnvironmentVarsInScriptPhases: Bool = false,
resolveDependenciesWithSystemScm: Bool = false,
disablePackageVersionLocking: Bool = false,
lastXcodeUpgradeCheck: Version? = nil
disablePackageVersionLocking: Bool = false
) -> Self {
self.init(
xcodeProjectName: xcodeProjectName,
organizationName: organizationName,
developmentRegion: developmentRegion,
disableShowEnvironmentVarsInScriptPhases: disableShowEnvironmentVarsInScriptPhases,
resolveDependenciesWithSystemScm: resolveDependenciesWithSystemScm,
disablePackageVersionLocking: disablePackageVersionLocking,
lastXcodeUpgradeCheck: lastXcodeUpgradeCheck
disablePackageVersionLocking: disablePackageVersionLocking
)
}
}

View File

@ -6,26 +6,41 @@ extension Project {
/// Defines how to generate automatic schemes
public let automaticSchemesOptions: AutomaticSchemesOptions
/// Tuist generates the project with the specific development region.
public let developmentRegion: String?
/// Disables generating Bundle accessors.
public let disableBundleAccessors: Bool
/// Tuist disables echoing the ENV in shell script build phases
public let disableShowEnvironmentVarsInScriptPhases: Bool
/// Disable the synthesized resource accessors generation
public let disableSynthesizedResourceAccessors: Bool
/// Text settings to override user ones for current project
public let textSettings: TextSettings
/// Tuist generates the project with the specific name on disk instead of using the project name.
public let xcodeProjectName: String?
public static func options(
automaticSchemesOptions: AutomaticSchemesOptions = .enabled(),
developmentRegion: String? = nil,
disableBundleAccessors: Bool = false,
disableShowEnvironmentVarsInScriptPhases: Bool = false,
disableSynthesizedResourceAccessors: Bool = false,
textSettings: TextSettings = .textSettings()
textSettings: TextSettings = .textSettings(),
xcodeProjectName: String? = nil
) -> Self {
self.init(
automaticSchemesOptions: automaticSchemesOptions,
developmentRegion: developmentRegion,
disableBundleAccessors: disableBundleAccessors,
disableShowEnvironmentVarsInScriptPhases: disableShowEnvironmentVarsInScriptPhases,
disableSynthesizedResourceAccessors: disableSynthesizedResourceAccessors,
textSettings: textSettings
textSettings: textSettings,
xcodeProjectName: xcodeProjectName
)
}
}

View File

@ -27,13 +27,19 @@ extension Workspace {
/// Contains options for autogenerated workspace schemes
public let autogeneratedWorkspaceSchemes: AutogeneratedWorkspaceSchemes
/// Allows to suppress warnings in Xcode about updates to recommended settings added in or below the specified Xcode version. The warnings appear when Xcode version has been upgraded.
/// It is recommended to set the version option to Xcode's version that is used for development of a project, for example `.lastXcodeUpgradeCheck(Version(13, 0, 0))` for Xcode 13.0.0.
public let lastXcodeUpgradeCheck: Version?
public static func options(
enableAutomaticXcodeSchemes: Bool? = false,
autogeneratedWorkspaceSchemes: AutogeneratedWorkspaceSchemes = .enabled()
autogeneratedWorkspaceSchemes: AutogeneratedWorkspaceSchemes = .enabled(),
lastXcodeUpgradeCheck: Version? = nil
) -> Self {
GenerationOptions(
enableAutomaticXcodeSchemes: enableAutomaticXcodeSchemes,
autogeneratedWorkspaceSchemes: autogeneratedWorkspaceSchemes
autogeneratedWorkspaceSchemes: autogeneratedWorkspaceSchemes,
lastXcodeUpgradeCheck: lastXcodeUpgradeCheck
)
}
}

View File

@ -75,7 +75,7 @@ final class SchemeDescriptorsGenerator: SchemeDescriptorsGenerating {
path: workspace.xcWorkspacePath.parentDirectory,
graphTraverser: graphTraverser,
generatedProjects: generatedProjects,
lastUpgradeCheck: workspace.lastUpgradeCheck
lastUpgradeCheck: workspace.generationOptions.lastXcodeUpgradeCheck
)
}

View File

@ -3,20 +3,19 @@ import TSCUtility
import TuistCore
public final class LastUpgradeVersionWorkspaceMapper: WorkspaceMapping {
let lastUpgradeVersion: Version
public init(lastUpgradeVersion: Version) {
self.lastUpgradeVersion = lastUpgradeVersion
}
public init() {}
// MARK: - WorkspaceMapping
public func map(workspace: WorkspaceWithProjects) throws -> (WorkspaceWithProjects, [SideEffectDescriptor]) {
guard let lastXcodeUpgradeCheck = workspace.workspace.generationOptions.lastXcodeUpgradeCheck else {
return (workspace, [])
}
var projects = workspace.projects
projects.indices.forEach { projects[$0].lastUpgradeCheck = lastUpgradeVersion }
projects.indices.forEach { projects[$0].lastUpgradeCheck = projects[$0].lastUpgradeCheck ?? lastXcodeUpgradeCheck }
var workspace = workspace
workspace.workspace.lastUpgradeCheck = lastUpgradeVersion
workspace.projects = projects
return (workspace, [])

View File

@ -0,0 +1,22 @@
import TuistCore
import TuistGraph
/// This mapper takes the `Project` `disableShowEnvironmentVarsInScriptPhases` option and pushes it down into all of the `Target`s shell script `TargetAction`s
public final class TargetActionDisableShowEnvVarsProjectMapper: ProjectMapping {
public init() {}
public func map(project: Project) throws -> (Project, [SideEffectDescriptor]) {
var project = project
project.targets = project.targets.map { target in
var mappedTarget = target
mappedTarget.scripts = mappedTarget.scripts.map {
var script = $0
script.showEnvVarsInLog = !project.options.disableShowEnvironmentVarsInScriptPhases
return script
}
return mappedTarget
}
return (project, [])
}
}

View File

@ -1,23 +0,0 @@
import TuistCore
import TuistGraph
/// This mapper takes the `Config`level setting `disableShowEnvironmentVarsInScriptPhases` and pushes it down into all of the `Project`'s shell script `TargetAction`s`
public final class TargetActionEnvironmentMapper: TargetMapping {
let showEnvVarsInLog: Bool
public init(_ showEnvVarsInLog: Bool) {
self.showEnvVarsInLog = showEnvVarsInLog
}
public func map(target: Target) throws -> (Target, [SideEffectDescriptor]) {
var target = target
let scripts: [TargetScript] = target.scripts.map {
var script = $0
script.showEnvVarsInLog = showEnvVarsInLog
return script
}
target.scripts = scripts
return (target, [SideEffectDescriptor]())
}
}

View File

@ -35,13 +35,8 @@ public struct Config: Equatable, Hashable {
swiftVersion: nil,
plugins: [],
generationOptions: .init(
xcodeProjectName: nil,
organizationName: nil,
developmentRegion: nil,
disableShowEnvironmentVarsInScriptPhases: false,
resolveDependenciesWithSystemScm: false,
disablePackageVersionLocking: false,
lastXcodeUpgradeCheck: nil
disablePackageVersionLocking: false
),
path: nil
)

View File

@ -3,18 +3,6 @@ import TSCUtility
extension Config {
/// Contains options related to the project generation.
public struct GenerationOptions: Codable, Hashable {
/// Tuist generates the project with the specific name on disk instead of using the project name.
public let xcodeProjectName: String?
/// Tuist generates the project with the specific organization name.
public let organizationName: String?
/// Tuist generates the project with the specific development region.
public let developmentRegion: String?
/// Tuist disables echoing the ENV in shell script build phases
public let disableShowEnvironmentVarsInScriptPhases: Bool
/// When passed, Xcode will resolve its Package Manager dependencies using the system-defined
/// accounts (for example, git) instead of the Xcode-defined accounts
public let resolveDependenciesWithSystemScm: Bool
@ -23,26 +11,12 @@ extension Config {
/// in their declarations.
public let disablePackageVersionLocking: Bool
/// Allows to suppress warnings in Xcode about updates to recommended settings added in or below the specified Xcode version. The warnings appear when Xcode version has been upgraded.
/// It is recommended to set the version option to Xcode's version that is used for development of a project, for example `.lastUpgradeCheck(Version(13, 0, 0))` for Xcode 13.0.0.
public let lastXcodeUpgradeCheck: Version?
public init(
xcodeProjectName: String?,
organizationName: String?,
developmentRegion: String?,
disableShowEnvironmentVarsInScriptPhases: Bool,
resolveDependenciesWithSystemScm: Bool,
disablePackageVersionLocking: Bool,
lastXcodeUpgradeCheck: Version?
disablePackageVersionLocking: Bool
) {
self.xcodeProjectName = xcodeProjectName
self.organizationName = organizationName
self.developmentRegion = developmentRegion
self.disableShowEnvironmentVarsInScriptPhases = disableShowEnvironmentVarsInScriptPhases
self.resolveDependenciesWithSystemScm = resolveDependenciesWithSystemScm
self.disablePackageVersionLocking = disablePackageVersionLocking
self.lastXcodeUpgradeCheck = lastXcodeUpgradeCheck
}
}
}

View File

@ -18,10 +18,10 @@ public struct Project: Hashable, Equatable, CustomStringConvertible, CustomDebug
public var name: String
/// Organization name.
public var organizationName: String?
public let organizationName: String?
/// Development region code e.g. `en`.
public var developmentRegion: String?
public let developmentRegion: String?
/// Additional project options.
public var options: Options

View File

@ -9,6 +9,9 @@ extension Project {
/// Disables generating Bundle accessors.
public let disableBundleAccessors: Bool
/// Tuist disables echoing the ENV in shell script build phases
public let disableShowEnvironmentVarsInScriptPhases: Bool
/// Disable the synthesized resource accessors generation
public let disableSynthesizedResourceAccessors: Bool
@ -18,11 +21,13 @@ extension Project {
public init(
automaticSchemesOptions: AutomaticSchemesOptions,
disableBundleAccessors: Bool,
disableShowEnvironmentVarsInScriptPhases: Bool,
disableSynthesizedResourceAccessors: Bool,
textSettings: TextSettings
) {
self.automaticSchemesOptions = automaticSchemesOptions
self.disableBundleAccessors = disableBundleAccessors
self.disableShowEnvironmentVarsInScriptPhases = disableShowEnvironmentVarsInScriptPhases
self.disableSynthesizedResourceAccessors = disableSynthesizedResourceAccessors
self.textSettings = textSettings
}

View File

@ -14,7 +14,6 @@ public struct Workspace: Equatable, Codable {
public var schemes: [Scheme]
public var ideTemplateMacros: IDETemplateMacros?
public var additionalFiles: [FileElement]
public var lastUpgradeCheck: Version?
public var generationOptions: GenerationOptions
// MARK: - Init
@ -27,11 +26,11 @@ public struct Workspace: Equatable, Codable {
schemes: [Scheme] = [],
generationOptions: GenerationOptions = .init(
enableAutomaticXcodeSchemes: false,
autogeneratedWorkspaceSchemes: .enabled(codeCoverageMode: .disabled, testingOptions: [])
autogeneratedWorkspaceSchemes: .enabled(codeCoverageMode: .disabled, testingOptions: []),
lastXcodeUpgradeCheck: nil
),
ideTemplateMacros: IDETemplateMacros? = nil,
additionalFiles: [FileElement] = [],
lastUpgradeCheck: Version? = nil
additionalFiles: [FileElement] = []
) {
self.path = path
self.xcWorkspacePath = xcWorkspacePath
@ -41,7 +40,6 @@ public struct Workspace: Equatable, Codable {
self.generationOptions = generationOptions
self.ideTemplateMacros = ideTemplateMacros
self.additionalFiles = additionalFiles
self.lastUpgradeCheck = lastUpgradeCheck
}
}
@ -61,8 +59,7 @@ extension Workspace {
schemes: schemes,
generationOptions: generationOptions,
ideTemplateMacros: ideTemplateMacros,
additionalFiles: additionalFiles + files.map { .file(path: $0) },
lastUpgradeCheck: lastUpgradeCheck
additionalFiles: additionalFiles + files.map { .file(path: $0) }
)
}
@ -75,8 +72,7 @@ extension Workspace {
schemes: schemes,
generationOptions: generationOptions,
ideTemplateMacros: ideTemplateMacros,
additionalFiles: additionalFiles,
lastUpgradeCheck: lastUpgradeCheck
additionalFiles: additionalFiles
)
}
@ -89,8 +85,7 @@ extension Workspace {
schemes: schemes,
generationOptions: generationOptions,
ideTemplateMacros: ideTemplateMacros,
additionalFiles: additionalFiles,
lastUpgradeCheck: lastUpgradeCheck
additionalFiles: additionalFiles
)
}

View File

@ -1,3 +1,5 @@
import TSCUtility
extension Workspace {
/// Contains options related to the workspace generation.
public struct GenerationOptions: Codable, Equatable {
@ -45,12 +47,18 @@ extension Workspace {
/// Options for autogenerated workspace schemes
public let autogeneratedWorkspaceSchemes: AutogeneratedWorkspaceSchemes
/// Allows to suppress warnings in Xcode about updates to recommended settings added in or below the specified Xcode version. The warnings appear when Xcode version has been upgraded.
/// It is recommended to set the version option to Xcode's version that is used for development of a project, for example `.lastXcodeUpgradeCheck(Version(13, 0, 0))` for Xcode 13.0.0.
public let lastXcodeUpgradeCheck: Version?
public init(
enableAutomaticXcodeSchemes: Bool?,
autogeneratedWorkspaceSchemes: AutogeneratedWorkspaceSchemes
autogeneratedWorkspaceSchemes: AutogeneratedWorkspaceSchemes,
lastXcodeUpgradeCheck: Version?
) {
self.enableAutomaticXcodeSchemes = enableAutomaticXcodeSchemes
self.autogeneratedWorkspaceSchemes = autogeneratedWorkspaceSchemes
self.lastXcodeUpgradeCheck = lastXcodeUpgradeCheck
}
}
}

View File

@ -27,22 +27,12 @@ extension Config {
extension Config.GenerationOptions {
public static func test(
xcodeProjectName: String? = nil,
organizationName: String? = nil,
developmentRegion: String? = nil,
disableShowEnvironmentVarsInScriptPhases: Bool = false,
resolveDependenciesWithSystemScm: Bool = false,
disablePackageVersionLocking: Bool = false,
lastXcodeUpgradeCheck: Version? = nil
disablePackageVersionLocking: Bool = false
) -> Self {
.init(
xcodeProjectName: xcodeProjectName,
organizationName: organizationName,
developmentRegion: developmentRegion,
disableShowEnvironmentVarsInScriptPhases: disableShowEnvironmentVarsInScriptPhases,
resolveDependenciesWithSystemScm: resolveDependenciesWithSystemScm,
disablePackageVersionLocking: disablePackageVersionLocking,
lastXcodeUpgradeCheck: lastXcodeUpgradeCheck
disablePackageVersionLocking: disablePackageVersionLocking
)
}
}

View File

@ -11,12 +11,7 @@ extension Project {
name: String = "Project",
organizationName: String? = nil,
developmentRegion: String? = nil,
options: Options = .init(
automaticSchemesOptions: .disabled,
disableBundleAccessors: false,
disableSynthesizedResourceAccessors: false,
textSettings: .init(usesTabs: nil, indentWidth: nil, tabWidth: nil, wrapsLines: nil)
),
options: Options = .test(automaticSchemesOptions: .disabled),
settings: Settings = Settings.test(),
filesGroup: ProjectGroup = .group(name: "Project"),
targets: [Target] = [Target.test()],
@ -54,12 +49,7 @@ extension Project {
name: String = "Project",
organizationName: String? = nil,
developmentRegion: String? = nil,
options: Options = .init(
automaticSchemesOptions: .disabled,
disableBundleAccessors: false,
disableSynthesizedResourceAccessors: false,
textSettings: .init(usesTabs: nil, indentWidth: nil, tabWidth: nil, wrapsLines: nil)
),
options: Options = .test(automaticSchemesOptions: .disabled),
settings: Settings = .default,
filesGroup: ProjectGroup = .group(name: "Project"),
targets: [Target] = [],

View File

@ -13,12 +13,14 @@ extension Project.Options {
testingOptions: []
),
disableBundleAccessors: Bool = false,
disableShowEnvironmentVarsInScriptPhases: Bool = false,
disableSynthesizedResourceAccessors: Bool = false,
textSettings: TextSettings = .init(usesTabs: nil, indentWidth: nil, tabWidth: nil, wrapsLines: nil)
) -> Self {
.init(
automaticSchemesOptions: automaticSchemesOptions,
disableBundleAccessors: disableBundleAccessors,
disableShowEnvironmentVarsInScriptPhases: disableShowEnvironmentVarsInScriptPhases,
disableSynthesizedResourceAccessors: disableSynthesizedResourceAccessors,
textSettings: textSettings
)

View File

@ -12,11 +12,7 @@ extension Workspace {
schemes: [Scheme] = [],
ideTemplateMacros: IDETemplateMacros? = nil,
additionalFiles: [FileElement] = [],
lastUpgradeCheck: Version? = nil,
generationOptions: GenerationOptions = .init(
enableAutomaticXcodeSchemes: false,
autogeneratedWorkspaceSchemes: .enabled(codeCoverageMode: .disabled, testingOptions: [])
)
generationOptions: GenerationOptions = .test()
) -> Workspace {
Workspace(
path: path,
@ -26,8 +22,21 @@ extension Workspace {
schemes: schemes,
generationOptions: generationOptions,
ideTemplateMacros: ideTemplateMacros,
additionalFiles: additionalFiles,
lastUpgradeCheck: lastUpgradeCheck
additionalFiles: additionalFiles
)
}
}
extension Workspace.GenerationOptions {
public static func test(
enableAutomaticXcodeSchemes: Bool? = false,
autogeneratedWorkspaceSchemes: AutogeneratedWorkspaceSchemes = .enabled(codeCoverageMode: .disabled, testingOptions: []),
lastXcodeUpgradeCheck: Version? = nil
) -> Self {
.init(
enableAutomaticXcodeSchemes: enableAutomaticXcodeSchemes,
autogeneratedWorkspaceSchemes: autogeneratedWorkspaceSchemes,
lastXcodeUpgradeCheck: lastXcodeUpgradeCheck
)
}
}

View File

@ -39,7 +39,7 @@ protocol GeneratorFactorying {
/// Returns the default generator.
/// - Parameter config: The project configuration.
/// - Returns: A Generator instance.
func `default`(config: Config) -> Generating
func `default`() -> Generating
/// Returns a generator that generates a cacheable project.
/// - Parameter config: The project configuration.
@ -71,7 +71,7 @@ class GeneratorFactory: GeneratorFactorying {
{
let contentHasher = ContentHasher()
let projectMapperFactory = ProjectMapperFactory(contentHasher: contentHasher)
let projectMappers = projectMapperFactory.default(config: config)
let projectMappers = projectMapperFactory.default()
let workspaceMapperFactory = WorkspaceMapperFactory(projectMapper: SequentialProjectMapper(mappers: projectMappers))
let graphMapperFactory = GraphMapperFactory(contentHasher: contentHasher)
@ -82,7 +82,7 @@ class GeneratorFactory: GeneratorFactorying {
cacheProfile: cacheProfile,
cacheOutputType: xcframeworks ? .xcframework : .framework
)
let workspaceMappers = workspaceMapperFactory.default(config: config)
let workspaceMappers = workspaceMapperFactory.default()
let manifestLoader = ManifestLoaderFactory().createManifestLoader()
return Generator(
manifestLoader: manifestLoader,
@ -94,10 +94,6 @@ class GeneratorFactory: GeneratorFactorying {
)
}
func `default`(config: Config) -> Generating {
self.default(config: config, contentHasher: ContentHasher())
}
func test(
config: Config,
automationPath: AbsolutePath,
@ -106,13 +102,12 @@ class GeneratorFactory: GeneratorFactorying {
) -> Generating {
let contentHasher = ContentHasher()
let projectMapperFactory = ProjectMapperFactory(contentHasher: contentHasher)
let projectMappers = projectMapperFactory.automation(config: config, skipUITests: skipUITests)
let projectMappers = projectMapperFactory.automation(skipUITests: skipUITests)
let workspaceMapperFactory = WorkspaceMapperFactory(projectMapper: SequentialProjectMapper(mappers: projectMappers))
let graphMapperFactory = GraphMapperFactory(contentHasher: contentHasher)
let graphMappers = graphMapperFactory.automation(config: config, testsCacheDirectory: testsCacheDirectory)
let workspaceMappers = workspaceMapperFactory.automation(
config: config,
workspaceDirectory: FileHandler.shared.resolveSymlinks(automationPath)
)
let manifestLoader = ManifestLoaderFactory().createManifestLoader()
@ -135,7 +130,7 @@ class GeneratorFactory: GeneratorFactorying {
) -> Generating {
let contentHasher = ContentHasher()
let projectMapperFactory = ProjectMapperFactory(contentHasher: contentHasher)
let projectMappers = projectMapperFactory.default(config: config)
let projectMappers = projectMapperFactory.default()
let workspaceMapperFactory = WorkspaceMapperFactory(projectMapper: SequentialProjectMapper(mappers: projectMappers))
let graphMapperFactory = GraphMapperFactory(contentHasher: contentHasher)
@ -152,7 +147,7 @@ class GeneratorFactory: GeneratorFactorying {
graphMappers = graphMapperFactory.cache(includedTargets: includedTargets)
}
let workspaceMappers = workspaceMapperFactory.cache(config: config, includedTargets: includedTargets)
let workspaceMappers = workspaceMapperFactory.cache(includedTargets: includedTargets)
let manifestLoader = ManifestLoaderFactory().createManifestLoader()
return Generator(
manifestLoader: manifestLoader,
@ -164,16 +159,14 @@ class GeneratorFactory: GeneratorFactorying {
)
}
// MARK: - Fileprivate
func `default`(config: Config, contentHasher _: ContentHashing) -> Generating {
func `default`() -> Generating {
let contentHasher = ContentHasher()
let projectMapperFactory = ProjectMapperFactory(contentHasher: contentHasher)
let projectMappers = projectMapperFactory.default(config: config)
let projectMappers = projectMapperFactory.default()
let workspaceMapperFactory = WorkspaceMapperFactory(projectMapper: SequentialProjectMapper(mappers: projectMappers))
let graphMapperFactory = GraphMapperFactory(contentHasher: contentHasher)
let graphMappers = graphMapperFactory.default()
let workspaceMappers = workspaceMapperFactory.default(config: config)
let workspaceMappers = workspaceMapperFactory.default()
let manifestLoader = ManifestLoaderFactory().createManifestLoader()
return Generator(
manifestLoader: manifestLoader,

View File

@ -12,13 +12,13 @@ protocol ProjectMapperFactorying {
/// Returns the default project mapper.
/// - Parameter config: The project configuration
/// - Returns: A project mapper instance.
func `default`(config: Config) -> [ProjectMapping]
func `default`() -> [ProjectMapping]
/// Returns a project mapper for automation.
/// - Parameter config: The project configuration.
/// - Parameter skipUITests: Whether UI tests should be skipped.
/// - Returns: An instance of a project mapper.
func automation(config: Config, skipUITests: Bool) -> [ProjectMapping]
func automation(skipUITests: Bool) -> [ProjectMapping]
}
final class ProjectMapperFactory: ProjectMapperFactorying {
@ -28,9 +28,9 @@ final class ProjectMapperFactory: ProjectMapperFactorying {
self.contentHasher = contentHasher
}
func automation(config: Config, skipUITests: Bool) -> [ProjectMapping] {
func automation(skipUITests: Bool) -> [ProjectMapping] {
var mappers: [ProjectMapping] = []
mappers += self.default(config: config)
mappers += self.default()
mappers.append(
SourceRootPathProjectMapper()
@ -45,7 +45,7 @@ final class ProjectMapperFactory: ProjectMapperFactorying {
return mappers
}
func `default`(config: Config) -> [ProjectMapping] {
func `default`() -> [ProjectMapping] {
var mappers: [ProjectMapping] = []
// Delete current derived
@ -59,11 +59,7 @@ final class ProjectMapperFactory: ProjectMapperFactorying {
)
// Logfile noise suppression
if config.generationOptions.disableShowEnvironmentVarsInScriptPhases {
mappers.append(
TargetProjectMapper(mapper: TargetActionEnvironmentMapper(false))
)
}
mappers.append(TargetActionDisableShowEnvVarsProjectMapper())
// Support for resources in libraries
mappers.append(ResourcesProjectMapper(contentHasher: ContentHasher()))
@ -75,12 +71,6 @@ final class ProjectMapperFactory: ProjectMapperFactorying {
// Info Plist
mappers.append(GenerateInfoPlistProjectMapper())
// Project name and organization
mappers.append(ProjectNameAndOrganizationMapper(config: config))
// Development region
mappers.append(ProjectDevelopmentRegionMapper(config: config))
// Template macros
mappers.append(IDETemplateMacrosMapper())

View File

@ -9,19 +9,19 @@ import TuistGraph
protocol WorkspaceMapperFactorying {
/// Returns the default workspace mapper.
/// - Returns: A workspace mapping instance.
func `default`(config: Config) -> [WorkspaceMapping]
func `default`() -> [WorkspaceMapping]
/// Returns a mapper to generate cacheable prorjects.
/// - Parameter config: The project configuration.
/// - Parameter includedTargets: The list of targets to cache.
/// - Returns: A workspace mapping instance.
func cache(config: Config, includedTargets: Set<String>) -> [WorkspaceMapping]
func cache(includedTargets: Set<String>) -> [WorkspaceMapping]
/// Returns a mapper for automation commands like build and test.
/// - Parameter config: The project configuration.
/// - Parameter workspaceDirectory: The directory where the workspace will be generated.
/// - Returns: A workspace mapping instance.
func automation(config: Config, workspaceDirectory: AbsolutePath) -> [WorkspaceMapping]
func automation(workspaceDirectory: AbsolutePath) -> [WorkspaceMapping]
}
final class WorkspaceMapperFactory: WorkspaceMapperFactorying {
@ -31,25 +31,25 @@ final class WorkspaceMapperFactory: WorkspaceMapperFactorying {
self.projectMapper = projectMapper
}
func cache(config: Config, includedTargets: Set<String>) -> [WorkspaceMapping] {
var mappers = self.default(config: config, forceWorkspaceSchemes: false)
func cache(includedTargets: Set<String>) -> [WorkspaceMapping] {
var mappers = self.default(forceWorkspaceSchemes: false)
mappers += [GenerateCacheableSchemesWorkspaceMapper(includedTargets: includedTargets)]
return mappers
}
func automation(config: Config, workspaceDirectory: AbsolutePath) -> [WorkspaceMapping] {
func automation(workspaceDirectory: AbsolutePath) -> [WorkspaceMapping] {
var mappers: [WorkspaceMapping] = []
mappers.append(AutomationPathWorkspaceMapper(workspaceDirectory: workspaceDirectory))
mappers += self.default(config: config, forceWorkspaceSchemes: true)
mappers += self.default(forceWorkspaceSchemes: true)
return mappers
}
func `default`(config: Config) -> [WorkspaceMapping] {
self.default(config: config, forceWorkspaceSchemes: false)
func `default`() -> [WorkspaceMapping] {
self.default(forceWorkspaceSchemes: false)
}
private func `default`(config: Config, forceWorkspaceSchemes: Bool) -> [WorkspaceMapping] {
private func `default`(forceWorkspaceSchemes: Bool) -> [WorkspaceMapping] {
var mappers: [WorkspaceMapping] = []
mappers.append(
@ -72,13 +72,9 @@ final class WorkspaceMapperFactory: WorkspaceMapperFactorying {
ModuleMapMapper()
)
if let lastUpgradeVersion = config.generationOptions.lastXcodeUpgradeCheck {
mappers.append(
LastUpgradeVersionWorkspaceMapper(
lastUpgradeVersion: lastUpgradeVersion
)
)
}
mappers.append(
LastUpgradeVersionWorkspaceMapper()
)
return mappers
}

View File

@ -74,7 +74,8 @@ final class ProjectEditorMapper: ProjectEditorMapping {
projects: projects.map(\.path),
generationOptions: .init(
enableAutomaticXcodeSchemes: false,
autogeneratedWorkspaceSchemes: .enabled(codeCoverageMode: .disabled, testingOptions: [])
autogeneratedWorkspaceSchemes: .enabled(codeCoverageMode: .disabled, testingOptions: []),
lastXcodeUpgradeCheck: nil
)
)
@ -254,6 +255,7 @@ final class ProjectEditorMapper: ProjectEditorMapping {
options: .init(
automaticSchemesOptions: .disabled,
disableBundleAccessors: true,
disableShowEnvironmentVarsInScriptPhases: false,
disableSynthesizedResourceAccessors: true,
textSettings: .init(usesTabs: nil, indentWidth: nil, tabWidth: nil, wrapsLines: nil)
),
@ -345,6 +347,7 @@ final class ProjectEditorMapper: ProjectEditorMapping {
options: .init(
automaticSchemesOptions: .disabled,
disableBundleAccessors: true,
disableShowEnvironmentVarsInScriptPhases: false,
disableSynthesizedResourceAccessors: true,
textSettings: .init(usesTabs: nil, indentWidth: nil, tabWidth: nil, wrapsLines: nil)
),

View File

@ -38,18 +38,15 @@ final class BuildService {
private let generatorFactory: GeneratorFactorying
private let buildGraphInspector: BuildGraphInspecting
private let targetBuilder: TargetBuilding
private let configLoader: ConfigLoading
init(
generatorFactory: GeneratorFactorying = GeneratorFactory(),
buildGraphInspector: BuildGraphInspecting = BuildGraphInspector(),
targetBuilder: TargetBuilding = TargetBuilder(),
configLoader: ConfigLoading = ConfigLoader(manifestLoader: ManifestLoader())
targetBuilder: TargetBuilding = TargetBuilder()
) {
self.generatorFactory = generatorFactory
self.buildGraphInspector = buildGraphInspector
self.targetBuilder = targetBuilder
self.configLoader = configLoader
}
// swiftlint:disable:next function_body_length
@ -62,8 +59,7 @@ final class BuildService {
path: AbsolutePath
) async throws {
let graph: Graph
let config = try configLoader.loadConfig(path: path)
let generator = generatorFactory.default(config: config)
let generator = generatorFactory.default()
if try (generate || buildGraphInspector.workspacePath(directory: path) == nil) {
graph = try await generator.generateWithGraph(path: path).1
} else {

View File

@ -45,7 +45,7 @@ final class CachePrintHashesService {
let absolutePath = absolutePath(path)
let timer = clock.startTimer()
let config = try configLoader.loadConfig(path: absolutePath)
let generator = generatorFactory.default(config: config)
let generator = generatorFactory.default()
let graph = try await generator.load(path: absolutePath)
let cacheOutputType: CacheOutputType = xcframeworks ? .xcframework : .framework
let cacheProfile = try CacheProfileResolver().resolveCacheProfile(named: profile, from: config)

View File

@ -44,21 +44,17 @@ final class RunService {
private let buildGraphInspector: BuildGraphInspecting
private let targetBuilder: TargetBuilding
private let targetRunner: TargetRunning
private let configLoader: ConfigLoading
init(
generatorFactory: GeneratorFactorying = GeneratorFactory(),
buildGraphInspector: BuildGraphInspecting = BuildGraphInspector(),
targetBuilder: TargetBuilding = TargetBuilder(),
targetRunner: TargetRunning = TargetRunner(),
configLoader: ConfigLoading = ConfigLoader(manifestLoader: ManifestLoader())
targetRunner: TargetRunning = TargetRunner()
) {
self.generatorFactory = generatorFactory
self.buildGraphInspector = buildGraphInspector
self.targetBuilder = targetBuilder
self.targetRunner = targetRunner
self.configLoader = configLoader
}
// swiftlint:disable:next function_body_length
@ -80,8 +76,7 @@ final class RunService {
}
let graph: Graph
let config = try self.configLoader.loadConfig(path: runPath)
let generator = generatorFactory.default(config: config)
let generator = generatorFactory.default()
if try (generate || buildGraphInspector.workspacePath(directory: runPath) == nil) {
logger.notice("Generating project for running", metadata: .section)
graph = try await generator.generateWithGraph(path: runPath).1

View File

@ -1,29 +0,0 @@
import Foundation
import ProjectDescription
import TSCBasic
import TuistCore
import TuistGraph
import TuistSupport
/// Mapper that changes the development region based on configuration
/// in the Config.swift
public final class ProjectDevelopmentRegionMapper: ProjectMapping {
private let config: TuistGraph.Config
public init(config: TuistGraph.Config) {
self.config = config
}
// MARK: - ProjectMapping
public func map(project: TuistGraph.Project) throws -> (TuistGraph.Project, [SideEffectDescriptor]) {
var project = project
// Xcode project development region
if let developmentRegion = config.generationOptions.developmentRegion {
project.developmentRegion = developmentRegion
}
return (project, [])
}
}

View File

@ -1,39 +0,0 @@
import Foundation
import ProjectDescription
import TSCBasic
import TuistCore
import TuistGraph
import TuistSupport
/// It's a mapper that changes the project name and organization based on the configuration
/// in the Config.swift
public class ProjectNameAndOrganizationMapper: ProjectMapping {
private let config: TuistGraph.Config
public init(config: TuistGraph.Config) {
self.config = config
}
// MARK: - ProjectMapping
public func map(project: TuistGraph.Project) throws -> (TuistGraph.Project, [SideEffectDescriptor]) {
var project = project
// Xcode project file name
if var xcodeFileName = config.generationOptions.xcodeProjectName {
let projectNameTemplate = TemplateString.Token.projectName.rawValue
xcodeFileName = xcodeFileName.replacingOccurrences(
of: projectNameTemplate,
with: project.name
)
project.xcodeProjPath = project.xcodeProjPath.parentDirectory.appending(component: "\(xcodeFileName).xcodeproj")
}
// Xcode project organization name
if let organizationName = config.generationOptions.organizationName {
project.organizationName = organizationName
}
return (project, [])
}
}

View File

@ -51,13 +51,8 @@ extension TuistGraph.Config.GenerationOptions {
/// - manifest: Manifest representation of Tuist config generation options
static func from(manifest: ProjectDescription.Config.GenerationOptions) throws -> TuistGraph.Config.GenerationOptions {
.init(
xcodeProjectName: manifest.xcodeProjectName?.description,
organizationName: manifest.organizationName,
developmentRegion: manifest.developmentRegion,
disableShowEnvironmentVarsInScriptPhases: manifest.disableShowEnvironmentVarsInScriptPhases,
resolveDependenciesWithSystemScm: manifest.resolveDependenciesWithSystemScm,
disablePackageVersionLocking: manifest.disablePackageVersionLocking,
lastXcodeUpgradeCheck: manifest.lastXcodeUpgradeCheck.map { .init($0.major, $0.minor, $0.patch) }
disablePackageVersionLocking: manifest.disablePackageVersionLocking
)
}
}

View File

@ -20,7 +20,9 @@ extension TuistGraph.Project {
resourceSynthesizerPathLocator: ResourceSynthesizerPathLocating
) throws -> TuistGraph.Project {
let name = manifest.name
let xcodeProjectName = manifest.options.xcodeProjectName ?? name
let organizationName = manifest.organizationName
let developmentRegion = manifest.options.developmentRegion
let options = TuistGraph.Project.Options.from(manifest: manifest.options)
let settings = try manifest.settings.map { try TuistGraph.Settings.from(manifest: $0, generatorPaths: generatorPaths) }
let targets = try manifest.targets.map {
@ -43,10 +45,10 @@ extension TuistGraph.Project {
return Project(
path: generatorPaths.manifestDirectory,
sourceRootPath: generatorPaths.manifestDirectory,
xcodeProjPath: generatorPaths.manifestDirectory.appending(component: "\(name).xcodeproj"),
xcodeProjPath: generatorPaths.manifestDirectory.appending(component: "\(xcodeProjectName).xcodeproj"),
name: name,
organizationName: organizationName,
developmentRegion: nil,
developmentRegion: developmentRegion,
options: options,
settings: settings ?? .default,
filesGroup: .group(name: "Project"),

View File

@ -9,6 +9,7 @@ extension TuistGraph.Project.Options {
.init(
automaticSchemesOptions: .from(manifest: manifest.automaticSchemesOptions),
disableBundleAccessors: manifest.disableBundleAccessors,
disableShowEnvironmentVarsInScriptPhases: manifest.disableShowEnvironmentVarsInScriptPhases,
disableSynthesizedResourceAccessors: manifest.disableSynthesizedResourceAccessors,
textSettings: .init(
usesTabs: manifest.textSettings.usesTabs,

View File

@ -16,7 +16,8 @@ extension TuistGraph.Workspace.GenerationOptions {
autogeneratedWorkspaceSchemes: try .from(
manifest: manifest.autogeneratedWorkspaceSchemes,
generatorPaths: generatorPaths
)
),
lastXcodeUpgradeCheck: manifest.lastXcodeUpgradeCheck.map { .init($0.major, $0.minor, $0.patch) }
)
}
}

View File

@ -7,13 +7,8 @@ final class ConfigTests: XCTestCase {
let config = Config(
cloud: Cloud(url: "https://cloud.tuist.io", projectId: "123", options: [.analytics]),
generationOptions: .options(
xcodeProjectName: "someprefix-\(.projectName)",
organizationName: "TestOrg",
developmentRegion: "de",
disableShowEnvironmentVarsInScriptPhases: true,
resolveDependenciesWithSystemScm: false,
disablePackageVersionLocking: true,
lastXcodeUpgradeCheck: .init(12, 5, 1)
disablePackageVersionLocking: true
)
)

View File

@ -148,8 +148,8 @@ final class TargetRunnerTests: TuistUnitTestCase {
let outputPath = try temporaryPath().appending(component: ".build")
let appPath = outputPath.appending(component: target.productNameWithExtension)
let arguments = ["Argument", "--option1", "AnotherArgument", "--option2=true", "-opt3"]
let minVersion = Version(string: "14.0")
let version = Version(string: "15.0")
let minVersion = Version("14.0.0")
let version = Version("15.0.0")
let deviceName = "iPhone 11"
let bundleId = "com.tuist.bundleid"

View File

@ -1728,7 +1728,7 @@ final class SchemeDescriptorsGeneratorTests: XCTestCase {
let workspace = Workspace.test(
projects: [project.path],
schemes: [.test()],
lastUpgradeCheck: .init(13, 0, 0)
generationOptions: .test(lastXcodeUpgradeCheck: .init(13, 0, 0))
)
let graph = Graph.test(

View File

@ -130,7 +130,7 @@ final class WorkspaceDescriptorGeneratorTests: TuistUnitTestCase {
let workspace = Workspace.test(
xcWorkspacePath: temporaryPath.appending(component: "Test.xcworkspace"),
projects: [],
generationOptions: .init(enableAutomaticXcodeSchemes: false, autogeneratedWorkspaceSchemes: .disabled)
generationOptions: .test(enableAutomaticXcodeSchemes: false)
)
let graph = Graph.test(workspace: workspace)
@ -150,7 +150,7 @@ final class WorkspaceDescriptorGeneratorTests: TuistUnitTestCase {
let workspace = Workspace.test(
xcWorkspacePath: temporaryPath.appending(component: "Test.xcworkspace"),
projects: [],
generationOptions: .init(enableAutomaticXcodeSchemes: true, autogeneratedWorkspaceSchemes: .disabled)
generationOptions: .test(enableAutomaticXcodeSchemes: true)
)
let graph = Graph.test(workspace: workspace)
@ -170,7 +170,7 @@ final class WorkspaceDescriptorGeneratorTests: TuistUnitTestCase {
let workspace = Workspace.test(
xcWorkspacePath: temporaryPath.appending(component: "Test.xcworkspace"),
projects: [],
generationOptions: .init(enableAutomaticXcodeSchemes: nil, autogeneratedWorkspaceSchemes: .disabled)
generationOptions: .test(enableAutomaticXcodeSchemes: nil)
)
let graph = Graph.test(workspace: workspace)

View File

@ -38,7 +38,9 @@ final class WorkspaceSettingsDescriptorGeneratorTests: TuistUnitTestCase {
func test_generate_withGenerationOptions() {
// Given
let workspace = Workspace.test(
generationOptions: .init(enableAutomaticXcodeSchemes: true, autogeneratedWorkspaceSchemes: .disabled)
generationOptions: .test(
enableAutomaticXcodeSchemes: true
)
)
// When

View File

@ -112,7 +112,7 @@ final class AutogeneratedWorkspaceSchemeWorkspaceMapperTests: TuistUnitTestCase
XCTAssertFalse(try XCTUnwrap(scheme.testAction?.coverage))
}
func test_map_diabled() throws {
func test_map_disabled() throws {
// Given
let subject = AutogeneratedWorkspaceSchemeWorkspaceMapper(forceWorkspaceSchemes: false)
let targetA = Target.test(
@ -157,7 +157,7 @@ final class AutogeneratedWorkspaceSchemeWorkspaceMapperTests: TuistUnitTestCase
project.path,
projectB.path,
],
generationOptions: .init(enableAutomaticXcodeSchemes: false, autogeneratedWorkspaceSchemes: .disabled)
generationOptions: .test(autogeneratedWorkspaceSchemes: .disabled)
)
// When
@ -217,7 +217,7 @@ final class AutogeneratedWorkspaceSchemeWorkspaceMapperTests: TuistUnitTestCase
project.path,
projectB.path,
],
generationOptions: .init(enableAutomaticXcodeSchemes: false, autogeneratedWorkspaceSchemes: .disabled)
generationOptions: .test(autogeneratedWorkspaceSchemes: .disabled)
)
// When
@ -462,10 +462,7 @@ final class AutogeneratedWorkspaceSchemeWorkspaceMapperTests: TuistUnitTestCase
projects: [
project.path,
],
generationOptions: .init(
enableAutomaticXcodeSchemes: nil,
autogeneratedWorkspaceSchemes: .enabled(codeCoverageMode: .disabled, testingOptions: [])
)
generationOptions: .test(autogeneratedWorkspaceSchemes: .enabled(codeCoverageMode: .disabled, testingOptions: []))
)
// When
@ -504,10 +501,7 @@ final class AutogeneratedWorkspaceSchemeWorkspaceMapperTests: TuistUnitTestCase
projects: [
project.path,
],
generationOptions: .init(
enableAutomaticXcodeSchemes: nil,
autogeneratedWorkspaceSchemes: .enabled(codeCoverageMode: .all, testingOptions: [])
)
generationOptions: .test(autogeneratedWorkspaceSchemes: .enabled(codeCoverageMode: .all, testingOptions: []))
)
// When
@ -550,8 +544,7 @@ final class AutogeneratedWorkspaceSchemeWorkspaceMapperTests: TuistUnitTestCase
projects: [
project.path,
],
generationOptions: .init(
enableAutomaticXcodeSchemes: nil,
generationOptions: .test(
autogeneratedWorkspaceSchemes: .enabled(codeCoverageMode: .targets([targetBRef]), testingOptions: [])
)
)
@ -610,10 +603,7 @@ final class AutogeneratedWorkspaceSchemeWorkspaceMapperTests: TuistUnitTestCase
projects: [
project.path,
],
generationOptions: .init(
enableAutomaticXcodeSchemes: nil,
autogeneratedWorkspaceSchemes: .enabled(codeCoverageMode: .relevant, testingOptions: [])
)
generationOptions: .test(autogeneratedWorkspaceSchemes: .enabled(codeCoverageMode: .relevant, testingOptions: []))
)
let subject = AutogeneratedWorkspaceSchemeWorkspaceMapper(forceWorkspaceSchemes: false)
@ -688,10 +678,7 @@ final class AutogeneratedWorkspaceSchemeWorkspaceMapperTests: TuistUnitTestCase
projectSingleCoverage.path,
projectAllCoverage.path,
],
generationOptions: .init(
enableAutomaticXcodeSchemes: nil,
autogeneratedWorkspaceSchemes: .enabled(codeCoverageMode: .relevant, testingOptions: [])
)
generationOptions: .test(autogeneratedWorkspaceSchemes: .enabled(codeCoverageMode: .relevant, testingOptions: []))
)
let subject = AutogeneratedWorkspaceSchemeWorkspaceMapper(forceWorkspaceSchemes: false)
@ -741,10 +728,7 @@ final class AutogeneratedWorkspaceSchemeWorkspaceMapperTests: TuistUnitTestCase
projects: [
project.path,
],
generationOptions: .init(
enableAutomaticXcodeSchemes: nil,
autogeneratedWorkspaceSchemes: .enabled(codeCoverageMode: .relevant, testingOptions: [])
)
generationOptions: .test(autogeneratedWorkspaceSchemes: .enabled(codeCoverageMode: .relevant, testingOptions: []))
)
let subject = AutogeneratedWorkspaceSchemeWorkspaceMapper(forceWorkspaceSchemes: false)
@ -807,8 +791,7 @@ final class AutogeneratedWorkspaceSchemeWorkspaceMapperTests: TuistUnitTestCase
project.path,
projectB.path,
],
generationOptions: .init(
enableAutomaticXcodeSchemes: nil,
generationOptions: .test(
autogeneratedWorkspaceSchemes: .enabled(
codeCoverageMode: .disabled,
testingOptions: [.parallelizable, .randomExecutionOrdering]
@ -919,8 +902,7 @@ final class AutogeneratedWorkspaceSchemeWorkspaceMapperTests: TuistUnitTestCase
project.path,
projectB.path,
],
generationOptions: .init(
enableAutomaticXcodeSchemes: nil,
generationOptions: .test(
autogeneratedWorkspaceSchemes: .enabled(codeCoverageMode: .disabled, testingOptions: [.parallelizable])
)
)
@ -1028,8 +1010,7 @@ final class AutogeneratedWorkspaceSchemeWorkspaceMapperTests: TuistUnitTestCase
project.path,
projectB.path,
],
generationOptions: .init(
enableAutomaticXcodeSchemes: nil,
generationOptions: .test(
autogeneratedWorkspaceSchemes: .enabled(codeCoverageMode: .disabled, testingOptions: [])
)
)

View File

@ -1250,8 +1250,7 @@ final class GraphLinterTests: TuistUnitTestCase {
let graphTraverser = GraphTraverser(
graph: .test(
workspace: .test(
generationOptions: .init(
enableAutomaticXcodeSchemes: false,
generationOptions: .test(
autogeneratedWorkspaceSchemes: .enabled(codeCoverageMode: .all, testingOptions: [])
)
)
@ -1288,8 +1287,7 @@ final class GraphLinterTests: TuistUnitTestCase {
let graph = Graph.test(
workspace: .test(
generationOptions: .init(
enableAutomaticXcodeSchemes: false,
generationOptions: .test(
autogeneratedWorkspaceSchemes: .enabled(codeCoverageMode: .relevant, testingOptions: [])
)
),
@ -1314,8 +1312,7 @@ final class GraphLinterTests: TuistUnitTestCase {
// Given
let graphTraverser = GraphTraverser(graph: .test(
workspace: .test(
generationOptions: .init(
enableAutomaticXcodeSchemes: false,
generationOptions: .test(
autogeneratedWorkspaceSchemes: .enabled(codeCoverageMode: .relevant, testingOptions: [])
)
)
@ -1348,8 +1345,7 @@ final class GraphLinterTests: TuistUnitTestCase {
)
let graph = Graph.test(
workspace: .test(
generationOptions: .init(
enableAutomaticXcodeSchemes: false,
generationOptions: .test(
autogeneratedWorkspaceSchemes: .enabled(
codeCoverageMode: .targets([.init(projectPath: project.path, name: "TargetA")]),
testingOptions: []
@ -1377,8 +1373,7 @@ final class GraphLinterTests: TuistUnitTestCase {
// Given
let graphTraverser = GraphTraverser(graph: .test(
workspace: .test(
generationOptions: .init(
enableAutomaticXcodeSchemes: false,
generationOptions: .test(
autogeneratedWorkspaceSchemes: .enabled(codeCoverageMode: .targets([]), testingOptions: [])
)
)
@ -1411,8 +1406,7 @@ final class GraphLinterTests: TuistUnitTestCase {
)
let graph = Graph.test(
workspace: .test(
generationOptions: .init(
enableAutomaticXcodeSchemes: false,
generationOptions: .test(
autogeneratedWorkspaceSchemes: .enabled(
codeCoverageMode: .targets([.init(projectPath: project.path, name: "TargetA")]),
testingOptions: []

View File

@ -11,7 +11,7 @@ final class LastUpgradeVersionWorkspaceMapperTests: TuistUnitTestCase {
override func setUp() {
super.setUp()
subject = LastUpgradeVersionWorkspaceMapper(lastUpgradeVersion: .init(12, 5, 1))
subject = LastUpgradeVersionWorkspaceMapper()
}
override func tearDown() {
@ -22,9 +22,13 @@ final class LastUpgradeVersionWorkspaceMapperTests: TuistUnitTestCase {
func test_maps_last_upgrade_version() throws {
// Given
subject = LastUpgradeVersionWorkspaceMapper(lastUpgradeVersion: .init(12, 5, 1))
subject = LastUpgradeVersionWorkspaceMapper()
let workspace = Workspace.test(lastUpgradeCheck: nil)
let workspace = Workspace.test(
generationOptions: .test(
lastXcodeUpgradeCheck: .init(12, 5, 1)
)
)
let projectAPath = try temporaryPath().appending(component: "A")
let projectBPath = try temporaryPath().appending(component: "B")
@ -76,13 +80,10 @@ final class LastUpgradeVersionWorkspaceMapperTests: TuistUnitTestCase {
lastUpgradeCheck: .init(12, 5, 1)
)
var mappedWorkspace = workspace
mappedWorkspace.lastUpgradeCheck = .init(12, 5, 1)
XCTAssertEqual(
gotWorkspaceWithProjects,
WorkspaceWithProjects(
workspace: mappedWorkspace,
workspace: workspace,
projects: [
mappedProjectA,
mappedProjectB,

View File

@ -5,17 +5,15 @@ import XCTest
@testable import TuistGenerator
@testable import TuistSupportTesting
final class ConfigShowEnvironmentMapperTests: TuistUnitTestCase {
final class TargetActionDisableShowEnvVarsProjectMapperTests: TuistUnitTestCase {
func test_map_environmentLoggingDisables() throws {
// Given
let targetMapper = TargetActionEnvironmentMapper(false)
let subject = TargetProjectMapper(mapper: targetMapper)
let subject = TargetActionDisableShowEnvVarsProjectMapper()
let scriptA = TargetScript(name: "Pre Script", order: .pre)
let scriptB = TargetScript(name: "Post Script", order: .post)
let targetA = Target.test(name: "A", scripts: [scriptA, scriptB])
let targetB = Target.test(name: "B", scripts: [scriptA, scriptB])
let project = Project.test(targets: [targetA, targetB])
let project = Project.test(options: .test(disableShowEnvironmentVarsInScriptPhases: true), targets: [targetA, targetB])
// When
let (updatedProject, _) = try subject.map(project: project)
@ -33,14 +31,12 @@ final class ConfigShowEnvironmentMapperTests: TuistUnitTestCase {
func test_map_environmentLoggingEnables() throws {
// Given
let targetMapper = TargetActionEnvironmentMapper(true)
let subject = TargetProjectMapper(mapper: targetMapper)
let subject = TargetActionDisableShowEnvVarsProjectMapper()
let scriptA = TargetScript(name: "Pre Script", order: .pre)
let scriptB = TargetScript(name: "Post Script", order: .post)
let targetA = Target.test(name: "A", scripts: [scriptA, scriptB])
let targetB = Target.test(name: "B", scripts: [scriptA, scriptB])
let project = Project.test(targets: [targetA, targetB])
let project = Project.test(options: .test(disableShowEnvironmentVarsInScriptPhases: false), targets: [targetA, targetB])
// When
let (updatedProject, _) = try subject.map(project: project)

View File

@ -7,10 +7,7 @@ import XCTest
final class WorkspaceGenerationOptionsTests: TuistUnitTestCase {
func test_codable_whenDefault() {
// Given
let subject = Workspace.GenerationOptions(
enableAutomaticXcodeSchemes: nil,
autogeneratedWorkspaceSchemes: .enabled(codeCoverageMode: .disabled, testingOptions: [])
)
let subject = Workspace.GenerationOptions.test()
// Then
XCTAssertCodable(subject)

View File

@ -15,16 +15,4 @@ final class WorkspaceTests: TuistUnitTestCase {
// Then
XCTAssertCodable(subject)
}
func test_codable_withGenerationOptions() {
// Given
let subject = Workspace.test(
path: "/path/to/workspace",
name: "name",
generationOptions: .init(enableAutomaticXcodeSchemes: false, autogeneratedWorkspaceSchemes: .disabled)
)
// Then
XCTAssertCodable(subject)
}
}

View File

@ -389,7 +389,7 @@ final class MultipleConfigurationsIntegrationTests: TuistUnitTestCase {
xcWorkspacePath: path.appending(component: "Workspace.xcworkspace"),
name: "Workspace",
projects: try projects.map { try pathTo($0) },
generationOptions: .init(enableAutomaticXcodeSchemes: nil, autogeneratedWorkspaceSchemes: .disabled)
generationOptions: .test(enableAutomaticXcodeSchemes: nil)
)
}

View File

@ -62,6 +62,7 @@ final class DumpServiceTests: TuistTestCase {
}
},
"disableBundleAccessors": false,
"disableShowEnvironmentVarsInScriptPhases": false,
"disableSynthesizedResourceAccessors": false,
"textSettings": {
@ -169,7 +170,6 @@ final class DumpServiceTests: TuistTestCase {
},
"generationOptions": {
"disablePackageVersionLocking": false,
"disableShowEnvironmentVarsInScriptPhases": false,
"resolveDependenciesWithSystemScm": false
},
"plugins": [

View File

@ -58,15 +58,11 @@ final class MockGeneratorFactory: GeneratorFactorying {
var invokedDefault = false
var invokedDefaultCount = 0
var invokedDefaultParameters: (config: Config, Void)?
var invokedDefaultParametersList = [(config: Config, Void)]()
var stubbedDefaultResult: Generating!
func `default`(config: Config) -> Generating {
func `default`() -> Generating {
invokedDefault = true
invokedDefaultCount += 1
invokedDefaultParameters = (config, ())
invokedDefaultParametersList.append((config, ()))
return stubbedDefaultResult
}

View File

@ -25,47 +25,26 @@ final class ProjectMapperFactoryTests: TuistUnitTestCase {
}
func test_default_when_synthesizing_of_resource_interfaces_is_disabled() {
// Given
let config = Config.default
// When
let got = subject.default(config: config)
let got = subject.default()
// Then
XCTAssertContainsElementOfType(got, SynthesizedResourceInterfaceProjectMapper.self)
}
func test_default_when_showing_env_variables_in_scripts_is_disabled() {
// Given
let config = Config.test(generationOptions: .test(disableShowEnvironmentVarsInScriptPhases: true))
func test_default_contains_target_mapper() {
// When
let got = subject.default(config: config)
let got = subject.default()
// Then
XCTAssertContainsElementOfType(got, TargetProjectMapper.self)
}
func test_default_when_showing_env_variables_in_scripts_is_enabled() {
// Given
let config = Config.default
// When
let got = subject.default(config: config)
// Then
XCTAssertDoesntContainElementOfType(got, TargetProjectMapper.self)
XCTAssertContainsElementOfType(got, TargetActionDisableShowEnvVarsProjectMapper.self)
}
func test_default_when_bundle_accessors_are_enabled() {
// Given
let config = Config.default
// When
let got = subject.default(config: config)
let got = subject.default()
// Then
@ -74,88 +53,48 @@ final class ProjectMapperFactoryTests: TuistUnitTestCase {
}
func test_default_contains_the_generate_info_plist_mapper() {
// Given
let config = Config.default
// When
let got = subject.default(config: config)
let got = subject.default()
// Then
XCTAssertContainsElementOfType(got, GenerateInfoPlistProjectMapper.self, after: DeleteDerivedDirectoryProjectMapper.self)
}
func test_default_contains_the_project_name_and_organization_mapper() {
// Given
let config = Config.default
// When
let got = subject.default(config: config)
// Then
XCTAssertContainsElementOfType(got, ProjectNameAndOrganizationMapper.self)
}
func test_default_contains_the_project_development_region_mapper() {
// Given
let config = Config.default
// When
let got = subject.default(config: config)
// Then
XCTAssertContainsElementOfType(got, ProjectDevelopmentRegionMapper.self)
}
func test_default_contains_the_ide_template_macros_mapper() {
// Given
let config = Config.default
// When
let got = subject.default(config: config)
let got = subject.default()
// Then
XCTAssertContainsElementOfType(got, IDETemplateMacrosMapper.self)
}
func test_default_contains_the_signing_mapper() {
// Given
let config = Config.default
// When
let got = subject.default(config: config)
let got = subject.default()
// Then
XCTAssertContainsElementOfType(got, SigningMapper.self)
}
func test_automation_contains_the_source_root_path_project_mapper() {
// Given
let config = Config.default
// When
let got = subject.automation(config: config, skipUITests: true)
let got = subject.automation(skipUITests: true)
// Then
XCTAssertContainsElementOfType(got, SourceRootPathProjectMapper.self)
}
func test_automation_contains_the_skip_ui_tests_mapper_when_skip_ui_tests_is_true() {
// Given
let config = Config.default
// When
let got = subject.automation(config: config, skipUITests: true)
let got = subject.automation(skipUITests: true)
// Then
XCTAssertContainsElementOfType(got, SkipUITestsProjectMapper.self)
}
func test_automation_doesnt_contain_the_skip_ui_tests_mapper_when_skip_ui_tests_is_false() {
// Given
let config = Config.default
// When
let got = subject.automation(config: config, skipUITests: false)
let got = subject.automation(skipUITests: false)
// Then
XCTAssertDoesntContainElementOfType(got, SkipUITestsProjectMapper.self)

View File

@ -1,5 +1,6 @@
import Foundation
import TSCBasic
import TSCUtility
import TuistCoreTesting
import TuistGraph
import TuistLoader
@ -28,12 +29,10 @@ final class WorkspaceMapperFactoryTests: TuistUnitTestCase {
func test_default_contains_the_project_workspace_mapper() {
// Given
let config = Config.default
subject =
WorkspaceMapperFactory(projectMapper: SequentialProjectMapper(mappers: projectMapperFactory.default(config: config)))
subject = WorkspaceMapperFactory(projectMapper: SequentialProjectMapper(mappers: projectMapperFactory.default()))
// When
let got = subject.default(config: config)
let got = subject.default()
// Then
XCTAssertContainsElementOfType(got, ProjectWorkspaceMapper.self)
@ -41,12 +40,10 @@ final class WorkspaceMapperFactoryTests: TuistUnitTestCase {
func test_default_contains_the_tuist_workspace_identifier_mapper() {
// Given
let config = Config.default
subject =
WorkspaceMapperFactory(projectMapper: SequentialProjectMapper(mappers: projectMapperFactory.default(config: config)))
subject = WorkspaceMapperFactory(projectMapper: SequentialProjectMapper(mappers: projectMapperFactory.default()))
// When
let got = subject.default(config: config)
let got = subject.default()
// Then
XCTAssertContainsElementOfType(got, TuistWorkspaceIdentifierMapper.self)
@ -54,12 +51,10 @@ final class WorkspaceMapperFactoryTests: TuistUnitTestCase {
func test_default_contains_the_tide_template_macros_mapper() {
// Given
let config = Config.default
subject =
WorkspaceMapperFactory(projectMapper: SequentialProjectMapper(mappers: projectMapperFactory.default(config: config)))
subject = WorkspaceMapperFactory(projectMapper: SequentialProjectMapper(mappers: projectMapperFactory.default()))
// When
let got = subject.default(config: config)
let got = subject.default()
// Then
XCTAssertContainsElementOfType(got, IDETemplateMacrosMapper.self)
@ -67,12 +62,10 @@ final class WorkspaceMapperFactoryTests: TuistUnitTestCase {
func test_default_contains_the_autogenerated_project_scheme_mapper_when_autogenerated_schemes_are_enabled() {
// Given
let config = Config.default
subject =
WorkspaceMapperFactory(projectMapper: SequentialProjectMapper(mappers: projectMapperFactory.default(config: config)))
subject = WorkspaceMapperFactory(projectMapper: SequentialProjectMapper(mappers: projectMapperFactory.default()))
// When
let got = subject.default(config: config)
let got = subject.default()
// Then
XCTAssertContainsElementOfType(got, AutogeneratedWorkspaceSchemeWorkspaceMapper.self)
@ -80,43 +73,33 @@ final class WorkspaceMapperFactoryTests: TuistUnitTestCase {
func test_default_contains_the_modulemap_mapper() {
// Given
let config = Config.default
subject =
WorkspaceMapperFactory(projectMapper: SequentialProjectMapper(mappers: projectMapperFactory.default(config: config)))
subject = WorkspaceMapperFactory(projectMapper: SequentialProjectMapper(mappers: projectMapperFactory.default()))
// When
let got = subject.default(config: config)
let got = subject.default()
// Then
XCTAssertContainsElementOfType(got, ModuleMapMapper.self)
}
func test_default_contains_the_last_upgrade_version_mapper_when_the_configuration_is_set() {
func test_default_contains_the_last_upgrade_version_mapper() {
// Given
let config = Config.test(generationOptions: .test(lastXcodeUpgradeCheck: "3.2.1"))
subject =
WorkspaceMapperFactory(projectMapper: SequentialProjectMapper(mappers: projectMapperFactory.default(config: config)))
subject = WorkspaceMapperFactory(projectMapper: SequentialProjectMapper(mappers: projectMapperFactory.default()))
// When
let got = subject.default(config: config)
let got = subject.default()
// Then
let mapper = XCTAssertContainsElementOfType(got, LastUpgradeVersionWorkspaceMapper.self)
XCTAssertEqual(mapper?.lastUpgradeVersion, "3.2.1")
XCTAssertContainsElementOfType(got, LastUpgradeVersionWorkspaceMapper.self)
}
func test_automation_contains_the_path_workspace_mapper() throws {
// Given
let workspaceDirectory = try temporaryPath()
let config = Config.default
subject =
WorkspaceMapperFactory(projectMapper: SequentialProjectMapper(mappers: projectMapperFactory.default(config: config)))
subject = WorkspaceMapperFactory(projectMapper: SequentialProjectMapper(mappers: projectMapperFactory.default()))
// When
let got = subject.automation(
config: config,
workspaceDirectory: workspaceDirectory
)
let got = subject.automation(workspaceDirectory: workspaceDirectory)
// Then
let mapper = XCTAssertContainsElementOfType(got, AutomationPathWorkspaceMapper.self)
@ -125,16 +108,11 @@ final class WorkspaceMapperFactoryTests: TuistUnitTestCase {
func test_cache_contains_the_generate_cacheable_schemes_workspace_mapper() throws {
// Given
let config = Config.default
let includedTargets = Set(arrayLiteral: "MyTarget")
subject =
WorkspaceMapperFactory(projectMapper: SequentialProjectMapper(mappers: projectMapperFactory.default(config: config)))
subject = WorkspaceMapperFactory(projectMapper: SequentialProjectMapper(mappers: projectMapperFactory.default()))
// When
let got = subject.cache(
config: config,
includedTargets: includedTargets
)
let got = subject.cache(includedTargets: includedTargets)
// Then
let mapper = XCTAssertContainsElementOfType(got, GenerateCacheableSchemesWorkspaceMapper.self)

View File

@ -142,7 +142,7 @@ final class RunServiceTests: TuistUnitTestCase {
let schemeName = "AScheme"
let configuration = "Test"
let minVersion = Target.test().deploymentTarget?.version.version()
let version = Version(string: "15.0.0")
let version = Version("15.0.0")
let deviceName = "iPhone 11"
let arguments = ["-arg1", "--arg2", "SomeArgument"]
targetRunner
@ -168,7 +168,7 @@ final class RunServiceTests: TuistUnitTestCase {
schemeName: schemeName,
configuration: configuration,
device: deviceName,
version: version?.description,
version: version.description,
arguments: arguments
)
await waitForExpectations(timeout: 1)

View File

@ -63,7 +63,7 @@ final class ConfigLoaderTests: TuistUnitTestCase {
let path: AbsolutePath = "/project/Tuist/Config.swift"
stub(path: path, exists: true)
stub(
config: .test(generationOptions: .options(developmentRegion: "fr")),
config: .test(),
at: path.parentDirectory
)
@ -77,7 +77,7 @@ final class ConfigLoaderTests: TuistUnitTestCase {
cache: nil,
swiftVersion: nil,
plugins: [],
generationOptions: .test(developmentRegion: "fr"),
generationOptions: .test(),
path: path
))
}
@ -104,7 +104,7 @@ final class ConfigLoaderTests: TuistUnitTestCase {
stub(path: $0, exists: true)
}
stub(
config: .test(generationOptions: .options(developmentRegion: "fr")),
config: .test(),
at: "/project/Tuist"
)
@ -118,7 +118,7 @@ final class ConfigLoaderTests: TuistUnitTestCase {
cache: nil,
swiftVersion: nil,
plugins: [],
generationOptions: .test(developmentRegion: "fr"),
generationOptions: .test(),
path: "/project/Tuist/Config.swift"
))
}

View File

@ -1,38 +0,0 @@
import ProjectDescription
import TuistCore
import TuistGraph
import TuistSupport
import XCTest
@testable import TuistCoreTesting
@testable import TuistLoader
@testable import TuistSupportTesting
final class ProjectDevelopmentRegionMapperTests: TuistUnitTestCase {
var subject: ProjectDevelopmentRegionMapper!
var config: TuistGraph.Config!
override func setUp() {
super.setUp()
config = TuistGraph.Config.test(generationOptions: .test(developmentRegion: "en"))
subject = ProjectDevelopmentRegionMapper(config: config)
}
override func tearDown() {
subject = nil
config = nil
super.tearDown()
}
func test_map_changes_the_development_region() throws {
// Given
let project = TuistGraph.Project.test(name: "Test", developmentRegion: nil)
// When
let (got, _) = try subject.map(project: project)
// Then
XCTAssertEqual(got.developmentRegion, "en")
}
}

View File

@ -1,55 +0,0 @@
import ProjectDescription
import TuistCore
import TuistGraph
import TuistSupport
import XCTest
@testable import TuistCoreTesting
@testable import TuistLoader
@testable import TuistSupportTesting
class ProjectNameAndOrganizationMapperTests: TuistUnitTestCase {
var subject: ProjectNameAndOrganizationMapper!
var config: TuistGraph.Config!
override func setUp() {
super.setUp()
let nameTemplate: TemplateString = "Tuist-\(.projectName)"
config = TuistGraph.Config.test(
generationOptions: .test(
xcodeProjectName: nameTemplate.description,
organizationName: "Tuist"
)
)
subject = ProjectNameAndOrganizationMapper(config: config)
}
override func tearDown() {
subject = nil
config = nil
super.tearDown()
}
func test_map_changes_the_project_name() throws {
// Given
let project = TuistGraph.Project.test(name: "Test")
// When
let (got, _) = try subject.map(project: project)
// Then
XCTAssertEqual(got.xcodeProjPath.basename, "Tuist-Test.xcodeproj")
}
func test_map_changes_the_organization() throws {
// Given
let project = TuistGraph.Project.test(name: "Test", organizationName: nil)
// When
let (got, _) = try subject.map(project: project)
// Then
XCTAssertEqual(got.organizationName, "Tuist")
}
}

View File

@ -0,0 +1,89 @@
import Foundation
import ProjectDescription
import TSCBasic
import TuistCore
import TuistLoaderTesting
import TuistSupport
import XCTest
@testable import TuistGraph
@testable import TuistLoader
@testable import TuistSupportTesting
final class ProjectManifestMapperTests: TuistUnitTestCase {
func test_from() throws {
// Given
let project = ProjectDescription.Project(
name: "Name",
organizationName: "Organization",
options: .options(
automaticSchemesOptions: .enabled(
targetSchemesGrouping: .byNameSuffix(build: ["build"], test: ["test"], run: ["run"]),
codeCoverageEnabled: true,
testingOptions: [.parallelizable]
),
developmentRegion: "us",
disableBundleAccessors: true,
disableShowEnvironmentVarsInScriptPhases: true,
disableSynthesizedResourceAccessors: true,
textSettings: .textSettings(usesTabs: true, indentWidth: 1, tabWidth: 2, wrapsLines: true),
xcodeProjectName: "XcodeName"
),
packages: [
.remote(url: "url", requirement: .branch("b")),
.local(path: "/path"),
],
targets: [],
schemes: [],
fileHeaderTemplate: .string("123"),
additionalFiles: [.glob(pattern: "/file.swift")],
resourceSynthesizers: []
)
fileHandler.stubExists = { _ in true }
// When
let got = try TuistGraph.Project.from(
manifest: project,
generatorPaths: .init(manifestDirectory: "/"),
plugins: .none,
externalDependencies: [:],
resourceSynthesizerPathLocator: MockResourceSynthesizerPathLocator()
)
// Then
XCTAssertEqual(
got,
TuistGraph.Project(
path: "/",
sourceRootPath: "/",
xcodeProjPath: "/XcodeName.xcodeproj",
name: "Name",
organizationName: "Organization",
developmentRegion: "us",
options: .init(
automaticSchemesOptions: .enabled(
targetSchemesGrouping: .byNameSuffix(build: ["build"], test: ["test"], run: ["run"]),
codeCoverageEnabled: true,
testingOptions: [.parallelizable]
),
disableBundleAccessors: true,
disableShowEnvironmentVarsInScriptPhases: true,
disableSynthesizedResourceAccessors: true,
textSettings: .init(usesTabs: true, indentWidth: 1, tabWidth: 2, wrapsLines: true)
),
settings: .default,
filesGroup: .group(name: "Project"),
targets: [],
packages: [
.remote(url: "url", requirement: .branch("b")),
.local(path: "/path"),
],
schemes: [],
ideTemplateMacros: .init(fileHeader: "123"),
additionalFiles: [.file(path: "/file.swift")],
resourceSynthesizers: [],
lastUpgradeCheck: nil
)
)
}
}

View File

@ -15,14 +15,22 @@ final class WorkspaceGenerationOptionsManifestMapperTests: TuistTestCase {
let generatorPaths = GeneratorPaths(manifestDirectory: temporaryPath)
let manifest = ProjectDescription.Workspace.GenerationOptions.options(
enableAutomaticXcodeSchemes: nil,
autogeneratedWorkspaceSchemes: .disabled
autogeneratedWorkspaceSchemes: .disabled,
lastXcodeUpgradeCheck: .init("1.2.3")
)
// When
let actual = try TuistGraph.Workspace.GenerationOptions.from(manifest: manifest, generatorPaths: generatorPaths)
// Then
XCTAssertEqual(actual, .init(enableAutomaticXcodeSchemes: nil, autogeneratedWorkspaceSchemes: .disabled))
XCTAssertEqual(
actual,
.init(
enableAutomaticXcodeSchemes: nil,
autogeneratedWorkspaceSchemes: .disabled,
lastXcodeUpgradeCheck: .init("1.2.3")
)
)
}
func test_from_whenAutomaticXcodeSchemeIsDisabled() throws {
@ -38,7 +46,14 @@ final class WorkspaceGenerationOptionsManifestMapperTests: TuistTestCase {
let actual = try TuistGraph.Workspace.GenerationOptions.from(manifest: manifest, generatorPaths: generatorPaths)
// Then
XCTAssertEqual(actual, .init(enableAutomaticXcodeSchemes: false, autogeneratedWorkspaceSchemes: .disabled))
XCTAssertEqual(
actual,
.init(
enableAutomaticXcodeSchemes: false,
autogeneratedWorkspaceSchemes: .disabled,
lastXcodeUpgradeCheck: nil
)
)
}
func test_from_whenAutomaticXcodeSchemeIsEnabled() throws {
@ -54,7 +69,14 @@ final class WorkspaceGenerationOptionsManifestMapperTests: TuistTestCase {
let actual = try TuistGraph.Workspace.GenerationOptions.from(manifest: manifest, generatorPaths: generatorPaths)
// Then
XCTAssertEqual(actual, .init(enableAutomaticXcodeSchemes: true, autogeneratedWorkspaceSchemes: .disabled))
XCTAssertEqual(
actual,
.init(
enableAutomaticXcodeSchemes: true,
autogeneratedWorkspaceSchemes: .disabled,
lastXcodeUpgradeCheck: nil
)
)
}
func test_from_whenAutogenerationOptionsIsEnabled() throws {
@ -80,7 +102,20 @@ final class WorkspaceGenerationOptionsManifestMapperTests: TuistTestCase {
autogeneratedWorkspaceSchemes: .enabled(
codeCoverageMode: .all,
testingOptions: [.parallelizable, .randomExecutionOrdering]
)
),
lastXcodeUpgradeCheck: nil
)
)
// Then
XCTAssertEqual(
actual,
.init(
enableAutomaticXcodeSchemes: true,
autogeneratedWorkspaceSchemes: .enabled(
codeCoverageMode: .all,
testingOptions: [.parallelizable, .randomExecutionOrdering]
),
lastXcodeUpgradeCheck: nil
)
)
}

View File

@ -69,14 +69,9 @@ Generation options allow customizing the generation of Xcode projects.
| Property | Description |
| ------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `xcodeProjectName(TemplateString)` | Customize the name of the generated .xcodeproj. |
| `organizationName(String)` | Customize the organization name of the generated .xcodeproj. |
| `developmentRegion(String)` | Customize the development region of the generated .xcodeproj. The default development region is `en`. |
| `disableShowEnvironmentVarsInScriptPhases` | Suppress logging of environment in Run Script build phases. |
| `templateMacros(IDETemplateMacros)` | Apply IDE Template macros to your project. |
| `resolveDependenciesWithSystemScm` | Resolve SPM dependencies using your system's SCM credentials, instead of Xcode accounts. |
| `disablePackageVersionLocking` | Disables locking Swift packages. This can speed up generation but does increase risk if packages are not locked in their declarations. |
| `lastXcodeUpgradeCheck(Version)` | Allows to suppress warnings in Xcode about updates to recommended settings added in or below the specified Xcode version. The warnings appear when Xcode version has been upgraded. It is recommended to set the version option to Xcode's version that is used for development of a project, for example `.lastUpgradeCheck(Version(13, 0, 0))` for Xcode 13.0.0. |
### TemplateString

View File

@ -82,9 +82,12 @@ List of additional options:
| Case | Description |
| --------------------------------------------------------------------------------------- | -------------------------------------------------------------------------- |
| `automaticSchemesOptions(AutomaticSchemesOptions)` | To configure automatic target schemes generation. |
| `disableSynthesizedResourceAccessors` | To disable synthesized resource accessors. |
| `developmentRegion` | To customize the development region. |
| `disableBundleAccessors` | To disables generating Bundle accessors. |
| `disableShowEnvironmentVarsInScriptPhases` | To suppress logging of environment in Run Script build phases. |
| `disableSynthesizedResourceAccessors` | To disable synthesized resource accessors. |
| `textSettings(usesTabs: Bool?, indentWidth: UInt?, tabWidth: UInt?, wrapsLines: Bool?)` | [Text settings](#text-settings) to override user ones for current project. |
| `xcodeProjectName` | To customize the name of the generated `.xcodeproj`. |
## AutomaticSchemesOptions

View File

@ -66,10 +66,11 @@ A `Workspace.swift` should initialize a variable of type `Workspace`. It can tak
Generation options allow customizing the generation of the Xcode workspace.
| Property | Description | Type | Required | Default |
| ------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------- | -------- | ----------------------------------------------------------- |
| `disableAutomaticXcodeSchemes` | Enable or disable automatic generation of schemes _by Xcode_. | [`AutomaticSchemeMode`](#automaticschememode) | No | `false` |
| `autogeneratedWorkspaceSchemes(AutogenerationOptions)` | Enable or disable automatic generation of `*-Workspace*` schemes. If enabled, options to configure code coverage and test targets can be passed in via associated values. | [`AutogeneratedWorkspaceSchemes`](#autogeneratedworkspaceschemes) | No | `.enabled(codeCoverageMode: .disabled, testingOptions: [])` |
| Property | Description | Type | Required | Default |
| ------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------- | -------- | ----------------------------------------------------------- |
| `disableAutomaticXcodeSchemes` | Enable or disable automatic generation of schemes _by Xcode_. | [`AutomaticSchemeMode`](#automaticschememode) | No | `false` |
| `autogeneratedWorkspaceSchemes(AutogenerationOptions)` | Enable or disable automatic generation of `*-Workspace*` schemes. If enabled, options to configure code coverage and test targets can be passed in via associated values. | [`AutogeneratedWorkspaceSchemes`](#autogeneratedworkspaceschemes) | No | `.enabled(codeCoverageMode: .disabled, testingOptions: [])` |
| `lastXcodeUpgradeCheck(Version)` | Allows to suppress warnings in Xcode about updates to recommended settings added in or below the specified Xcode version. The warnings appear when Xcode version has been upgraded. | `Version` | No | `nil` |
### CodeCoverageMode

View File

@ -1,13 +1,5 @@
Feature: Generate a new project using Tuist (suite 1)
Scenario: The project is an iOS application with tests (app_with_development_region_config)
Given that tuist is available
And I have a working directory
Then I copy the fixture app_with_development_region_config 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-iphonesimulator' contains the Info.plist key 'CFBundleDevelopmentRegion' with value 'de'
Scenario: The project is an iOS application with tests (ios_app_with_tests)
Given that tuist is available
And I have a working directory

View File

@ -294,14 +294,6 @@ A simple iOS app with a Core Data model and Mapping Model (.xcmappingmodel)
An iOS app that has a dependency with a dependency with a framework for macOS.
## app_with_development_region_config
An iOS app where the development region is defined at the `Config` level.
## app_with_organization_name_config
An iOS app where the organization name is defined at the `Config` level.
## app_with_organization_name_project
An iOS app where the organization name is defined at the `Project` level.

View File

@ -1,19 +0,0 @@
import UIKit
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
func application(_: UIApplication, didFinishLaunchingWithOptions _: [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
}
func hello() -> String {
"AppDelegate.hello()"
}
}

View File

@ -1,7 +0,0 @@
import ProjectDescription
let config = Config(
generationOptions: .options(
developmentRegion: "de"
)
)

View File

@ -1,43 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>$(DEVELOPMENT_LANGUAGE)</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>$(PRODUCT_NAME)</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleVersion</key>
<string>1</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>NSHumanReadableCopyright</key>
<string>Copyright ©. All rights reserved.</string>
<key>UIRequiredDeviceCapabilities</key>
<array>
<string>armv7</string>
</array>
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
<key>UISupportedInterfaceOrientations~ipad</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationPortraitUpsideDown</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
</dict>
</plist>

View File

@ -1,21 +0,0 @@
import ProjectDescription
let project = Project(
name: "App",
targets: [
Target(
name: "App",
platform: .iOS,
product: .app,
bundleId: "io.tuist.app",
infoPlist: .file(path: .relativeToManifest("Info.plist")),
sources: "App/**",
settings: .settings(
base: [
"CODE_SIGN_IDENTITY": "",
"CODE_SIGNING_REQUIRED": "NO",
]
)
),
]
)

View File

@ -1,63 +0,0 @@
### macOS ###
# General
.DS_Store
.AppleDouble
.LSOverride
# Icon must end with two
Icon
# Thumbnails
._*
# Files that might appear in the root of a volume
.DocumentRevisions-V100
.fseventsd
.Spotlight-V100
.TemporaryItems
.Trashes
.VolumeIcon.icns
.com.apple.timemachine.donotpresent
# Directories potentially created on remote AFP share
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk
### Xcode ###
# Xcode
#
# gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore
## User settings
xcuserdata/
## compatibility with Xcode 8 and earlier (ignoring not required starting Xcode 9)
*.xcscmblueprint
*.xccheckout
## compatibility with Xcode 3 and earlier (ignoring not required starting Xcode 4)
build/
DerivedData/
*.moved-aside
*.pbxuser
!default.pbxuser
*.mode1v3
!default.mode1v3
*.mode2v3
!default.mode2v3
*.perspectivev3
!default.perspectivev3
### Xcode Patch ###
*.xcodeproj/*
!*.xcodeproj/project.pbxproj
!*.xcodeproj/xcshareddata/
!*.xcworkspace/contents.xcworkspacedata
/*.gcno
### Projects ###
*.xcodeproj
*.xcworkspace

View File

@ -1,19 +0,0 @@
import UIKit
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
func application(_: UIApplication, didFinishLaunchingWithOptions _: [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
}
func hello() -> String {
"AppDelegate.hello()"
}
}

View File

@ -1,5 +0,0 @@
import ProjectDescription
let config = Config(
generationOptions: .options(organizationName: "Tuist")
)

View File

@ -1,43 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>$(DEVELOPMENT_LANGUAGE)</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>$(PRODUCT_NAME)</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleVersion</key>
<string>1</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>NSHumanReadableCopyright</key>
<string>Copyright ©. All rights reserved.</string>
<key>UIRequiredDeviceCapabilities</key>
<array>
<string>armv7</string>
</array>
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
<key>UISupportedInterfaceOrientations~ipad</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationPortraitUpsideDown</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
</dict>
</plist>

View File

@ -1,21 +0,0 @@
import ProjectDescription
let project = Project(
name: "App",
targets: [
Target(
name: "App",
platform: .iOS,
product: .app,
bundleId: "io.tuist.app",
infoPlist: .file(path: .relativeToManifest("Info.plist")),
sources: "App/**",
settings: .settings(
base: [
"CODE_SIGN_IDENTITY": "",
"CODE_SIGNING_REQUIRED": "NO",
]
)
),
]
)

View File

@ -1,5 +0,0 @@
import ProjectDescription
let config = Config(
generationOptions: .options(lastXcodeUpgradeCheck: Version(12, 5, 1))
)

View File

@ -2,6 +2,7 @@ import ProjectDescription
let project = Project(
name: "AppWithSpace",
options: .options(disableShowEnvironmentVarsInScriptPhases: true),
targets: [
Target(
name: "AppWithSpace",

View File

@ -2,6 +2,7 @@ import ProjectDescription
let project = Project(
name: "App",
options: .options(disableShowEnvironmentVarsInScriptPhases: true),
targets: [
Target(
name: "App",

View File

@ -1,5 +0,0 @@
import ProjectDescription
let config = Config(
generationOptions: .options(disableShowEnvironmentVarsInScriptPhases: true)
)

View File

@ -1,5 +0,0 @@
import ProjectDescription
let config = Config(
generationOptions: .options(xcodeProjectName: "AwesomePrefix-\(.projectName)-AwesomeSuffix")
)

View File

@ -1,6 +0,0 @@
import ProjectDescription
let config = Config(
generationOptions: [
]
)