Skip to content

Commit abac8c7

Browse files
committed
Merge branch 'bsneed/xcode15_fix'
2 parents 0be3a68 + 4d7d337 commit abac8c7

11 files changed

+3049
-9
lines changed

Package.resolved

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Package.swift

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,30 +4,57 @@
44
import PackageDescription
55

66
let dependencies: [Package.Dependency]
7-
#if swift(>=5.7)
7+
let versionedTargets: [Target]
8+
let versionedDependencies: [Target.Dependency]
9+
10+
#if swift(>=5.9)
11+
dependencies = [
12+
.package(url: "https://github.com/apple/swift-argument-parser.git", .exact("1.2.3")),
13+
.package(name: "SwiftPM", url: "https://github.com/apple/swift-package-manager.git", .branch("release/5.9")),
14+
.package(url: "https://github.com/apple/swift-tools-support-core.git", .branch("release/5.9")),
15+
]
16+
versionedTargets = [
17+
.target(
18+
name: "Xcodeproj",
19+
dependencies: [
20+
.product(name: "SwiftPM-auto", package: "SwiftPM"),
21+
.product(name: "SwiftToolsSupport-auto", package: "swift-tools-support-core"),
22+
]
23+
)
24+
]
25+
versionedDependencies = ["Xcodeproj"]
26+
#elseif swift(>=5.7)
827
dependencies = [
928
.package(url: "https://github.com/apple/swift-argument-parser.git", .exact("1.0.3")),
1029
.package(name: "SwiftPM", url: "https://github.com/apple/swift-package-manager.git", .branch("release/5.7")),
1130
.package(url: "https://github.com/apple/swift-tools-support-core.git", .branch("release/5.7")),
1231
]
32+
versionedTargets = []
33+
versionedDependencies = []
1334
#elseif swift(>=5.6)
1435
dependencies = [
1536
.package(url: "https://github.com/apple/swift-argument-parser.git", .exact("1.0.3")),
1637
.package(name: "SwiftPM", url: "https://github.com/apple/swift-package-manager.git", .branch("release/5.6")),
1738
.package(url: "https://github.com/apple/swift-tools-support-core.git", .exact("0.2.5"))
1839
]
40+
versionedTargets = []
41+
versionedDependencies = []
1942
#elseif swift(>=5.5)
2043
dependencies = [
2144
.package(url: "https://github.com/apple/swift-argument-parser.git", .exact("0.4.4")),
2245
.package(name: "SwiftPM", url: "https://github.com/apple/swift-package-manager.git", .branch("release/5.5")),
2346
.package(url: "https://github.com/apple/swift-tools-support-core.git", .exact("0.2.3"))
2447
]
48+
versionedTargets = []
49+
versionedDependencies = []
2550
#else
2651
dependencies = [
2752
.package(url: "https://github.com/apple/swift-argument-parser.git", .exact("0.3.2")),
2853
.package(name: "SwiftPM", url: "https://github.com/apple/swift-package-manager.git", .revision("swift-5.3.3-RELEASE")),
2954
.package(url: "https://github.com/apple/swift-tools-support-core.git", .exact("0.1.12"))
3055
]
56+
versionedTargets = []
57+
versionedDependencies = []
3158
#endif
3259

