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

Ability to set run options/diagnostics in schemes #325

Open
erikkerber opened this issue Jun 28, 2018 · 7 comments · May be fixed by #880
Open

Ability to set run options/diagnostics in schemes #325

erikkerber opened this issue Jun 28, 2018 · 7 comments · May be fixed by #880

Comments

@erikkerber
Copy link

erikkerber commented Jun 28, 2018

If this is something currently supported, let me know and I can make it more clear in the docs.

The "run" options in a scheme have several options that are unable to be set via XcodeGen. Namely those in the "Options" and "Diagnostics" tabs:

2018-06-28 at 2 07 pm

2018-06-28 at 2 07 pm

Setting one of these options results in fairly irregular output in the resulting xcscheme file. This example shows what is generated for enabling the thread sanitizer and zombies:

2018-06-28 at 2 04 pm

It would be great to have first-class support for these fields in YAML. i.e.:

run:
  enableThreadSanitizer: true
  commandLineArguments:
    "-set-store": false
   ... etc
@hydra1983
Copy link

Any progress?

@yonaskolb
Copy link
Owner

No progress here. I just replied to another issue requesting scheme changes #538

As more and more of these small options come up I'm beginning to think that maybe supporting them all is untenable. Schemes have a lot of options around them and are quite fast moving in terms of changes within Xcode. We might even have to start thinking about dropping off support for complex schemes, and letting people just create them in Xcode and checking them in. If XcodeGen didn't remove all shared schemes on generation, would this solve your use case, or do you need them to be totally dynamic definable in the project spec?
Adding support for user schemes that aren't deleted has been discussed here as well #515

Any thoughts around this? Would schemes created in Xcode suffice?

@johndpope
Copy link
Contributor

johndpope commented Mar 25, 2019

I'd say asking for help from community would make life easier for yourself.
Apple should even contribute. Otherwise - I guess sponsorships could propel things - or some documentation to help users upgrade /debug this program would get things over the line. Seems to be a lot of interest - maybe tag this ticket as 'help wanted'. Some companies have staff with hours on their hands - some step by steps on how to add a new attribute might go a long way to fostering new pull requests with enhancements. Some of the better PRs - consider adding authors as contributors to project.

@yonaskolb
Copy link
Owner

We do have lots of contributors and quite a few collaborators in the project, as well as CONTRIBUTING doc (this could be fleshed out much more though)
Adding some more specific documentation about how to add certain properties would definitely be good 👍

The issue is one of general maintainability and what XcodeGen should focus on. PR's that add properties like this are definitely welcome, but that doesn't mean it will be maintained in the future to the same degree as the core pbxproj generation, unless we get funding as you say.

@muehlemann
Copy link

Referencing my question from Friday: #596. Will close it because this issue covers the question in broader detail.

Have there been any updates on this?

@yonaskolb
Copy link
Owner

No updates here other than a PR for disableMainThreadChecker #601

I'm thinking the best short term option is to add an option overrideSchemes: false (either in the spec, or a command line option? 🤔) that won't create schemes if they already exist. This lets someone edit the shared schemes within Xcode and even check them in if desired

@Kylmakalle
Copy link

WORKAROUND: Easiest way for me to patch that is python script

project.yml

postGenCommand: >-
    schemes="MyScheme MySchemeUI";  
    echo "Manually patching '${schemes}' to enable Thread Sanitizer.";  
    for scheme in $schemes ;
    do
      FILE="MyProject.xcodeproj/xcshareddata/xcschemes/${scheme}.xcscheme";
      echo "Patching ${FILE}...";
      python3 patch_thread_sanitizer.py "${FILE}";
    done

patch_thread_sanitizer.py

import xml.etree.ElementTree as ET
import sys
import argparse

def patch_thread_sanitizer(file_path: str):
    """
        Patch Scheme and set Thread Sanitizer=YES
    """
    tree = ET.parse(file_path)
    root = tree.getroot()

    found_launch_action = False

    for child in root:
        if child.tag == 'LaunchAction':
            found_launch_action = True
            child.attrib['enableThreadSanitizer'] = 'YES'
    
    if found_launch_action:
        tree.write(file_path)
    else:
        sys.exit(f"Unable to locate LaunchAction in {file_path}. Aborting patch!")


if __name__ == '__main__':
    parser = argparse.ArgumentParser()
    parser.add_argument("scheme_path", help="Path to xcscheme file")
    
    args = parser.parse_args()
    patch_thread_sanitizer(args.scheme_path)

Inspired by TestPlan patch #846 (comment)

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

Successfully merging a pull request may close this issue.

6 participants