Repository navigation
Description
Description
Cross-import overlays don't import automatically on Linux/WSL with swift 6.4+. Looks like a regression of #152. it seems that after #153 this argument was lost for swiftbuild config after #229 PR.
Minimal example to reproduce (xtool new example, then replace the app file)
import SwiftUI
import PhotosUI
// `PhotosPickerItem` is declared in `_PhotosUI_SwiftUI`, a cross-import overlay
// that should be imported implicitly when both PhotosUI and SwiftUI are imported.
// manual import _PhotosUI_SwiftUI will fix the problem
@main
struct exampleApp: App {
@State private var item: PhotosPickerItem?
var body: some Scene {
WindowGroup {
PhotosPicker("Pick a photo", selection: $item)
}
}
}xtool dev: fails with:
error: cannot find type 'PhotosPickerItem' in scope
Cause
#153 added -Xfrontend -enable-cross-import-overlays to toolset.json. However after #229, Swift 6.4+ builds use toolset-swb.json which has no swiftCompiler section.
Build logs
xtool dev
Planning...
Building for debugging...
error: SwiftCompile normal arm64 failed with a nonzero exit code. Command line: cd /home/srggr/hi/example/xtool
macro expansion @State:2:24: error: cannot find type 'PhotosPickerItem' in scope
`- /home/srggr/hi/example/Sources/example/exampleApp.swift:9:47: note: expanded code originates here
7 | @main
8 | struct exampleApp: App {
9 | @State private var item: PhotosPickerItem?
| `- note: in expansion of macro 'State' on property 'item' here
+--- macro expansion @State -----------------------------------------
| 1 | private var __item = SwiftUICore.State._makeStorage(({
| 2 | let value: PhotosPickerItem? = nil
| | `- error: cannot find type 'PhotosPickerItem' in scope
| 3 | return value
| 4 | }))
+--------------------------------------------------------------------
10 |
11 | var body: some Scene {
/home/srggr/hi/example/Sources/example/exampleApp.swift:9:30: error: cannot find type 'PhotosPickerItem' in scope
7 | @main
8 | struct exampleApp: App {
9 | @State private var item: PhotosPickerItem?
| `- error: cannot find type 'PhotosPickerItem' in scope
10 |
11 | var body: some Scene {
macro expansion @State:8:27: error: cannot find type 'PhotosPickerItem' in scope
`- /home/srggr/hi/example/Sources/example/exampleApp.swift:9:47: note: expanded code originates here
7 | @main
8 | struct exampleApp: App {
9 | @State private var item: PhotosPickerItem?
| `- note: in expansion of macro 'State' on property 'item' here
+--- macro expansion @State -----------------------------------------
| 6 | @SwiftUICore._StatePropertyWrapperStorage(initialValue: "JHM3ZXhhbXBsZTBBM0FwcFY0aXRlbTMzX0YzQ0VDMDYwRUVFNUJFOTg0MTRFQ0Y5RDdFOUI3MDlETEw1U3RhdGVmTXBfMjBfaW5pdGlhbFN0b3JlZFZhbHVlX2ZNdV8=")
| 7 | private var _item: SwiftUICore.State<_>! = SwiftUICore._stateNil(of: {
| 8 | SwiftUICore.State<PhotosPickerItem?>(initialValue: nil)
| | `- error: cannot find type 'PhotosPickerItem' in scope
| 9 | })
|10 |
+--------------------------------------------------------------------
10 |
11 | var body: some Scene {
macro expansion @State:7:38: error: could not infer type for placeholder
`- /home/srggr/hi/example/Sources/example/exampleApp.swift:9:47: note: expanded code originates here
7 | @main
8 | struct exampleApp: App {
9 | @State private var item: PhotosPickerItem?
| `- note: in expansion of macro 'State' on property 'item' here
+--- macro expansion @State -----------------------------------------
| 5 |
| 6 | @SwiftUICore._StatePropertyWrapperStorage(initialValue: "JHM3ZXhhbXBsZTBBM0FwcFY0aXRlbTMzX0YzQ0VDMDYwRUVFNUJFOTg0MTRFQ0Y5RDdFOUI3MDlETEw1U3RhdGVmTXBfMjBfaW5pdGlhbFN0b3JlZFZhbHVlX2ZNdV8=")
| 7 | private var _item: SwiftUICore.State<_>! = SwiftUICore._stateNil(of: {
| | `- error: could not infer type for placeholder
| 8 | SwiftUICore.State<PhotosPickerItem?>(initialValue: nil)
| 9 | })
+--------------------------------------------------------------------
10 |
11 | var body: some Scene {
macro expansion @State:12:39: error: cannot find type 'PhotosPickerItem' in scope
`- /home/srggr/hi/example/Sources/example/exampleApp.swift:9:47: note: expanded code originates here
7 | @main
8 | struct exampleApp: App {
9 | @State private var item: PhotosPickerItem?
| `- note: in expansion of macro 'State' on property 'item' here
+--- macro expansion @State -----------------------------------------
|10 |
|11 | @SwiftUICore._StateProjectedValue
|12 | private var $item = SwiftUICore.State<PhotosPickerItem?>(initialValue: nil).projectedValue
| | `- error: cannot find type 'PhotosPickerItem' in scope
|13 |
|14 | @SwiftUICore._StateInitialStoredValue("U3dpZnRVSUNvcmUuU3RhdGUuX21ha2VTdG9yYWdlKGluaXRpYWxWYWx1ZTogeyBsZXQgeDogUGhvdG9zUGlja2VySXRlbT8gPSBuaWwKcmV0dXJuIHggfSgpKQ==")
+--------------------------------------------------------------------
10 |
11 | var body: some Scene {
macro expansion @State:16:20: error: cannot find type 'PhotosPickerItem' in scope
`- /home/srggr/hi/example/Sources/example/exampleApp.swift:9:47: note: expanded code originates here
7 | @main
8 | struct exampleApp: App {
9 | @State private var item: PhotosPickerItem?
| `- note: in expansion of macro 'State' on property 'item' here
+--- macro expansion @State -----------------------------------------
|14 | @SwiftUICore._StateInitialStoredValue("U3dpZnRVSUNvcmUuU3RhdGUuX21ha2VTdG9yYWdlKGluaXRpYWxWYWx1ZTogeyBsZXQgeDogUGhvdG9zUGlja2VySXRlbT8gPSBuaWwKcmV0dXJuIHggfSgpKQ==")
|15 | private static var $s7example0A3AppV4item33_F3CEC060EEE5BE98414ECF9D7E9B709DLL5StatefMp_20_initialStoredValue_fMu_ = (SwiftUICore.State._makeStorage(initialValue: {
|16 | let x: PhotosPickerItem? = nil
| | `- error: cannot find type 'PhotosPickerItem' in scope
|17 | return x
|18 | }()))
+--------------------------------------------------------------------
10 |
11 | var body: some Scene {
Environment
Host OS (macOS/Linux/WSL):
WSL
Host OS version:
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=26.04
DISTRIB_CODENAME=resolute
DISTRIB_DESCRIPTION="Ubuntu 26.04.1 LTS"
PRETTY_NAME="Ubuntu 26.04.1 LTS"
NAME="Ubuntu"
VERSION_ID="26.04"
VERSION="26.04.1 LTS (Resolute Raccoon)"
VERSION_CODENAME=resolute
ID=ubuntu
ID_LIKE=debian
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
UBUNTU_CODENAME=resolute
LOGO=ubuntu-logo
Swift version:
Swift version 6.4.1 (swift-6.4.1-RELEASE)
Target: x86_64-unknown-linux-gnu
SDK version:
xtool 1.22.2
iPhoneOS27.1.sdk
Activity
sdk: fix cross-import overlays with SwiftBuild (#361)