Skip to content

Instantly share code, notes, and snippets.

@grav
Last active August 29, 2015 14:08
Show Gist options
  • Save grav/d8f44d1a2ad527e764dc to your computer and use it in GitHub Desktop.
Save grav/d8f44d1a2ad527e764dc to your computer and use it in GitHub Desktop.
Get Xcode path from AppCode settings
import javax.xml.xpath.*;
import org.xml.sax.InputSource;
public class XcodePath {
public static void main(String[] args){
String appcodeOptions = System.getProperty("user.home") + "/Library/Preferences/appCode30/options/other.xml";
String xpathExpression = "/application/component[@name='XcodeSettings']/option[@name='selectedXcode']/@value";
XPathFactory xpathFactory = XPathFactory.newInstance();
XPath xpath = xpathFactory.newXPath();
try{
XPathExpression expr = xpath.compile(xpathExpression);
InputSource inputSource = new InputSource(new java.io.FileReader(appcodeOptions));
String result = expr.evaluate(inputSource);
System.out.println(result);
} catch(Exception e){
System.out.println(e);
}
}
}
@grav
Copy link
Author

grav commented Oct 23, 2014

$ javac XcodePath.java  && java XcodePath
/Applications/Xcode511.app/Contents/Developer

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