mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
7dc0b5153e
Summary: Fixes https://github.com/facebook/react-native/issues/30708. When given the `--port` option to the `npx react-native run-ios` command, [the React Native CLI passes the `RCT_METRO_PORT` variable when calling `xcodebuild`](https://github.com/react-native-community/cli/blob/ada951606e52ad98346cd72beeb15b56ceda8b7c/packages/platform-ios/src/commands/runIOS/index.ts#L552). This used to adjust the port used when building on iOS, but this appears to have stopped working when the xcodeproj configuration was removed in favor of CocoaPods ([link, load the diff for React.xcodeproj](https://github.com/facebook/react-native/commit/79a7828b91b405de7399cd8cdc1aaaf610ce9d75#diff-43a2b2682727878049c3283b9361d9ad94964b63105fda6a834ba23baa5b471bL5199-L5205)). This change re-adds the preprocessor definition that was used to pull the environment variable in, and now the `--port` flag works again. ## Changelog [iOS] [Fixed] - Fixed the ability to pass the port to use for Metro when running `react-native run-ios --port <port>`. Pull Request resolved: https://github.com/facebook/react-native/pull/33726 Test Plan: 1. Using an example project generated from the 0.68.1 template, I modified `node_modules/react-native/React-Core.podspec` to have the same changes. 2. Deleted my project's `ios/Pods` folder and re-ran `bundle exec pod install` 3. Ran `yarn ios --port=9900` and verified that the app is connected to Metro, and check again with a refresh of the app. 4. Verified that I saw traffic on port 9900 when refreshing the app with `sudo lsof -i :9900` 5. Stopped the app and tested `yarn ios` without a port, and used `lsof` again to ensure it was using the default port `8081` again I also ran the iOS tests locally and they passed. Reviewed By: dmitryrykun Differential Revision: D36097840 Pulled By: cipolleschi fbshipit-source-id: c3f31789e15f6cd3386350e917cfa715b2d7fd58
96 lines
4.3 KiB
Ruby
96 lines
4.3 KiB
Ruby
# Copyright (c) Meta Platforms, Inc. and affiliates.
|
||
#
|
||
# This source code is licensed under the MIT license found in the
|
||
# LICENSE file in the root directory of this source tree.
|
||
|
||
require "json"
|
||
|
||
package = JSON.parse(File.read(File.join(__dir__, "package.json")))
|
||
version = package['version']
|
||
|
||
source = { :git => 'https://github.com/facebook/react-native.git' }
|
||
if version == '1000.0.0'
|
||
# This is an unpublished version, use the latest commit hash of the react-native repo, which we’re presumably in.
|
||
source[:commit] = `git rev-parse HEAD`.strip if system("git rev-parse --git-dir > /dev/null 2>&1")
|
||
else
|
||
source[:tag] = "v#{version}"
|
||
end
|
||
|
||
folly_compiler_flags = '-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1 -Wno-comma -Wno-shorten-64-to-32'
|
||
folly_version = '2021.06.28.00-v2'
|
||
boost_compiler_flags = '-Wno-documentation'
|
||
|
||
header_subspecs = {
|
||
'CoreModulesHeaders' => 'React/CoreModules/**/*.h',
|
||
'RCTActionSheetHeaders' => 'Libraries/ActionSheetIOS/*.h',
|
||
'RCTAnimationHeaders' => 'Libraries/NativeAnimation/{Drivers/*,Nodes/*,*}.{h}',
|
||
'RCTBlobHeaders' => 'Libraries/Blob/{RCTBlobManager,RCTFileReaderModule}.h',
|
||
'RCTImageHeaders' => 'Libraries/Image/*.h',
|
||
'RCTLinkingHeaders' => 'Libraries/LinkingIOS/*.h',
|
||
'RCTNetworkHeaders' => 'Libraries/Network/*.h',
|
||
'RCTPushNotificationHeaders' => 'Libraries/PushNotificationIOS/*.h',
|
||
'RCTSettingsHeaders' => 'Libraries/Settings/*.h',
|
||
'RCTTextHeaders' => 'Libraries/Text/**/*.h',
|
||
'RCTVibrationHeaders' => 'Libraries/Vibration/*.h',
|
||
}
|
||
|
||
Pod::Spec.new do |s|
|
||
s.name = "React-Core"
|
||
s.version = version
|
||
s.summary = "The core of React Native."
|
||
s.homepage = "https://reactnative.dev/"
|
||
s.license = package["license"]
|
||
s.author = "Facebook, Inc. and its affiliates"
|
||
s.platforms = { :ios => "12.4" }
|
||
s.source = source
|
||
s.resource_bundle = { "AccessibilityResources" => ["React/AccessibilityResources/*.lproj"]}
|
||
s.compiler_flags = folly_compiler_flags + ' ' + boost_compiler_flags
|
||
s.header_dir = "React"
|
||
s.framework = "JavaScriptCore"
|
||
s.pod_target_xcconfig = { "HEADER_SEARCH_PATHS" => "\"$(PODS_TARGET_SRCROOT)/ReactCommon\" \"$(PODS_ROOT)/boost\" \"$(PODS_ROOT)/DoubleConversion\" \"$(PODS_ROOT)/RCT-Folly\" \"${PODS_ROOT}/Headers/Public/React-hermes\" \"${PODS_ROOT}/Headers/Public/hermes-engine\" \"${PODS_ROOT}/Headers/Public/FlipperKit\" \"$(PODS_ROOT)/Headers/Public/ReactCommon\" \"$(PODS_ROOT)/Headers/Public/React-RCTFabric\"", "DEFINES_MODULE" => "YES", "GCC_PREPROCESSOR_DEFINITIONS" => "RCT_METRO_PORT=${RCT_METRO_PORT}" }
|
||
s.user_target_xcconfig = { "HEADER_SEARCH_PATHS" => "\"$(PODS_ROOT)/Headers/Private/React-Core\""}
|
||
s.default_subspec = "Default"
|
||
|
||
s.subspec "Default" do |ss|
|
||
ss.source_files = "React/**/*.{c,h,m,mm,S,cpp}"
|
||
ss.exclude_files = "React/CoreModules/**/*",
|
||
"React/DevSupport/**/*",
|
||
"React/Fabric/**/*",
|
||
"React/FBReactNativeSpec/**/*",
|
||
"React/Tests/**/*",
|
||
"React/Inspector/**/*"
|
||
ss.private_header_files = "React/Cxx*/*.h"
|
||
end
|
||
|
||
s.subspec "DevSupport" do |ss|
|
||
ss.source_files = "React/DevSupport/*.{h,mm,m}",
|
||
"React/Inspector/*.{h,mm,m}"
|
||
|
||
ss.dependency "React-Core/Default", version
|
||
ss.dependency "React-Core/RCTWebSocket", version
|
||
ss.dependency "React-jsinspector", version
|
||
end
|
||
|
||
s.subspec "RCTWebSocket" do |ss|
|
||
ss.source_files = "Libraries/WebSocket/*.{h,m}"
|
||
ss.dependency "React-Core/Default", version
|
||
end
|
||
|
||
# Add a subspec containing just the headers for each
|
||
# pod that should live under <React/*.h>
|
||
header_subspecs.each do |name, headers|
|
||
s.subspec name do |ss|
|
||
ss.source_files = headers
|
||
ss.dependency "React-Core/Default"
|
||
end
|
||
end
|
||
|
||
s.dependency "RCT-Folly", folly_version
|
||
s.dependency "React-cxxreact", version
|
||
s.dependency "React-perflogger", version
|
||
s.dependency "React-jsi", version
|
||
s.dependency "React-jsiexecutor", version
|
||
s.dependency "Yoga"
|
||
s.dependency "glog"
|
||
end
|