PC パソコン

Xcode 27: Fix “VStack>” Cannot Convert to “VStack>”

After upgrading a SwiftUI project to Xcode 27, a concrete generic constraint containing TupleView may fail with “cannot convert value of type ‘VStack<TupleContent<…>>’ to expected argument type ‘VStack<TupleView<…>>’.” The unified @ContentBuilder now produces TupleContent for multiple expressions instead of the concrete TupleView shape named by older code.

Representative diagnostics

error: cannot convert value of type
'VStack<TupleContent<Text, Text>>'
to expected argument type
'VStack<TupleView<(Text, Text)>>'

A container such as Label can produce this variation:

error: cannot convert value of type
'Label<TupleContent<Text, Text?>, Image?>'
to expected argument type
'Label<TupleView<(Text, Optional<Text>)>, Optional<Image>>'

Reproducing the error

import SwiftUI

struct CardView<Content: View>: View {
    var content: Content
    var body: some View { content }

    init(@ContentBuilder content: () -> Content) {
        self.content = content()
    }
}

extension CardView
where Content == VStack<TupleView<(Text, Text)>> {
    init(title: String, subtitle: String) {
        self = CardView {
            VStack {
                Text(title)
                Text(subtitle)
            }
        }
    }
}

Root cause

Xcode 27 unifies previously separate SwiftUI result builders under @ContentBuilder. Its concrete result for multiple expressions is TupleContent.

Most SwiftUI code does not spell out these implementation types. The mismatch appears when source names TupleView as a nested type in a where clause, type alias, stored property, or return type. The generated TupleContent then conflicts with the declared TupleView.

Important: The text values and stack layout are valid. The failure comes from Xcode 27 changing the builder’s concrete result type.

Affected conditions and versions

  • The project is compiled with Xcode 27.
  • A @ContentBuilder or SwiftUI container contains multiple expressions.
  • A generic constraint explicitly names a nested TupleView.
  • The same source compiled with an earlier Xcode release.

Apple documents this as an Xcode 27 source compatibility change in TN3211, not as a temporary issue with a promised fixed version.

Recommended solutions

1. Prefer some View

Avoid depending on the builder’s concrete shape whenever possible.

@ViewBuilder
func makeCard(title: String, subtitle: String) -> some View {
    VStack {
        Text(title)
        Text(subtitle)
    }
}

2. Use TupleContent when a concrete type is required

If the minimum deployment target is iOS 27, iPadOS 27, macOS 27, or visionOS 27 or later, update the constraint.

extension CardView
where Content == VStack<TupleContent<Text, Text>> {
    init(title: String, subtitle: String) {
        self = CardView {
            VStack {
                Text(title)
                Text(subtitle)
            }
        }
    }
}

3. Back-deploying before version 27

When TupleContent is unavailable on an older deployment target, retain the TupleView constraint and construct it explicitly.

extension CardView
where Content == VStack<TupleView<(Text, Text)>> {
    init(title: String, subtitle: String) {
        self = CardView {
            VStack {
                TupleView((
                    Text(title),
                    Text(subtitle)
                ))
            }
        }
    }
}

Alternative approaches

  • Replace the specialized extension that exposes TupleView with a regular generic initializer.
  • Return some View from a builder function instead of fixing a type alias to an implementation type.
  • Extract complicated content into a small dedicated view.
  • Update dependencies to a release that supports Xcode 27.

AnyView can erase the concrete type, but may affect view structure, identity, and optimization. Prefer some View or a conventional generic design first.

How to verify the fix

  1. Confirm that the diagnostic contains both TupleContent and TupleView.
  2. Search the project for TupleView<.
  3. Check the minimum deployment target before selecting a migration.
  4. Run Product > Clean Build Folder and rebuild.
  5. Compile Debug and Release.
  6. Test the oldest supported OS, previews, the Simulator, and a device for ordering and conditional-content changes.

Cautions

  • TupleContent is a version-27 API, so it cannot simply replace TupleView for an older deployment target.
  • The exact types and optional values in the diagnostic depend on the builder content.
  • TupleView is a concrete SwiftUI implementation type. Avoid exposing it in new APIs when possible.
  • Clearing Derived Data cannot fix a real declared-versus-generated type mismatch.

Summary

In Xcode 27, the unified @ContentBuilder produces TupleContent for multiple expressions. Prefer some View to avoid concrete-type coupling. If a concrete type is unavoidable and the deployment target is version 27 or later, use TupleContent. For earlier targets, retain the TupleView constraint and construct that view explicitly inside the builder.

Official references