Created
March 13, 2023 10:14
-
-
Save ast3150/e87d3e0710393dabab882466fc6f985d to your computer and use it in GitHub Desktop.
Ruby script to download Firebase executables when using PodBuilder
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require 'json' | |
require 'open-uri' | |
require 'fileutils' | |
# Define the path where the executables should be stored | |
install_path = "./Pods/FirebaseCrashlytics/" | |
def download_executable(version, executable_name, install_path) | |
url = "https://raw.githubusercontent.com/firebase/firebase-ios-sdk/#{version}/Crashlytics/#{executable_name}" | |
file_path = "#{install_path}/#{executable_name}" | |
# Create the install path directory if it doesn't exist | |
FileUtils.mkdir_p(install_path) | |
File.open(file_path, "wb") do |file| | |
URI.open(url, "rb") do |url| | |
file.write(url.read) | |
end | |
end | |
File.chmod(0755, file_path) | |
puts "#{executable_name} executable installed to #{install_path}" | |
end | |
# Parse the PodBuilder.json file to get the installed version | |
podbuilder_file = "./PodBuilder/Prebuilt/FirebaseCrashlytics/PodBuilder.json" | |
podbuilder_json = File.read(podbuilder_file) | |
podbuilder_data = JSON.parse(podbuilder_json) | |
entry = podbuilder_data["entry"] | |
version = entry.scan(/=([\d\.]+)/).flatten.first | |
# Download the run and upload-symbols executables | |
download_executable(version, "run", install_path) | |
download_executable(version, "upload-symbols", install_path) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
post_install do |pi| | |
download_executable_script_path = "./download_firebase_executables.rb" | |
system("ruby #{download_executable_script_path}") | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The script is expected to be placed in the project's root directory. If you want to place it somewhere else, you may have to adjust the paths in the script accordingly.