【问题标题】:RCTLinking > issue > Pointer is missing a nullability type specifier (_Nonnull, _Nullable, or _Null_unspecified)RCTLinking > 问题 > 指针缺少可空性类型说明符(_Nonnull、_Nullable 或 _Null_unspecified)
【发布时间】:2019-03-27 11:46:33
【问题描述】:

只是好奇自 XCode 版本 10.2 (10E125) 更新后是否还有其他人收到此问题并知道修复方法?

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

【问题讨论】:

    标签: ios objective-c xcode react-native


    【解决方案1】:

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

    现在可以成功构建。

    【讨论】:

      【解决方案2】:

      如果您使用的是 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 的可空性完整性检查。

      【讨论】:

      • 不幸的是,似乎不适用于头文件。
      【解决方案3】:

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

      【讨论】:

        猜你喜欢
        • 2017-09-30
        • 1970-01-01
        • 2016-06-06
        • 1970-01-01
        • 2021-07-03
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多