From 126339f1c8ad9a78a4270f243ad7840cf626aa11 Mon Sep 17 00:00:00 2001 From: Dale <1363082+dalemyers@users.noreply.github.com> Date: Mon, 2 Dec 2024 21:44:05 +0000 Subject: [PATCH] Run preGenCommand before checking the cache (#1519) The preGenCommand may generate files, change paths, etc. If we run this after checking the cache, it never gets the chance to run if the cache hasn't changed. Running it before checking the cache lets us make these changes and _then_ we can check the cache to see if we need to regenerate or not. Co-authored-by: Dale Myers --- Sources/XcodeGenCLI/Commands/GenerateCommand.swift | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Sources/XcodeGenCLI/Commands/GenerateCommand.swift b/Sources/XcodeGenCLI/Commands/GenerateCommand.swift index 8ae7ba86..8b7e27b5 100644 --- a/Sources/XcodeGenCLI/Commands/GenerateCommand.swift +++ b/Sources/XcodeGenCLI/Commands/GenerateCommand.swift @@ -39,6 +39,11 @@ class GenerateCommand: ProjectCommand { let projectPath = projectDirectory + "\(project.name).xcodeproj" + // run pre gen command before we use the cache as the scripts may change it + if let command = project.options.preGenCommand { + try Task.run(bash: command, directory: projectDirectory.absolute().string) + } + let cacheFilePath = self.cacheFilePath ?? Path("~/.xcodegen/cache/\(projectSpecPath.absolute().string.md5)").absolute() var cacheFile: CacheFile? @@ -69,11 +74,6 @@ class GenerateCommand: ProjectCommand { } } - // run pre gen command - if let command = project.options.preGenCommand { - try Task.run(bash: command, directory: projectDirectory.absolute().string) - } - // validate project do { try project.validateMinimumXcodeGenVersion(version)