update to xcodeproj 9.10.1 (#1597)

This commit is contained in:
Yonas Kolb
2026-03-03 22:43:05 +11:00
committed by GitHub
parent 140cd5ee65
commit a904543801
16 changed files with 268 additions and 241 deletions
+54 -52
View File
@@ -294,21 +294,21 @@ public class PBXProjGenerator {
}.flatMap { $0 }
).sorted()
let defaultAttributes: [String: Any] = [
var projectAttributes: [String: ProjectAttribute] = [
"BuildIndependentTargetsInParallel": "YES"
]
var projectAttributes: [String: Any] = defaultAttributes.merged(project.attributes)
// Set default LastUpgradeCheck if user did not specify
let lastUpgradeKey = "LastUpgradeCheck"
if !projectAttributes.contains(where: { (key, value) -> Bool in
key == lastUpgradeKey && value is String
}) {
projectAttributes[lastUpgradeKey] = project.xcodeVersion
for (key, value) in project.attributes {
projectAttributes[key] = ProjectAttribute(any: value)
}
// Set default LastUpgradeCheck if user did not specify a valid string value
let lastUpgradeKey = "LastUpgradeCheck"
if !(project.attributes[lastUpgradeKey] is String) {
projectAttributes[lastUpgradeKey] = .string(project.xcodeVersion)
}
if !assetTags.isEmpty {
projectAttributes["knownAssetTags"] = assetTags
projectAttributes["knownAssetTags"] = .array(assetTags)
}
var knownRegions = Set(sourceGenerator.knownRegions)
@@ -483,9 +483,9 @@ public class PBXProjGenerator {
let productType: PBXProductType = targetObject.productType ?? .none
let buildSettings = defaultConfiguration.buildSettings
let settings = Settings(buildSettings: buildSettings, configSettings: [:], groups: [])
let deploymentTargetString = buildSettings[platform.deploymentTargetSetting] as? String
let deploymentTargetString = buildSettings[platform.deploymentTargetSetting]?.stringValue
let deploymentTarget = deploymentTargetString == nil ? nil : try Version.parse(deploymentTargetString!)
let requiresObjCLinking = (buildSettings["OTHER_LDFLAGS"] as? String)?.contains("-ObjC") ?? (productType == .staticLibrary)
let requiresObjCLinking = buildSettings["OTHER_LDFLAGS"]?.stringValue?.contains("-ObjC") ?? (productType == .staticLibrary)
let dependencyTarget = Target(
name: targetObject.name,
type: productType,
@@ -534,9 +534,9 @@ public class PBXProjGenerator {
return addObject(copyFilesBuildPhase)
}
func generateTargetAttributes() -> [PBXTarget: [String: Any]] {
func generateTargetAttributes() -> [PBXTarget: [String: ProjectAttribute]] {
var targetAttributes: [PBXTarget: [String: Any]] = [:]
var targetAttributes: [PBXTarget: [String: ProjectAttribute]] = [:]
let testTargets = pbxProj.nativeTargets.filter { $0.productType == .uiTestBundle || $0.productType == .unitTestBundle }
for testTarget in testTargets {
@@ -546,24 +546,24 @@ public class PBXProjGenerator {
guard let buildConfigurations = target.buildConfigurationList?.buildConfigurations else { return nil }
return buildConfigurations
.compactMap { $0.buildSettings["TEST_TARGET_NAME"] as? String }
.compactMap { $0.buildSettings["TEST_TARGET_NAME"]?.stringValue }
.first
}
guard let name = testTargetName(testTarget) else { continue }
guard let target = self.pbxProj.targets(named: name).first else { continue }
targetAttributes[testTarget, default: [:]].merge(["TestTargetID": target])
targetAttributes[testTarget, default: [:]].merge(["TestTargetID": .targetReference(target)])
}
func generateTargetAttributes(_ target: ProjectTarget, pbxTarget: PBXTarget) {
if !target.attributes.isEmpty {
targetAttributes[pbxTarget, default: [:]].merge(target.attributes)
targetAttributes[pbxTarget, default: [:]].merge(target.attributes.mapValues { ProjectAttribute(any: $0) })
}
func getSingleBuildSetting(_ setting: String) -> String? {
let settings = project.configs.compactMap {
project.getCombinedBuildSetting(setting, target: target, config: $0) as? String
project.getCombinedBuildSetting(setting, target: target, config: $0)?.stringValue
}
guard settings.count == project.configs.count,
let firstSetting = settings.first,
@@ -575,7 +575,7 @@ public class PBXProjGenerator {
func setTargetAttribute(attribute: String, buildSetting: String) {
if let setting = getSingleBuildSetting(buildSetting) {
targetAttributes[pbxTarget, default: [:]].merge([attribute: setting])
targetAttributes[pbxTarget, default: [:]].merge([attribute: .string(setting)])
}
}
@@ -706,6 +706,7 @@ public class PBXProjGenerator {
var systemExtensions: [PBXBuildFile] = []
var appClips: [PBXBuildFile] = []
var carthageFrameworksToEmbed: [String] = []
var buildFileCopyPhases: [PBXBuildFile: BuildPhaseSpec.CopyFilesSettings] = [:]
let targetDependencies = (target.transitivelyLinkDependencies ?? project.options.transitivelyLinkDependencies) ?
getAllDependenciesPlusTransitiveNeedingEmbedding(target: target) : target.dependencies
@@ -714,7 +715,7 @@ public class PBXProjGenerator {
(target.type.isApp || target.type == .watch2Extension))
let directlyEmbedCarthage = target.directlyEmbedCarthageDependencies ?? targetSupportsDirectEmbed
func getEmbedSettings(dependency: Dependency, codeSign: Bool) -> [String: Any] {
func getEmbedSettings(dependency: Dependency, codeSign: Bool) -> [String: BuildFileSetting] {
var embedAttributes: [String] = []
if codeSign {
embedAttributes.append("CodeSignOnCopy")
@@ -722,19 +723,15 @@ public class PBXProjGenerator {
if dependency.removeHeaders {
embedAttributes.append("RemoveHeadersOnCopy")
}
var retval: [String:Any] = ["ATTRIBUTES": embedAttributes]
if let copyPhase = dependency.copyPhase {
retval["COPY_PHASE"] = copyPhase
}
return retval
return ["ATTRIBUTES": .array(embedAttributes)]
}
func getDependencyFrameworkSettings(dependency: Dependency) -> [String: Any]? {
func getDependencyFrameworkSettings(dependency: Dependency) -> [String: BuildFileSetting]? {
var linkingAttributes: [String] = []
if dependency.weakLink {
linkingAttributes.append("Weak")
}
return !linkingAttributes.isEmpty ? ["ATTRIBUTES": linkingAttributes] : nil
return !linkingAttributes.isEmpty ? ["ATTRIBUTES": .array(linkingAttributes)] : nil
}
func processTargetDependency(_ dependency: Dependency, dependencyTarget: Target, embedFileReference: PBXFileElement?, platform: String?, platforms: [String]?) {
@@ -766,8 +763,9 @@ public class PBXProjGenerator {
pbxBuildFile.platformFilters = platforms
let embedFile = addObject(pbxBuildFile)
if dependency.copyPhase != nil {
if let copyPhase = dependency.copyPhase {
// custom copy takes precedence
buildFileCopyPhases[embedFile] = copyPhase
customCopyDependenciesReferences.append(embedFile)
} else if dependencyTarget.type.isExtension {
if dependencyTarget.type == .extensionKitExtension {
@@ -858,7 +856,8 @@ public class PBXProjGenerator {
pbxBuildFile.platformFilters = platforms
let embedFile = addObject(pbxBuildFile)
if dependency.copyPhase != nil {
if let copyPhase = dependency.copyPhase {
buildFileCopyPhases[embedFile] = copyPhase
customCopyDependenciesReferences.append(embedFile)
} else {
copyFrameworksReferences.append(embedFile)
@@ -916,7 +915,8 @@ public class PBXProjGenerator {
pbxBuildFile.platformFilters = platforms
let embedFile = addObject(pbxBuildFile)
if dependency.copyPhase != nil {
if let copyPhase = dependency.copyPhase {
buildFileCopyPhases[embedFile] = copyPhase
customCopyDependenciesReferences.append(embedFile)
} else {
copyFrameworksReferences.append(embedFile)
@@ -989,7 +989,8 @@ public class PBXProjGenerator {
pbxBuildFile.platformFilters = platforms
let embedFile = addObject(pbxBuildFile)
if dependency.copyPhase != nil {
if let copyPhase = dependency.copyPhase {
buildFileCopyPhases[embedFile] = copyPhase
customCopyDependenciesReferences.append(embedFile)
} else {
copyFrameworksReferences.append(embedFile)
@@ -1052,7 +1053,8 @@ public class PBXProjGenerator {
let embedFile = addObject(
PBXBuildFile(file: fileReference, settings: getEmbedSettings(dependency: dependency, codeSign: dependency.codeSign ?? true))
)
if dependency.copyPhase != nil {
if let copyPhase = dependency.copyPhase {
buildFileCopyPhases[embedFile] = copyPhase
customCopyDependenciesReferences.append(embedFile)
} else {
copyFrameworksReferences.append(embedFile)
@@ -1107,11 +1109,11 @@ public class PBXProjGenerator {
}
func splitCopyDepsByDestination(_ references: [PBXBuildFile]) -> [BuildPhaseSpec.CopyFilesSettings : [PBXBuildFile]] {
var retval = [BuildPhaseSpec.CopyFilesSettings : [PBXBuildFile]]()
for reference in references {
guard let key = reference.settings?["COPY_PHASE"] as? BuildPhaseSpec.CopyFilesSettings else { continue }
guard let key = buildFileCopyPhases[reference] else { continue }
var filesWithSameDestination = retval[key] ?? [PBXBuildFile]()
filesWithSameDestination.append(reference)
retval[key] = filesWithSameDestination
@@ -1162,7 +1164,7 @@ public class PBXProjGenerator {
addResourcesBuildPhase()
}
let swiftObjCInterfaceHeader = project.getCombinedBuildSetting("SWIFT_OBJC_INTERFACE_HEADER_NAME", target: target, config: project.configs[0]) as? String
let swiftObjCInterfaceHeader = project.getCombinedBuildSetting("SWIFT_OBJC_INTERFACE_HEADER_NAME", target: target, config: project.configs[0])?.stringValue
let swiftInstallObjCHeader = project.getBoolBuildSetting("SWIFT_INSTALL_OBJC_HEADER", target: target, config: project.configs[0]) ?? true // Xcode default
if target.type == .staticLibrary
@@ -1327,12 +1329,12 @@ public class PBXProjGenerator {
// Set CODE_SIGN_ENTITLEMENTS
if let entitlements = target.entitlements {
buildSettings["CODE_SIGN_ENTITLEMENTS"] = entitlements.path
buildSettings["CODE_SIGN_ENTITLEMENTS"] = .string(entitlements.path)
}
// Set INFOPLIST_FILE based on the resolved value
if let infoPlistFile = infoPlistFiles[config] {
buildSettings["INFOPLIST_FILE"] = infoPlistFile
buildSettings["INFOPLIST_FILE"] = .string(infoPlistFile)
}
// automatically calculate bundle id
@@ -1343,7 +1345,7 @@ public class PBXProjGenerator {
.replacingOccurrences(of: "_", with: "-")
.components(separatedBy: characterSet)
.joined(separator: "")
buildSettings["PRODUCT_BUNDLE_IDENTIFIER"] = bundleIdPrefix + "." + escapedTargetName
buildSettings["PRODUCT_BUNDLE_IDENTIFIER"] = .string(bundleIdPrefix + "." + escapedTargetName)
}
// automatically set test target name
@@ -1353,7 +1355,7 @@ public class PBXProjGenerator {
if dependency.type == .target,
let dependencyTarget = project.getTarget(dependency.reference),
dependencyTarget.type.isApp {
buildSettings["TEST_TARGET_NAME"] = dependencyTarget.name
buildSettings["TEST_TARGET_NAME"] = .string(dependencyTarget.name)
break
}
}
@@ -1380,13 +1382,13 @@ public class PBXProjGenerator {
if anyDependencyRequiresObjCLinking {
let otherLinkingFlags = "OTHER_LDFLAGS"
let objCLinking = "-ObjC"
if var array = buildSettings[otherLinkingFlags] as? [String] {
if var array = buildSettings[otherLinkingFlags]?.arrayValue {
array.append(objCLinking)
buildSettings[otherLinkingFlags] = array
} else if let string = buildSettings[otherLinkingFlags] as? String {
buildSettings[otherLinkingFlags] = [string, objCLinking]
buildSettings[otherLinkingFlags] = .array(array)
} else if let string = buildSettings[otherLinkingFlags]?.stringValue {
buildSettings[otherLinkingFlags] = .array([string, objCLinking])
} else {
buildSettings[otherLinkingFlags] = ["$(inherited)", objCLinking]
buildSettings[otherLinkingFlags] = .array(["$(inherited)", objCLinking])
}
}
@@ -1410,13 +1412,13 @@ public class PBXProjGenerator {
// set framework search paths
if !configFrameworkBuildPaths.isEmpty {
let frameworkSearchPaths = "FRAMEWORK_SEARCH_PATHS"
if var array = buildSettings[frameworkSearchPaths] as? [String] {
if var array = buildSettings[frameworkSearchPaths]?.arrayValue {
array.append(contentsOf: configFrameworkBuildPaths)
buildSettings[frameworkSearchPaths] = array
} else if let string = buildSettings[frameworkSearchPaths] as? String {
buildSettings[frameworkSearchPaths] = [string] + configFrameworkBuildPaths
buildSettings[frameworkSearchPaths] = .array(array)
} else if let string = buildSettings[frameworkSearchPaths]?.stringValue {
buildSettings[frameworkSearchPaths] = .array([string] + configFrameworkBuildPaths)
} else {
buildSettings[frameworkSearchPaths] = ["$(inherited)"] + configFrameworkBuildPaths
buildSettings[frameworkSearchPaths] = .array(["$(inherited)"] + configFrameworkBuildPaths)
}
}
@@ -1506,7 +1508,7 @@ public class PBXProjGenerator {
let values: [(Config, String)] = project.configs.compactMap { config in
// First, if the plist path was defined by `INFOPLIST_FILE`, use that
let buildSettings = project.getTargetBuildSettings(target: target, config: config)
if let value = buildSettings["INFOPLIST_FILE"] as? String {
if let value = buildSettings["INFOPLIST_FILE"]?.stringValue {
return (config, value)
}
+13 -20
View File
@@ -14,7 +14,7 @@ extension Project {
if let firstPlatform = targets.first?.platform,
targets.allSatisfy({ $0.platform == firstPlatform })
{
buildSettings["SDKROOT"] = firstPlatform.sdkRoot
buildSettings["SDKROOT"] = .string(firstPlatform.sdkRoot)
}
if let type = config.type, options.settingPresets.applyProject {
@@ -25,7 +25,7 @@ extension Project {
// apply custom platform version
for platform in Platform.allCases {
if let version = options.deploymentTarget.version(for: platform) {
buildSettings[platform.deploymentTargetSetting] = version.deploymentTarget
buildSettings[platform.deploymentTargetSetting] = .string(version.deploymentTarget)
}
}
@@ -63,7 +63,7 @@ extension Project {
if target.platform == .auto {
// this fix is necessary because the platform preset overrides the original value
buildSettings["SDKROOT"] = Platform.auto.rawValue
buildSettings["SDKROOT"] = .string(Platform.auto.rawValue)
}
}
@@ -75,16 +75,16 @@ extension Project {
let supportedPlatformBuildSettings = SettingsPresetFile.supportedDestination(supportedDestination).getBuildSettings()
buildSettings += supportedPlatformBuildSettings
if let value = supportedPlatformBuildSettings?["SUPPORTED_PLATFORMS"] as? String {
if let value = supportedPlatformBuildSettings?["SUPPORTED_PLATFORMS"]?.stringValue {
supportedPlatforms += value.components(separatedBy: " ")
}
if let value = supportedPlatformBuildSettings?["TARGETED_DEVICE_FAMILY"] as? String {
if let value = supportedPlatformBuildSettings?["TARGETED_DEVICE_FAMILY"]?.stringValue {
targetedDeviceFamily += value.components(separatedBy: ",")
}
}
buildSettings["SUPPORTED_PLATFORMS"] = supportedPlatforms.joined(separator: " ")
buildSettings["TARGETED_DEVICE_FAMILY"] = targetedDeviceFamily.joined(separator: ",")
buildSettings["SUPPORTED_PLATFORMS"] = .string(supportedPlatforms.joined(separator: " "))
buildSettings["TARGETED_DEVICE_FAMILY"] = .string(targetedDeviceFamily.joined(separator: ","))
}
// apply custom platform version
@@ -92,11 +92,11 @@ extension Project {
if !specSupportedDestinations.isEmpty {
for supportedDestination in specSupportedDestinations {
if let platform = Platform(rawValue: supportedDestination.rawValue) {
buildSettings[platform.deploymentTargetSetting] = version.deploymentTarget
buildSettings[platform.deploymentTargetSetting] = .string(version.deploymentTarget)
}
}
} else {
buildSettings[target.platform.deploymentTargetSetting] = version.deploymentTarget
buildSettings[target.platform.deploymentTargetSetting] = .string(version.deploymentTarget)
}
}
@@ -140,7 +140,7 @@ extension Project {
}
// combines all levels of a target's settings: target, target config, project, project config
public func getCombinedBuildSetting(_ setting: String, target: ProjectTarget, config: Config) -> Any? {
public func getCombinedBuildSetting(_ setting: String, target: ProjectTarget, config: Config) -> BuildSetting? {
if let target = target as? Target,
let value = getTargetBuildSettings(target: target, config: config)[setting] {
return value
@@ -160,15 +160,7 @@ extension Project {
}
public func getBoolBuildSetting(_ setting: String, target: ProjectTarget, config: Config) -> Bool? {
guard let value = getCombinedBuildSetting(setting, target: target, config: config) else { return nil }
if let boolValue = value as? Bool {
return boolValue
} else if let stringValue = value as? String {
return stringValue == "YES"
}
return nil
getCombinedBuildSetting(setting, target: target, config: config)?.boolValue
}
public func targetHasBuildSetting(_ setting: String, target: Target, config: Config) -> Bool {
@@ -264,10 +256,11 @@ extension SettingsPresetFile {
return nil
}
guard let buildSettings = try? loadYamlDictionary(path: settingsPath) else {
guard let dictionary = try? loadYamlDictionary(path: settingsPath) else {
print("Error parsing \"\(name)\" settings")
return nil
}
let buildSettings: BuildSettings = dictionary.mapValues { BuildSetting(any: $0) }
settingPresetSettings[path] = .cached(buildSettings)
return buildSettings
}
+5 -5
View File
@@ -121,7 +121,7 @@ class SourceGenerator {
func generateSourceFile(targetType: PBXProductType, targetSource: TargetSource, path: Path, fileReference: PBXFileElement? = nil, buildPhases: [Path: BuildPhaseSpec]) -> SourceFile {
let fileReference = fileReference ?? fileReferencesByPath[path.string.lowercased()]!
var settings: [String: Any] = [:]
var settings: [String: BuildFileSetting] = [:]
let fileType = getFileType(path: path)
var attributes: [String] = targetSource.attributes + (fileType?.attributes ?? [])
var chosenBuildPhase: BuildPhaseSpec?
@@ -173,15 +173,15 @@ class SourceGenerator {
}
if chosenBuildPhase == .sources && !compilerFlags.isEmpty {
settings["COMPILER_FLAGS"] = compilerFlags
settings["COMPILER_FLAGS"] = .string(compilerFlags)
}
if !attributes.isEmpty {
settings["ATTRIBUTES"] = attributes
settings["ATTRIBUTES"] = .array(attributes)
}
if chosenBuildPhase == .resources && !assetTags.isEmpty {
settings["ASSET_TAGS"] = assetTags
settings["ASSET_TAGS"] = .array(assetTags)
}
let platforms = makeDestinationFilters(for: path, with: targetSource.destinationFilters, or: targetSource.inferDestinationFiltersByPath)