jpsim / SourceKitten

An adorable little framework and command line tool for interacting with SourceKit.
MIT License
2.31k stars 226 forks source link

SourceKittenFramework crashes when running as a part of a Swift Package Plugin due to sandbox #824

Closed a4z closed 1 month ago

a4z commented 1 month ago

Hi, I have a command line utility that depends on SourceKittenFramework, which I utilize as a Swift Package Command plugin.

The dump says:

0   libxpc.dylib                           0x18c948400 _xpc_api_misuse + 92
1   libxpc.dylib                           0x18c924b64 xpc_connection_send_message_with_reply_sync + 632
2   sourcekitd                             0x104825f6c sourcekitd_send_request_sync + 684
3   SourceKittenFramework                  0x104c42968 Request.send() + 140 (Request.swift:335)

I tried various network/socket permissions for the plugin, but it did not help. Only if I disable the sandbox on the command line does it work.

Is this a known problem, and is there anything I could do? (the program I run is on an older version of SourceKitten, updating is problematic) But if this was a known problem with an older version that is now solved, I could possible get an update

johnfairh commented 1 month ago

I think you need to move to SourceKitten 0.32.0 or higher:

Between SourceKitten 0.32.0 and 0.33.0 you can set IN_PROCESS_SOURCEKIT to make SourceKitten use the in-process version of sourcekit. This env var was introduced for exactly your scenario.

In SourceKitten 0.33.0 the env var was removed in favour of always using the in-process version.

(edit: if you are already >= 0.33.0 then let's discuss...)

a4z commented 1 month ago

Thanks! That sounds very promising!!

Is there any particular reason why version 0.33.0 is not on Cocoapod?

pod search SourceKittenFramework

SourceKittenFramework (0.34.1)
   An adorable little framework for interacting with SourceKit.
   pod 'SourceKittenFramework', '~> 0.34.1'
   - Homepage: https://github.com/jpsim/SourceKitten
   - Source:   https://github.com/jpsim/SourceKitten.git
   - Versions: 0.34.1, 0.34.0, 0.32.0, 0.31.0, 0.30.1, 0.30.0, 0.29.0, 0.28.0, 0.27.0, 0.26.0, 0.25.0, 0.24.0, 0.23.2, 0.23.1, 0.23.0, 0.22.0, 0.21.3, 0.21.2, 0.21.1, 0.21.0, 0.20.0, 0.19.1, 0.19.0, 0.18.4, 0.18.3,
   0.18.2, 0.18.1, 0.18.0, 0.17.6, 0.17.5, 0.17.4, 0.17.3, 0.17.2, 0.17.1, 0.17.0, 0.16.0 [trunk repo]

Anyhow, there seem to have been some API changes. It might take at least until tomorrow before I can say more. But thanks so far, this gives me at least some hope!

a4z commented 1 month ago

Works, thank you so much!!