1require 'open3' 2require 'pathname' 3 4 5def maybe_generate_xcode_env_file!() 6 project_directory = Pod::Config.instance.project_root 7 xcode_env_file = File.join(project_directory, '.xcode.env.local') 8 if File.exist?(xcode_env_file) 9 return 10 end 11 12 # Adding the meta character `;` at the end of command for Ruby `Kernel.exec` to execute the command in shell. 13 stdout, stderr, status = Open3.capture3('node --print "process.argv[0]";') 14 node_path = stdout.strip 15 if !stderr.empty? || status.exitstatus != 0 || node_path.empty? 16 Pod::UI.warn "Unable to generate `.xcode.env.local` for Node.js binary path: #{stderr}" 17 else 18 Pod::UI.info "Auto-generating `.xcode.env.local` with $NODE_BINARY=#{node_path}" 19 File.write(xcode_env_file, "export NODE_BINARY=\"#{node_path}\"\n") 20 end 21end 22