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

Clear default build settings #89

Closed
keith opened this issue Oct 16, 2017 · 15 comments
Closed

Clear default build settings #89

keith opened this issue Oct 16, 2017 · 15 comments

Comments

@keith
Copy link
Collaborator

keith commented Oct 16, 2017

It would be nice if there were a way to clear the default settings XcodeGen provides. This is useful if you define all your settings in xcconfig files, so when you generate the project, you don't want its default settings to shadow yours. I almost expected it to with this configuration:

name: Project
settings:
  base: []
targets:
  Project:
    type: application
    platform: iOS

But I understand these base settings are just additive to the project. In the meantime I might use xcodeproj to wipe these settings out after project generation.

@yonaskolb
Copy link
Owner

Interesting. This mirrors the thoughts in #77

@keith
Copy link
Collaborator Author

keith commented Oct 16, 2017

Ah yes, I think that kind of only half captures the problem though, since even if you're not overriding the setting, you may not want it to be set in the project. This happens for us a lot in our all Swift app, where we don't really want Objective-C build settings to be set, since future developers won't know if we actually need it, or if it was just set by default by Xcode

@yonaskolb
Copy link
Owner

What do you suggest as way to opt out of setting presets? There are presets for the project, debug and release configurations, each platform and each target

@keith
Copy link
Collaborator Author

keith commented Oct 19, 2017

I guess maybe a top level attribute for this? In theory it could also be per-target, but that seems like overkill?

@yonaskolb
Copy link
Owner

What about this?

options:
  clearBaseSettings: true

You can already clear debug and release settings by simply providing a different type other than debug or release

configs:
  Debug: none
  Release: none

@keith
Copy link
Collaborator Author

keith commented Oct 19, 2017

You can already clear debug and release settings by simply providing a different type other than debug or release

Oh interesting, is that all that is used for?

@yonaskolb
Copy link
Owner

Yep, that's all that does. It's documented in the Project spec

@yonaskolb
Copy link
Owner

Another option is to not apply the base settings if the config type is cleared.
From this:

buildSettings += SettingsPresetFile.base.getBuildSettings()
if let type = config.type {
    buildSettings += SettingsPresetFile.config(type).getBuildSettings()
}

to this:

if let type = config.type {
    buildSettings += SettingsPresetFile.base.getBuildSettings()
    buildSettings += SettingsPresetFile.config(type).getBuildSettings()
}

@pepicrft
Copy link

I'm more for the clearBaseSettings solution. I think it's more explicit and the attribute is at the level of the project, where it's getting applied. Modifying the project configuration based on a target attribute might be too implicit for the developer who wouldn't expect the base settings to be cleared. This could be solved by adding some documentation though.

@yonaskolb
Copy link
Owner

The configs aren’t a target level attribute, they live on the top level project. Also those debug and release settings actually get applied to the project, not the target

@pepicrft
Copy link

Cool! then I'd go with the solution that you proposed.

@yonaskolb
Copy link
Owner

@keith it's implemented here #100. Have a look and see if this suits your needs 👍

@yonaskolb
Copy link
Owner

There could still be another solution to clear all the presets including those in targets. Maybe an options.applySettingPresets which could be one of the following:

  • all (default)
  • targets (don't apply any project settings ie, base, debug or release)
  • none

What do you think?
Maybe if we had that #100 wouldn't be needed as it would be strange to set all here and none on the configs?

@yonaskolb
Copy link
Owner

@keith, I've added a followup PR #101 that allows you to fully control the setting presets. Setting this to none removes the need for the commit I noticed you have here:
lyft@3d2fe09

@keith
Copy link
Collaborator Author

keith commented Oct 22, 2017

Awesome!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants