-
Notifications
You must be signed in to change notification settings - Fork 5.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Getting Derived Data path value from Xcode preferences #12232
Getting Derived Data path value from Xcode preferences #12232
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Few small nit picks 🙃
end | ||
|
||
def self.available_options | ||
[ | ||
FastlaneCore::ConfigItem.new(key: :derived_data_path, | ||
env_name: "DERIVED_DATA_PATH", | ||
description: "Custom path for derivedData", | ||
default_value: "~/Library/Developer/Xcode/DerivedData") | ||
default_value: xcode_preferences['IDECustomDerivedDataLocation'] || "~/Library/Developer/Xcode/DerivedData") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add default_value_dynamic: true
into the initializer of this ConfigItem
? Its a way to note that the default value is calculated dynamically
if File.exist?(file) | ||
return CFPropertyList.native_types(CFPropertyList::List.new(file: file).value) | ||
end | ||
return '' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you return nil
here instead of an empty string?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, but it creates some complexity that I would like to avoid. I pushed the changes, let me know if you prefer return an empty string or nil
.
def self.xcode_preferences | ||
file = File.expand_path("~/Library/Preferences/com.apple.dt.Xcode.plist") | ||
if File.exist?(file) | ||
return CFPropertyList.native_types(CFPropertyList::List.new(file: file).value) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we also check to make sure that CFPropertyList::List.new(file: file).value
exists before calling CFPropertyList.native_types
?
xcode_preferences['IDECustomDerivedDataLocation'] | ||
rescue | ||
nil | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One last thing 🙃 Can we change this begin/rescue to...
path = xcode_preferences ? xcode_preferences['IDECustomDerivedDataLocation'] : nil
path ||= "~/Library/Developer/Xcode/DerivedData"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ofc 🥇
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for making those changes! Tried this out and this worked 💯 Happy fastlaning 🚀
Hey @bguidolim 👋 Thank you for your contribution to fastlane and congrats on getting this pull request merged 🎉 Please let us know if this change requires an immediate release by adding a comment here 👍 |
Congratulations! 🎉 This was released as part of fastlane 2.90.0 🚀 |
Checklist
bundle exec rspec
from the root directory to see all new and existing tests passbundle exec rubocop -a
to ensure the code style is validMotivation and Context
This PR fix #11951
Description
Changed action to get value from Xcode preferences if exists, if not uses default value.