Skip to content

fix: fix build failure with older versions and Hermes #2500

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

Merged
merged 2 commits into from
May 20, 2025
Merged
Changes from all commits
Commits
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
23 changes: 7 additions & 16 deletions packages/react-native/sdks/hermes-engine/hermes-utils.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
require 'net/http'
require 'rexml/document'
require 'open3' # [macOS]
require 'json' # [macOS]

HERMES_GITHUB_URL = "https://github.com/facebook/hermes.git"
ENV_BUILD_FROM_SOURCE = "RCT_BUILD_HERMES_FROM_SOURCE"
Expand Down Expand Up @@ -242,22 +243,12 @@ def resolve_url_redirects(url)
# [macOS react-native-macos does not publish macos specific hermes artifacts
# so we attempt to find the latest patch version of the iOS artifacts and use that
def findLastestVersionWithArtifact(version)
versionWithoutPatch = version.match(/^(\d+\.\d+)/)
xml_data, = Open3.capture3("curl -s https://repo1.maven.org/maven2/com/facebook/react/react-native-artifacts/maven-metadata.xml")

metadata = REXML::Document.new(xml_data)
versions = metadata.elements.to_a('//metadata/versioning/versions/version')

# Extract version numbers and sort them
filtered_versions = versions.select { |version| version.text.match?(/^#{versionWithoutPatch}\.\d+$/) }
if filtered_versions.empty?
return
end

version_numbers = filtered_versions.map { |version| version.text }
sorted_versions = version_numbers.sort_by { |v| Gem::Version.new(v) }

return sorted_versions.last
# See https://central.sonatype.org/search/rest-api-guide/ for details on query params
versionWithoutPatch = "#{version.match(/^(\d+\.\d+)/)}"
res, = Open3.capture3("curl -s https://search.maven.org/solrsearch/select?q=g:com.facebook.react+AND+a:react-native-artifacts+AND+v:#{versionWithoutPatch}.*&core=gav&rows=1&wt=json")
wt = JSON.parse(res)
response = wt['response']
return response['docs'][0]['v'] unless response['numFound'] == 0
end
# macOS]

Expand Down
Loading