Skip to content

Commit

Permalink
Merge branch 'main' into allow-slash-in-target-name
Browse files Browse the repository at this point in the history
  • Loading branch information
kapitoshka438 committed May 14, 2024
2 parents b5a3707 + 4ecde1d commit 337fc02
Show file tree
Hide file tree
Showing 29 changed files with 395 additions and 45 deletions.
2 changes: 1 addition & 1 deletion .mise.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[tools]
tuist = "4.12.1"
tuist = "4.13.0"
swiftlint = "0.54.0"
swiftformat = "0.53.3"
pnpm = "8.15.6"
Expand Down
18 changes: 18 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,23 @@
# Changelog

## 4.13.0 - 2024-05-14

### Tuist

#### Added

- Add defaultConfiguration generation option to Config.swift [#6255](https://github.com/tuist/tuist/pull/6255) by [@fortmarek](https://github.com/fortmarek)

#### Fixed

- Fix integration of SPM packages with spaces in their name [#6264](https://github.com/tuist/tuist/pull/6264) by [@kapitoshka438](https://github.com/kapitoshka438)
- Align bundle name with dashes sanitizing with SPM [#6265](https://github.com/tuist/tuist/pull/6265) by [@danibachar](https://github.com/danibachar)
- Do not automatically add -ObjC flag when integrating Objective-C dependencies [#6244](https://github.com/tuist/tuist/pull/6244) by [@thedavidharris](https://github.com/thedavidharris)

### Tuist Cloud

- no changes

## 4.12.1 - 2024-05-07

### Tuist
Expand Down
10 changes: 8 additions & 2 deletions Sources/ProjectDescription/ConfigGenerationOptions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,19 +31,25 @@ extension Config {
/// dependencies won't build until all dependencies are declared explicitly.
public let enforceExplicitDependencies: Bool

/// The default configuration to be used when generating the project.
/// If not specified, Tuist generates for the first (when alphabetically sorted) debug configuration.
public var defaultConfiguration: String?

public static func options(
resolveDependenciesWithSystemScm: Bool = false,
disablePackageVersionLocking: Bool = false,
clonedSourcePackagesDirPath: Path? = nil,
staticSideEffectsWarningTargets: StaticSideEffectsWarningTargets = .all,
enforceExplicitDependencies: Bool = false
enforceExplicitDependencies: Bool = false,
defaultConfiguration: String? = nil
) -> Self {
self.init(
resolveDependenciesWithSystemScm: resolveDependenciesWithSystemScm,
disablePackageVersionLocking: disablePackageVersionLocking,
clonedSourcePackagesDirPath: clonedSourcePackagesDirPath,
staticSideEffectsWarningTargets: staticSideEffectsWarningTargets,
enforceExplicitDependencies: enforceExplicitDependencies
enforceExplicitDependencies: enforceExplicitDependencies,
defaultConfiguration: defaultConfiguration
)
}
}
Expand Down
3 changes: 3 additions & 0 deletions Sources/TuistAcceptanceTesting/TuistAcceptanceFixtures.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import Foundation

public enum TuistAcceptanceFixtures {
case appWithBuildRules
case appWithCustomDefaultConfiguration
case appWithFrameworkAndTests
case appWithPlugins
case appWithPreviews
Expand Down Expand Up @@ -73,6 +74,8 @@ public enum TuistAcceptanceFixtures {
switch self {
case .appWithBuildRules:
return "app_with_build_rules"
case .appWithCustomDefaultConfiguration:
return "app_with_custom_default_configuration"
case .appWithFrameworkAndTests:
return "app_with_framework_and_tests"
case .appWithPlugins:
Expand Down
33 changes: 0 additions & 33 deletions Sources/TuistGenerator/Mappers/ModuleMapMapper.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import TuistSupport
public final class ModuleMapMapper: GraphMapping { // swiftlint:disable:this type_body_length
private static let modulemapFileSetting = "MODULEMAP_FILE"
private static let otherCFlagsSetting = "OTHER_CFLAGS"
private static let otherLinkerFlagsSetting = "OTHER_LDFLAGS"
private static let otherSwiftFlagsSetting = "OTHER_SWIFT_FLAGS"
private static let headerSearchPaths = "HEADER_SEARCH_PATHS"

Expand Down Expand Up @@ -82,14 +81,6 @@ public final class ModuleMapMapper: GraphMapping { // swiftlint:disable:this typ
mappedSettingsDictionary[Self.headerSearchPaths] = updatedHeaderSearchPaths
}

if let updatedOtherLinkerFlags = Self.updatedOtherLinkerFlags(
targetID: targetID,
oldOtherLinkerFlags: mappedSettingsDictionary[Self.otherLinkerFlagsSetting],
targetToDependenciesMetadata: targetToDependenciesMetadata
) {
mappedSettingsDictionary[Self.otherLinkerFlagsSetting] = updatedOtherLinkerFlags
}

let targetSettings = target.settings ?? Settings(
base: [:],
configurations: [:],
Expand Down Expand Up @@ -277,28 +268,4 @@ public final class ModuleMapMapper: GraphMapping { // swiftlint:disable:this typ

return .array(mappedOtherCFlags)
}

private static func updatedOtherLinkerFlags(
targetID: TargetID,
oldOtherLinkerFlags: SettingsDictionary.Value?,
targetToDependenciesMetadata: [TargetID: Set<DependencyMetadata>]
) -> SettingsDictionary.Value? {
guard let dependenciesModuleMaps = targetToDependenciesMetadata[targetID]?.compactMap(\.moduleMapPath),
!dependenciesModuleMaps.isEmpty
else { return nil }

var mappedOtherLinkerFlags: [String]
switch oldOtherLinkerFlags ?? .array(["$(inherited)"]) {
case let .array(values):
mappedOtherLinkerFlags = values
case let .string(value):
mappedOtherLinkerFlags = value.split(separator: " ").map(String.init)
}

if !mappedOtherLinkerFlags.contains("-ObjC") {
mappedOtherLinkerFlags.append("-ObjC")
}

return .array(mappedOtherLinkerFlags)
}
}
5 changes: 4 additions & 1 deletion Sources/TuistGraph/Models/ConfigGenerationOptions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,22 @@ extension Config {
public let clonedSourcePackagesDirPath: AbsolutePath?
public let staticSideEffectsWarningTargets: StaticSideEffectsWarningTargets
public let enforceExplicitDependencies: Bool
public let defaultConfiguration: String?

public init(
resolveDependenciesWithSystemScm: Bool,
disablePackageVersionLocking: Bool,
clonedSourcePackagesDirPath: AbsolutePath? = nil,
staticSideEffectsWarningTargets: StaticSideEffectsWarningTargets = .all,
enforceExplicitDependencies: Bool = false
enforceExplicitDependencies: Bool = false,
defaultConfiguration: String? = nil
) {
self.resolveDependenciesWithSystemScm = resolveDependenciesWithSystemScm
self.disablePackageVersionLocking = disablePackageVersionLocking
self.clonedSourcePackagesDirPath = clonedSourcePackagesDirPath
self.staticSideEffectsWarningTargets = staticSideEffectsWarningTargets
self.enforceExplicitDependencies = enforceExplicitDependencies
self.defaultConfiguration = defaultConfiguration
}
}
}
6 changes: 4 additions & 2 deletions Sources/TuistGraphTesting/Models/Config+TestData.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,16 @@ extension Config.GenerationOptions {
disablePackageVersionLocking: Bool = false,
clonedSourcePackagesDirPath: AbsolutePath? = nil,
staticSideEffectsWarningTargets: TuistGraph.Config.GenerationOptions.StaticSideEffectsWarningTargets = .all,
enforceExplicitDependencies: Bool = false
enforceExplicitDependencies: Bool = false,
defaultConfiguration: String? = nil
) -> Self {
.init(
resolveDependenciesWithSystemScm: resolveDependenciesWithSystemScm,
disablePackageVersionLocking: disablePackageVersionLocking,
clonedSourcePackagesDirPath: clonedSourcePackagesDirPath,
staticSideEffectsWarningTargets: staticSideEffectsWarningTargets,
enforceExplicitDependencies: enforceExplicitDependencies
enforceExplicitDependencies: enforceExplicitDependencies,
defaultConfiguration: defaultConfiguration
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@ extension TuistGraph.Config.GenerationOptions {
clonedSourcePackagesDirPath: clonedSourcePackagesDirPath,
staticSideEffectsWarningTargets: TuistGraph.Config.GenerationOptions.StaticSideEffectsWarningTargets
.from(manifest: manifest.staticSideEffectsWarningTargets),
enforceExplicitDependencies: manifest.enforceExplicitDependencies
enforceExplicitDependencies: manifest.enforceExplicitDependencies,
defaultConfiguration: manifest.defaultConfiguration
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -839,6 +839,14 @@ final class GenerateAcceptanceTestSPMPackage: TuistAcceptanceTestCase {
}
}

final class GenerateAcceptanceTestAppWithDefaultConfiguration: TuistAcceptanceTestCase {
func test_app_with_custom_default_configuration() async throws {
try setUpFixture(.appWithCustomDefaultConfiguration)
try await run(GenerateCommand.self)
try await run(BuildCommand.self)
}
}

extension TuistAcceptanceTestCase {
private func resourcePath(
for productName: String,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,6 @@ final class ModuleMapMapperTests: TuistUnitTestCase {
"-fmodule-map-file=$(SRCROOT)/../B/B2/B2.module",
]),
"HEADER_SEARCH_PATHS": .array(["$(inherited)", "$(SRCROOT)/../B/B1/include", "$(SRCROOT)/../B/B2/include"]),
"OTHER_LDFLAGS": .array(["$(inherited)", "-ObjC"]),
]),
dependencies: [
.project(target: "B1", path: projectBPath),
Expand All @@ -134,7 +133,6 @@ final class ModuleMapMapperTests: TuistUnitTestCase {
"OTHER_CFLAGS": .array(["$(inherited)", "-fmodule-map-file=$(SRCROOT)/B2/B2.module"]),
"OTHER_SWIFT_FLAGS": .array(["$(inherited)", "-Xcc", "-fmodule-map-file=$(SRCROOT)/B2/B2.module"]),
"HEADER_SEARCH_PATHS": .array(["$(SRCROOT)/B1/include", "$(SRCROOT)/B2/include"]),
"OTHER_LDFLAGS": .array(["$(inherited)", "-ObjC"]),
]),
dependencies: [
.target(name: "B2"),
Expand Down Expand Up @@ -262,7 +260,6 @@ final class ModuleMapMapperTests: TuistUnitTestCase {
"-fmodule-map-file=$(SRCROOT)/../B/B/B.module",
]),
"HEADER_SEARCH_PATHS": .array(["$(inherited)", "$(SRCROOT)/../B/B/include"]),
"OTHER_LDFLAGS": .array(["$(inherited)", "-ObjC"]),
],
configurations: [:],
defaultSettings: .recommended
Expand Down
8 changes: 8 additions & 0 deletions docs/docs/guide/project/dependencies.md
Original file line number Diff line number Diff line change
Expand Up @@ -194,3 +194,11 @@ pod install

> [!WARNING]
> CocoaPods dependencies are not compatible with workflows like `build` or `test` that run `xcodebuild` right after generating the project. They are also incompatible with binary caching and selective testing since the fingerprinting logic doesn't account for the Pods dependencies.
## Objective-C Dependencies

When integrating Objective-C dependencies, the inclusion of certain flags on the consuming target may be necessary to avoid runtime crashes as detailed in [Apple Technical Q&A QA1490](https://developer.apple.com/library/archive/qa/qa1490/_index.html).

Since the build system and Tuist have no way of inferring whether the flag is necessary or not, and since the flag comes with potentially undesirable side effects, Tuist will not automatically apply any of these flags, and because Swift Package Manager considers `-ObjC` to be included via an `.unsafeFlag` most packages cannot include it as part of their default linking settings when required.

Consumers of Objective-C dependencies (or internal Objective-C targets) should apply `-ObjC` or `-force_load` flags when required by setting `OTHER_LDFLAGS` on consuming targets.
70 changes: 70 additions & 0 deletions fixtures/app_with_custom_default_configuration/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
### 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

### Tuist derived files ###
graph.dot
Derived/

### Tuist managed dependencies ###
Tuist/.build
2 changes: 2 additions & 0 deletions fixtures/app_with_custom_default_configuration/.mise.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[tools]
tuist = "4.11.0"
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"colors" : [
{
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading

0 comments on commit 337fc02

Please sign in to comment.