Skip to content

Commit 30c1f44

Browse files
authored
Static library framework build for xcframeworks zip (#4799)
1 parent a062dbb commit 30c1f44

File tree

5 files changed

+375
-104
lines changed

5 files changed

+375
-104
lines changed

ZipBuilder/Sources/ZipBuilder/CocoaPodUtils.swift

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@ enum CocoaPodUtils {
4040
}
4141

4242
/// Information associated with an installed pod.
43-
struct PodInfo {
43+
/// This is a class so that moduleMapContents can be updated via reference.
44+
class PodInfo {
4445
/// The version of the generated pod.
4546
let version: String
4647

@@ -49,6 +50,36 @@ enum CocoaPodUtils {
4950

5051
/// The location of the pod on disk.
5152
let installedLocation: URL
53+
54+
/// Source pod flag.
55+
let isSourcePod: Bool
56+
57+
/// Binary frameworks in this pod.
58+
let binaryFrameworks: [URL]
59+
60+
/// The contents of the module map for all frameworks associated with the pod.
61+
var moduleMapContents: String
62+
63+
init(version: String, dependencies: [String], installedLocation: URL) {
64+
self.version = version
65+
self.dependencies = dependencies
66+
self.installedLocation = installedLocation
67+
moduleMapContents = ""
68+
69+
// Get all the frameworks contained in this directory.
70+
var binaryFrameworks: [URL] = []
71+
if installedLocation != LaunchArgs.shared.localPodspecPath {
72+
do {
73+
binaryFrameworks = try FileManager.default.recursivelySearch(for: .frameworks,
74+
in: installedLocation)
75+
} catch {
76+
fatalError("Cannot search for .framework files in Pods directory " +
77+
"\(installedLocation): \(error)")
78+
}
79+
}
80+
self.binaryFrameworks = binaryFrameworks
81+
isSourcePod = binaryFrameworks == []
82+
}
5283
}
5384

5485
/// Executes the `pod cache clean --all` command to remove any cached CocoaPods.
@@ -314,9 +345,11 @@ enum CocoaPodUtils {
314345
""" // Explicit newline above to ensure it's included in the String.
315346
}
316347

348+
if LaunchArgs.shared.dynamic {
349+
podfile += " use_frameworks!\n"
350+
}
317351
// Include the minimum iOS version.
318352
podfile += """
319-
use_frameworks!
320353
platform :ios, '\(LaunchArgs.shared.minimumIOSVersion)'
321354
target 'FrameworkMaker' do\n
322355
"""

0 commit comments

Comments
 (0)