Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion Sources/XcodeGraph/Models/Plist.swift
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,9 @@ public enum InfoPlist: Equatable, Codable, Sendable {
// User defined dictionary of keys/values for an info.plist file.
case dictionary([String: Plist.Value], configuration: BuildConfiguration? = nil)

// A user defined xcconfig variable map to .entitlements file
case variable(String, configuration: BuildConfiguration? = nil)

// User defined dictionary of keys/values for an info.plist file extending the default set of keys/values
// for the target type.
case extendingDefault(with: [String: Plist.Value], configuration: BuildConfiguration? = nil)
Expand All @@ -123,7 +126,12 @@ public enum InfoPlist: Equatable, Codable, Sendable {

extension InfoPlist: ExpressibleByStringLiteral {
public init(stringLiteral value: String) {
self = .file(path: try! AbsolutePath(validating: value)) // swiftlint:disable:this force_try
let regexPattern = #"^\$\((.+)\)|^\$\{(.+)\}"#
if let _ = value.range(of: regexPattern, options: .regularExpression) {
self = .variable(value)
} else {
self = .file(path: try! AbsolutePath(validating: value)) // swiftlint:disable:this force_try
}
}
}

Expand Down
10 changes: 10 additions & 0 deletions Tests/XcodeGraphTests/Models/InfoPlistTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,14 @@ final class InfoPlistTests: XCTestCase {
// Then
XCTAssertEqual(subject.path, try AbsolutePath(validating: "/path/Info.list"))
}

func test_expressive_by_string_literal_using_build_variable() {
// Given
let subject1: InfoPlist = "$(CONFIGURATION)/Info.list"
let subject2: InfoPlist = "${CONFIGURATION}/Info.list"

// Then
XCTAssertEqual(subject1, .variable("$(CONFIGURATION)/Info.list", configuration: nil))
XCTAssertEqual(subject2, .variable("${CONFIGURATION}/Info.list", configuration: nil))
}
}