Skip to content

Instantly share code, notes, and snippets.

@Greenheart
Last active December 19, 2022 22:49
Show Gist options
  • Save Greenheart/9f4d9cb39073050cb1fe16fbf75da56b to your computer and use it in GitHub Desktop.
Save Greenheart/9f4d9cb39073050cb1fe16fbf75da56b to your computer and use it in GitHub Desktop.
Fix react-native builds on case sensitive file systems by linking headers

A workaround is to add the following to the post_install step in ios/Podfile. This way it will be automatically applied when you reinstall dependencies.

# Link headers to fix build on case sensitive file systems
# This will only be executed on case sensitive file systems where "pods" doesn't resolve to "Pods"
unless File.exist? "pods"
  # For files, create a symlink with `ln -s`
  system('cd Pods/Headers/Public; ln -s Protobuf protobuf')
  
  # For directories, create a symlink with `ln -sfh`
  system('cd Pods/Headers/Public; ln -sfh OpenSSL openssl')
  
  # Some cases require more advanced scripting to resolve errors that happened during the installation
  # For example some files might end up in the wrong director and need to be manually moved
  # Ensure Yoga headers end up in the same directory, and create a symlink to allow other iOS code to import fom lowercase "yoga" directory.
  system('cd Pods/Headers/Public; mv `find yoga/*.*` Yoga; rm -rf yoga; ln -sfh Yoga yoga')

  # Add a similar step for each dependency with broken headers
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment