I got python all embedded with my project using PythonKit in Xcode and my python files are built as bundle resources so everything is working when I archive and then export as copy build. It loads python from the resources and then loads my scripts.
Big problem though is whenever I send the app to another computer to test it, it crashes immediately upon opening with this error:
Translated Report (Full Report Below)
-------------------------------------
Process: Filex [27455]
Path: /private/var/folders/*/Filex.app/Contents/MacOS/Filex
Identifier: com.scorpionstudios.Filex
Version: 1.0 (1)
Code Type: X86-64 (Native)
Parent Process: launchd [1]
User ID: 501
Date/Time: 2024-06-29 13:55:12.8411 -0700
OS Version: macOS 14.5 (23F79)
Report Version: 12
Bridge OS Version: 8.5 (21P5077)
Anonymous UUID: 0BCB58F4-9F99-4BF4-18CD-32398D822138
Sleep/Wake UUID: 2CD8D2B8-6C7E-4A0A-9B76-EFCB335AD370
Time Awake Since Boot: 1200000 seconds
Time Since Wake: 121 seconds
System Integrity Protection: enabled
Crashed Thread: 0
Exception Type: EXC_BAD_INSTRUCTION (SIGILL)
Exception Codes: 0x0000000000000001, 0x0000000000000000
Termination Reason: Namespace SIGNAL, Code 4 Illegal instruction: 4
Terminating Process: exc handler [27455]
Kernel Triage:
VM - (arg = 0x3) mach_vm_allocate_kernel failed within call to vm_map_enter
VM - (arg = 0x3) mach_vm_allocate_kernel failed within call to vm_map_enter
VM - (arg = 0x3) mach_vm_allocate_kernel failed within call to vm_map_enter
VM - (arg = 0x3) mach_vm_allocate_kernel failed within call to vm_map_enter
VM - (arg = 0x3) mach_vm_allocate_kernel failed within call to vm_map_enter
Thread 0 Crashed:
0 libswiftCore.dylib 0x7ff81796cd9f _assertionFailure(_:_:file:line:flags:) + 351
1 libswiftCore.dylib 0x7ff8179c4a48 swift_unexpectedError + 840
2 Filex 0x10442930f PythonInterface.import(_:) + 111
3 Filex 0x1044238e4 PythonAPI.init() + 5796
4 Filex 0x104422231 PythonAPI.__allocating_init() + 33
5 Filex 0x1043f5918 implicit closure #2 in implicit closure #1 in variable initialization expression of Main._pythonAPI + 24
6 SwiftUI 0x7ff9148f840f 0x7ff913d73000 + 12080143
I can’t figure out why this is happening??? If I comment out this line of code the error doesn’t happen:
var main : PythonObject = Python.import("main")
“main” is a file module (main.py) that is is included in the apps bundle resources and I added the resource path Bundle.main.path(forResource: “Resources”, ofType: nil). It works on my computer when I build it so I don’t know why it doesn’t work on others??? Any ideas?