diff --git a/java/src/processing/mode/java/JavaBuild.java b/java/src/processing/mode/java/JavaBuild.java index 57a2622c8..3e26af922 100644 --- a/java/src/processing/mode/java/JavaBuild.java +++ b/java/src/processing/mode/java/JavaBuild.java @@ -1186,7 +1186,7 @@ public class JavaBuild { pw.close(); // attempt to code sign if the Xcode tools appear to be installed - if (Platform.isMacOS() && new File("/usr/bin/codesign_allocate").exists()) { + if (Platform.isMacOS() && isXcodeInstalled()) { if (embedJava) { ProcessHelper.ffs("codesign", "--force", "--sign", "-", jdkPath); } @@ -1334,6 +1334,21 @@ public class JavaBuild { } + static Boolean xcodeInstalled; + + static protected boolean isXcodeInstalled() { + if (xcodeInstalled == null) { + Process p = PApplet.launch("xcode-select", "-p"); + int result = -1; + try { + result = p.waitFor(); + } catch (InterruptedException e) { } + xcodeInstalled = (result == 0); + } + return xcodeInstalled; + } + + /** * Run the launch4j build.xml file through ant to create the exe. * Most of this code was lifted from Android mode.