Skip to content

Commit

Permalink
Move .m to .mm to make obj-c and C++ headers compatible (#38135)
Browse files Browse the repository at this point in the history
Summary:
Pull Request resolved: #38135

Changelog:
[iOS][Changed] - Move .m to .mm to make obj-c and C++ headers compatible

Reviewed By: RSNara

Differential Revision: D47140743

fbshipit-source-id: 1f1fb24571f5154b17992d6a71587803407b9dd1
  • Loading branch information
Lulu Wu authored and facebook-github-bot committed Jul 24, 2023
1 parent b06c2d7 commit 42d6745
Show file tree
Hide file tree
Showing 79 changed files with 187 additions and 72 deletions.
4 changes: 2 additions & 2 deletions packages/react-native/Libraries/AppDelegate/RCTAppDelegate.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
* LICENSE file in the root directory of this source tree.
*/

#import <React/RCTBridge.h>
#import <React/RCTBridgeDelegate.h>
#import <UIKit/UIKit.h>

@class RCTBridge;
@protocol RCTBridgeDelegate;
@protocol RCTComponentViewProtocol;
@class RCTSurfacePresenterBridgeAdapter;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,9 @@ Pod::Spec.new do |s|

if is_new_arch_enabled
s.dependency "React-BridgelessCore"
s.dependency "React-BridgelessHermes"
if ENV['USE_HERMES'] == nil || ENV['USE_HERMES'] == "1"
s.dependency "React-BridgelessHermes"
end
s.dependency "React-BridgelessApple"
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ BOOL RCTUpscalingRequired(

// Calculate aspect ratios if needed (don't bother if resizeMode == stretch)
CGFloat aspect = 0.0, targetAspect = 0.0;
if (resizeMode != UIViewContentModeScaleToFill) {
if (resizeMode != RCTResizeModeStretch) {
aspect = sourceSize.width / sourceSize.height;
targetAspect = destSize.width / destSize.height;
if (aspect == targetAspect) {
Expand Down Expand Up @@ -267,8 +267,8 @@ BOOL RCTUpscalingRequired(
CFRelease(sourceRef);
return nil;
}
NSNumber *width = CFDictionaryGetValue(imageProperties, kCGImagePropertyPixelWidth);
NSNumber *height = CFDictionaryGetValue(imageProperties, kCGImagePropertyPixelHeight);
NSNumber *width = (NSNumber *)CFDictionaryGetValue(imageProperties, kCGImagePropertyPixelWidth);
NSNumber *height = (NSNumber *)CFDictionaryGetValue(imageProperties, kCGImagePropertyPixelHeight);
CGSize sourceSize = {width.doubleValue, height.doubleValue};
CFRelease(imageProperties);

Expand All @@ -281,7 +281,7 @@ BOOL RCTUpscalingRequired(
destScale = RCTScreenScale();
}

if (resizeMode == UIViewContentModeScaleToFill) {
if (resizeMode == RCTResizeModeStretch) {
// Decoder cannot change aspect ratio, so RCTResizeModeStretch is equivalent
// to RCTResizeModeCover for our purposes
resizeMode = RCTResizeModeCover;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ Pod::Spec.new do |s|
"CLANG_CXX_LANGUAGE_STANDARD" => "c++17",
"HEADER_SEARCH_PATHS" => header_search_paths.join(' ')
}
s.framework = ["Accelerate", "UIKit"]

s.dependency "RCT-Folly", folly_version
s.dependency "React-Codegen", version
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ NS_ASSUME_NONNULL_BEGIN
RCT_EXTERN NSString *RCTInterpolateString(
NSString *pattern,
CGFloat inputValue,
NSArray *inputRange,
NSArray<NSNumber *> *inputRange,
NSArray<NSArray<NSNumber *> *> *outputRange,
NSString *extrapolateLeft,
NSString *extrapolateRight);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* LICENSE file in the root directory of this source tree.
*/

#import <React/RCTInterpolationAnimatedNode.h>
#import "RCTInterpolationAnimatedNode.h"

#import <React/RCTAnimationUtils.h>
#import <React/RCTConvert.h>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ uint32_t RCTColorFromComponents(CGFloat red, CGFloat green, CGFloat blue, CGFloa

#if TARGET_IPHONE_SIMULATOR
// Based on https://stackoverflow.com/a/13307674
float UIAnimationDragCoefficient(void);
UIKIT_EXTERN float UIAnimationDragCoefficient(void);
#endif

CGFloat RCTAnimationDragCoefficient(void)
Expand Down
4 changes: 3 additions & 1 deletion packages/react-native/Libraries/Text/React-RCTText.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,11 @@ Pod::Spec.new do |s|
s.author = "Meta Platforms, Inc. and its affiliates"
s.platforms = { :ios => min_ios_version_supported }
s.source = source
s.source_files = "**/*.{h,m}"
s.source_files = "**/*.{h,m,mm}"
s.preserve_paths = "package.json", "LICENSE", "LICENSE-docs"
s.header_dir = "RCTText"
s.framework = ["MobileCoreServices"]

s.dependency "Yoga"
s.dependency "React-Core/RCTTextHeaders", version
end
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ @implementation RCTInputAccessoryShadowView
- (void)insertReactSubview:(RCTShadowView *)subview atIndex:(NSInteger)atIndex
{
[super insertReactSubview:subview atIndex:atIndex];
subview.width = (YGValue){RCTScreenSize().width, YGUnitPoint};
subview.width = (YGValue){static_cast<float>(RCTScreenSize().width), YGUnitPoint};
}

@end
4 changes: 2 additions & 2 deletions packages/react-native/React-Core.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -91,15 +91,15 @@ Pod::Spec.new do |s|
"React/Fabric/**/*",
"React/FBReactNativeSpec/**/*",
"React/Tests/**/*",
"React/Inspector/**/*"
"React/Inspector/**/*",
]
# If we are using Hermes (the default is use hermes, so USE_HERMES can be nil), we don't have jsc installed
# So we have to exclude the JSCExecutorFactory
if ENV['USE_HERMES'] == nil || ENV['USE_HERMES'] == "1"
exclude_files = exclude_files.append("React/CxxBridge/JSCExecutorFactory.{h,mm}")
end
ss.exclude_files = exclude_files
ss.private_header_files = "React/Cxx*/*.h"
ss.private_header_files = "React/CxxLogUtils/*.h"
end

s.subspec "DevSupport" do |ss|
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,9 @@ - (UIWindow *)alertWindow

- (void)show:(BOOL)animated completion:(void (^)(void))completion
{
UIUserInterfaceStyle style =
RCTSharedApplication().delegate.window.overrideUserInterfaceStyle ?: UIUserInterfaceStyleUnspecified;
UIUserInterfaceStyle style = RCTSharedApplication().delegate.window.overrideUserInterfaceStyle
? RCTSharedApplication().delegate.window.overrideUserInterfaceStyle
: UIUserInterfaceStyleUnspecified;
self.overrideUserInterfaceStyle = style;

[self.alertWindow makeKeyAndVisible];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ - (instancetype)initWithFrame:(CGRect)frame color:(UIColor *)color
_length = (NSUInteger)floor(frame.size.width);
_height = (NSUInteger)floor(frame.size.height);
_scale = 60.0 / (CGFloat)_height;
_frames = calloc(sizeof(CGFloat), _length);
_frames = (CGFloat *)calloc(sizeof(CGFloat), _length);
_color = color;

[self.layer addSublayer:self.graph];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ Pod::Spec.new do |s|
"CLANG_CXX_LANGUAGE_STANDARD" => "c++17",
"HEADER_SEARCH_PATHS" => header_search_paths.join(" ")
}

s.framework = "UIKit"
s.dependency "React-Codegen", version
s.dependency "RCT-Folly", folly_version
s.dependency "RCTTypeSafety", version
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,14 @@ Pod::Spec.new do |s|
s.dependency "React-NativeModulesApple"
s.dependency "React-RCTFabric"
s.dependency "React-BridgelessCore"
s.dependency "React-BridgelessHermes"
s.dependency "React-Mapbuffer"
s.dependency "React-jserrorhandler"

if ENV["USE_HERMES"] == nil || ENV["USE_HERMES"] == "1"
s.dependency "hermes-engine"
s.dependency "React-BridgelessHermes"
else
s.dependency "React-jsi"
s.exclude_files = "platform/ios/Hermes/*.{mm,h}"
s.dependency "React-jsc"
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ Pod::Spec.new do |s|
if ENV["USE_HERMES"] == nil || ENV["USE_HERMES"] == "1"
s.dependency "hermes-engine"
else
s.dependency "React-jsi"
s.dependency "React-jsc"
end

end
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,6 @@ Pod::Spec.new do |s|
if ENV["USE_HERMES"] == nil || ENV["USE_HERMES"] == "1"
s.dependency "hermes-engine"
else
s.dependency "React-jsi"
s.dependency "React-jsc"
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
#import <React/RCTModuleData.h>
#import <React/RCTPerformanceLogger.h>
#import <React/RCTSurfacePresenter.h>
#import <ReactCommon/RCTLegacyUIManagerConstantsProvider.h>
#import <ReactCommon/RCTTurboModuleManager.h>
#import <ReactCommon/RuntimeExecutor.h>
#import <cxxreact/ReactMarker.h>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
#pragma once

#include <react/debug/react_native_assert.h>
#include <react/renderer/mapbuffer/MapBuffer.h>
#include <vector>
#include "MapBuffer.h"

namespace facebook::react {

Expand Down
4 changes: 3 additions & 1 deletion packages/react-native/scripts/cocoapods/bridgeless.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ def setup_bridgeless!(react_native_path: "../node_modules/react-native")
pod "React-jsitracing", :path => "#{react_native_path}/ReactCommon/hermes/executor/"
pod "React-runtimescheduler", :path => "#{react_native_path}/ReactCommon/react/renderer/runtimescheduler"
pod 'React-BridgelessCore', :path => "#{react_native_path}/ReactCommon/react/bridgeless"
pod 'React-BridgelessHermes', :path => "#{react_native_path}/ReactCommon/react/bridgeless"
if ENV["USE_HERMES"] == nil || ENV["USE_HERMES"] == "1"
pod 'React-BridgelessHermes', :path => "#{react_native_path}/ReactCommon/react/bridgeless"
end
pod 'React-BridgelessApple', :path => "#{react_native_path}/ReactCommon/react/bridgeless"
end
2 changes: 1 addition & 1 deletion packages/react-native/scripts/react_native_pods.rb
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ def use_react_native! (
pod 'Yoga', :path => "#{prefix}/ReactCommon/yoga", :modular_headers => true

pod 'DoubleConversion', :podspec => "#{prefix}/third-party-podspecs/DoubleConversion.podspec"
pod 'glog', :podspec => "#{prefix}/third-party-podspecs/glog.podspec", :modular_headers => true
pod 'glog', :podspec => "#{prefix}/third-party-podspecs/glog.podspec"
pod 'boost', :podspec => "#{prefix}/third-party-podspecs/boost.podspec"
pod 'RCT-Folly', :podspec => "#{prefix}/third-party-podspecs/RCT-Folly.podspec", :modular_headers => true

Expand Down
Loading

0 comments on commit 42d6745

Please sign in to comment.