RCTLinking>问题>指针缺少可为空类型说明符(_Nonnull,_Nullable或_Null_unspecified)

时间:2019-03-27 11:46:33

标签: ios objective-c xcode react-native

自从XCode版本10.2(10E125)更新以来,是否还有其他人正在获得此信息并知道解决方法?

  • macOS Mojave 10.14.3(18D109)
  • “反应本机”:“ 0.57.0”
  • 节点v11.6.0
  • npm:6.5.0-next.0
  • 纱线:1.14.0-20181221.0548

3 个答案:

答案 0 :(得分:2)

它最终归结为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

现在成功构建。

答案 1 :(得分:1)

如果您正在使用cocoapods(并且不检入Pod),则可以将其添加到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的可空性完整性检查。

答案 2 :(得分:0)

为了消除警告,我使用补丁包添加 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