Skip to content
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

Merged
merged 5 commits into from
Apr 5, 2018
Merged

Getting Derived Data path value from Xcode preferences #12232

merged 5 commits into from
Apr 5, 2018

Conversation

bguidolim
Copy link
Contributor

Checklist

  • I've run bundle exec rspec from the root directory to see all new and existing tests pass
  • I've followed the fastlane code style and run bundle exec rubocop -a to ensure the code style is valid
  • I've read the Contribution Guidelines
  • I've updated the documentation if necessary.

Motivation and Context

This PR fix #11951

Description

Changed action to get value from Xcode preferences if exists, if not uses default value.

@bguidolim bguidolim changed the title Getting default value from Xcode preferences Getting Derived Data path value from Xcode preferences Apr 4, 2018
Copy link
Member

@joshdholtz joshdholtz left a 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")
Copy link
Member

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 ''
Copy link
Member

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?

Copy link
Contributor Author

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)
Copy link
Member

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
Copy link
Member

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"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ofc 🥇

Copy link
Member

@joshdholtz joshdholtz left a 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 🚀

@joshdholtz joshdholtz merged commit 8045b09 into fastlane:master Apr 5, 2018
@bguidolim bguidolim deleted the feature-clear_derived_data branch April 5, 2018 13:02
@fastlane-bot
Copy link

Hey @bguidolim 👋

Thank you for your contribution to fastlane and congrats on getting this pull request merged 🎉
The code change now lives in the master branch, however it wasn't released to RubyGems yet.
We usually ship about once a week, and your PR will be included in the next one.

Please let us know if this change requires an immediate release by adding a comment here 👍
We'll notify you once we shipped a new release with your changes 🚀

@fastlane-bot
Copy link

Congratulations! 🎉 This was released as part of fastlane 2.90.0 🚀

@fastlane fastlane locked and limited conversation to collaborators Jun 10, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[enhancement] Read path to derived data folder from xcode settings in clear_derived_data action
4 participants