Skip to content

[cxx-interop] Workaround compiler error when importing AppKit/UIKit with C++ interop #78694

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

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion lib/Frontend/ModuleInterfaceLoader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2205,7 +2205,10 @@ InterfaceSubContextDelegateImpl::runInSubCompilerInstance(StringRef moduleName,
// interop enabled by the Swift CI because it uses an old host SDK.
// FIXME: Hack for CoreGraphics.swiftmodule, which cannot be rebuilt because
// of a CF_OPTIONS bug (rdar://142762174).
if (moduleName == "Darwin" || moduleName == "CoreGraphics") {
// FIXME: Hack for AppKit.swiftmodule / UIKit.swiftmodule, which cannot be
// rebuilt because of an NS_OPTIONS bug (rdar://143033209)
if (moduleName == "Darwin" || moduleName == "CoreGraphics"
|| moduleName == "AppKit" || moduleName == "UIKit") {
subInvocation.getLangOptions().EnableCXXInterop = false;
subInvocation.getLangOptions().cxxInteropCompatVersion = {};
BuildArgs.erase(llvm::remove_if(BuildArgs,
Expand Down
16 changes: 16 additions & 0 deletions test/Interop/Cxx/objc-correctness/appkit-uikit.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// RUN: %target-swift-frontend -typecheck -verify -I %S/Inputs -cxx-interoperability-mode=default %s

// REQUIRES: objc_interop
// REQUIRES: VENDOR=apple

#if canImport(AppKit)
import AppKit

var _: AttributeScopes.AppKitAttributes.UnderlineStyleAttribute! = nil

#elseif canImport(UIKit)
import UIKit

var _: AttributeScopes.AppKitAttributes.UnderlineStyleAttribute! = nil

#endif