Skip to content

Commit fabaa8b

Browse files
authored
Clean the pod cache before starting. (#2554)
This prevents errors from occurring, and will also ensure that the most recent version will be included if it was rebuilt.
1 parent 8ed8504 commit fabaa8b

File tree

3 files changed

+21
-3
lines changed

3 files changed

+21
-3
lines changed

ZipBuilder/Sources/ZipBuilder/CocoaPodUtils.swift

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,20 @@ public enum CocoaPodUtils {
5050
}
5151
}
5252

53-
/// Execute the `pod cache list` command to get the Pods currently cached on your machine.
53+
/// Executes the `pod cache clean --all` command to remove any cached CocoaPods.
54+
public static func cleanPodCache() {
55+
let result = Shell.executeCommandFromScript("pod cache clean --all", outputToConsole: false)
56+
switch result {
57+
case let .error(code):
58+
fatalError("Could not clean the pod cache, the command exited with \(code). Try running the" +
59+
"command in Terminal to see what's wrong.")
60+
case .success:
61+
// No need to do anything else, continue on.
62+
print("Successfully cleaned pod cache.")
63+
return
64+
}
65+
}
66+
5467
/// Executes the `pod cache list` command to get the Pods curerntly cached on your machine.
5568
///
5669
/// - Parameter dir: The directory containing all installed pods.

ZipBuilder/Sources/ZipBuilder/ShellUtils.swift

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,10 @@ extension Shell {
5454
scriptPath = tempScriptsDir.appendingPathComponent("wrapper.sh")
5555

5656
// Write the temporary script contents to the script's path. CocoaPods complains when LANG
57-
// isn't set in the environment, so explicitly set it here.
57+
// isn't set in the environment, so explicitly set it here. The `/usr/local/git/current/bin`
58+
// is to allow the `sso` protocol if it's there.
5859
let contents = """
59-
export PATH="/usr/local/bin:$PATH"
60+
export PATH="/usr/local/bin:/usr/local/git/current/bin:$PATH"
6061
export LANG="en_US.UTF-8"
6162
source ~/.bash_profile
6263
\(command)

ZipBuilder/Sources/ZipBuilder/ZipBuilder.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,10 @@ struct ZipBuilder {
182182
// builds to just install a subset: `[.core, .analytics, .storage, .firestore]` for example.
183183
let subspecsToInstall = Subspec.allCases
184184

185+
// Remove CocoaPods cache so the build gets updates after a version is rebuilt during the
186+
// release process.
187+
CocoaPodUtils.cleanPodCache()
188+
185189
// We need to install all the subpsecs in order to get every single framework that we'll need
186190
// for the zip file. We can't install each one individually since some pods depend on different
187191
// subspecs from the same pod (ex: GoogleUtilities, GoogleToolboxForMac, etc). All of the code

0 commit comments

Comments
 (0)