@@ -57,13 +57,17 @@ enum CocoaPodUtils {
57
57
/// Binary frameworks in this pod.
58
58
let binaryFrameworks : [ URL ]
59
59
60
+ /// Subspecs installed for this pod.
61
+ let subspecs : Set < String >
62
+
60
63
/// The contents of the module map for all frameworks associated with the pod.
61
64
var moduleMapContents : String
62
65
63
- init ( version: String , dependencies: [ String ] , installedLocation: URL ) {
66
+ init ( version: String , dependencies: [ String ] , installedLocation: URL , subspecs : Set < String > ) {
64
67
self . version = version
65
68
self . dependencies = dependencies
66
69
self . installedLocation = installedLocation
70
+ self . subspecs = subspecs
67
71
moduleMapContents = " "
68
72
69
73
// Get all the frameworks contained in this directory.
@@ -186,30 +190,48 @@ enum CocoaPodUtils {
186
190
break
187
191
}
188
192
if let ( pod, version) = detectVersion ( fromLine: line) {
189
- let corePod = pod. components ( separatedBy: " / " ) [ 0 ]
190
- currentPod = corePod. trimmingCharacters ( in: quotes)
193
+ currentPod = pod. trimmingCharacters ( in: quotes)
191
194
pods [ currentPod!] = version
192
195
} else if let currentPod = currentPod {
193
196
let matches = depRegex. matches ( in: line, range: NSRange ( location: 0 , length: line. utf8. count) )
194
197
// Match something like - GTMSessionFetcher/Full (= 1.3.0)
195
198
if let match = matches. first {
196
199
let depLine = ( line as NSString ) . substring ( with: match. range ( at: 0 ) ) as String
197
200
// Split spaces and subspecs.
198
- let dep = depLine. components ( separatedBy: [ " " , " / " ] ) [ 2 ] . trimmingCharacters ( in: quotes)
201
+ let dep = depLine. components ( separatedBy: [ " " ] ) [ 2 ] . trimmingCharacters ( in: quotes)
199
202
if dep != currentPod {
200
- if deps [ currentPod] == nil {
201
- deps [ currentPod] = Set ( )
202
- }
203
- deps [ currentPod] ? . insert ( dep)
203
+ deps [ currentPod, default: Set ( ) ] . insert ( dep)
204
204
}
205
205
}
206
206
}
207
207
}
208
+ // Organize the subspecs
209
+ var versions : [ String : String ] = [ : ]
210
+ var subspecs : [ String : Set < String > ] = [ : ]
211
+
212
+ for (podName, version) in pods {
213
+ let subspecArray = podName. components ( separatedBy: " / " )
214
+ if subspecArray. count > 2 {
215
+ fatalError ( " Multi-layered subspecs are not supported - \( podName) " )
216
+ } else if subspecArray. count == 1 {
217
+ versions [ podName] = version
218
+ } else {
219
+ if let previousVersion = versions [ podName] , version != previousVersion {
220
+ fatalError ( " Different installed versions for \( podName) . " +
221
+ " \( version) versus \( previousVersion) " )
222
+ } else {
223
+ let basePodName = subspecArray [ 0 ]
224
+ versions [ basePodName] = version
225
+ subspecs [ basePodName, default: Set ( ) ] . insert ( subspecArray [ 1 ] )
226
+ deps [ basePodName] = deps [ basePodName, default: Set ( ) ] . union ( deps [ podName] ?? Set ( ) )
227
+ }
228
+ }
229
+ }
208
230
209
231
// Generate an InstalledPod for each Pod found.
210
232
let podsDir = projectDir. appendingPathComponent ( " Pods " )
211
233
var installedPods : [ String : PodInfo ] = [ : ]
212
- for (podName, version) in pods {
234
+ for (podName, version) in versions {
213
235
var podDir = podsDir. appendingPathComponent ( podName)
214
236
// Make sure that pod got installed if it's not coming from a local podspec.
215
237
if !FileManager. default. directoryExists ( at: podDir) {
@@ -220,7 +242,8 @@ enum CocoaPodUtils {
220
242
podDir = repoDir
221
243
}
222
244
let dependencies = [ String] ( deps [ podName] ?? [ ] )
223
- let podInfo = PodInfo ( version: version, dependencies: dependencies, installedLocation: podDir)
245
+ let podInfo = PodInfo ( version: version, dependencies: dependencies, installedLocation: podDir,
246
+ subspecs: subspecs [ podName] ?? Set ( ) )
224
247
installedPods [ podName] = podInfo
225
248
}
226
249
return installedPods
0 commit comments