只是好奇自XCode版本10.2(10E125)更新以来是否有其他人得到这个并知道修复程序?
- macOS 莫哈韦 10.14.3 (18D109)
- "反应原生":"0.57.0">
- 节点 v11.6.0
- NPM:6.5.0-下一个.0
- 纱线:1.14.0-20181221.0548
最后归结为RCTLinkingManager.h
。
我用非空断言修改了它,如下所示:
/**
* Copyright (c) 2015-present, Facebook, Inc.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
#import <UIKit/UIKit.h>
#import <React/RCTEventEmitter.h>
@interface RCTLinkingManager : RCTEventEmitter
+ (BOOL)application:(UIApplication *_Nonnull)app
openURL:(NSURL *_Nonnull)URL
options:(NSDictionary<UIApplicationOpenURLOptionsKey,id> *_Nonnull)options;
+ (BOOL)application:(UIApplication *_Nonnull)application
openURL:(NSURL *_Nonnull)URL
sourceApplication:(NSString *_Nonnull)sourceApplication
annotation:(id _Nonnull )annotation;
+ (BOOL)application:(UIApplication *_Nonnull)application
continueUserActivity:(NSUserActivity *_Nonnull)userActivity
restorationHandler:(void (^_Nonnull)(NSArray * __nullable))restorationHandler;
@end
现在获得成功的构建。
如果您使用的是 cocoapods(并且不签入 Pods),则可以将其添加到 podfile 的底部:
post_install do |installer|
installer.pods_project.targets.each do |target|
case target.name
when /AReact/
target.build_configurations.each do |config|
# Xcode 10.2 requires suppression of nullability for React
# https://stackoverflow.com/questions/37691049/xcode-compile-flag-to-suppress-nullability-warnings-not-working
config.build_settings['WARNING_CFLAGS'] ||= ['"-Wno-nullability-completeness"']
end
end
end
end
这将关闭 React Native 的可空性完整性检查。
为了摆脱警告,我使用添加NS_ASSUME_NONNULL*的补丁包修改了两个头文件(RCTEventEmitter.h和RCTJSInvokerModule.h)。
#import <React/RCTBridge.h>
#import <React/RCTJSInvokerModule.h>
NS_ASSUME_NONNULL_BEGIN
@interface RCTEventEmitter : NSObject <RCTBridgeModule, RCTJSInvokerModule>
// ...
@end
NS_ASSUME_NONNULL_END