Skip to content

Commit 4cf275f

Browse files
authored
[Infra] Refactors small areas of the ZipBuilder (#9920)
1 parent 734f9f5 commit 4cf275f

File tree

2 files changed

+22
-24
lines changed

2 files changed

+22
-24
lines changed

ReleaseTooling/Sources/ZipBuilder/CocoaPodUtils.swift

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,12 +73,11 @@ enum CocoaPodUtils {
7373

7474
/// The debug description as required by `CustomDebugStringConvertible`.
7575
var debugDescription: String {
76-
var desc = name
7776
if let version = version {
78-
desc.append(" v\(version)")
77+
return "\(name) v\(version)"
78+
} else {
79+
return name
7980
}
80-
81-
return desc
8281
}
8382
}
8483

ReleaseTooling/Sources/ZipBuilder/ModuleMapBuilder.swift

Lines changed: 19 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -111,13 +111,11 @@ struct ModuleMapBuilder {
111111
/// Build the module map files for the source frameworks.
112112
///
113113
func build() {
114-
for (_, info) in installedPods {
115-
if info.isSourcePod == false ||
116-
info.transitiveFrameworks != nil ||
117-
info.versionedPod.name == "Firebase" {
118-
continue
119-
}
120-
generate(framework: info)
114+
for framework in installedPods.values
115+
where framework.isSourcePod &&
116+
framework.versionedPod.name != "Firebase" &&
117+
framework.transitiveFrameworks == nil {
118+
generate(framework: framework)
121119
}
122120
}
123121

@@ -129,12 +127,14 @@ struct ModuleMapBuilder {
129127
private func generate(framework: FrameworkInfo) {
130128
let podName = framework.versionedPod.name
131129
let deps = CocoaPodUtils.transitiveVersionedPodDependencies(for: podName, in: allPods)
132-
_ = CocoaPodUtils.installPods(allSubspecList(framework: framework) + deps,
133-
inDir: projectDir,
134-
platform: platform,
135-
customSpecRepos: customSpecRepos,
136-
localPodspecPath: localPodspecPath,
137-
linkage: .forcedStatic)
130+
131+
CocoaPodUtils.installPods(allSubspecList(framework: framework) + deps,
132+
inDir: projectDir,
133+
platform: platform,
134+
customSpecRepos: customSpecRepos,
135+
localPodspecPath: localPodspecPath,
136+
linkage: .forcedStatic)
137+
138138
let xcconfigFile = projectDir.appendingPathComponents(["Pods", "Target Support Files",
139139
"Pods-FrameworkMaker",
140140
"Pods-FrameworkMaker.release.xcconfig"])
@@ -146,15 +146,14 @@ struct ModuleMapBuilder {
146146
private func allSubspecList(framework: FrameworkInfo) -> [CocoaPodUtils.VersionedPod] {
147147
let name = framework.versionedPod.name
148148
let version = framework.versionedPod.version
149-
let subspecs = framework.subspecs
150-
if subspecs.count == 0 {
151-
return [CocoaPodUtils.VersionedPod(name: "\(name)", version: version)]
149+
150+
guard framework.subspecs.count > 0 else {
151+
return [CocoaPodUtils.VersionedPod(name: name, version: version)]
152152
}
153-
var list: [CocoaPodUtils.VersionedPod] = []
154-
for subspec in framework.subspecs {
155-
list.append(CocoaPodUtils.VersionedPod(name: "\(name)/\(subspec)", version: version))
153+
154+
return framework.subspecs.map { subspec in
155+
CocoaPodUtils.VersionedPod(name: "\(name)/\(subspec)", version: version)
156156
}
157-
return list
158157
}
159158

160159
// Extract the framework and library dependencies for a framework from

0 commit comments

Comments
 (0)