Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 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
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,14 @@ end

# package.json
package = JSON.parse(File.read(File.join(react_native_path, "package.json")))
# [macOS
rn_version = package['version']
version = findLatestVersionWithArtifact(rn_version) || rn_version
# macOS]
version = findMatchingHermesVersion(package) # [macOS] Use special logic instead of just package['version']

source_type = hermes_source_type(version, react_native_path)
source = podspec_source(source_type, version, react_native_path)

Pod::Spec.new do |spec|
spec.name = "hermes-engine"
spec.version = version
spec.version = version || package['version'] # [macOS] If version is nil, fall back to package version so CocoaPods doesn't fail
spec.summary = "Hermes is a small and lightweight JavaScript engine optimized for running React Native."
spec.description = "Hermes is a JavaScript engine optimized for fast start-up of React Native apps. It features ahead-of-time static optimization and compact bytecode."
spec.homepage = "https://hermesengine.dev"
Expand Down
22 changes: 11 additions & 11 deletions packages/react-native/sdks/hermes-engine/hermes-utils.rb
Original file line number Diff line number Diff line change
Expand Up @@ -296,20 +296,20 @@ def resolve_url_redirects(url)
return (`curl -Ls -o /dev/null -w %{url_effective} \"#{url}\"`)
end

# [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 findLatestVersionWithArtifact(version)
if version == "1000.0.0"
# The main branch builds from source, so skip the artifact check
# [macOS
# Tries to find a suitable Hermes version for a given react-native-macos package.
# For stable branches, we prefer this to be specified as a peer dependency.
def findMatchingHermesVersion(package)
if package['version'] == "1000.0.0"
# The main branch builds from source, so skip this check
return nil
end

# 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
if packages['peerDependencies']
return package['peerDependencies']['react-native']
end

hermes_log("No matching Hermes version found. Defaulting to main branch, which may be unreliable.")
end
# macOS]

Expand Down
Loading