Ok, so looks like we're getting there. Thank you for coming along the journey with me.
TLDR; solved a bunch of problems, jump to last heading for current problem.
Entitlements
The correct "inherit" entitlements (for child items) are:
com.apple.security.app-sandbox
com.apple.security.inherit
Inherit Entitlement Notes
And the reason it didn't work during my previous attempt was because of a downstream issue which I'll get to in a minute.
With this updated "inherit" plist, I continued to receive Unsatisfied entitlements: com.apple.security.application-groups, but as mentioned here this is a non-fatal issue and can often be ignored. (adding a com.apple.security.application-groups to the "inherit" plist caused other errors for me).
All things ending in .framework, .app and .node need to be signed with this "inherit" entitlements.
Main Entitlements
For the record, my main app entitlements is as follows:
com.apple.security.app-sandbox
com.apple.application-identifier: TTTTTTTT.com.nnnnnnnnnnnnn.nnnnn
com.apple.developer.team-identifier: TTTTTT
com.apple.security.network.client
com.apple.security.network.server
com.apple.security.device.usb (specific to my app, others may not need this)
com.apple.security.device.serial (specific to my app, others may not need this)
com.apple.security.files.user-selected.read-write
com.apple.security.cs.allow-jit
com.apple.security.cs.allow-unsigned-executable-memory
com.apple.security.cs.disable-executable-page-protection
com.apple.security.cs.allow-dyld-environment-variables
com.apple.security.cs.disable-library-validation
keychain-access-groups: [TTTTTTTT.*]
com.apple.security.application-groups: [TTTTTTTT.com.nnnnnnnnnnnnn.nnnnn]
Debugging
Dtruss: I was able to capture the sys calls by unsigning the main binary (Contents/MacOS/Nnnnn), but that required sudo-ing and the application seemed to be in a different sandbox when I did that and hit issues trying to read attributes from the main .app folder. In retrospect, I think that output was misleading for what I was trying to do.
XCode: I tried to run the app via XCode's Debug > Debug Executable..., I ran into issues because my app doesn't have the com.apple.security.get-task-allow entitlement. But, just adding that entitlement to the main entitlements didn't work for me. (I think it conflicts with com.apple.security.app-sandbox?). Instead of dealing with that, I was able to just disable SIP with csrutil disable (via recovery mode reboot) and attach XCode no problem.
When running in XCode, I was able to find that the exit was because of a failed assertion on the Mach Port.
Mach/XPC Stuff
Next issue was this pesky panic: FATAL:mach_port_rendezvous.cc(142)] Check failed: kr == KERN_SUCCESS. bootstrap_check_in. You can see the source code here
https://chromium.googlesource.com/chromium/src/base/+/master/mac/mach_port_rendezvous.cc. Digging through the console logs, I was able to find this error Sandbox: Nnnnn(23775) deny(1) mach-register com.nnnnnnnnnnnnn.nnnnnn.MachPortRendezvousServer.23775.
Btw, I kept SIP disabled for this part so I could attach my XCode debugger.
So that's interesting, can't register a mach port... maybe a permissions issue me thinks? Digging around, I found that XPC naming must match your app identity
A Service Management login item can only run a single XPC listener and its name must match the name of the login item. - https://developer.apple.com/forums/thread/703702?answerId=709877022#709877022
:wave: thank you Quinn.
So, if the name needs to match... my error says it's trying to register without the TTTTT part of TTTTT.com.nnnnnnnnn.nnnn... So why is chromium / electron doing that...
Going back to the chromium source code from above, jump to line 143 - note: mac::BaseBundleID(). Ok, so dig backwards, where does that come from - here it is: https://source.chromium.org/chromium/chromium/src/+/HEAD:base/mac/foundation_util.mm;l=289. which relies on base_bundle_id which is set in SetBaseBundleID.
Some quick googling, that's set over here in electron. And interesting.. it looks for a ElectronTeamID Info.plist property. Quick check of our Info.plist - nada.
Updated the build process to include ElectronTeamID: TTTTTT in my Info.plist. Cool, works great!
Fun note: my app doesn't require com.apple.security.temporary-exception.mach-lookup.global-name since from what I can tell, com.apple.security.application-groups and com.apple.security.app-sandbox allow you to use any named Mach Port with a prefix of TTTTT.com.nnnnnnnnnn.nnnn.
Pink Flashing Screen
Once I tested that everything was working, I re-enabled SIP (csrutil enable) and started the app. Got a pink and white seizure-type screen. The console logs showed this error: kernel CODE SIGNING: 1036[nnnnn Helper (Re] vm_map_protect:6073(0x0,0x0,0x7) can't have both write and exec at the same time.
I tried using com.apple.security.cs.disable-executable-page-protection in my main entitlement (since it would get inherited by the Helper), but that didn't work. Back to the drawing board...