@@ -36,13 +36,40 @@ enum CocoaPodUtils {
36
36
37
37
// MARK: - Public API
38
38
39
- struct VersionedPod : Decodable , CustomDebugStringConvertible {
39
+ // Codable is required because Decodable does not make CodingKeys available.
40
+ struct VersionedPod : Codable , CustomDebugStringConvertible {
40
41
/// Public name of the pod.
41
42
let name : String
42
43
43
44
/// The version of the requested pod.
44
45
let version : String ?
45
46
47
+ /// Platforms supported
48
+ let platforms : Set < String >
49
+
50
+ init ( name: String ,
51
+ version: String ? ,
52
+ platforms: Set < String > = [ " ios " , " macos " , " tvos " ] ) {
53
+ self . name = name
54
+ self . version = version
55
+ self . platforms = platforms
56
+ }
57
+
58
+ init ( from decoder: Decoder ) throws {
59
+ let container = try decoder. container ( keyedBy: CodingKeys . self)
60
+ name = try container. decode ( String . self, forKey: . name)
61
+ if let platforms = try container. decodeIfPresent ( Set< String> . self , forKey: . platforms) {
62
+ self . platforms = platforms
63
+ } else {
64
+ platforms = [ " ios " , " macos " , " tvos " ]
65
+ }
66
+ if let version = try container. decodeIfPresent ( String . self, forKey: . version) {
67
+ self . version = version
68
+ } else {
69
+ version = nil
70
+ }
71
+ }
72
+
46
73
/// The debug description as required by `CustomDebugStringConvertible`.
47
74
var debugDescription : String {
48
75
var desc = name
@@ -141,7 +168,7 @@ enum CocoaPodUtils {
141
168
/// - Parameters:
142
169
/// - pods: List of VersionedPods to install
143
170
/// - directory: Destination directory for the pods.
144
- /// - minimumIOSVersion: The minimum iOS version as a string. Ex. `10.0` .
171
+ /// - platform: Install for one platform at a time .
145
172
/// - customSpecRepos: Additional spec repos to check for installation.
146
173
/// - linkage: Specifies the linkage type. When `forcedStatic` is used, for the module map
147
174
/// construction, we want pod names not module names in the generated OTHER_LD_FLAGS
@@ -150,7 +177,7 @@ enum CocoaPodUtils {
150
177
@discardableResult
151
178
static func installPods( _ pods: [ VersionedPod ] ,
152
179
inDir directory: URL ,
153
- minimumIOSVersion : String ,
180
+ platform : Platform ,
154
181
customSpecRepos: [ URL ] ? ,
155
182
localPodspecPath: URL ? ,
156
183
linkage: LinkageType ) -> [ String : PodInfo ] {
@@ -171,7 +198,7 @@ enum CocoaPodUtils {
171
198
try writePodfile ( for: pods,
172
199
toDirectory: directory,
173
200
customSpecRepos: customSpecRepos,
174
- minimumIOSVersion : minimumIOSVersion ,
201
+ platform : platform ,
175
202
localPodspecPath: localPodspecPath,
176
203
linkage: linkage)
177
204
} catch let FileManager . FileError . directoryNotFound( path) {
@@ -300,7 +327,7 @@ enum CocoaPodUtils {
300
327
}
301
328
}
302
329
303
- static func podInstallPrepare( inProjectDir projectDir: URL , paths : ZipBuilder . FilesystemPaths ) {
330
+ static func podInstallPrepare( inProjectDir projectDir: URL , templateDir : URL ) {
304
331
do {
305
332
// Create the directory and all intermediate directories.
306
333
try FileManager . default. createDirectory ( at: projectDir, withIntermediateDirectories: true )
@@ -310,7 +337,7 @@ enum CocoaPodUtils {
310
337
}
311
338
// Copy the Xcode project needed in order to be able to install Pods there.
312
339
let templateFiles = Constants . ProjectPath. requiredFilesForBuilding. map {
313
- paths . templateDir. appendingPathComponent ( $0)
340
+ templateDir. appendingPathComponent ( $0)
314
341
}
315
342
for file in templateFiles {
316
343
// Each file should be copied to the temporary project directory with the same name.
@@ -414,7 +441,7 @@ enum CocoaPodUtils {
414
441
/// is not empty.
415
442
private static func generatePodfile( for pods: [ VersionedPod ] ,
416
443
customSpecsRepos: [ URL ] ? ,
417
- minimumIOSVersion : String ,
444
+ platform : Platform ,
418
445
localPodspecPath: URL ? ,
419
446
linkage: LinkageType ) -> String {
420
447
// Start assembling the Podfile.
@@ -440,9 +467,9 @@ enum CocoaPodUtils {
440
467
podfile += " use_frameworks! :linkage => :static \n "
441
468
}
442
469
443
- // Include the minimum iOS version.
470
+ // Include the platform and its minimum version.
444
471
podfile += """
445
- platform :ios , ' \( minimumIOSVersion ) '
472
+ platform : \( platform . name ) , ' \( platform . minimumVersion ) '
446
473
target 'FrameworkMaker' do \n
447
474
"""
448
475
@@ -504,7 +531,7 @@ enum CocoaPodUtils {
504
531
private static func writePodfile( for pods: [ VersionedPod ] ,
505
532
toDirectory directory: URL ,
506
533
customSpecRepos: [ URL ] ? ,
507
- minimumIOSVersion : String ,
534
+ platform : Platform ,
508
535
localPodspecPath: URL ? ,
509
536
linkage: LinkageType ) throws {
510
537
guard FileManager . default. directoryExists ( at: directory) else {
@@ -516,7 +543,7 @@ enum CocoaPodUtils {
516
543
let path = directory. appendingPathComponent ( " Podfile " )
517
544
let podfile = generatePodfile ( for: pods,
518
545
customSpecsRepos: customSpecRepos,
519
- minimumIOSVersion : minimumIOSVersion ,
546
+ platform : platform ,
520
547
localPodspecPath: localPodspecPath,
521
548
linkage: linkage)
522
549
do {
0 commit comments