Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disable Swift compiler sandboxing in Xcode 15.3+ to fix nested sandboxing #1206

Merged

Conversation

adincebic
Copy link
Contributor

@adincebic adincebic commented May 22, 2024

This should solve #1202
and #1204

There were issues with Swift compiler plugins (incl. macros) and nested sandboxes on macOS with Swift 5.9 that have been fixed with 5.10:
swift: apple/swift#70079
swift-driver: apple/swift-driver#1493
swift-package-manager: apple/swift-package-manager#7167

I am not sure whether this flag is required on Linux too.

@luispadron luispadron changed the title Disable Swift sandbox when Xcode 15.3 is used Disable Swift compiler sandboxing in Xcode 15.3+ to fix nested sandboxing May 22, 2024
@luispadron
Copy link
Contributor

Is it possible to add a test case as well for this, would catch regressions in the future

Signed-off-by: Adin Cebic <cebic.ad@gmail.com>
@adincebic adincebic force-pushed the ac/disable-swift-sandbox-on-xcode-15_3 branch from 7db5d24 to be3196b Compare May 22, 2024 15:37
@adincebic
Copy link
Contributor Author

Is it possible to add a test case as well for this, would catch regressions in the future

@luispadron No reason not to, just need to learn how to write tests in Starlark :)

swift/internal/feature_names.bzl Show resolved Hide resolved
swift/internal/feature_names.bzl Outdated Show resolved Hide resolved
swift/internal/xcode_swift_toolchain.bzl Outdated Show resolved Hide resolved
swift/internal/xcode_swift_toolchain.bzl Outdated Show resolved Hide resolved
adincebic and others added 3 commits May 22, 2024 18:40
Co-authored-by: Brentley Jones <github@brentleyjones.com>
Signed-off-by: Adin Cebic <cebic.ad@gmail.com>
Signed-off-by: Adin Cebic <cebic.ad@gmail.com>
@adincebic
Copy link
Contributor Author

Is it possible to add a test case as well for this, would catch regressions in the future

@luispadron I added the test though it is not that comprehensive. Maybe a better integration test would be to add example project with SwiftUI preview macro and build that on CI down the road.
Does this small test suffice for now?

Copy link
Contributor

@luispadron luispadron left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for fixing up and addressing comments!

@keith
Copy link
Member

keith commented May 22, 2024

Is this fixed in 15.4?

@luispadron
Copy link
Contributor

@keith tested in the reproducer @adincebic provided but looks like its still broken unless we disable_sandbox:

<unknown>:0: warning: compiler plugin not loaded: '/Applications/Xcode-15.4.0.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/swift-plugin-server; failed to initialize
app/source/ContentView.swift:15:1: error: external macro implementation type 'PreviewsMacros.SwiftUIView' could not be found for macro 'Preview(_:body:)'
#Preview {
^
SwiftUI.Preview:2:41: note: 'Preview(_:body:)' declared here
@freestanding(declaration) public macro Preview(_ name: String? = nil, body: @escaping @MainActor () -> any View) = #externalMacro(module: "PreviewsMacros", type: "SwiftUIView")
    

@keith keith requested a review from brentleyjones May 22, 2024 21:13
@keith keith merged commit 3e85693 into bazelbuild:master May 22, 2024
15 checks passed
@PhilCai1993
Copy link

We use -load-plugin-library instead of executable, it works well, without the sandboxing issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants