-
Notifications
You must be signed in to change notification settings - Fork 105
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
Adding support to creating custom schemes #225
Conversation
Hey, sorry, I didn't forget about this. Promise. I'm going to look over these ASAP. |
No problem! |
@gfontenot Have you gotten a chance to look at this? |
Would be awesome of this could get integrated anytime soon! 👍🏻 |
Thanks for implementing this @marcelofabri ! I have a few things I'd like to see addressed if you're up for it. First, Follow the thoughtbot Ruby style guide. I plan on enabling houndci.com soon once I have time to update the config, but until then we have to manually confirm we're following it. A few violations I see here are:
Second, that large nested Lastly, Docs and tests. You said this still needs them, are you waiting for us to approve the implementation before doing those tasks? What do you think? |
Thanks for the feedback, @jakecraige. About the violations:
About the About docs and tests: I'd like an OK on the feature itself before spending too much time on them. Also, is there a easy way to edit the I also would like some help to start the tests. I haven't found any tests on |
@@ -20,7 +20,8 @@ class ProjectConfiguration | |||
:xcode_command, | |||
:extra_config, | |||
:extra_test_config, | |||
:deployment_target | |||
:deployment_target, | |||
:schemes |
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.
This is where the trailing comma is needed
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.
But isn't the rule only for lists? Is this any different than https://github.com/thoughtbot/guides/blob/master/style/ruby/sample.rb#L19? (I'm not a Ruby developer, so forgive me if I'm writing something dumb)
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.
Yeah, what you linked to is a method definition. It's actually a syntax error there so we can't do it. The example that shows this case is here
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.
Actually, I get an error if I try to add a comma:
liftoff/lib/liftoff/project_configuration.rb:26: syntax error, unexpected tSYMBEG, expecting keyword_do or '{' or '(' (SyntaxError)
attr_writer :author,
^
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.
Whoops! I didn't see this was an attr_accessor list here. You're correct!
For 2, it's something we'd like to change going forward so we can retro-actively change them over when we touch that part of the code. For this one, use double-quotes in your new code since you didn't alter any existing code that uses single ones. That make sense? I'm not familiar with editing the For the tests, You can look to the project_configuration_spec.rb for an example of how to set up the base spec. From there I see 2 possibilities. the latter being my preferred approach:
What do you think? |
@jakecraige I think I covered all the style violations and have dealt with the nested About the tests, I like the 2nd approach. However, to fully testing, I'd still need a project for creating a scheme, wouldn't I? |
My bad on the trailing comma stuff. I didn't notice that was an It's looking much better now. Great work! With the new class/testing, you'll probably need to stub out the Xcode project so that we don't need an actual one to work with. The new class would probably take the project as a param in the initializer do you could pass it a fake one and make assertions off of that. |
xcode_project.generate_scheme | ||
|
||
if @config.schemes | ||
@config.schemes.each do |scheme_config| |
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.
What are your thoughts on making a method called schemes
that returns this config or an empty array to remove this conditional?
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.
👍
The Editing them shouldn't be too difficult, but it's an intimidating format. Try looking at some similar examples (like the |
@gfontenot: thanks! @jakecraige: I've extracted the changes to another class. Could you please take a look? I'll try to get the tests and docs figured out later today. |
@@ -0,0 +1,50 @@ | |||
module Liftoff | |||
class SchemeBuilder | |||
|
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.
Remove this extra newline?
Thanks for the great work! |
This feature looks awesome. Was thinking about working on this but glad someone beat me to it! @marcelofabri - does this have the ability to define custom configuration (xcconfig) files with the custom schemes baked in? |
@borwahs currently, no. My idea was to use this with #224, so you could have something like this in your build_configurations:
- name: Debug-CI
type: debug
- name: Release-CI
type: release
extra_config:
Debug-CI:
GCC_PREPROCESSOR_DEFINITIONS:
- $(inherited)
- APP_CI=1
Release-CI:
GCC_PREPROCESSOR_DEFINITIONS:
- $(inherited)
- APP_CI=1
schemes:
- name: <%= project_name %>-CI
actions:
test:
build_configuration: Debug-CI
launch:
build_configuration: Debug-CI
profile:
build_configuration: Release-CI
archive:
build_configuration: Release-CI
analyze:
build_configuration: Release-CI |
@marcelofabri - that looks awesome. I'll be looking forward to it when it gets merged in! |
@jakecraige Sorry for the delay, but I was able to play with this only today. I have done 2 tests around this, but I wasn't able to test an important part (the setup of Do you have any ideas? |
I was able to create a test by using a plain I also updated Unless I missed something, I think this is ready to merge! 😄 |
Thanks! I'm traveling this weekend and beginning a new project next week so
|
end | ||
|
||
def create_schemes | ||
@xcode_project.generate_default_scheme |
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.
What do you think about making @xcode_project
and @config
private attr_readers
and using that throughout this class to access them?
We have an open PR for our guides that recommends this that looks like it's probably going to be merged. thoughtbot/guides#331
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.
Should I keep using @xcode_project
and @config
Inside initialize
?
@jakecraige Thanks for taking a look at this! I've just pushed 6ad5994, which fixes most of the comments you've made. |
(test, launch, profile, archive or analyze). In order to create additional | ||
schemes, you should add the | ||
.Ic schemes | ||
key in your |
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.
Is this missing a word after "your"?
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.
No, because .Nm
in the next line will be replaced by liftoffrc
Code wise, this is looking great and I think it's ready to go! Thanks for being patient and working through this with me @marcelofabri Could you squash the commits down? |
@jakecraige Thanks for the help and all suggestions. It's definitely better now! |
Merged in 4c99412 Thanks again. |
This adds basic support to creation of custom schemes on
.liftoffrc
:actions
can betest
,launch
,profile
,archive
oranalyze
and the only supported customization so far isbuild_configuration
, but this can be extended to other options (such as "Launch due to background fetch").I've done specifically for
build_configuration
but maybe we should support automatically (i.e. without having references inliftoff
) all supported options in a scheme.As my other PR, this still needs tests and documentation.
I'm also not particularly happy with the chain of
ifs
increate_schemes
, but I couldn't figure a better way in Ruby (geez, I miss Objective-C nil behavior).