Skip to content

Commit 59e6122

Browse files
committed
get code signing to work again on macOS for exported applications
1 parent 9f28410 commit 59e6122

File tree

5 files changed

+40
-13
lines changed

5 files changed

+40
-13
lines changed

build/build.xml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -672,16 +672,26 @@
672672
<fileset file="shared/changes.md" />
673673
</copy>
674674

675+
<!-- Can't use this method since the appbundler builds have split:
676+
we have a fat binary on aarch64 that has a broken x86_64 build,
677+
and the x86_64 version has no aarch64 build at all.
678+
For 4.0, this is being copied manually. -->
675679
<!-- Use the Processing executable as the stub for exported apps.
676680
This works b/c everything app-specific is in Info.plist. -->
681+
<!--
677682
<property name="app.stub"
678683
value="${contents.dir}/Java/modes/java/application/mac-app-stub" />
684+
-->
679685
<!-- Grab a copy of the stub binary before it is signed.
680686
(See processing.mode.java.JavaBuild for usage.)
681687
Prevents signing errors with exported apps. -->
688+
<!--
682689
<copy file="${contents.dir}/MacOS/Processing" tofile="${app.stub}" />
690+
-->
683691
<!-- The ant copy command does not preserve permissions. -->
692+
<!--
684693
<chmod file="${app.stub}" perm="ugo+x" />
694+
-->
685695

686696
<antcall target="assemble">
687697
<param name="target.path" value="${contents.dir}/Java" />
84.4 KB
Binary file not shown.

java/application/stub-macos-x86_64

44.6 KB
Binary file not shown.

java/src/processing/mode/java/JavaBuild.java

Lines changed: 26 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -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;

todo.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ X working on macOS, written up for Windows and Linux
1616
X test on Windows and Linux
1717
X working on an updated welcome screen
1818
X fix usages of .array() method in PDE code
19+
X get code signing to work again on macOS for exported applications
20+
X absolutely floored that it was broken this long
1921

2022
docs
2123
X update theme instructions
@@ -254,6 +256,8 @@ _ https://github.com/processing/processing/wiki/troubleshooting
254256
_ and update the Help menu to link to it
255257
_ and maybe the FAQ too?
256258

259+
lipo stub-aarch64-fat -remove x86_64 -output stub-aarch64
260+
257261

258262
4.0 / with Casey
259263
_ what things do we want to call out for the release?

0 commit comments

Comments
 (0)