Skip to content
This repository was archived by the owner on Jul 31, 2025. It is now read-only.

Commit 6e5b2c0

Browse files
authored
Add CLI arguments and update spec (#2)
* Add CLI arguments and update spec * Implement support for as-yet unreleased new xcodegen option --project-root will be available in the next xcodegen release
1 parent ba8584d commit 6e5b2c0

File tree

3 files changed

+62
-1
lines changed

3 files changed

+62
-1
lines changed

README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,11 @@ More Information on [_XcodeGen_](https://github.com/yonaskolb/XcodeGen)
2121
```ruby
2222
xcodegen(
2323
spec: "PATH/project.yml",
24-
project: "PATH/Project.xcodeproj"
24+
project: "PATH/Project.xcodeproj",
25+
quiet: true,
26+
use_cache: true,
27+
cache_path: "~/.xcodegen/cache/MyProject",
28+
project_root: "../"
2529
)
2630
```
2731

lib/fastlane/plugin/xcodegen/actions/xcodegen_action.rb

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ def self.run(params)
1717
cmd = ["xcodegen"]
1818
cmd << "--spec #{params[:spec]}" if params[:spec]
1919
cmd << "--project #{params[:project]}" if params[:project]
20+
cmd << "--quiet" if params[:quiet]
21+
cmd << "--use-cache" if params[:use_cache]
22+
cmd << "--cache-path #{params[:cache_path]}" if params[:cache_path]
23+
cmd << "--project-root #{params[:project_root]}" if params[:project_root]
2024

2125
Actions.sh(cmd.join(' '))
2226
end
@@ -45,6 +49,24 @@ def self.available_options
4549
FastlaneCore::ConfigItem.new(key: :project,
4650
env_name: "XCODEGEN_PROJECT",
4751
description: "The path to the folder where the project should be generated",
52+
optional: true),
53+
FastlaneCore::ConfigItem.new(key: :quiet,
54+
env_name: "XCODEGEN_QUIET",
55+
description: "Whether to suppress informational and success messages",
56+
optional: true,
57+
is_string: false),
58+
FastlaneCore::ConfigItem.new(key: :use_cache,
59+
env_name: "XCODEGEN_USE_CACHE",
60+
description: "Used to prevent unnecessarily generating the project",
61+
optional: true,
62+
is_string: false),
63+
FastlaneCore::ConfigItem.new(key: :cache_path,
64+
env_name: "XCODEGEN_CACHE_PATH",
65+
description: "A custom path to use for your cache file",
66+
optional: true),
67+
FastlaneCore::ConfigItem.new(key: :project_root,
68+
env_name: "XCODEGEN_PROJECT_ROOT",
69+
description: "The path to the project root directory",
4870
optional: true)
4971
]
5072
end

spec/xcodegen_action_spec.rb

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,41 @@
2222

2323
expect(result).to eq("xcodegen --project /tmp/Project.xcodeproj")
2424
end
25+
it "sets the quiet param" do
26+
result = Fastlane::FastFile.new.parse("lane :test do
27+
xcodegen(quiet: true)
28+
end").runner.execute(:test)
29+
30+
expect(result).to eq("xcodegen --quiet")
31+
end
32+
it "sets the use-cache param" do
33+
result = Fastlane::FastFile.new.parse("lane :test do
34+
xcodegen(use_cache: true)
35+
end").runner.execute(:test)
36+
37+
expect(result).to eq("xcodegen --use-cache")
38+
end
39+
it "sets the cache-path param" do
40+
result = Fastlane::FastFile.new.parse("lane :test do
41+
xcodegen(cache_path: '~/.xcodegen/cache/MyProject')
42+
end").runner.execute(:test)
43+
44+
expect(result).to eq("xcodegen --cache-path ~/.xcodegen/cache/MyProject")
45+
end
46+
it "sets the project-root param" do
47+
result = Fastlane::FastFile.new.parse("lane :test do
48+
xcodegen(project_root: '../')
49+
end").runner.execute(:test)
50+
51+
expect(result).to eq("xcodegen --project-root ../")
52+
end
53+
it "ignores the quiet and use-cache params if false" do
54+
result = Fastlane::FastFile.new.parse("lane :test do
55+
xcodegen(quiet: false, use_cache: false)
56+
end").runner.execute(:test)
57+
58+
expect(result).to eq("xcodegen")
59+
end
2560
end
2661
end
2762
end

0 commit comments

Comments
 (0)