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

AppCode 3 Xcodepath from settings #63

Merged
merged 5 commits into from
Nov 10, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion Support/AppCode/Dyci/Dyci.iml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,20 @@
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="jdk" jdkName="1.6" jdkType="JavaSDK" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="module-library">
<library>
<CLASSES>
<root url="file:///Applications/AppCode.app/Contents/lib" />
</CLASSES>
<JAVADOC />
<SOURCES>
<root url="file:///Applications/AppCode.app/Contents/lib" />
</SOURCES>
<jarDirectory url="file:///Applications/AppCode.app/Contents/lib" recursive="false" />
</library>
</orderEntry>
</component>
</module>

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