Hey all!
Updating older code & libraries to some of the new Swift 5.9 / iOS 17 changes. Running into a weird issue with Xcode 15. Whenever I try to add a local Swift package, Xcode immediately crashes with the following trace. Anyone else seeing something similar or have a workaround?
-------------------------------------
Translated Report (Full Report Below)
-------------------------------------
Process: Xcode [24187]
Path: /Applications/Xcode-beta.app/Contents/MacOS/Xcode
Identifier: com.apple.dt.Xcode
Version: 15.0 (22181.17)
Build Info: IDEFrameworks-22181017000000000~2 (15A5160n)
Code Type: ARM-64 (Native)
Parent Process: launchd [1]
User ID: 501
Date/Time: 2023-06-12 12:45:18.5995 -0700
OS Version: macOS 13.4 (22F66)
Report Version: 12
Anonymous UUID: 69A2C560-2753-9460-D969-DC28F9918E8D
Sleep/Wake UUID: ADBB3D7D-6D24-4E07-BAA2-F7C0952990C0
Time Awake Since Boot: 130000 seconds
Time Since Wake: 4284 seconds
System Integrity Protection: enabled
Crashed Thread: 0 Dispatch queue: com.apple.main-thread
Exception Type: EXC_CRASH (SIGABRT)
Exception Codes: 0x0000000000000000, 0x0000000000000000
Application Specific Information:
abort() called
Application Specific Signatures:
IDESwiftPackageDataSource.PreflightablePackage.swift:127@@asSourcePackageReference(with:)
Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
0 libsystem_kernel.dylib 0x19b194724 __pthread_kill + 8
1 libsystem_pthread.dylib 0x19b1cbc28 pthread_kill + 288
2 libsystem_c.dylib 0x19b0d9ae8 abort + 180
3 IDEKit 0x1079f9bcc +[IDEAssertionHandler _handleAssertionWithLogString:assertionSignature:assertionReason:extraBacktrace:] + 972
4 IDEKit 0x1079fa4ac -[IDEAssertionHandler handleFailureInFunction:fileName:lineNumber:assertionSignature:messageFormat:arguments:] + 772
5 DVTFoundation 0x103fbf878 _DVTAssertionHandler + 472
6 DVTFoundation 0x103fbfce4 _DVTAssertFromSwift + 260
7 DVTFoundation 0x10408a678 _DVTAssert(_:file:line:function:varargs:) + 276
8 DVTFoundation 0x104089748 DVTAssert(_:_:file:line:function:_:) + 444
9 IDESwiftPackageUI 0x134d41af4 AvailablePackageOrigins.Origin.asSourcePackageReference(with:) + 568
10 IDESwiftPackageUI 0x134c44894 IDESwiftPackageChooseOptionsViewController.addPackage(_:) + 1020
11 IDESwiftPackageUI 0x134c44f48 @objc IDESwiftPackageChooseOptionsViewController.cancel(_:) + 80
12 AppKit 0x19e6718a8 -[NSApplication(NSResponder) sendAction:to:from:] + 440
13 DVTKit 0x102eaa234 __37-[DVTApplication sendAction:to:from:]_block_invoke + 300
14 DVTFoundation 0x103fc1594 DVTInvokeWithFailureHint + 76
15 DVTKit 0x102eaa00c -[DVTApplication sendAction:to:from:] + 404
16 AppKit 0x19e6716c0 -[NSControl sendAction:to:] + 72
17 AppKit 0x19e671604 __26-[NSCell _sendActionFrom:]_block_invoke + 100
18 AppKit 0x19e67152c -[NSCell _sendActionFrom:] + 204
19 AppKit 0x19e671450 -[NSButtonCell _sendActionFrom:] + 88
20 AppKit 0x19e66ea54 NSControlTrackMouse + 1480
21 AppKit 0x19e66e460 -[NSCell trackMouse:inRect:ofView:untilMouseUp:] + 144
22 AppKit 0x19e66e318 -[NSButtonCell trackMouse:inRect:ofView:untilMouseUp:] + 488
23 AppKit 0x19e66d7e4 -[NSControl mouseDown:] + 448
24 AppKit 0x19e66c2cc -[NSWindow(NSEventRouting) _handleMouseDownEvent:isDelayedEvent:] + 3476
25 AppKit 0x19e5f6f08 -[NSWindow(NSEventRouting) _reallySendEvent:isDelayedEvent:] + 364
26 AppKit 0x19e5f6bc8 -[NSWindow(NSEventRouting) sendEvent:] + 284
27 AppKit 0x19e5f5f0c -[NSApplication(NSEvent) sendEvent:] + 1556
28 IDEKit 0x107a62bd0 -[IDEApplication sendEvent:] + 596
29 AppKit 0x19e845fc4 -[NSApplication _handleEvent:] + 60
30 AppKit 0x19e4bd368 -[NSApplication run] + 500
31 DVTKit 0x102ea8fb4 -[DVTApplication run] + 60
32 AppKit 0x19e494794 NSApplicationMain + 880
33 dyld 0x19ae73f28 start + 2236
Figured out the issue. This seems to have been happening because of a cyclical reference when adding a package in the parent directory of the Xcode project:
├ MyPackage
├ Package.swift
│ ├ Sources
│ │ ├ Hello.swift
│ │ ├ World.swift
│ ├ MyPackageDemo
│ │ ├ MyPackageDemo.xcodeproj
│ │ ├ ...
I solved this by adding a blank package file to the demo project's root directory:
// swift-tools-version:5.9
import PackageDescription
let package = Package()
I'm now able to add the package via Xcode without crashing 🙌🏼