Giter Club home page Giter Club logo

xcode-ast-dump's Introduction

xcode-ast-dump

This is a simple script for dumping the Swift AST from within Xcode. Read more about how and why this works here.

Usage

In Xcode:

  1. In the build settings for the target that you're interested in dumping the AST for, set the SWIFT_EXEC user defined build setting to the path of ast.py.
  2. Add AST_DUMP_FILE="$(SRCROOT)/$(TARGET_NAME).ast" to Preprocessor Macros(GCC_PREPROCESSOR_DEFINITIONS) setting. You can put any path you want. This path will be used for saving build log information with ast tree dump
  3. Build the target
  4. Check output file, you set in AST_DUMP_FILE setting.

In a shell:

  1. Build your target normally
  2. Go to the Report Navigator
  3. Find the "Compile Swift Sources" step from your build (if it was an incremental build you may have to clean your project first)
  4. Copy the arguments that were passed to swiftc
  5. Escape any special characters such as & (Xcode escapes spaces but not special shell characters. In order to pass them to this script you'll have to escape them yourself)
  6. Run ./ast.py ARGUMENTS > output.ast 2>&1

Notes

  • For larger projects this will take a very long time to run and may cause Xcode to hang, if this happens it might be easier to run from a shell
  • If you integrate the script in Xcode, the build will fail but the AST output will still be in the build log
  • The larger the project, the larger the output, you may end up opening a very large file
  • This script calls swiftc based on the environment variables from Xcode, or the first one that's found in your $PATH. This may not be what you expect. Set the AST_SWIFTC environment variable if you would like to change this
  • This has only been tested with a small number of projects, please file any issues you find

xcode-ast-dump's People

Contributors

keith avatar paultaykalo avatar

Watchers

 avatar James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.