Skip to content

Commit

Permalink
Merge pull request #218 from polac24/support-
Browse files Browse the repository at this point in the history
[Cocoapods] Ensure the source build phase exist before enabling xcrc
  • Loading branch information
polac24 authored Aug 1, 2023
2 parents afb1f9e + be87c37 commit 6a1335e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
7 changes: 7 additions & 0 deletions cocoapods-plugin/lib/cocoapods-xcremotecache/command/hooks.rb
Original file line number Diff line number Diff line change
Expand Up @@ -409,6 +409,11 @@ def self.save_lldbinit_rewrite(user_proj_directory,fake_src_root)
File.write(LLDB_INIT_PATH, lldbinit_lines.join("\n"), mode: "w")
end

# Contrary to AbstractTarget.source_build_phase, it only finds a build phase, without creating one if it doesn't exist
def self.find_source_build_phase(target)
target.build_phases.find { |bp| bp.class == Xcodeproj::Project::Object::PBXSourcesBuildPhase }
end

Pod::HooksManager.register('cocoapods-xcremotecache', :pre_install) do |installer_context|
# The main responsibility of that hook is forcing Pods regeneration when XCRemoteCache is enabled for the first time
# In the post_install hook, this plugin adds extra build settings and steps to all Pods targets, but only when XCRemoteCache
Expand Down Expand Up @@ -520,6 +525,8 @@ def self.save_lldbinit_rewrite(user_proj_directory,fake_src_root)
# Attach XCRemoteCache to Pods targets
# Enable only for native targets which can have compilation steps
installer_context.pods_project.native_targets.each do |target|
# Ensure the PBXSourcesBuildPhase exists as the flow would unnecessary create an empty source build phase otherwise
next if find_source_build_phase(target).nil?
next if target.source_build_phase.files_references.empty?
next if target.name.start_with?("Pods-")
next if target.name.end_with?("Tests")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@
# limitations under the License.

module CocoapodsXcremotecache
VERSION = "0.0.17"
VERSION = "0.0.18"
end

0 comments on commit 6a1335e

Please sign in to comment.