mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Summary: Fix build failure on iOS with pnpm and use_frameworks! due to cocoapods copying symlinked headers to wrong paths When using pnpm all packages are symlinked to node_modules/.pnpm to prevent phantom dependency resolution. This causes react-native iOS build to fail because Cocoapods copies headers to incorrect destinations when they're behind symlinks. The fix resolves absolute paths to the header_mappings_dir at pod install time. With absolute paths cocoapods copies the headers correctly. This commit also adds a few missing header search paths in use_frameworks! mode. Fixes https://github.com/facebook/react-native/issues/38140 ## Changelog: <!-- Help reviewers and the release process by writing your own changelog entry. Pick one each for the category and type tags: [IOS] [FIXED] - Build failure with pnpm and use_frameworks! due to incorrect header paths For more details, see: https://reactnative.dev/contributing/changelogs-in-pull-requests Pull Request resolved: https://github.com/facebook/react-native/pull/38158 Test Plan: 1. `pnpm pnpx react-native@latest init AwesomeProject` 2. `cd AwesomeProject` 3. `rm -rf node_modules yarn.lock` 4. `mkdir patches` 5. copy [react-native@0.72.1.patch](https://github.com/facebook/react-native/files/11937570/react-native%400.72.1.patch) to `patches/` 6. Add patch to package.json ``` "pnpm": { "patchedDependencies": { "react-native@0.72.1": "patches/react-native@0.72.1.patch" } } ``` 7. `pnpm install` 8. `cd ios` 9. `NO_FLIPPER=1 USE_FRAMEWORKS=static pod install` 10. `cd ..` 11. `pnpm react-native run-ios` Hopefully an automated test of building with `pnpm` can be added to CI. I don't know how to make that happen, hopefully someone at facebook can do it. Reviewed By: dmytrorykun Differential Revision: D47211946 Pulled By: cipolleschi fbshipit-source-id: 87640bd3f32f023c43291213b5291a7b990d7e1f
65 lines
2.9 KiB
Ruby
65 lines
2.9 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.07.22.00'
|
||
|
||
header_search_paths = [
|
||
"\"$(PODS_ROOT)/RCT-Folly\"",
|
||
"\"${PODS_ROOT}/Headers/Public/React-Codegen/react/renderer/components\"",
|
||
"\"${PODS_CONFIGURATION_BUILD_DIR}/React-Codegen/React_Codegen.framework/Headers\""
|
||
]
|
||
|
||
if ENV["USE_FRAMEWORKS"]
|
||
header_search_paths = header_search_paths.concat([
|
||
"\"$(PODS_CONFIGURATION_BUILD_DIR)/ReactCommon/ReactCommon.framework/Headers/react/nativemodule/core\"",
|
||
"\"$(PODS_CONFIGURATION_BUILD_DIR)/React-NativeModulesApple/React_NativeModulesApple.framework/Headers\"",
|
||
"\"$(PODS_CONFIGURATION_BUILD_DIR)/React-NativeModulesApple/React_NativeModulesApple.framework/Headers/build/generated/ios\"",
|
||
"\"$(PODS_CONFIGURATION_BUILD_DIR)/React-Codegen/React_Codegen.framework/Headers/build/generated/ios\"",
|
||
"\"$(PODS_CONFIGURATION_BUILD_DIR)/React-Codegen/React_Codegen.framework/Headers\"",
|
||
])
|
||
end
|
||
|
||
Pod::Spec.new do |s|
|
||
s.name = "React-RCTSettings"
|
||
s.version = version
|
||
s.summary = "A wrapper for NSUserDefaults, a persistent key-value store available only on iOS."
|
||
s.homepage = "https://reactnative.dev/"
|
||
s.documentation_url = "https://reactnative.dev/docs/settings"
|
||
s.license = package["license"]
|
||
s.author = "Meta Platforms, Inc. and its affiliates"
|
||
s.platforms = { :ios => "12.4" }
|
||
s.compiler_flags = folly_compiler_flags + ' -Wno-nullability-completeness'
|
||
s.source = source
|
||
s.source_files = "*.{m,mm}"
|
||
s.preserve_paths = "package.json", "LICENSE", "LICENSE-docs"
|
||
s.header_dir = "RCTSettings"
|
||
s.pod_target_xcconfig = {
|
||
"USE_HEADERMAP" => "YES",
|
||
"CLANG_CXX_LANGUAGE_STANDARD" => "c++17",
|
||
"HEADER_SEARCH_PATHS" => header_search_paths.join(' ')
|
||
}
|
||
|
||
s.dependency "RCT-Folly", folly_version
|
||
s.dependency "React-Codegen", version
|
||
s.dependency "RCTTypeSafety", version
|
||
s.dependency "ReactCommon/turbomodule/core", version
|
||
s.dependency "React-jsi", version
|
||
s.dependency "React-Core/RCTSettingsHeaders", version
|
||
end
|