3360
let platforms: [SupportedPlatform]
@@ -53,8 +80,8 @@ let package = Package(
5380

5481
dependencies: dependencies,
5582

56-
targets: [
57-
.target(name: "CreateXCFramework", dependencies: [
83+
targets: versionedTargets + [
84+
.target(name: "CreateXCFramework", dependencies: versionedDependencies + [
5885
.product(name: "ArgumentParser", package: "swift-argument-parser"),
5986
.product(name: "SwiftPM-auto", package: "SwiftPM"),
6087
.product(name: "SwiftToolsSupport-auto", package: "swift-tools-support-core"),

Sources/Xcodeproj/CMakeLists.txt

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# This source file is part of the Swift open source project
2+
#
3+
# Copyright (c) 2014 - 2019 Apple Inc. and the Swift project authors
4+
# Licensed under Apache License v2.0 with Runtime Library Exception
5+
#
6+
# See http://swift.org/LICENSE.txt for license information
7+
# See http://swift.org/CONTRIBUTORS.txt for Swift project authors
8+
9+
add_library(Xcodeproj STATIC
10+
generate.swift
11+
pbxproj.swift
12+
PropertyList.swift
13+
SchemesGenerator.swift
14+
Target+PBXProj.swift
15+
XcodeProjectModel.swift
16+
XcodeProjectModelSerialization.swift)
17+
target_link_libraries(Xcodeproj PUBLIC
18+
TSCBasic
19+
Basics
20+
PackageGraph)
21+
# NOTE(compnerd) workaround for CMake not setting up include flags yet
22+
set_target_properties(Xcodeproj PROPERTIES
23+
INTERFACE_INCLUDE_DIRECTORIES ${CMAKE_Swift_MODULE_DIRECTORY})
24+

Sources/Xcodeproj/PropertyList.swift

Lines changed: 154 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,154 @@
1+
//===----------------------------------------------------------------------===//
2+
//
3+
// This source file is part of the Swift open source project
4+
//
5+
// Copyright (c) 2014-2017 Apple Inc. and the Swift project authors
6+
// Licensed under Apache License v2.0 with Runtime Library Exception
7+
//
8+
// See http://swift.org/LICENSE.txt for license information
9+
// See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
10+
//
11+
//===----------------------------------------------------------------------===//
12+
13+
#if swift(>=5.9)
14+
15+
/// A enum representing data types for legacy PropertyList type.
16+
/// Note that the `identifier` enum is not strictly necessary,
17+
/// but useful to semantically distinguish the strings that
18+
/// represents object identifiers from those that are just data.
19+
/// see: https://developer.apple.com/library/mac/documentation/Cocoa/Conceptual/PropertyLists/OldStylePlists/OldStylePLists.html
20+
public enum PropertyList {
21+
case identifier(String)
22+
case string(String)
23+
case array([PropertyList])
24+
case dictionary([String: PropertyList])
25+
26+
var string: String? {
27+
if case .string(let string) = self {
28+
return string
29+
}
30+
return nil
31+
}
32+
33+
var array: [PropertyList]? {
34+
if case .array(let array) = self {
35+
return array
36+
}
37+
return nil
38+
}
39+
}
40+
41+
extension PropertyList: ExpressibleByStringLiteral {
42+
public typealias UnicodeScalarLiteralType = StringLiteralType
43+
public typealias ExtendedGraphemeClusterLiteralType = StringLiteralType
44+
45+
public init(unicodeScalarLiteral value: UnicodeScalarLiteralType) {
46+
self = .string(value)
47+
}
48+
public init(extendedGraphemeClusterLiteral value: ExtendedGraphemeClusterLiteralType) {
49+
self = .string(value)
50+
}
51+
public init(stringLiteral value: StringLiteralType) {
52+
self = .string(value)
53+
}
54+
}
55+
56+
extension PropertyList: CustomStringConvertible {
57+
public var description: String {
58+
return serialize()
59+
}
60+
}
61+
62+
extension PropertyList {
63+
/// Serializes the Plist enum to string.
64+
public func serialize() -> String {
65+
return generatePlistRepresentation(plist: self, indentation: Indentation())
66+
}
67+
68+
/// Escapes the string for plist.
69+
/// Finds the instances of quote (") and backward slash (\) and prepends
70+
/// the escape character backward slash (\).
71+
static func escape(string: String) -> String {
72+
func needsEscape(_ char: UInt8) -> Bool {
73+
return char == UInt8(ascii: "\\") || char == UInt8(ascii: "\"")
74+
}
75+
76+
guard let pos = string.utf8.firstIndex(where: needsEscape) else {
77+
return string
78+
}
79+
var newString = String(string[..<pos])
80+
for char in string.utf8[pos...] {
81+
if needsEscape(char) {
82+
newString += "\\"
83+
}
84+
newString += String(UnicodeScalar(char))
85+
}
86+
return newString
87+
}
88+
}
89+
90+
extension PropertyList {
91+
/// Private struct to generate indentation strings.
92+
fileprivate struct Indentation: CustomStringConvertible {
93+
var level: Int = 0
94+
mutating func increase() {
95+
level += 1
96+
precondition(level > 0, "indentation level overflow")
97+
}
98+
mutating func decrease() {
99+
precondition(level > 0, "indentation level underflow")
100+
level -= 1
101+
}
102+
var description: String {
103+
return String(repeating: " ", count: level)
104+
}
105+
}
106+
107+
/// Private function to generate OPENSTEP-style plist representation.
108+
fileprivate func generatePlistRepresentation(plist: PropertyList, indentation: Indentation) -> String {
109+
// Do the appropriate thing for each type of plist node.
110+
switch plist {
111+
112+
case .identifier(let ident):
113+
// FIXME: we should assert that the identifier doesn't need quoting
114+
return ident
115+
116+
case .string(let string):
117+
return "\"" + PropertyList.escape(string: string) + "\""
118+
119+
case .array(let array):
120+
var indent = indentation
121+
var str = "(\n"
122+
indent.increase()
123+
for (i, item) in array.enumerated() {
124+
str += "\(indent)\(generatePlistRepresentation(plist: item, indentation: indent))"
125+
str += (i != array.count - 1) ? ",\n" : "\n"
126+
}
127+
indent.decrease()
128+
str += "\(indent))"
129+
return str
130+
131+
case .dictionary(let dict):
132+
var indent = indentation
133+
let dict = dict.sorted(by: {
134+
// Make `isa` sort first (just for readability purposes).
135+
switch ($0.key, $1.key) {
136+
case ("isa", "isa"): return false
137+
case ("isa", _): return true
138+
case (_, "isa"): return false
139+
default: return $0.key < $1.key
140+
}
141+
})
142+
var str = "{\n"
143+
indent.increase()
144+
for item in dict {
145+
str += "\(indent)\(item.key) = \(generatePlistRepresentation(plist: item.value, indentation: indent));\n"
146+
}
147+
indent.decrease()
148+
str += "\(indent)}"
149+
return str
150+
}
151+
}
152+
}
153+
154+
#endif

0 commit comments

Comments
 (0)