@@ -710,8 +710,14 @@ protected boolean exportApplication(File destFolder,
710710 File macosFolder = new File (contentsFolder , "MacOS" );
711711 macosFolder .mkdirs ();
712712 // This is an unsigned copy of the app binary (see build/build.xml)
713- Util .copyFile (mode .getContentFile ("application/mac-app-stub" ),
714- new File (contentsFolder , "MacOS/" + sketch .getMainName ()));
713+ File stubFile =
714+ mode .getContentFile ("application/stub-" + exportVariant );
715+ File execFile =
716+ new File (contentsFolder , "MacOS/" + sketch .getMainName ());
717+ Util .copyFile (stubFile , execFile );
718+ if (!execFile .setExecutable (true )) {
719+ throw new IOException ("Could not make " + execFile + " executable." );
720+ }
715721
716722 File pkgInfo = new File (contentsFolder , "PkgInfo" );
717723 PrintWriter writer = PApplet .createWriter (pkgInfo );
@@ -908,12 +914,17 @@ protected boolean exportApplication(File destFolder,
908914 pw .close ();
909915
910916 // attempt to code sign if the Xcode tools appear to be installed
911- if (Platform .isMacOS () && isXcodeInstalled ()) {
912- if (embedJava ) {
913- ProcessHelper .ffs ("codesign" , "--force" , "--sign" , "-" , jdkPath );
917+ String appPath = dotAppFolder .getAbsolutePath ();
918+ if (Platform .isMacOS ()) {
919+ if (isXcodeInstalled ()) {
920+ // if (embedJava) {
921+ // ProcessHelper.ffs("codesign", "--force", "--sign", "--deep", "-", jdkPath);
922+ // }
923+ ProcessHelper .ffs ("codesign" , "--force" , "--deep" , "--sign" , "-" , appPath );
924+ } else {
925+ System .err .println ("Xcode not installed, install it and manually sign this app:" );
926+ System .err .println ("codesign --force --deep --sign - " + appPath );
914927 }
915- String appPath = dotAppFolder .getAbsolutePath ();
916- ProcessHelper .ffs ("codesign" , "--force" , "--sign" , "-" , appPath );
917928 }
918929
919930 } else if (exportPlatform == PConstants .WINDOWS ) {
@@ -1078,13 +1089,15 @@ static public String[] getArgsJavaFX(String modulePath) {
10781089
10791090 static protected boolean isXcodeInstalled () {
10801091 if (xcodeInstalled == null ) {
1092+ // Note that this is *not* an xcrun tool, because it's part of the OS.
1093+ // pkgutil --file-info /usr/bin/xcode-select
1094+ // https://stackoverflow.com/a/32752859/18247494
1095+ StringList stdout = new StringList ();
1096+ StringList stderr = new StringList ();
1097+ int result = PApplet .exec (stdout , stderr , "/usr/bin/xcode-select" , "-p" );
1098+
1099+ // Returns 0 if installed, 2 if not (-1 if exception)
10811100 // http://stackoverflow.com/questions/15371925
1082- Process p = PApplet .launch ("xcode-select" , "-p" );
1083- int result = -1 ;
1084- try {
1085- result = p .waitFor ();
1086- } catch (InterruptedException ignored ) { }
1087- // returns 0 if installed, 2 if not (-1 if exception)
10881101 xcodeInstalled = (result == 0 );
10891102 }
10901103 return xcodeInstalled ;
0 commit comments