patch_crashlytics_run_path.rb 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. #!/usr/bin/env ruby
  2. # Copyright 2025 Google LLC
  3. #
  4. # Licensed under the Apache License, Version 2.0 (the "License");
  5. # you may not use this file except in compliance with the License.
  6. # You may obtain a copy of the License at
  7. #
  8. # http://www.apache.org/licenses/LICENSE-2.0
  9. #
  10. # Unless required by applicable law or agreed to in writing, software
  11. # distributed under the License is distributed on an "AS IS" BASIS,
  12. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. # See the License for the specific language governing permissions and
  14. # limitations under the License.
  15. require 'xcodeproj'
  16. # This script patches the Crashlytics Quickstart's Xcode project to fix the
  17. # path to the `run` script for XCFramework-based builds.
  18. #
  19. # The default project assumes an SPM dependency. This script changes the path
  20. # to point to the location where the `run` script is placed in the zip
  21. # distribution test environment.
  22. project_path = 'quickstart-ios/crashlytics/CrashlyticsExample.xcodeproj'
  23. project = Xcodeproj::Project.open(project_path)
  24. new_path = '"${SRCROOT}/Firebase/run"'
  25. project.targets.each do |target|
  26. target.build_phases.each do |phase|
  27. if phase.is_a?(Xcodeproj::Project::Object::PBXShellScriptBuildPhase) && phase.name == 'Run Script'
  28. if phase.shell_script.include?('SourcePackages/checkouts/firebase-ios-sdk/Crashlytics/run')
  29. puts "Patching Run Script phase in target '#{target.name}' to: #{new_path}"
  30. phase.shell_script = new_path
  31. end
  32. end
  33. end
  34. end
  35. project.save