@@ -171,10 +171,14 @@ public enum CocoaPodUtils {
171
171
let podsDir = projectDir. appendingPathComponent ( " Pods " )
172
172
var installedPods : [ String : PodInfo ] = [ : ]
173
173
for (podName, version) in pods {
174
- let podDir = podsDir. appendingPathComponent ( podName)
175
- guard FileManager . default. directoryExists ( at: podDir) else {
176
- fatalError ( " Directory for \( podName) doesn't exist at \( podDir) - failed while getting " +
177
- " information for installed Pods. " )
174
+ var podDir = podsDir. appendingPathComponent ( podName)
175
+ // Make sure that pod got installed if it's not coming from a local podspec.
176
+ if !FileManager. default. directoryExists ( at: podDir) {
177
+ guard let repoDir = LaunchArgs . shared. localPodspecPath else {
178
+ fatalError ( " Directory for \( podName) doesn't exist at \( podDir) - failed while getting " +
179
+ " information for installed Pods. " )
180
+ }
181
+ podDir = repoDir
178
182
}
179
183
let dependencies = [ String] ( deps [ podName] ?? [ ] )
180
184
let podInfo = PodInfo ( version: version, dependencies: dependencies, installedLocation: podDir)
@@ -304,12 +308,38 @@ public enum CocoaPodUtils {
304
308
target 'FrameworkMaker' do \n
305
309
"""
306
310
311
+ var versionsSpecified = false
312
+
307
313
// Loop through the subspecs passed in and use the actual Pod name.
308
314
for pod in pods {
309
- let version = pod. version == nil ? " " : " , ' \( pod. version!) ' "
310
- podfile += " pod ' \( pod. name) ' " + version + " \n "
315
+ podfile += " pod ' \( pod. name) ' "
316
+ // Check if we want to use a local version of the podspec.
317
+ if let localURL = LaunchArgs . shared. localPodspecPath,
318
+ FileManager . default. fileExists ( atPath: localURL. appendingPathComponent ( pod. name + " .podspec " ) . path) {
319
+ podfile += " , :path => ' \( localURL. path) ' "
320
+ } else if let podVersion = pod. version {
321
+ podfile += " , ' \( podVersion) ' "
322
+ }
323
+ if pod. version != nil {
324
+ // Don't add Google pods if versions were specified or we're doing a secondary install
325
+ // to create module maps.
326
+ versionsSpecified = true
327
+ }
328
+ podfile += " \n "
311
329
}
312
330
331
+ // If we're using local pods, explicitly add Google* podspecs if they exist and there are no
332
+ // explicit versions in the Podfile. Note there are versions for local podspecs if we're doing
333
+ // the secondary install for module map building.
334
+ if !versionsSpecified, let localURL = LaunchArgs . shared. localPodspecPath {
335
+ let podspecs = try ! FileManager . default. contentsOfDirectory ( atPath: localURL. path)
336
+ for podspec in podspecs {
337
+ if podspec. starts ( with: " Google " ) , podspec. hasSuffix ( " .podspec " ) {
338
+ let podName = podspec. replacingOccurrences ( of: " .podspec " , with: " " )
339
+ podfile += " pod ' \( podName) ', :path => ' \( localURL. path) / \( podspec) ' \n "
340
+ }
341
+ }
342
+ }
313
343
podfile += " end "
314
344
return podfile
315
345
}
0 commit comments