From 21320aaf672cca1be61add3ca1a4797fb57dc461 Mon Sep 17 00:00:00 2001 From: Dale Myers Date: Thu, 7 Nov 2024 09:42:30 +0000 Subject: [PATCH] Run preGenCommand before checking the cache 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. --- 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..d03dd3ac 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 scrips 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)