It crashes in a couple of sec. with following console error after execution, Although it works fine without sandbox activation :
“Sandbox: test(8409) deny(1) forbidden-sandbox-reinit”
1-Requirments:
macOS Catalina 10.15.4Python 3.6
PyInstaller 4.0
Certification:Developer ID Application
Manual(without Xcode): build, signing, notarizing and sandboxing
2.Implementing Simple Code Ex(test.py):(No matter which code content is used, all crash)
from AppKit import NSOpenPanel
from objc import YES, NO
panel = NSOpenPanel.openPanel()
panel.setTitle("open file")
panel.setAllowsMultipleSelection(NO)
panel.setCanChooseDirectories_(YES)
panel.runModal()
3.Creating test.spec:
blockcipher = None
a = Analysis(['test.py'],
pathex=['/Users/Emre/Documents/Work/models/research/objectdetection'],
binaries=[],
datas=[],
hiddenimports=[],
hookspath=[],
runtimehooks=[],
excludes=[],
winnopreferredirects=False,
winprivateassemblies=False,
cipher=blockcipher)
pyz = PYZ(a.pure, a.zippeddata,
cipher=blockcipher)
exe = EXE(pyz,
a.scripts,
a.binaries,
a.zipfiles,
a.datas,
name='test',
debug=False,
strip=False,
upx=True,
runtimetmpdir=None,
console=False )
app = BUNDLE(exe,
name='test.app',
icon=None,
bundle_identifier=None)
4.Creating .App File:
python3.6 -m PyInstaller -F test.spec5.Creating Entitlements(Entitlements.plist):
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-url(not allowed to be added in developer forum)">
<plist version="1.0">
<dict>
<key>com.apple.security.app-sandbox</key>
<true/>
</dict>
</plist>
6.Codesiging Manually:
codesign --force --options=runtime --sign "Developer ID Application: Emre (xxxx)” test.app --entitlements Entitlements.plist7.Generate dmg file via disk utility for Notarizing from test.py:
-8.Notarizing the application:
xcrun altool --notarize-app --primary-bundle-id "com.emre" --username "emre@gmail.com" --password "@keychain:AppSpecPass" --file /Users/Emre/Documents/Work/models/research/objectdetection/dist/test.dmg9.Verification Of Certificate and sandboxing:
spctl -a -t exec -vv test.apptest.app: accepted
source=Notarized Developer ID
origin=Developer ID Application: Emre Guenaydin (93DS7PC26P)
codesign --verify --deep --strict --verbose=2 test.app
test.app: valid on disk
test.app: satisfies its Designated Requirement
codesign -dvvv --entitlements :- test.app
Executable=/Users/Emre/Documents/Work/models/research/objectdetection/dist/untitled folder/test.app/Contents/MacOS/test
Identifier=test
Format=app bundle with Mach-O thin (x86_64)
CodeDirectory v=20500 size=73712 flags=0x10000(runtime) hashes=2295+5 location=embedded
Hash type=sha256 size=32
CandidateCDHash sha1=e3716fc5262107748b2658e4cbbcee97670268c1
CandidateCDHashFull sha1=e3716fc5262107748b2658e4cbbcee97670268c1
CandidateCDHash sha256=6fe01092e170231a9fdc855871ce3161b71b8af5
CandidateCDHashFull sha256=6fe01092e170231a9fdc855871ce3161b71b8af597cd78410dcea3b80092e5c0
Hash choices=sha1,sha256
CMSDigest=cf0a13051e77eba16609e67ca580b24d2698becad591a45fac911d44ddbef0b6
CMSDigestType=2
CDHash=6fe01092e170231a9fdc855871ce3161b71b8af5
Signature size=9058
Authority=Developer ID Application: Emre (***)
Authority=Developer ID Certification Authority
Authority=Apple Root CA
Timestamp=20. Sep 2020 at 23:40:39
Info.plist entries=8
TeamIdentifier=***
Runtime Version=10.11.0
Sealed Resources version=2 rules=13 files=1
Internal requirements count=1 size=164
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-url(not allowed to be commented in developer forum)">
<plist version="1.0">
<dict>
<key>com.apple.security.app-sandbox</key>
<true/>
</dict>
</plist>
10.Execute .app file:
Crashes with following console report follow:default 23:45:08.671813+0200 secinitd test[8055]: AppSandbox request successful
default 23:45:09.275405+0200 secinitd test[8056]: AppSandbox request successful
error 23:45:09.504553+0200 sandboxd Failed to produce a full report for: test[8056].
error 23:45:09.504643+0200 sandboxd Sandbox: test(8056) deny(1) forbidden-sandbox-reinit