Skip to content

Commit

Permalink
Merge branch 'main' into feature/tmp-merged-branches
Browse files Browse the repository at this point in the history
# Conflicts:
#	CHANGELOG.md
#	Sources/TuistSupport/Constants.swift
  • Loading branch information
Mohga Gamea committed May 21, 2023
2 parents 474fff5 + 9bb3b37 commit 1464d6b
Show file tree
Hide file tree
Showing 69 changed files with 1,625 additions and 411 deletions.
27 changes: 27 additions & 0 deletions .all-contributorsrc
Original file line number Diff line number Diff line change
Expand Up @@ -1003,6 +1003,33 @@
"contributions": [
"code"
]
},
{
"login": "batuhansk",
"name": "Batuhan Saka",
"avatar_url": "https://avatars.githubusercontent.com/u/9626765?v=4",
"profile": "http://linkedin.com/in/batuhansaka",
"contributions": [
"code"
]
},
{
"login": "JCSooHwanCho",
"name": "SooHwanCho",
"avatar_url": "https://avatars.githubusercontent.com/u/51935215?v=4",
"profile": "http://jcsoohwancho.github.io",
"contributions": [
"code"
]
},
{
"login": "griches",
"name": "Gary Riches",
"avatar_url": "https://avatars.githubusercontent.com/u/798117?v=4",
"profile": "http://www.bouncingball.mobi",
"contributions": [
"code"
]
}
],
"contributorsPerLine": 7,
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
with:
ref: ${{ github.head_ref }}
fetch-depth: 0
token: ${{ secrets.GH_RELEASE_TOKEN }}
token: ${{ secrets.GITHUB_TOKEN }}
- name: 'Get Previous tag'
id: previoustag
uses: "WyriHaximus/github-action-get-previous-tag@v1"
Expand All @@ -51,7 +51,7 @@ jobs:
configuration: ".github/workflows/changelog-configuration.json"
toTag: "main"
env:
GITHUB_TOKEN: ${{ secrets.GH_RELEASE_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Update Changelog
uses: stefanzweifel/changelog-updater-action@v1
with:
Expand Down Expand Up @@ -90,9 +90,9 @@ jobs:
if: ${{ github.event.inputs.publish == 'true' }}
uses: softprops/action-gh-release@v1
with:
token: ${{ secrets.GH_RELEASE_TOKEN }}
token: ${{ secrets.GITHUB_TOKEN }}
files: build/*
name: ${{ needs.prepare-release.outputs.version }}
tag_name: ${{ needs.prepare-release.outputs.version }}
body: ${{ needs.prepare-release.outputs.changelog }}
target_commitish: ${{ needs.prepare-release.outputs.commit_hash }}
target_commitish: ${{ needs.prepare-release.outputs.commit_hash }}
17 changes: 17 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,23 @@
- Fixed a "Template.swift" file not found error when executing `tuist init -t <git url>` by [@Buju77](https://github.com/Buju77)
- Fixed wrong http regex for repo url used in `TemplateLocationParsing` (old regex wrongfully matched with ssh urls that included username) by [@MohgaNabil](https://github.com/MohgaNabil)

## 3.19.0-runtastic - 2023-05-16

- no changes

## 3.19.0 - 2023-04-29

### Added

- Add support for watchOS extension to have WidgetKit extension dependencies [#5153](https://github.com/tuist/tuist/pull/5153) by [@griches](https://github.com/griches)
- Support for SwiftUI font in font template [#5168](https://github.com/tuist/tuist/pull/5168) by [@L-j-h-c](https://github.com/L-j-h-c)
- Support for custom shell path in `ExecuteAction` [#5154](https://github.com/tuist/tuist/pull/5154) by [@JCSooHwanCho](https://github.com/JCSooHwanCho)

### Fixed

- Exclude Swift Package build directory from manifest search [#5143](https://github.com/tuist/tuist/pull/5143) by [@ajevans99](https://github.com/ajevans99)
- Fix errors when archiving projects with static XCFrameworks [#5157](https://github.com/tuist/tuist/pull/5157) by [@kwridan](https://github.com/kwridan)

## 3.18.0 - 2023-04-14

### Added
Expand Down
4 changes: 2 additions & 2 deletions Package.resolved
Original file line number Diff line number Diff line change
Expand Up @@ -265,8 +265,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/tuist/XcodeProj.git",
"state" : {
"revision" : "b6de1bfe021b861c94e7c83821b595083f74b997",
"version" : "8.8.0"
"revision" : "5fdac93cb4a7fd4bad5ac2da34e5bc878263043f",
"version" : "8.10.0"
}
},
{
Expand Down
2 changes: 1 addition & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ let package = Package(
.package(url: "https://github.com/SwiftDocOrg/GraphViz.git", exact: "0.2.0"),
.package(url: "https://github.com/SwiftGen/StencilSwiftKit.git", exact: "2.9.0"),
.package(url: "https://github.com/SwiftGen/SwiftGen", exact: "6.5.1"),
.package(url: "https://github.com/tuist/XcodeProj.git", exact: "8.8.0"),
.package(url: "https://github.com/tuist/XcodeProj.git", exact: "8.10.0"),
],
targets: [
.target(
Expand Down
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,11 @@ Thanks goes to these wonderful people:
<td align="center" valign="top" width="14.28%"><a href="https://github.com/oozoofrog"><img src="https://avatars.githubusercontent.com/u/3011832?v=4" width="100px;" alt=""/><br /><sub><b>oozoofrog</b></sub></a></td>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/MartinStrambach"><img src="https://avatars.githubusercontent.com/u/11178869?v=4" width="100px;" alt=""/><br /><sub><b>Martin Strambach</b></sub></a></td>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/sh-a-n"><img src="https://avatars.githubusercontent.com/u/2219548?v=4" width="100px;" alt=""/><br /><sub><b>sh-a-n</b></sub></a></td>
<td align="center" valign="top" width="14.28%"><a href="http://linkedin.com/in/batuhansaka"><img src="https://avatars.githubusercontent.com/u/9626765?v=4" width="100px;" alt=""/><br /><sub><b>Batuhan Saka</b></sub></a></td>
<td align="center" valign="top" width="14.28%"><a href="http://jcsoohwancho.github.io"><img src="https://avatars.githubusercontent.com/u/51935215?v=4" width="100px;" alt=""/><br /><sub><b>SooHwanCho</b></sub></a></td>
</tr>
<tr>
<td align="center" valign="top" width="14.28%"><a href="http://www.bouncingball.mobi"><img src="https://avatars.githubusercontent.com/u/798117?v=4" width="100px;" alt=""/><br /><sub><b>Gary Riches</b></sub></a></td>
</tr>
</tbody>
</table>
Expand Down
11 changes: 6 additions & 5 deletions Sources/ProjectAutomation/Tuist.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ public enum Tuist {

/// Loads and returns the graph at the given path.
/// - parameter path: the path which graph should be loaded. If nil, the current path is used.
public static func graph(at path: String? = nil) throws -> Graph {
/// - parameter environmentKeys: the environment keys that should be copied. If empty, no environment variables will be passed.
public static func graph(at path: String? = nil, environmentKeys: Set<String> = []) throws -> Graph {
// If a task is executed via `tuist`, it gets passed the binary path as a last argument.
// Otherwise, fallback to go
let tuistBinaryPath = ProcessInfo.processInfo.environment["TUIST_CONFIG_BINARY_PATH"] ?? "tuist"
Expand All @@ -44,10 +45,10 @@ public enum Tuist {
}
let forceConfigCacheDirectory = "TUIST_CONFIG_FORCE_CONFIG_CACHE_DIRECTORY"
var environment: [String: String] = [:]
if let configCacheDirectory = ProcessInfo.processInfo.environment[forceConfigCacheDirectory],
!configCacheDirectory.isEmpty
{
environment[forceConfigCacheDirectory] = configCacheDirectory
for environmentKey in environmentKeys + [forceConfigCacheDirectory] {
if let value = ProcessInfo.processInfo.environment[environmentKey], !value.isEmpty {
environment[environmentKey] = value
}
}
try run(
arguments,
Expand Down
6 changes: 5 additions & 1 deletion Sources/ProjectDescription/ExecuteAction.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,13 @@ public struct ExecutionAction: Equatable, Codable {
public let scriptText: String
public let target: TargetReference?

public init(title: String = "Run Script", scriptText: String, target: TargetReference? = nil) {
/// The path to the shell which shall execute this script. if it is nil, Xcode will use default value.
public let shellPath: String?

public init(title: String = "Run Script", scriptText: String, target: TargetReference? = nil, shellPath: String? = nil) {
self.title = title
self.scriptText = scriptText
self.target = target
self.shellPath = shellPath
}
}
84 changes: 72 additions & 12 deletions Sources/TuistGenerator/Generator/LinkGenerator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -435,6 +435,8 @@ final class LinkGenerator: LinkGenerating {
pbxproj: PBXProj,
fileElements: ProjectFileElements
) throws {
let dependencies = graphTraverser.copyProductDependencies(path: path, name: target.name).sorted()

// If the current target, which is non-shared (e.g., static lib), depends on other focused targets which
// include Swift code, we must ensure those are treated as dependencies so that Xcode builds the targets
// in the correct order. Unfortunately, those deps can be part of other projects which would require
Expand All @@ -448,17 +450,34 @@ final class LinkGenerator: LinkGenerating {
//
// This technique also allows resource bundles that reside in different projects to get built ahead of the
// "Copy Bundle Resources" phase.
try generateDependenciesBuildPhase(
dependencies: dependencies,
pbxTarget: pbxTarget,
pbxproj: pbxproj,
fileElements: fileElements
)

let dependencies = graphTraverser.copyProductDependencies(path: path, name: target.name).sorted()

if !dependencies.isEmpty {
try generateDependenciesBuildPhase(
dependencies: dependencies,
pbxTarget: pbxTarget,
pbxproj: pbxproj,
fileElements: fileElements
)
}
// For static framewor/library XCFrameworks, we need Xcode to process it to extract the
// the relevant product within it within it based on the architecture and place in
// the products directory. This allows the current target to see the symbols from the XCFramework.
//
// Copying to products is not a nop like it is for regular static targets due to the processing step,
// applying the same technique results in the following error:
//
// ```
// Multiple commands produce ...
// ```
// A slightly different build phase is needed, where the destination is unique per target (this does
// lead to some wasted derrived data disk space, but only when archiving to limit impact).
// As of Xcode 14.2, this seems to achieve the desired effect of getting Xcode to process the XCFramework
// without explicitly linking it nor producing the multiple commands error.
try generateStaticXCFrameworksDependenciesBuildPhase(
dependencies: dependencies,
pbxTarget: pbxTarget,
pbxproj: pbxproj,
target: target,
fileElements: fileElements
)
}

private func generateDependenciesBuildPhase(
Expand All @@ -480,8 +499,7 @@ final class LinkGenerator: LinkGenerating {
buildFile.platformFilter = platformFilter?.xcodeprojValue
pbxproj.add(object: buildFile)
files.append(buildFile)
case let .xcframework(path: path, _, _, _),
let .framework(path: path, _, _, _, _, _, _, _),
case let .framework(path: path, _, _, _, _, _, _, _),
let .library(path: path, _, _, _):
guard let fileRef = fileElements.file(path: path) else {
throw LinkGeneratorError.missingReference(path: path)
Expand Down Expand Up @@ -512,6 +530,48 @@ final class LinkGenerator: LinkGenerating {
pbxTarget.buildPhases.append(buildPhase)
}

private func generateStaticXCFrameworksDependenciesBuildPhase(
dependencies: [GraphDependencyReference],
pbxTarget: PBXTarget,
pbxproj: PBXProj,
target: Target,
fileElements: ProjectFileElements
) throws {
var files: [PBXBuildFile] = []

for dependency in dependencies.sorted() {
switch dependency {
case let .xcframework(path: path, _, _, _):
guard let fileRef = fileElements.file(path: path) else {
throw LinkGeneratorError.missingReference(path: path)
}
let buildFile = PBXBuildFile(file: fileRef)
pbxproj.add(object: buildFile)
files.append(buildFile)
default:
break
}
}

if files.isEmpty {
return
}

// Need a unique (but stable) destination path per target
// to avoid "multiple commands produce:" errors in Xcode
let buildPhase = PBXCopyFilesBuildPhase(
dstPath: "_StaticXCFrameworkDependencies/\(target.name)",
dstSubfolderSpec: .productsDirectory,
name: "Static XCFramework Dependencies",
buildActionMask: 8,
files: files,
runOnlyForDeploymentPostprocessing: true
)

pbxproj.add(object: buildPhase)
pbxTarget.buildPhases.append(buildPhase)
}

func createSDKBuildFile(for fileReference: PBXFileReference, status: SDKStatus) -> PBXBuildFile {
var settings: [String: Any]?
if status == .optional {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -731,6 +731,7 @@ final class SchemeDescriptorsGenerator: SchemeDescriptorsGenerating {
return XCScheme.ExecutionAction(
scriptText: action.scriptText,
title: action.title,
shellToInvoke: action.shellPath,
environmentBuildable: nil
)
}
Expand All @@ -745,6 +746,7 @@ final class SchemeDescriptorsGenerator: SchemeDescriptorsGenerating {
return XCScheme.ExecutionAction(
scriptText: action.scriptText,
title: action.title,
shellToInvoke: action.shellPath,
environmentBuildable: buildableReference
)
}
Expand Down
1 change: 1 addition & 0 deletions Sources/TuistGenerator/Linter/GraphLinter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -562,6 +562,7 @@ public class GraphLinter: GraphLinting {
LintableTarget(platform: .watchOS, product: .dynamicLibrary),
LintableTarget(platform: .watchOS, product: .framework),
LintableTarget(platform: .watchOS, product: .staticFramework),
LintableTarget(platform: .watchOS, product: .appExtension),
],

LintableTarget(platform: .watchOS, product: .appExtension): [
Expand Down
8 changes: 4 additions & 4 deletions Sources/TuistGenerator/Linter/TargetLinter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -73,14 +73,14 @@ class TargetLinter: TargetLinting {
private func lintProductName(target: Target) -> [LintingIssue] {
var allowed = CharacterSet(charactersIn: "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_")

if target.product == .app {
let allowsDot = target.product == .app || target.product == .commandLineTool
if allowsDot {
allowed.formUnion(CharacterSet(charactersIn: "."))
}

if target.productName.unicodeScalars.allSatisfy(allowed.contains) == false {
let reason = target.product == .app ?
"Invalid product name '\(target.productName)'. This string must contain only alphanumeric (A-Z,a-z,0-9), period (.), and underscore (_) characters." :
"Invalid product name '\(target.productName)'. This string must contain only alphanumeric (A-Z,a-z,0-9), and underscore (_) characters."
let reason =
"Invalid product name '\(target.productName)'. This string must contain only alphanumeric (A-Z,a-z,0-9)\(allowsDot ? ", period (.)" : ""), and underscore (_) characters."

return [LintingIssue(reason: reason, severity: .warning)]
}
Expand Down
17 changes: 17 additions & 0 deletions Sources/TuistGenerator/Templates/FontsTemplate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ extension SynthesizedResourceInterfaceTemplates {
#elseif os(iOS) || os(tvOS) || os(watchOS)
import UIKit.UIFont
#endif
#if canImport(SwiftUI)
import SwiftUI
#endif
// swiftlint:disable superfluous_disable_command
// swiftlint:disable file_length
Expand Down Expand Up @@ -63,6 +66,20 @@ extension SynthesizedResourceInterfaceTemplates {
return font
}
#if canImport(SwiftUI)
@available(iOS 13.0, tvOS 13.0, watchOS 6.0, macOS 10.15, *)
{{accessModifier}} func swiftUIFont(size: CGFloat) -> SwiftUI.Font {
guard let font = Font(font: self, size: size) else {
fatalError("Unable to initialize font '\\(name)' (\\(family))")
}
#if os(macOS)
return SwiftUI.Font.custom(font.fontName, size: font.size)
#elseif os(iOS) || os(tvOS) || os(watchOS)
return SwiftUI.Font(font)
#endif
}
#endif
{{accessModifier}} func register() {
// swiftlint:disable:next conditional_returns_on_newline
guard let url = url else { return }
Expand Down
4 changes: 4 additions & 0 deletions Sources/TuistGraph/Models/ExecutionAction.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ public struct ExecutionAction: Equatable, Codable {
public let scriptText: String
/// Name of the build or test target that will provide the action's build settings.
public let target: TargetReference?
/// The path to the shell which shall execute this script. if it is nil, Xcode will use default value.
public let shellPath: String?

public let showEnvVarsInLog: Bool

Expand All @@ -20,11 +22,13 @@ public struct ExecutionAction: Equatable, Codable {
title: String,
scriptText: String,
target: TargetReference?,
shellPath: String?,
showEnvVarsInLog: Bool = true
) {
self.title = title
self.scriptText = scriptText
self.target = target
self.shellPath = shellPath
self.showEnvVarsInLog = showEnvVarsInLog
}
}
1 change: 1 addition & 0 deletions Sources/TuistKit/ProjectEditor/ProjectEditor.swift
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ final class ProjectEditor: ProjectEditing {

let pathsToExclude = [
"**/\(Constants.tuistDirectoryName)/\(Constants.DependenciesDirectory.name)/**",
"**/\(Constants.DependenciesDirectory.packageBuildDirectoryName)/**",
] + tuistIgnoreEntries
let projectDescriptionPath = try resourceLocator.projectDescription()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ extension TuistGraph.ExecutionAction {
name: $0.targetName
)
}
return ExecutionAction(title: manifest.title, scriptText: manifest.scriptText, target: targetReference)
return ExecutionAction(
title: manifest.title,
scriptText: manifest.scriptText,
target: targetReference,
shellPath: manifest.shellPath
)
}
}
Loading

0 comments on commit 1464d6b

Please sign in to comment.