Skip to content
This repository has been archived by the owner on Oct 4, 2019. It is now read-only.

Commit

Permalink
Merge pull request #64 from DyCI/feature/appcode3-xcodepath
Browse files Browse the repository at this point in the history
Detect Xcode version from AppCode
  • Loading branch information
PaulTaykalo committed Nov 10, 2014
2 parents 151a431 + 66cff3e commit d47c4e6
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Support/AppCode/Dyci/Dyci.iml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="jdk" jdkName="IDEA IC-135.1230" jdkType="IDEA JDK" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>
Expand Down
Binary file modified Support/AppCode/Dyci/Dyci.jar
Binary file not shown.
5 changes: 4 additions & 1 deletion Support/AppCode/Dyci/META-INF/plugin.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<idea-plugin version="2">
<id>com.stanfy.dyci</id>
<name>DYCI - Dynamic code injection Tool</name>
<version>1.1</version>
<version>1.2</version>
<vendor email="[email protected]" url="http://www.yourcompany.com">YourCompany</vendor>

<description>
Expand All @@ -15,6 +15,9 @@

<change-notes>
<![CDATA[
Version 1.2
Detect selected Xcode version from AppCode settings
Version 1.1
Latest AppCode support.
]]>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,13 @@

import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;

import javax.xml.xpath.*;
import org.xml.sax.InputSource;

/**
* Created with IntelliJ IDEA.
* User: paultaykalo
Expand Down Expand Up @@ -49,6 +53,25 @@ public void actionPerformed(final AnActionEvent actionEvent) {


}

private String xcodePath(final AnActionEvent actionEvent,java.io.FileReader fileReader){
String xpathExpression = "/application/component[@name='XcodeSettings']/option[@name='selectedXcode']/@value";
String result = null;

XPathFactory xpathFactory = XPathFactory.newInstance();
XPath xpath = xpathFactory.newXPath();
try{
XPathExpression expr = xpath.compile(xpathExpression);
InputSource inputSource = new InputSource(fileReader);
result = expr.evaluate(inputSource);

} catch(Exception e){
LOG.error("Exception getting Xcode path: " + e.getMessage());
this.showMessageBubble(actionEvent, MessageType.ERROR, "Failed to run injection script");
}

return result;
}

private void injectFile(final AnActionEvent actionEvent, final String path) {

Expand All @@ -69,9 +92,21 @@ private void injectFile(final AnActionEvent actionEvent, final String path) {
this.showMessageBubble(actionEvent, MessageType.ERROR, "Cannot run injection. No Dyci scripts were found. Make sure, that you've ran install.sh");
return;
}

String appcodeOptionsFilename = System.getProperty("user.home") + "/Library/Preferences/appCode30/options/other.xml";

String[] commands;
try {
FileReader appcodeOptions = new FileReader(appcodeOptionsFilename);
String xcodePath = xcodePath(actionEvent, appcodeOptions);
commands = new String[] {dyciScriptLocation, path, xcodePath};
} catch(IOException e) {
// If the file cannot be found, it might not be a problem (user has appcode 2 or maybe the setting wasn't saved)
// We'll just leave it up to the dyci script to find Xcode.
commands = new String[] {dyciScriptLocation, path};
}

Runtime rt = Runtime.getRuntime();
String[] commands = {dyciScriptLocation, path};
try {
Process proc = rt.exec(commands);

Expand Down

0 comments on commit d47c4e6

Please sign in to comment.