简体   繁体   中英

Xcode build parse javascript

In my apps I use A UIWebView to run bundled Javascript files. It is a cumbersome development cycle to wait until there's a parse error at runtime.

During an XCode build how can I parse Javascript files?

If you want to parse Javascript files as part of an Xcode build use JSL ( http://www.javascriptlint.com/ ) via a runscript Build Phase:

find . -name "*.js" -exec jsl -process {} \; | sed 's/lint //' | sed 
's/SyntaxError/error/' | sed 's/\.js(\([0-9]*\))/.js:\1:0/' 1>&2

This reformats the output so that Xcode registers the warnings and errors in it's Issue Navigator and will link to the exact line in the code.

I tried a number of JS parsers but JSL had the right balance of capability and output compatibility to be be munged for Xcode logs.

(I've posed and answered my own question here as I couldn't find a similar enough question and answer, so solved it myself and thought I should share).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM