Xcode build error after changing project target iOS major version

I am using Xcode 14.0.1, and testing on an iPhone 12 mini with IOS 16.0.

My project target was IOS 14.0. I need something later for TagView according to the comments, so I set that to 16.0 in the project TARGETS > iOS Deployment Target, which updated the PROJECT > iOS Deployment Target.

I now get an error "The compiler is unable to type-check this expression in reasonable time; try breaking up the expression into distinct sub-expressions" when I build. The error line is " var body: some View { " so there is not a lot of clues to that. This is not a big project.

If I change the target 15.0 I get the same error. I tried Product > Clean Build Folder but that did not help.

If I change the target to 14.7 it builds, and runs.

Is there something extra I need to do when changing the target iOS major version?

Answered by Richard_Kirk in 731708022

Fixed it. I replaced...

ForEach (SWD.swatches) { sw in
    if (sw.id > 0) {
        ...
    }

...with...

ForEach (SWD.swatches.filter { $0.id > 0} ) { sw in
    ...
}

The first one worked up to iOS 14.7 but seems to confuse the build from 15.0 onwards.

I have managed to isolate the region that causes the build problem. This is cheering as it means it is probably my fault: but I got away with it up until 14.7, but something changed in 15.0.

I have a conditional in a ForEach loop...

`    ForEach (SWD.swatches) { sw in

      if (sw.id > 0) { // <- this is bad

  ...make a View...

        }

}

`

Accepted Answer

Fixed it. I replaced...

ForEach (SWD.swatches) { sw in
    if (sw.id > 0) {
        ...
    }

...with...

ForEach (SWD.swatches.filter { $0.id > 0} ) { sw in
    ...
}

The first one worked up to iOS 14.7 but seems to confuse the build from 15.0 onwards.

Xcode build error after changing project target iOS major version
 
 
Q