Skip to content

Fix metadata-generator on Xcode 13 #147

@adrian-branescu

Description

@adrian-branescu

I've enabled TNS_DEBUG_METADATA_PATH and tested using the following environment

{ N } runtime: 8.1
OS: macOS Big Sur 11.6.1
Xcode: 13.2.1 (AppleClang 13.0.0.13000029)
Target: iOS 15.0.1 (physical device)

metadata-generation-stderr-arm64.txt contains hundreds of fatal error: could not build module

While building module 'VisionKit' imported from /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS15.2.sdk/System/Library/Frameworks/VisionKit.framework/Headers/VisionKit.h:9:
While building module 'UIKit' imported from /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS15.2.sdk/System/Library/Frameworks/VisionKit.framework/Headers/VNDocumentCameraViewController.h:9:
While building module 'Foundation' imported from /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS15.2.sdk/System/Library/Frameworks/UIKit.framework/Headers/UIKit.h:8:
In file included from <module-includes>:1:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS15.2.sdk/System/Library/Frameworks/Foundation.framework/Headers/Foundation.h:130:
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS15.2.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSURLSession.h:500:168: error: expected ')'
- (void)readDataOfMinLength:(NSUInteger)minBytes maxLength:(NSUInteger)maxBytes timeout:(NSTimeInterval)timeout completionHandler:(void (^) (NSData * _Nullable_result data, BOOL atEOF, NSError * _Nullable error))completionHandler;
                                                                                                                                                                       ^
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS15.2.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSURLSession.h:500:141: note: to match this '('
- (void)readDataOfMinLength:(NSUInteger)minBytes maxLength:(NSUInteger)maxBytes timeout:(NSTimeInterval)timeout completionHandler:(void (^) (NSData * _Nullable_result data, BOOL atEOF, NSError * _Nullable error))completionHandler;
                                                                                                                                            ^
While building module 'VisionKit' imported from /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS15.2.sdk/System/Library/Frameworks/VisionKit.framework/Headers/VisionKit.h:9:
While building module 'UIKit' imported from /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS15.2.sdk/System/Library/Frameworks/VisionKit.framework/Headers/VNDocumentCameraViewController.h:9:
In file included from <module-includes>:1:
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS15.2.sdk/System/Library/Frameworks/UIKit.framework/Headers/UIKit.h:8:9: fatal error: could not build module 'Foundation'
#import <Foundation/Foundation.h>
 ~~~~~~~^

The build succeeds though, but looking at the YAML dumped for the native plugins a lot of methods and data types are missing. This explains the crashes reported on iOS 15+ devices if Xcode 13 was used to build the native app.

If I repeat the same experiment with Xcode 12.5.1 (AppleClang 12.0.5.12050022) instead, then metadata-generation-stderr-arm64.txt log no longer contains any fatal error and the YAMLs and .d.ts typings look fine.

I suspect that metadata-generator Clang plugin needs to be updated to take into account AppleClang 13 breaking changes.

This issue will become more pressing for the NativeScript community as times goes by because Apple states the following

Starting April 2022, iOS and iPadOS apps submitted to the App Store must be built with Xcode 13 and the iOS 15 SDK. 

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions