Skip to content

Commit

Permalink
Fix: Handle cases where search header path does not end with "Headers" (
Browse files Browse the repository at this point in the history
#431)

- Fixed issue with search header paths not ending with "Headers".
- Replaced incorrect usage of `map` with `flatMap` to resolve mapping error.
  • Loading branch information
Ethan-IS authored Jan 17, 2025
1 parent aaa408d commit 0f6e963
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ final class XcodeBuild {
"-project \(paths.project.shellFriendly)",
"SYMROOT=\(paths.symroot.shellFriendly)"
])
options.resultBundlePath.map {
options.resultBundlePath.flatMap {
arguments.append("-resultBundlePath \($0.shellFriendly)")
}
arguments.append(contentsOf: options.xcargs)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ final class TargetsHasher {
"xcargs": xcargs.sorted()
],
"buildPhases": buildPhaseHasher.hashContext(target: target),
"product": target.product.map(productHasher.hashContext) as Any,
"product": target.product.flatMap(productHasher.hashContext) as Any,
"configurations": configurationsHasher.hashContext(target),
"cocoaPodsScripts": cocoaPodsScriptsHasher.hashContext(target),
"buildRules": buildRulesHasher.hashContext(target.buildRules)
Expand All @@ -93,7 +93,7 @@ extension TargetsHasher: ITargetsHasher {
targets.modifyIf(rehash) { resetHash($0) }

let xcodeVersion = try xcodeCLTVersionProvider.version()
let formattedXcodeBuildVersion = xcodeVersion.build.map { " (\($0))" } ?? ""
let formattedXcodeBuildVersion = xcodeVersion.build.flatMap { " (\($0))" } ?? ""
let formattedXcodeVersion = "\(xcodeVersion.base)" + formattedXcodeBuildVersion
try await targets.merging(targets.flatMapValues(\.dependencies)).values.concurrentForEach { target in
guard target.targetHashContext == nil else { return }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ extension EnvironmentCollector: IEnvironmentCollector {
rugbyEnvironment: [String: String]
) async throws -> [String] {
let xcodeCLTInfo = try xcodeCLTVersionProvider.version()
let xcodeCLTVersion = xcodeCLTInfo.build.map { "\(xcodeCLTInfo.base) (\($0))" } ?? xcodeCLTInfo.base
let xcodeCLTVersion = xcodeCLTInfo.build.flatMap { "\(xcodeCLTInfo.base) (\($0))" } ?? xcodeCLTInfo.base
var output = try [
"Rugby version: \(rugbyVersion)",
await getSwiftVersion(),
Expand Down
2 changes: 1 addition & 1 deletion Sources/RugbyFoundation/Core/Use/SupportFilesPatcher.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ struct FileReplacement {

enum ReplacementBoundary {
static let prefix = #"(?<=(\"|'|\s))"#
static let suffix = #"(?=(\"|'|\s))"#
static let suffix = #"(?=(\"|'|\s|/))"#
}

protocol ISupportFilesPatcher: AnyObject {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ final class XcodeProjectDataSource: Loggable {
func save() async throws {
// Save only read projects
var projects = cachedSubprojects ?? []
cachedRootProject.map { projects.append($0) }
cachedRootProject.flatMap { projects.append($0) }

try await projects.concurrentMap { project in
try project.xcodeProj.write(pathString: project.path, override: true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import XCTest
final class SupportFilesPatcherTests: XCTestCase {
private var sut: ISupportFilesPatcher!
private var expectedPrefixBoundary = #"(?<=(\"|'|\s))"#
private var expectedSuffixBoundary = #"(?=(\"|'|\s))"#
private var expectedSuffixBoundary = #"(?=(\"|'|\s|/))"#

override func setUp() {
super.setUp()
Expand Down

0 comments on commit 0f6e963

Please sign in to comment.