Skip to content

[ios][prebuild] Added backwards compatible use of prebuild through cocoapods #52223

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 31 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
269456c
[ios-prebuild] Implemented support for prebuilt in cocoapods
chrfalch Jun 18, 2025
1e8c963
refactor: extract abort code to helper function
cipolleschi Jun 19, 2025
0e91ead
refactor: simplify if check
cipolleschi Jun 19, 2025
7b456c0
refactor: rename podspec_source_download_prebuild_release_tarball to …
cipolleschi Jun 19, 2025
5adfe16
rename: release_tarball_url to stable
cipolleschi Jun 19, 2025
e0b0756
fix: handle XML requests properly
cipolleschi Jun 19, 2025
93dc62a
fix: remove resolve_redirect as it is not used
cipolleschi Jun 19, 2025
742c205
fix: remove resolve_redirect from rndependencies as it is not used
cipolleschi Jun 19, 2025
284a20b
refactor: abort if use local rndeps when no file is present
cipolleschi Jun 19, 2025
ad732b8
fix: fix build from source
cipolleschi Jun 19, 2025
08a6a1a
chore: add task to TODO
cipolleschi Jun 19, 2025
0aa7989
fix: revert change to dSYM path
cipolleschi Jun 19, 2025
6f1e48d
[ios][prebuild] fixed missing changes to ReactCodegen.podspec.template
chrfalch Jun 19, 2025
3252173
[ios][prebuild] fixed header search paths in ReactCodegen template
chrfalch Jun 19, 2025
b7b0013
fix: support build rn core from source with prebuild rn dep
cipolleschi Jun 19, 2025
27d152c
Update snapshot of ReactCodegen.podspec.template
cipolleschi Jun 19, 2025
c863979
fix: reset Podfile
cipolleschi Jun 19, 2025
9eb756e
[ios][prebuild] added missing RCTVibration target to Package.swift
chrfalch Jun 24, 2025
e500cbc
[ios][prebuild] Updated Podspecs to be backwards compatible
chrfalch Jun 24, 2025
7ad9227
[ios][prebuild] Added use of the podspec_sources function
chrfalch Jun 24, 2025
af385d5
[ios][prebuild] Reverted changes to ReactCodegen podspec template
chrfalch Jun 24, 2025
c018d47
[ios][prebuild] Added use of podspec_sources in React-RCTTest.podspec
chrfalch Jun 24, 2025
1d1048c
Merge branch 'main' into @chrfalch/cocoa-pods-rn-core-final
cipolleschi Jun 24, 2025
91ce089
chore: remove .build-with-prebuilds file
cipolleschi Jun 24, 2025
300ea08
fix: update ReactCodegen test snapshot
cipolleschi Jun 24, 2025
4b03118
fix: use a single definition for hermes-engine
cipolleschi Jun 24, 2025
888902c
[ios][prebuild] fixed wrong type of source file
chrfalch Jun 24, 2025
e04f0e1
fix: cocoapods also in hybrid mode (RNDep prebuild)
cipolleschi Jun 24, 2025
a42b9f7
chore: reset Podfile.lock
cipolleschi Jun 24, 2025
0d69d2d
fix: use the right source_files for modal
cipolleschi Jun 24, 2025
d44a228
Merge remote-tracking branch 'origin/main' into @chrfalch/cocoa-pods-…
cipolleschi Jun 25, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ Pod::Spec.new do |s|
s.author = "Meta Platforms, Inc. and its affiliates"
s.platforms = min_supported_versions
s.source = source
s.source_files = "*.{m}"
s.source_files = podspec_sources("*.{m}", "")
s.preserve_paths = "package.json", "LICENSE", "LICENSE-docs"
s.header_dir = "RCTActionSheet"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ Pod::Spec.new do |s|
s.author = "Meta Platforms, Inc. and its affiliates"
s.platforms = min_supported_versions
s.source = source
s.source_files = "**/*.{c,h,m,mm,S,cpp}"
s.source_files = podspec_sources("**/*.{c,h,m,mm,S,cpp}", "**/*.h")

