Leo
Leo

Reputation: 10813

RCTLinking > issue > Pointer is missing a nullability type specifier (_Nonnull, _Nullable, or _Null_unspecified)

Just curious if anybody else is getting this since the XCode Version 10.2 (10E125) update and know the fix?

Upvotes: 2

Views: 3156

Answers (3)

Simon Bengtsson
Simon Bengtsson

Reputation: 8151

To get rid of the warnings I modified the two header files (RCTEventEmitter.h and RCTJSInvokerModule.h) using patch-package adding NS_ASSUME_NONNULL*.

#import <React/RCTBridge.h>
#import <React/RCTJSInvokerModule.h>

NS_ASSUME_NONNULL_BEGIN

@interface RCTEventEmitter : NSObject <RCTBridgeModule, RCTJSInvokerModule>

// ...

@end

NS_ASSUME_NONNULL_END

Upvotes: 0

Chase Holland
Chase Holland

Reputation: 2258

If you're using cocoapods (and don't check your Pods in), you can add this to the bottom of your 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

This will flip off the nullability completeness check for React Native.

Upvotes: 2

Leo
Leo

Reputation: 10813

It boiled down to RCTLinkingManager.h in the end.

I amended it with non-null assertions like so:

/**
 * 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

And now getting a successful build.

Upvotes: 5

Related Questions