mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-01-12 22:50:10 +08:00
Fix 50 xcode warnings (#23553)
Summary: This PR reduces the number of warnings in React from 68 to 18. Mostly by marking unused variables. RNTester's warnings are more than halved. [iOS] [Fixed] - Xcode warnings Pull Request resolved: https://github.com/facebook/react-native/pull/23553 Differential Revision: D14151339 Pulled By: hramos fbshipit-source-id: 8255330bf910a69a4c03051d91d7b0de3fadf2d1
This commit is contained in:
committed by
Facebook Github Bot
parent
ff588b5087
commit
19866aee3d
@@ -43,7 +43,7 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
- (instancetype)initWithBridge:(RCTBridge *)bridge
|
||||
moduleName:(NSString *)moduleName
|
||||
initialProperties:(NSDictionary *)initialProperties NS_DESIGNATED_INITIALIZER;
|
||||
initialProperties:(NSDictionary *)initialProperties;
|
||||
|
||||
#pragma mark - Dealing with UIView representation, the Main thread only access
|
||||
|
||||
|
||||
@@ -182,7 +182,7 @@
|
||||
|
||||
#pragma mark - Bridge Events
|
||||
|
||||
- (void)handleBridgeWillLoadJavaScriptNotification:(NSNotification *)notification
|
||||
- (void)handleBridgeWillLoadJavaScriptNotification:(__unused NSNotification *)notification
|
||||
{
|
||||
RCTAssertMainQueue();
|
||||
|
||||
@@ -505,19 +505,19 @@
|
||||
|
||||
#pragma mark - RCTSurfaceRootShadowViewDelegate
|
||||
|
||||
- (void)rootShadowView:(RCTRootShadowView *)rootShadowView didChangeIntrinsicSize:(CGSize)intrinsicSize
|
||||
- (void)rootShadowView:(__unused RCTRootShadowView *)rootShadowView didChangeIntrinsicSize:(CGSize)intrinsicSize
|
||||
{
|
||||
self.intrinsicSize = intrinsicSize;
|
||||
}
|
||||
|
||||
- (void)rootShadowViewDidStartRendering:(RCTSurfaceRootShadowView *)rootShadowView
|
||||
- (void)rootShadowViewDidStartRendering:(__unused RCTSurfaceRootShadowView *)rootShadowView
|
||||
{
|
||||
[self _setStage:RCTSurfaceStageSurfaceDidInitialRendering];
|
||||
|
||||
dispatch_semaphore_signal(_rootShadowViewDidStartRenderingSemaphore);
|
||||
}
|
||||
|
||||
- (void)rootShadowViewDidStartLayingOut:(RCTSurfaceRootShadowView *)rootShadowView
|
||||
- (void)rootShadowViewDidStartLayingOut:(__unused RCTSurfaceRootShadowView *)rootShadowView
|
||||
{
|
||||
[self _setStage:RCTSurfaceStageSurfaceDidInitialLayout];
|
||||
|
||||
@@ -531,7 +531,7 @@
|
||||
|
||||
#pragma mark - RCTUIManagerObserver
|
||||
|
||||
- (BOOL)uiManager:(RCTUIManager *)manager performMountingWithBlock:(RCTUIManagerMountingBlock)block
|
||||
- (BOOL)uiManager:(__unused RCTUIManager *) manager performMountingWithBlock:(RCTUIManagerMountingBlock)block
|
||||
{
|
||||
if (atomic_load(&_waitingForMountingStageOnMainQueue) && (self.stage & RCTSurfaceStageSurfaceDidInitialLayout)) {
|
||||
// Atomic equivalent of `_waitingForMountingStageOnMainQueue = NO;`.
|
||||
@@ -547,7 +547,7 @@
|
||||
return NO;
|
||||
}
|
||||
|
||||
- (void)uiManagerDidPerformMounting:(RCTUIManager *)manager
|
||||
- (void)uiManagerDidPerformMounting:(__unused RCTUIManager *)manager
|
||||
{
|
||||
if (self.stage & RCTSurfaceStageSurfaceDidInitialLayout) {
|
||||
[self _setStage:RCTSurfaceStageSurfaceDidInitialMounting];
|
||||
|
||||
@@ -226,14 +226,14 @@ RCT_NOT_IMPLEMENTED(- (nullable instancetype)initWithCoder:(NSCoder *)coder)
|
||||
|
||||
#pragma mark - RCTSurfaceDelegate
|
||||
|
||||
- (void)surface:(RCTSurface *)surface didChangeStage:(RCTSurfaceStage)stage
|
||||
- (void)surface:(__unused RCTSurface *)surface didChangeStage:(RCTSurfaceStage)stage
|
||||
{
|
||||
RCTExecuteOnMainQueue(^{
|
||||
[self setStage:stage];
|
||||
});
|
||||
}
|
||||
|
||||
- (void)surface:(RCTSurface *)surface didChangeIntrinsicSize:(CGSize)intrinsicSize
|
||||
- (void)surface:(__unused RCTSurface *)surface didChangeIntrinsicSize:(__unused CGSize)intrinsicSize
|
||||
{
|
||||
RCTExecuteOnMainQueue(^{
|
||||
[self _invalidateLayout];
|
||||
|
||||
@@ -15,7 +15,7 @@ namespace react {
|
||||
|
||||
std::unique_ptr<JSExecutor> JSCExecutorFactory::createJSExecutor(
|
||||
std::shared_ptr<ExecutorDelegate> delegate,
|
||||
std::shared_ptr<MessageQueueThread> jsQueue) {
|
||||
std::shared_ptr<MessageQueueThread> __unused jsQueue) {
|
||||
return folly::make_unique<JSIExecutor>(
|
||||
facebook::jsc::makeJSCRuntime(),
|
||||
delegate,
|
||||
|
||||
@@ -101,7 +101,7 @@ static bool isRAMBundle(NSData *script) {
|
||||
|
||||
static void registerPerformanceLoggerHooks(RCTPerformanceLogger *performanceLogger) {
|
||||
__weak RCTPerformanceLogger *weakPerformanceLogger = performanceLogger;
|
||||
ReactMarker::logTaggedMarker = [weakPerformanceLogger](const ReactMarker::ReactMarkerId markerId, const char *tag) {
|
||||
ReactMarker::logTaggedMarker = [weakPerformanceLogger](const ReactMarker::ReactMarkerId markerId, const char *__unused tag) {
|
||||
switch (markerId) {
|
||||
case ReactMarker::RUN_JS_BUNDLE_START:
|
||||
[weakPerformanceLogger markStartForTag:RCTPLScriptExecution];
|
||||
|
||||
@@ -97,7 +97,7 @@ public:
|
||||
RCTAssert(NO, @"RAM bundles are not supported in RCTObjcExecutor");
|
||||
}
|
||||
|
||||
void registerBundle(uint32_t bundleId, const std::string &bundlePath) override {
|
||||
void registerBundle(uint32_t __unused bundleId, const std::string __unused &bundlePath) override {
|
||||
RCTAssert(NO, @"RAM bundles are not supported in RCTObjcExecutor");
|
||||
}
|
||||
|
||||
|
||||
@@ -71,7 +71,7 @@ struct Registration {
|
||||
addObserverForName:RCTBundleURLProviderUpdatedNotification
|
||||
object:nil
|
||||
queue:[NSOperationQueue mainQueue]
|
||||
usingBlock:^(NSNotification *_Nonnull note) {
|
||||
usingBlock:^(NSNotification *_Nonnull __unused note) {
|
||||
[weakSelf bundleURLSettingsChanged];
|
||||
}];
|
||||
}
|
||||
@@ -198,7 +198,7 @@ static BOOL isSupportedVersion(NSNumber *version)
|
||||
|
||||
#pragma mark - RCTReconnectingWebSocketDelegate
|
||||
|
||||
- (void)reconnectingWebSocketDidOpen:(RCTReconnectingWebSocket *)webSocket
|
||||
- (void)reconnectingWebSocketDidOpen:(__unused RCTReconnectingWebSocket *)webSocket
|
||||
{
|
||||
std::vector<Registration<RCTConnectedHandler>> registrations;
|
||||
{
|
||||
@@ -259,7 +259,7 @@ static BOOL isSupportedVersion(NSNumber *version)
|
||||
}
|
||||
}
|
||||
|
||||
- (void)reconnectingWebSocketDidClose:(RCTReconnectingWebSocket *)webSocket
|
||||
- (void)reconnectingWebSocketDidClose:(__unused RCTReconnectingWebSocket *)webSocket
|
||||
{
|
||||
std::lock_guard<std::mutex> l(_mutex);
|
||||
_socketConnected = NO;
|
||||
|
||||
@@ -484,7 +484,11 @@ RCT_EXPORT_MODULE()
|
||||
self->_extraDataViewController = [RCTRedBoxExtraDataViewController new];
|
||||
self->_extraDataViewController.actionDelegate = self;
|
||||
}
|
||||
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
|
||||
[self->_bridge.eventDispatcher sendDeviceEventWithName:@"collectRedBoxExtraData" body:nil];
|
||||
#pragma clang diagnostic pop
|
||||
|
||||
if (!self->_window) {
|
||||
self->_window = [[RCTRedBoxWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
|
||||
|
||||
@@ -1179,7 +1179,7 @@ RCT_EXPORT_METHOD(dispatchViewManagerCommand:(nonnull NSNumber *)reactTag
|
||||
[tags addObject:shadowView.reactTag];
|
||||
}
|
||||
|
||||
[self addUIBlock:^(RCTUIManager *uiManager, NSDictionary<NSNumber *, UIView *> *viewRegistry) {
|
||||
[self addUIBlock:^(__unused RCTUIManager *uiManager, NSDictionary<NSNumber *, UIView *> *viewRegistry) {
|
||||
for (NSNumber *tag in tags) {
|
||||
UIView<RCTComponent> *view = viewRegistry[tag];
|
||||
[view didUpdateReactSubviews];
|
||||
@@ -1204,7 +1204,7 @@ RCT_EXPORT_METHOD(dispatchViewManagerCommand:(nonnull NSNumber *)reactTag
|
||||
[tags setObject:props forKey:shadowView.reactTag];
|
||||
}
|
||||
|
||||
[self addUIBlock:^(RCTUIManager *uiManager, NSDictionary<NSNumber *, UIView *> *viewRegistry) {
|
||||
[self addUIBlock:^(__unused RCTUIManager *uiManager, NSDictionary<NSNumber *, UIView *> *viewRegistry) {
|
||||
for (NSNumber *tag in tags) {
|
||||
UIView<RCTComponent> *view = viewRegistry[tag];
|
||||
[view didSetProps:[tags objectForKey:tag]];
|
||||
|
||||
@@ -167,9 +167,9 @@ RCT_EXTERN void RCTProfileSendResult(RCTBridge *bridge, NSString *route, NSData
|
||||
|
||||
typedef struct {
|
||||
const char *key;
|
||||
int key_len;
|
||||
unsigned long key_len;
|
||||
const char *value;
|
||||
int value_len;
|
||||
unsigned long value_len;
|
||||
} systrace_arg_t;
|
||||
|
||||
typedef struct {
|
||||
|
||||
@@ -52,7 +52,7 @@ static RCTFontWeight weightOfFont(UIFont *font)
|
||||
];
|
||||
});
|
||||
|
||||
for (NSInteger i = 0; i < fontNames.count; i++) {
|
||||
for (NSInteger i = 0; i < 0 || i < (unsigned)fontNames.count; i++) {
|
||||
if ([font.fontName.lowercaseString hasSuffix:fontNames[i]]) {
|
||||
return (RCTFontWeight)[fontWeights[i] doubleValue];
|
||||
}
|
||||
|
||||
@@ -69,7 +69,7 @@ numberOfRowsInComponent:(__unused NSInteger)component
|
||||
return [RCTConvert NSString:_items[row][@"label"]];
|
||||
}
|
||||
|
||||
- (CGFloat)pickerView:(UIPickerView *)pickerView rowHeightForComponent:(NSInteger)component {
|
||||
- (CGFloat)pickerView:(__unused UIPickerView *)pickerView rowHeightForComponent:(NSInteger)__unused component {
|
||||
return _font.pointSize + 19;
|
||||
}
|
||||
|
||||
|
||||
@@ -119,7 +119,7 @@ static NSURLCredential* clientAuthenticationCredential;
|
||||
* This method is called whenever JavaScript running within the web view calls:
|
||||
* - window.webkit.messageHandlers.[MessageHanderName].postMessage
|
||||
*/
|
||||
- (void)userContentController:(WKUserContentController *)userContentController
|
||||
- (void)userContentController:(__unused WKUserContentController *)userContentController
|
||||
didReceiveScriptMessage:(WKScriptMessage *)message
|
||||
{
|
||||
if (_onMessage != nil) {
|
||||
@@ -232,7 +232,7 @@ static NSURLCredential* clientAuthenticationCredential;
|
||||
* Decides whether to allow or cancel a navigation.
|
||||
* @see https://fburl.com/42r9fxob
|
||||
*/
|
||||
- (void) webView:(WKWebView *)webView
|
||||
- (void) webView:(__unused WKWebView *)webView
|
||||
decidePolicyForNavigationAction:(WKNavigationAction *)navigationAction
|
||||
decisionHandler:(void (^)(WKNavigationActionPolicy))decisionHandler
|
||||
{
|
||||
@@ -262,7 +262,7 @@ static NSURLCredential* clientAuthenticationCredential;
|
||||
if (![self.delegate webView:self
|
||||
shouldStartLoadForRequest:event
|
||||
withCallback:_onShouldStartLoadWithRequest]) {
|
||||
decisionHandler(WKNavigationResponsePolicyCancel);
|
||||
decisionHandler(WKNavigationActionPolicyCancel);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -281,15 +281,15 @@ static NSURLCredential* clientAuthenticationCredential;
|
||||
}
|
||||
|
||||
// Allow all navigation by default
|
||||
decisionHandler(WKNavigationResponsePolicyAllow);
|
||||
decisionHandler(WKNavigationActionPolicyAllow);
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when an error occurs while the web view is loading content.
|
||||
* @see https://fburl.com/km6vqenw
|
||||
*/
|
||||
- (void) webView:(WKWebView *)webView
|
||||
didFailProvisionalNavigation:(WKNavigation *)navigation
|
||||
- (void) webView:(__unused WKWebView *)webView
|
||||
didFailProvisionalNavigation:(__unused WKNavigation *)navigation
|
||||
withError:(NSError *)error
|
||||
{
|
||||
if (_onLoadingError) {
|
||||
@@ -318,7 +318,7 @@ static NSURLCredential* clientAuthenticationCredential;
|
||||
clientAuthenticationCredential = credential;
|
||||
}
|
||||
|
||||
- (void) webView:(WKWebView *)webView
|
||||
- (void) webView:(__unused WKWebView *)webView
|
||||
didReceiveAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge
|
||||
completionHandler:(void (^)(NSURLSessionAuthChallengeDisposition disposition, NSURLCredential * _Nullable))completionHandler
|
||||
{
|
||||
@@ -348,8 +348,8 @@ static NSURLCredential* clientAuthenticationCredential;
|
||||
* Called when the navigation is complete.
|
||||
* @see https://fburl.com/rtys6jlb
|
||||
*/
|
||||
- (void) webView:(WKWebView *)webView
|
||||
didFinishNavigation:(WKNavigation *)navigation
|
||||
- (void) webView:(__unused WKWebView *)webView
|
||||
didFinishNavigation:(__unused WKNavigation *)navigation
|
||||
{
|
||||
if (_messagingEnabled) {
|
||||
#if RCT_DEV
|
||||
|
||||
@@ -61,15 +61,15 @@ RCT_EXPORT_METHOD(postMessage:(nonnull NSNumber *)reactTag message:(NSString *)m
|
||||
}];
|
||||
}
|
||||
|
||||
RCT_CUSTOM_VIEW_PROPERTY(bounces, BOOL, RCTWKWebView) {
|
||||
RCT_CUSTOM_VIEW_PROPERTY(bounces, BOOL, __unused RCTWKWebView) {
|
||||
view.bounces = json == nil ? true : [RCTConvert BOOL: json];
|
||||
}
|
||||
|
||||
RCT_CUSTOM_VIEW_PROPERTY(scrollEnabled, BOOL, RCTWKWebView) {
|
||||
RCT_CUSTOM_VIEW_PROPERTY(scrollEnabled, BOOL, __unused RCTWKWebView) {
|
||||
view.scrollEnabled = json == nil ? true : [RCTConvert BOOL: json];
|
||||
}
|
||||
|
||||
RCT_CUSTOM_VIEW_PROPERTY(decelerationRate, CGFloat, RCTWKWebView) {
|
||||
RCT_CUSTOM_VIEW_PROPERTY(decelerationRate, CGFloat, __unused RCTWKWebView) {
|
||||
view.decelerationRate = json == nil ? UIScrollViewDecelerationRateNormal : [RCTConvert CGFloat: json];
|
||||
}
|
||||
|
||||
@@ -135,7 +135,7 @@ RCT_EXPORT_METHOD(stopLoading:(nonnull NSNumber *)reactTag)
|
||||
|
||||
#pragma mark - Exported synchronous methods
|
||||
|
||||
- (BOOL) webView:(RCTWKWebView *)webView
|
||||
- (BOOL) webView:(__unused RCTWKWebView *)webView
|
||||
shouldStartLoadForRequest:(NSMutableDictionary<NSString *, id> *)request
|
||||
withCallback:(RCTDirectEventBlock)callback
|
||||
{
|
||||
|
||||
@@ -33,10 +33,10 @@
|
||||
* Removing support for setting padding from any outside code
|
||||
* to prevent interferring this with local data.
|
||||
*/
|
||||
- (void)setPadding:(YGValue)value {}
|
||||
- (void)setPaddingLeft:(YGValue)value {}
|
||||
- (void)setPaddingRight:(YGValue)value {}
|
||||
- (void)setPaddingTop:(YGValue)value {}
|
||||
- (void)setPaddingBottom:(YGValue)value {}
|
||||
- (void)setPadding:(__unused YGValue)value {}
|
||||
- (void)setPaddingLeft:(__unused YGValue)value {}
|
||||
- (void)setPaddingRight:(__unused YGValue)value {}
|
||||
- (void)setPaddingTop:(__unused YGValue)value {}
|
||||
- (void)setPaddingBottom:(__unused YGValue)value {}
|
||||
|
||||
@end
|
||||
|
||||
@@ -759,7 +759,7 @@ RCT_SCROLL_EVENT_HANDLER(scrollViewDidScrollToTop, onScrollToTop)
|
||||
CGFloat smallerOffset = 0.0;
|
||||
CGFloat largerOffset = maximumOffset;
|
||||
|
||||
for (int i = 0; i < self.snapToOffsets.count; i++) {
|
||||
for (unsigned long i = 0; i < self.snapToOffsets.count; i++) {
|
||||
CGFloat offset = [[self.snapToOffsets objectAtIndex:i] floatValue];
|
||||
|
||||
if (offset <= targetOffset) {
|
||||
@@ -1024,7 +1024,7 @@ RCT_SCROLL_EVENT_HANDLER(scrollViewDidScrollToTop, onScrollToTop)
|
||||
- (void)uiManagerWillPerformMounting:(RCTUIManager *)manager
|
||||
{
|
||||
RCTAssertUIManagerQueue();
|
||||
[manager prependUIBlock:^(RCTUIManager *uiManager, NSDictionary<NSNumber *, UIView *> *viewRegistry) {
|
||||
[manager prependUIBlock:^(__unused RCTUIManager *uiManager, __unused NSDictionary<NSNumber *, UIView *> *viewRegistry) {
|
||||
BOOL horz = [self isHorizontal:self->_scrollView];
|
||||
NSUInteger minIdx = [self->_maintainVisibleContentPosition[@"minIndexForVisible"] integerValue];
|
||||
for (NSUInteger ii = minIdx; ii < self->_contentView.subviews.count; ++ii) {
|
||||
@@ -1041,7 +1041,7 @@ RCT_SCROLL_EVENT_HANDLER(scrollViewDidScrollToTop, onScrollToTop)
|
||||
}
|
||||
}
|
||||
}];
|
||||
[manager addUIBlock:^(RCTUIManager *uiManager, NSDictionary<NSNumber *, UIView *> *viewRegistry) {
|
||||
[manager addUIBlock:^(__unused RCTUIManager *uiManager, __unused NSDictionary<NSNumber *, UIView *> *viewRegistry) {
|
||||
if (self->_maintainVisibleContentPosition == nil) {
|
||||
return; // The prop might have changed in the previous UIBlocks, so need to abort here.
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user