Skip to content

Commit

Permalink
fix(visionos): fix build failing when Hermes is enabled (#2308)
Browse files Browse the repository at this point in the history
  • Loading branch information
tido64 authored Nov 6, 2024
1 parent 8f51846 commit 9a0d1e1
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 6 deletions.
1 change: 1 addition & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ require:
AllCops:
NewCops: enable
Exclude:
- "**/Pods/**/*"
- "**/node_modules/**/*"
- "vendor/bundle/**/*"
TargetRubyVersion: 2.6
Expand Down
4 changes: 4 additions & 0 deletions ios/pod_helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,10 @@ def use_hermes?(options)
use_hermes = ENV.fetch('USE_HERMES', nil)
return use_hermes == '1' unless use_hermes.nil?

# Hermes prebuilds for visionOS was introduced in 0.76
is_visionos = options[:path].end_with?('react-native-visionos')
ENV['RCT_BUILD_HERMES_FROM_SOURCE'] = 'true' if is_visionos && options[:version] < v(0, 76, 0)

options[:hermes_enabled] == true
end

Expand Down
38 changes: 32 additions & 6 deletions test/test_pod_helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -83,21 +83,47 @@ def test_new_architecture_enabled?
end

def test_use_hermes?
options = { path: '../node_modules/react-native' }

ENV.delete('RCT_BUILD_HERMES_FROM_SOURCE')
ENV.delete('USE_HERMES')

refute(use_hermes?({}))
assert(use_hermes?({ hermes_enabled: true }))
refute(use_hermes?(options))
assert(use_hermes?({ **options, hermes_enabled: true }))
refute(ENV.fetch('RCT_BUILD_HERMES_FROM_SOURCE', nil))

ENV['USE_HERMES'] = '0'

refute(use_hermes?({}))
refute(use_hermes?({ hermes_enabled: true }))
refute(use_hermes?(options))
refute(use_hermes?({ **options, hermes_enabled: true }))
refute(ENV.fetch('RCT_BUILD_HERMES_FROM_SOURCE', nil))

ENV['USE_HERMES'] = '1'

assert(use_hermes?({}))
assert(use_hermes?({ hermes_enabled: true }))
assert(use_hermes?(options))
assert(use_hermes?({ **options, hermes_enabled: true }))
refute(ENV.fetch('RCT_BUILD_HERMES_FROM_SOURCE', nil))

ENV.delete('RCT_BUILD_HERMES_FROM_SOURCE')
ENV.delete('USE_HERMES')
end

def test_use_hermes_visionos?
options = {
path: '../node_modules/@callstack/react-native-visionos',
hermes_enabled: true,
}

ENV.delete('RCT_BUILD_HERMES_FROM_SOURCE')
ENV.delete('USE_HERMES')

assert(use_hermes?({ **options, version: v(0, 76, 0) }))
refute(ENV.fetch('RCT_BUILD_HERMES_FROM_SOURCE', nil))

assert(use_hermes?({ **options, version: v(0, 75, 0) }))
assert_equal('true', ENV.fetch('RCT_BUILD_HERMES_FROM_SOURCE'))

ENV.delete('RCT_BUILD_HERMES_FROM_SOURCE')
ENV.delete('USE_HERMES')
end

Expand Down

0 comments on commit 9a0d1e1

Please sign in to comment.