# This guard prevent to install the dependencies when we run `pod install` in the old architecture.
s.compiler_flags = other_cflags
Expand Down
2 changes: 1 addition & 1 deletion packages/react-native/Libraries/Blob/React-RCTBlob.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ Pod::Spec.new do |s|
s.platforms = min_supported_versions
s.compiler_flags = '-Wno-nullability-completeness'
s.source = source
s.source_files = "*.{h,m,mm}"
s.source_files = podspec_sources("*.{h,m,mm}", "**/*.h")
s.preserve_paths = "package.json", "LICENSE", "LICENSE-docs"
s.header_dir = "RCTBlob"
s.pod_target_xcconfig = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ Pod::Spec.new do |s|
s.author = "Meta Platforms, Inc. and its affiliates"
s.platforms = min_supported_versions
s.source = source
s.source_files = "**/*.{c,h,m,mm,cpp}"
s.source_files = podspec_sources("**/*.{c,h,m,mm,cpp}", "**/*.h")
s.header_dir = "FBLazyVector"

end
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ Pod::Spec.new do |s|
s.platforms = min_supported_versions
s.compiler_flags = '-Wno-nullability-completeness'
s.source = source
s.source_files = "*.{m,mm}"
s.source_files = podspec_sources("*.{m,mm}", "**/*.h")
s.preserve_paths = "package.json", "LICENSE", "LICENSE-docs"
s.header_dir = "RCTImage"
s.pod_target_xcconfig = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ Pod::Spec.new do |s|
s.platforms = min_supported_versions
s.compiler_flags = '-Wno-nullability-completeness'
s.source = source
s.source_files = "*.{m,mm}"
s.source_files = podspec_sources("*.{m,mm}", "")
s.preserve_paths = "package.json", "LICENSE", "LICENSE-docs"
s.header_dir = "RCTLinking"
s.pod_target_xcconfig = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ Pod::Spec.new do |s|
s.platforms = min_supported_versions
s.compiler_flags = '-Wno-nullability-completeness'
s.source = source
s.source_files = "**/*.{h,m,mm}"
s.source_files = podspec_sources("**/*.{h,m,mm}", "**/*.h")
s.preserve_paths = "package.json", "LICENSE", "LICENSE-docs"
s.header_dir = "RCTAnimation"
s.pod_target_xcconfig = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ Pod::Spec.new do |s|
s.platforms = min_supported_versions
s.compiler_flags = '-Wno-nullability-completeness'
s.source = source
s.source_files = "*.{m,mm}"
s.source_files = podspec_sources("*.{m,mm}", "")
s.preserve_paths = "package.json", "LICENSE", "LICENSE-docs"
s.header_dir = "RCTNetwork"
s.pod_target_xcconfig = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,6 @@ Pod::Spec.new do |s|
s.author = "Meta Platforms, Inc. and its affiliates"
s.platforms = min_supported_versions
s.source = source
s.source_files = "**/*.{c,h,m,mm,cpp}"
s.source_files = podspec_sources("**/*.{c,h,m,mm,cpp}", "**/*.h")
s.header_dir = "RCTRequired"
end
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ Pod::Spec.new do |s|
s.platforms = min_supported_versions
s.compiler_flags = '-Wno-nullability-completeness'
s.source = source
s.source_files = "*.{m,mm}"
s.source_files = podspec_sources("*.{m,mm}", "**/*.h")
s.preserve_paths = "package.json", "LICENSE", "LICENSE-docs"
s.header_dir = "RCTSettings"
s.pod_target_xcconfig = {
Expand Down
2 changes: 1 addition & 1 deletion packages/react-native/Libraries/Text/React-RCTText.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ Pod::Spec.new do |s|
s.author = "Meta Platforms, Inc. and its affiliates"
s.platforms = min_supported_versions
s.source = source
s.source_files = "**/*.{h,m,mm}"
s.source_files = podspec_sources("**/*.{h,m,mm}", "**/*.h")
s.preserve_paths = "package.json", "LICENSE", "LICENSE-docs"
s.header_dir = "RCTText"
s.framework = ["MobileCoreServices"]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ Pod::Spec.new do |s|
s.author = "Meta Platforms, Inc. and its affiliates"
s.platforms = min_supported_versions
s.source = source
s.source_files = "**/*.{c,h,m,mm,cpp}"
s.source_files = podspec_sources("**/*.{c,h,m,mm,cpp}", "**/*.h")
s.header_dir = "RCTTypeSafety"
s.pod_target_xcconfig = {
"USE_HEADERMAP" => "YES",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ Pod::Spec.new do |s|
s.platforms = min_supported_versions
s.compiler_flags = '-Wno-nullability-completeness'
s.source = source
s.source_files = "*.{m,mm}"
s.source_files = podspec_sources("*.{m,mm}", "**/*.h")
s.preserve_paths = "package.json", "LICENSE", "LICENSE-docs"
s.header_dir = "RCTVibration"
s.pod_target_xcconfig = {
Expand Down
10 changes: 10 additions & 0 deletions packages/react-native/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -495,6 +495,14 @@ let reactRCTNetwork = RNTarget(
dependencies: [.yoga, .jsi, .reactTurboModuleCore]
)

/// React-RCTVibration.podspec
let reactRCTVibration = RNTarget(
name: .reactRCTVibration,
path: "Libraries/Vibration",
linkedFrameworks: ["AudioToolbox"],
dependencies: [.yoga, .jsi, .reactTurboModuleCore]
)

/// React-RCTAppDelegate.podspec
let reactAppDelegate = RNTarget(
name: .reactAppDelegate,
Expand Down Expand Up @@ -560,6 +568,7 @@ let targets = [
reactRCTText,
reactRCTBlob,
reactRCTNetwork,
reactRCTVibration,
reactRCTLinking,
reactCoreModules,
reactTurboModuleBridging,
Expand Down Expand Up @@ -731,6 +740,7 @@ extension String {
static let reactRCTText = "React-RCTText"
static let reactRCTBlob = "React-RCTBlob"
static let reactRCTNetwork = "React-RCTNetwork"
static let reactRCTVibration = "React-RCTVibration"
static let reactRCTActionSheet = "React-RCTActionSheet" // Empty target
static let reactRCTLinking = "React-RCTLinking"
static let reactCoreModules = "React-CoreModules"
Expand Down
94 changes: 32 additions & 62 deletions packages/react-native/React-Core-prebuilt.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -4,76 +4,47 @@
# 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 = ReactNativeCoreUtils.resolve_podspec_source()

header_search_paths = [
"${PODS_ROOT}/Headers/Private/React-Core-prebuilt",
"${PODS_ROOT}/Headers/Private/React-Core-prebuilt/RCTDeprecation",
"${PODS_ROOT}/Headers/Private/React-Core-prebuilt/ReactCommon/yoga",
"${PODS_ROOT}/Headers/Private/React-Core-prebuilt/ReactCommon",
"${PODS_ROOT}/Headers/Private/React-Core-prebuilt/Libraries/AppDelegate",
"${PODS_ROOT}/Headers/Private/React-Core-prebuilt/Libraries",

"$(REACT_NATIVE_PATH)/React/Base",
"$(REACT_NATIVE_PATH)/ReactCommon",
"$(REACT_NATIVE_PATH)/Libraries",
"$(REACT_NATIVE_PATH)/ReactApple",
"$(REACT_NATIVE_PATH)/ReactCxxPlatform",
"$(REACT_NATIVE_PATH)/ReactCommon/react/runtime/platform/ios",
"${REACT_NATIVE_PATH}/ReactCommon/jsi",
"$(REACT_NATIVE_PATH)/ReactCommon/jsiexecutor/",
"$(REACT_NATIVE_PATH)/ReactCommon/react/nativemodule/samples/platform/ios",
"$(REACT_NATIVE_PATH)/ReactCommon/react/nativemodule/samples",
]

Pod::Spec.new do |spec|
spec.name = 'React-Core-prebuilt'
spec.version = version
spec.summary = "Prebuilt core of React Native."
spec.homepage = "https://reactnative.dev/"
spec.description = 'Prebuilt React Native Core libraries and headers'
spec.homepage = 'https://github.com/facebook/react-native'
spec.license = package['license']
spec.authors = 'meta'
spec.platforms = min_supported_versions
spec.source = source

spec.vendored_frameworks = "React.xcframework"

spec.preserve_paths = '**/*.*'
spec.header_mappings_dir = 'React.xcframework/Headers'
spec.source_files = 'React.xcframework/Headers/**/*.{h,hpp}'

spec.module_name = 'React'
spec.module_map = 'React.xcframework/Modules/module.modulemap'
spec.public_header_files = 'React.xcframework/Headers/**/*.h'

# Setup the consuming project's search paths
spec.user_target_xcconfig = {
"HEADER_SEARCH_PATHS" => header_search_paths,
"SWIFT_INCLUDE_PATHS" => "${PODS_ROOT}/Headers/Private/React-Core-prebuilt",
'DEFINES_MODULE' => 'YES',
'CLANG_ENABLE_MODULES' => 'YES',
}

spec.pod_target_xcconfig = {
'WARNING_CFLAGS' => '-Wno-comma -Wno-shorten-64-to-32',
"CLANG_CXX_LANGUAGE_STANDARD" => rct_cxx_language_standard(),
'DEFINES_MODULE' => 'YES',
'CLANG_ENABLE_MODULES' => 'YES',
}
Pod::Spec.new do |s|
s.name = "React-Core-prebuilt"
s.version = version
s.summary = "The core of React Native prebuilt frameworks."
s.homepage = "https://reactnative.dev/"
s.license = package["license"]
s.author = "Meta Platforms, Inc. and its affiliates"
s.platforms = min_supported_versions
s.source = source
s.vendored_frameworks = "React.xcframework"

s.preserve_paths = '**/*.*'
s.header_mappings_dir = 'React.xcframework/Headers'
s.source_files = 'React.xcframework/Headers/**/*.{h,hpp}'

s.module_name = 'React'
s.module_map = 'React.xcframework/Modules/module.modulemap'
s.public_header_files = 'React.xcframework/Headers/**/*.h'

add_rn_third_party_dependencies(s)

# We need to make sure that the React.xcframework is copied correctly - in the downloaded tarball
# the root directory is the framework, but when using it we need to have it in a subdirectory
# called React.xcframework, so we need to move the contents of the tarball into that directory.
# This is done in the prepare_command.
spec.prepare_command = <<~'CMD'
# We need to make sure that the headers are copied to the right place - local tar.gz has a different structure
# than the one from the maven repo
s.prepare_command = <<~'CMD'
CURRENT_PATH=$(pwd)
XCFRAMEWORK_PATH="${CURRENT_PATH}/React.xcframework"
# Check if XCFRAMEWORK_PATH is empty
if [ -z "$XCFRAMEWORK_PATH" ]; then
echo "ERROR: XCFRAMEWORK_PATH is empty."
exit 0
fi
mkdir -p "${XCFRAMEWORK_PATH}"
find "$CURRENT_PATH" -mindepth 1 -maxdepth 1 ! -name "$(basename "$XCFRAMEWORK_PATH")" -exec mv {} "$XCFRAMEWORK_PATH" \;
CMD
Expand Down Expand Up @@ -102,8 +73,7 @@ Pod::Spec.new do |spec|
# always run the script without warning
script_phase[:always_out_of_date] = "1"
end

spec.script_phase = script_phase
s.script_phase = script_phase
end

end
17 changes: 12 additions & 5 deletions packages/react-native/React-Core.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ Pod::Spec.new do |s|
s.default_subspec = "Default"

s.subspec "Default" do |ss|
ss.source_files = "React/**/*.{c,h,m,mm,S,cpp}"
ss.source_files = podspec_sources("React/**/*.{c,h,m,mm,S,cpp}", "React/**/*.h")
exclude_files = [
"React/CoreModules/**/*",
"React/DevSupport/**/*",
Expand All @@ -76,25 +76,32 @@ Pod::Spec.new do |s|
"React/Inspector/**/*",
"React/Runtime/**/*",
]

# The default is use hermes, we don't have jsc installed
exclude_files = exclude_files.append("React/CxxBridge/JSCExecutorFactory.{h,mm}")

ss.exclude_files = exclude_files
ss.private_header_files = "React/Cxx*/*.h"

# Include prebuilt if we're not building from source
if !ReactNativeCoreUtils.build_rncore_from_source()
ss.dependency "React-Core-prebuilt", version
end
end

s.subspec "DevSupport" do |ss|
ss.source_files = "React/DevSupport/*.{h,mm,m}",
"React/Inspector/*.{h,mm,m}"
ss.source_files = podspec_sources(["React/DevSupport/*.{h,mm,m}",
"React/Inspector/*.{h,mm,m}"],
["React/DevSupport/*.h",
"React/Inspector/*.h"])

ss.dependency "React-Core/Default", version
ss.dependency "React-Core/RCTWebSocket", version
ss.private_header_files = "React/Inspector/RCTCxx*.h"
end

s.subspec "RCTWebSocket" do |ss|
ss.source_files = "Libraries/WebSocket/*.{h,m}"
ss.source_files = podspec_sources("Libraries/WebSocket/*.{h,m}", "Libraries/WebSocket/*.h")
ss.dependency "React-Core/Default", version
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ Pod::Spec.new do |s|
s.compiler_flags = '-Wno-nullability-completeness'
s.source = source

s.source_files = "**/*.{c,m,mm,cpp}"
s.source_files = podspec_sources("**/*.{c,m,mm,cpp}", "**/*.h")

s.ios.exclude_files = "PlatformStubs/**/*"
exclude_files = ["RCTStatusBarManager.mm"]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ Pod::Spec.new do |s|
s.author = "Meta Platforms, Inc. and its affiliates"
s.platforms = min_supported_versions
s.source = source
s.source_files = "FBReactNativeSpec/**/*.{c,h,m,mm,cpp}"
s.source_files = podspec_sources("FBReactNativeSpec/**/*.{c,h,m,mm,cpp}", "FBReactNativeSpec/**/*.{h}")
s.exclude_files = "FBReactNativeSpec/react/renderer/components",
s.compiler_flags = new_arch_flags
s.header_dir = 'FBReactNativeSpec'
Expand Down Expand Up @@ -63,7 +63,7 @@ Pod::Spec.new do |s|
add_rn_third_party_dependencies(s)

s.subspec "components" do |ss|
ss.source_files = "FBReactNativeSpec/react/renderer/components/FBReactNativeSpec/**/*.{m,mm,cpp,h}"
ss.source_files = podspec_sources("FBReactNativeSpec/react/renderer/components/FBReactNativeSpec/**/*.{m,mm,cpp,h}", "FBReactNativeSpec/react/renderer/components/FBReactNativeSpec/**/*.{h}")
ss.header_dir = "react/renderer/components/FBReactNativeSpec"

add_dependency(ss, "React-featureflags")
Expand Down
4 changes: 2 additions & 2 deletions packages/react-native/React/React-RCTFabric.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ Pod::Spec.new do |s|
s.author = "Meta Platforms, Inc. and its affiliates"
s.platforms = min_supported_versions
s.source = source
s.source_files = "Fabric/**/*.{c,h,m,mm,S,cpp}"
s.source_files = podspec_sources("Fabric/**/*.{c,h,m,mm,S,cpp}", "Fabric/**/*.{h}")
s.exclude_files = "**/tests/*",
"**/android/*",
s.compiler_flags = new_arch_flags
Expand Down Expand Up @@ -99,7 +99,7 @@ Pod::Spec.new do |s|
add_rn_third_party_dependencies(s)

s.test_spec 'Tests' do |test_spec|
test_spec.source_files = "Tests/**/*.{mm}"
test_spec.source_files = podspec_sources("Tests/**/*.{mm}", "")
test_spec.framework = "XCTest"
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ Pod::Spec.new do |s|
s.author = "Meta Platforms, Inc. and its affiliates"
s.platforms = min_supported_versions
s.source = source
s.source_files = "*.{h,mm}"
s.source_files = podspec_sources("*.{h,mm}", "*.h")
s.compiler_flags = new_arch_flags
s.header_dir = header_dir
s.module_name = module_name
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Pod::Spec.new do |s|
s.homepage = "https://reactnative.dev/"
s.source = { :git => 'https://github.com/facebook/react-native.git', :tag => 'v#{version}' }
s.summary = "Macros for marking APIs as deprecated"
s.source_files = ["Exported/*.h", "RCTDeprecation.m"]
s.source_files = podspec_sources(["Exported/*.h", "RCTDeprecation.m"], "Exported/*.h")
s.pod_target_xcconfig = {
"DEFINES_MODULE" => "YES",
"CLANG_CXX_LANGUAGE_STANDARD" => rct_cxx_language_standard()
Expand Down
Loading
Loading