mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Fix Xcode warnings in React-Core pod (#29622)
Summary: With the upgrade to React Native 0.63, we started running into nullability warnings that were breaking our build. This PR fixes those nullability warnings as well as a few other warnings in React-Core. ## Changelog <!-- Help reviewers and the release process by writing your own changelog entry. For example, see: https://github.com/facebook/react-native/wiki/Changelog --> [iOS] [Fixed] - Fix xcodebuild warnings in React-Core Pull Request resolved: https://github.com/facebook/react-native/pull/29622 Test Plan: - Nullability annotations should only affect compilation, but even though RNTester compiles, I'm not fully convinced that this won't break projects downstream. It would be good to get another opinion on this. - The change in `RCTAllocateRootViewTag` is the only real logic change in this PR. We throw an exception if the root view tag is not in the correct format, so this change seems safe after some basic manual testing in RNTester. Reviewed By: shergin Differential Revision: D23386678 Pulled By: appden fbshipit-source-id: a74875195a4614c3248e8f968aa98602e3ee2de0
This commit is contained in:
committed by
Facebook GitHub Bot
parent
f5c246d50e
commit
cb719a16cc
@@ -14,6 +14,8 @@
|
||||
#import <React/RCTImageURLLoader.h>
|
||||
#import <React/RCTImageCache.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
/**
|
||||
* If available, RCTImageRedirectProtocol is invoked before loading an asset.
|
||||
* Implementation should return either a new URL or nil when redirection is
|
||||
@@ -132,3 +134,5 @@ typedef NS_ENUM(NSUInteger, RCTImageLoaderPriority) {
|
||||
- (void)setImageCache:(id<RCTImageCache>)cache;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
|
||||
@@ -10,9 +10,11 @@
|
||||
#import <React/RCTBridge.h>
|
||||
#import <React/RCTResizeMode.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
typedef void (^RCTImageLoaderProgressBlock)(int64_t progress, int64_t total);
|
||||
typedef void (^RCTImageLoaderPartialLoadBlock)(UIImage *image);
|
||||
typedef void (^RCTImageLoaderCompletionBlock)(NSError *error, UIImage *image);
|
||||
typedef void (^RCTImageLoaderCompletionBlock)(NSError * _Nullable error, UIImage * _Nullable image);
|
||||
typedef dispatch_block_t RCTImageLoaderCancellationBlock;
|
||||
|
||||
/**
|
||||
@@ -71,3 +73,5 @@ typedef dispatch_block_t RCTImageLoaderCancellationBlock;
|
||||
- (BOOL)shouldCacheLoadedImages;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
|
||||
+20
-20
@@ -218,7 +218,24 @@ RCT_NOT_IMPLEMENTED(-(instancetype)init)
|
||||
|
||||
- (void)didReceiveReloadCommand
|
||||
{
|
||||
[self reloadWithReason:@"Command"];
|
||||
#if RCT_ENABLE_INSPECTOR
|
||||
// Disable debugger to resume the JsVM & avoid thread locks while reloading
|
||||
[RCTInspectorDevServerHelper disableDebugger];
|
||||
#endif
|
||||
|
||||
[[NSNotificationCenter defaultCenter] postNotificationName:RCTBridgeWillReloadNotification object:self userInfo:nil];
|
||||
|
||||
/**
|
||||
* Any thread
|
||||
*/
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
// WARNING: Invalidation is async, so it may not finish before re-setting up the bridge,
|
||||
// causing some issues. TODO: revisit this post-Fabric/TurboModule.
|
||||
[self invalidate];
|
||||
// Reload is a special case, do not preserve launchOptions and treat reload as a fresh start
|
||||
self->_launchOptions = nil;
|
||||
[self setUp];
|
||||
});
|
||||
}
|
||||
|
||||
- (NSArray<Class> *)moduleClasses
|
||||
@@ -269,7 +286,7 @@ RCT_NOT_IMPLEMENTED(-(instancetype)init)
|
||||
*/
|
||||
- (void)reload
|
||||
{
|
||||
[self reloadWithReason:@"Unknown from bridge"];
|
||||
RCTTriggerReloadCommandListeners(@"Unknown from bridge");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -277,24 +294,7 @@ RCT_NOT_IMPLEMENTED(-(instancetype)init)
|
||||
*/
|
||||
- (void)reloadWithReason:(NSString *)reason
|
||||
{
|
||||
#if RCT_ENABLE_INSPECTOR
|
||||
// Disable debugger to resume the JsVM & avoid thread locks while reloading
|
||||
[RCTInspectorDevServerHelper disableDebugger];
|
||||
#endif
|
||||
|
||||
[[NSNotificationCenter defaultCenter] postNotificationName:RCTBridgeWillReloadNotification object:self userInfo:nil];
|
||||
|
||||
/**
|
||||
* Any thread
|
||||
*/
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
// WARNING: Invalidation is async, so it may not finish before re-setting up the bridge,
|
||||
// causing some issues. TODO: revisit this post-Fabric/TurboModule.
|
||||
[self invalidate];
|
||||
// Reload is a special case, do not preserve launchOptions and treat reload as a fresh start
|
||||
self->_launchOptions = nil;
|
||||
[self setUp];
|
||||
});
|
||||
RCTTriggerReloadCommandListeners(reason);
|
||||
}
|
||||
|
||||
- (void)onFastRefresh
|
||||
|
||||
@@ -13,13 +13,13 @@
|
||||
@property (nonatomic, copy, readonly) NSString *file;
|
||||
@property (nonatomic, readonly) NSInteger lineNumber;
|
||||
@property (nonatomic, readonly) NSInteger column;
|
||||
@property (nonatomic, readonly) NSInteger collapse;
|
||||
@property (nonatomic, readonly) BOOL collapse;
|
||||
|
||||
- (instancetype)initWithMethodName:(NSString *)methodName
|
||||
file:(NSString *)file
|
||||
lineNumber:(NSInteger)lineNumber
|
||||
column:(NSInteger)column
|
||||
collapse:(NSInteger)collapse;
|
||||
collapse:(BOOL)collapse;
|
||||
- (NSDictionary *)toDictionary;
|
||||
|
||||
+ (instancetype)stackFrameWithLine:(NSString *)line;
|
||||
|
||||
@@ -57,7 +57,7 @@ static NSRegularExpression *RCTJSStackFrameRegex()
|
||||
file:(NSString *)file
|
||||
lineNumber:(NSInteger)lineNumber
|
||||
column:(NSInteger)column
|
||||
collapse:(NSInteger)collapse
|
||||
collapse:(BOOL)collapse
|
||||
{
|
||||
if (self = [super init]) {
|
||||
_methodName = methodName;
|
||||
@@ -100,7 +100,7 @@ static NSRegularExpression *RCTJSStackFrameRegex()
|
||||
file:file
|
||||
lineNumber:[lineNumber integerValue]
|
||||
column:[column integerValue]
|
||||
collapse:@NO];
|
||||
collapse:NO];
|
||||
}
|
||||
|
||||
+ (instancetype)stackFrameWithDictionary:(NSDictionary *)dict
|
||||
@@ -109,7 +109,7 @@ static NSRegularExpression *RCTJSStackFrameRegex()
|
||||
file:dict[@"file"]
|
||||
lineNumber:[RCTNilIfNull(dict[@"lineNumber"]) integerValue]
|
||||
column:[RCTNilIfNull(dict[@"column"]) integerValue]
|
||||
collapse:[RCTNilIfNull(dict[@"collapse"]) integerValue]];
|
||||
collapse:[RCTNilIfNull(dict[@"collapse"]) boolValue]];
|
||||
}
|
||||
|
||||
+ (NSArray<RCTJSStackFrame *> *)stackFramesWithLines:(NSString *)lines
|
||||
|
||||
@@ -113,7 +113,7 @@ RCT_NOT_IMPLEMENTED(-(instancetype)init)
|
||||
- (void)handleKeyUIEventSwizzle:(UIEvent *)event
|
||||
{
|
||||
NSString *modifiedInput = nil;
|
||||
UIKeyModifierFlags *modifierFlags = nil;
|
||||
UIKeyModifierFlags modifierFlags = 0;
|
||||
BOOL isKeyDown = NO;
|
||||
|
||||
if ([event respondsToSelector:@selector(_modifiedInput)]) {
|
||||
|
||||
@@ -97,4 +97,4 @@ typedef id<RCTBridgeModule> (^RCTBridgeModuleProvider)(void);
|
||||
@end
|
||||
|
||||
RCT_EXTERN void RCTSetIsMainQueueExecutionOfConstantsToExportDisabled(BOOL val);
|
||||
RCT_EXTERN BOOL RCTIsMainQueueExecutionOfConstantsToExportDisabled();
|
||||
RCT_EXTERN BOOL RCTIsMainQueueExecutionOfConstantsToExportDisabled(void);
|
||||
|
||||
@@ -1119,26 +1119,6 @@ RCT_NOT_IMPLEMENTED(-(instancetype)initWithBundleURL
|
||||
{
|
||||
}
|
||||
|
||||
- (void)reload
|
||||
{
|
||||
if (!_valid) {
|
||||
RCTLogWarn(
|
||||
@"Attempting to reload bridge before it's valid: %@. Try restarting the development server if connected.",
|
||||
self);
|
||||
}
|
||||
RCTTriggerReloadCommandListeners(@"Unknown from cxx bridge");
|
||||
}
|
||||
|
||||
- (void)reloadWithReason:(NSString *)reason
|
||||
{
|
||||
if (!_valid) {
|
||||
RCTLogWarn(
|
||||
@"Attempting to reload bridge before it's valid: %@. Try restarting the development server if connected.",
|
||||
self);
|
||||
}
|
||||
RCTTriggerReloadCommandListeners(reason);
|
||||
}
|
||||
|
||||
- (Class)executorClass
|
||||
{
|
||||
return _parentBridge.executorClass;
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
|
||||
#import "RCTUIManagerUtils.h"
|
||||
|
||||
#import <libkern/OSAtomic.h>
|
||||
#import <stdatomic.h>
|
||||
|
||||
#import "RCTAssert.h"
|
||||
|
||||
@@ -98,6 +98,6 @@ void RCTUnsafeExecuteOnUIManagerQueueSync(dispatch_block_t block)
|
||||
NSNumber *RCTAllocateRootViewTag()
|
||||
{
|
||||
// Numbering of these tags goes from 1, 11, 21, 31, ..., 100501, ...
|
||||
static int64_t rootViewTagCounter = -1;
|
||||
return @(OSAtomicIncrement64(&rootViewTagCounter) * 10 + 1);
|
||||
static _Atomic int64_t rootViewTagCounter = 0;
|
||||
return @(atomic_fetch_add_explicit(&rootViewTagCounter, 1, memory_order_relaxed) * 10 + 1);
|
||||
}
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
#import "RCTDefines.h"
|
||||
#import "RCTLog.h"
|
||||
#import "RCTModuleData.h"
|
||||
#import "RCTReloadCommand.h"
|
||||
#import "RCTUIManager.h"
|
||||
#import "RCTUIManagerUtils.h"
|
||||
#import "RCTUtils.h"
|
||||
@@ -378,7 +379,7 @@ void RCTProfileUnhookModules(RCTBridge *bridge)
|
||||
|
||||
+ (void)reload
|
||||
{
|
||||
[RCTProfilingBridge() reloadWithReason:@"Profiling controls"];
|
||||
RCTTriggerReloadCommandListeners(@"Profiling controls");
|
||||
}
|
||||
|
||||
+ (void)toggle:(UIButton *)target
|
||||
|
||||
@@ -15,6 +15,8 @@
|
||||
@class RCTShadowView;
|
||||
@class UIView;
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface RCTComponentData : NSObject
|
||||
|
||||
@property (nonatomic, readonly) Class managerClass;
|
||||
@@ -23,7 +25,7 @@
|
||||
|
||||
- (instancetype)initWithManagerClass:(Class)managerClass bridge:(RCTBridge *)bridge NS_DESIGNATED_INITIALIZER;
|
||||
|
||||
- (UIView *)createViewWithTag:(NSNumber *)tag rootTag:(NSNumber *)rootTag;
|
||||
- (UIView *)createViewWithTag:(nullable NSNumber *)tag rootTag:(nullable NSNumber *)rootTag;
|
||||
- (RCTShadowView *)createShadowViewWithTag:(NSNumber *)tag;
|
||||
- (void)setProps:(NSDictionary<NSString *, id> *)props forView:(id<RCTComponent>)view;
|
||||
- (void)setProps:(NSDictionary<NSString *, id> *)props forShadowView:(RCTShadowView *)shadowView;
|
||||
@@ -34,3 +36,5 @@
|
||||
- (NSDictionary<NSString *, id> *)viewConfig;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
|
||||
@@ -63,7 +63,7 @@ static SEL selectorForType(NSString *type)
|
||||
|
||||
RCT_NOT_IMPLEMENTED(-(instancetype)init)
|
||||
|
||||
- (UIView *)createViewWithTag:(NSNumber *)tag rootTag:(NSNumber *)rootTag
|
||||
- (UIView *)createViewWithTag:(nullable NSNumber *)tag rootTag:(nullable NSNumber *)rootTag
|
||||
{
|
||||
RCTAssertMainQueue();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user