tvOS / Xcode 12 Expected a type "UISplitViewControllerStyle"

I have a universal iOS / tvOS app with a mixed Obj-C/C++ and Swift codebase. The UI for the iOS & tvOS apps is mostly separate, save for a few views here & there.

Using the Xcode 12 betas (currently on beta 6), I am getting an error building the tvOS app in every Obj-C class that includes my Project-Swift.h header:

Code Block
Parse Issue
Expected a type
Project-Swift.h
(dozens of *.m and *.h files)


This is the section of the Project-Swift.h header that is generating the error:

Code Block
SWIFT_CLASS("_TtC4Apex27SiteListSplitViewController")
@interface SiteListSplitViewController : UISplitViewController <PCOSiteConnectionStatusChanged>
- (void)viewDidLoad;
- (void)viewDidAppear:(BOOL)animated;
@property (nonatomic) CGFloat preferredPrimaryColumnWidthFraction;
- (nullable instancetype)initWithCoder:(NSCoder * _Nonnull)coder OBJC_DESIGNATED_INITIALIZER;
- (nonnull instancetype)initWithNibName:(NSString * _Nullable)nibNameOrNil bundle:(NSBundle * _Nullable)nibBundleOrNil OBJC_DESIGNATED_INITIALIZER;
=== // Error is on "UISplitViewControllerStyle" ===
- (nonnull instancetype)initWithStyle:(UISplitViewControllerStyle)style OBJC_DESIGNATED_INITIALIZER SWIFT_AVAILABILITY(tvos,introduced=14.0);
@end


In the iOS app I use an Obj-C UISplitViewController subclass, which builds just fine. In the tvOS app I use a Swift UISplitViewController subclass.

There is nothing in the UISplitViewController swift class that should be exposed to Obj-C. I'm assuming it's being added to the header because it's a UISplitViewController subclass though.

I know tvOS 14 defines single and double column split views now, but even if I try to go into the story board and update the style from Undefined to anything else, I still get the error. I've also tried changing the deployment target to 14.0, but that didn't change anything either.

If I build this project with Xcode 11, the offending line in my -Swift.h file (- (nonnull instancetype)initWithStyle:(UISplitViewControllerStyle)style OBJC_DESIGNATED_INITIALIZER SWIFT_AVAILABILITY(tvos,introduced=14.0);)
doesn't exist.

Again, I'm assuming it has something to do with the new UISplitViewController column styles in tvOS 14, but I cannot figure out what I'm supposed to do to get it to work, nor why my iOS project doesn't have this problem.
Answered by oe_jbondo in 637135022
Finally figured this out. It turns out the problem was that the version of Xcode set by xcode-select was the store version of Xcode (11.7).

Once Xcode 12 was released & I installed the update the problem inexplicably disappeared. However, our build server still hade Xcode 11.7 set as the default with xcode-select (even though the build was actually using Xcode 12), so when I pushed a build of our tvOS app the problem showed back up. It took several days of mucking around before it finally occurred to try changing the version of Xcode set with xcode-select. When I set Xcode 12 as the default with xcode-select on the build machine the problem disappeared again.

To be clear - it was not that the project was using the wrong version of Xcode to build - I have a script set to select a specific version of Xcode on the build machine, and on my local machine I was using Xcode 12 to build the project. The problem was specifically the version that was set with xcode-select. For some reason, during the linking process, Xcode 12 (presumably xcodebuild) is using whatever version is set with xcode-select and not actually using the version of Xcode the build was started with.

This seems like a bug in Xcode 12, for which I'll be filing a report.
As you note, Xcode 12 uses newly coded/defined split views.

I'd expect that if you're massaging a legacy hybrid app it might not be comfortable with that project.

This may be one of those times when you need to create a new project via that Xcode, adding your elements in, step-by-step, building on what it's already comfortable with until you break something, then attack that code specifically...not fun, but perhaps the shortest route out the other side.

Can help to work another new project without your mods in parallel so you have a baseline example to study.

Tactics that might also help - cleaning the build folder as a routine, and maybe even putting things off until a release version of Xcode 12 drops that you can focus on without bugs and/or crippled/missing/incomplete/work-in-progress API.

Feel free to file bugs against the beta, seeing what comes back.

Good luck.
Accepted Answer
Finally figured this out. It turns out the problem was that the version of Xcode set by xcode-select was the store version of Xcode (11.7).

Once Xcode 12 was released & I installed the update the problem inexplicably disappeared. However, our build server still hade Xcode 11.7 set as the default with xcode-select (even though the build was actually using Xcode 12), so when I pushed a build of our tvOS app the problem showed back up. It took several days of mucking around before it finally occurred to try changing the version of Xcode set with xcode-select. When I set Xcode 12 as the default with xcode-select on the build machine the problem disappeared again.

To be clear - it was not that the project was using the wrong version of Xcode to build - I have a script set to select a specific version of Xcode on the build machine, and on my local machine I was using Xcode 12 to build the project. The problem was specifically the version that was set with xcode-select. For some reason, during the linking process, Xcode 12 (presumably xcodebuild) is using whatever version is set with xcode-select and not actually using the version of Xcode the build was started with.

This seems like a bug in Xcode 12, for which I'll be filing a report.
tvOS / Xcode 12 Expected a type "UISplitViewControllerStyle"
 
 
Q