Skip to content

Commit

Permalink
add support for Swift PM package references
Browse files Browse the repository at this point in the history
  • Loading branch information
igor-makarov committed May 19, 2024
1 parent 83f96f3 commit 07e3aed
Showing 1 changed file with 27 additions and 2 deletions.
29 changes: 27 additions & 2 deletions lib/censorius.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ def generate_paths(object, parent_path = '') # rubocop:disable Metrics/Cyclomati
generate_paths_target_dependency(object, parent_path)
when Xcodeproj::Project::Object::PBXReferenceProxy
generate_paths_reference_proxy(object, parent_path)
when Xcodeproj::Project::Object::XCRemoteSwiftPackageReference
generate_paths_remote_swift_package_reference(object, parent_path)
when Xcodeproj::Project::Object::XCSwiftPackageProductDependency
generate_paths_remote_swift_package_product_dependency(object, parent_path)
else
raise "Unrecognized: #{object.class}, at: #{parent_path}"
end
Expand All @@ -56,6 +60,9 @@ def generate_paths_project(project)
project.targets.each do |target|
generate_paths(target, path)
end
project.package_references.each do |package_reference|
generate_paths(package_reference, path)
end
end

def generate_paths_configuration_list(configuration_list, parent_path)
Expand Down Expand Up @@ -83,6 +90,9 @@ def generate_paths_target(target, parent_path)
target.dependencies.each do |dependency|
generate_paths(dependency, path)
end
target.package_product_dependencies.each do |dependency|
generate_paths(dependency, path)
end
end

def generate_paths_phase(phase, parent_path)
Expand All @@ -93,8 +103,15 @@ def generate_paths_phase(phase, parent_path)
end

def generate_paths_build_file(build_file, parent_path)
file_ref_path = generate_paths(build_file.file_ref)
@paths_by_object[build_file] = "#{parent_path}/PBXBuildFile(#{file_ref_path})"
if build_file.file_ref
file_ref_path = generate_paths(build_file.file_ref)
@paths_by_object[build_file] = "#{parent_path}/PBXBuildFile(#{file_ref_path})"
elsif build_file.product_ref
product_ref_path = generate_paths(build_file.product_ref)
@paths_by_object[build_file] = "#{parent_path}/PBXBuildFile(#{product_ref_path})"
else
raise "Unsupported: #{build_file}"
end
end

def generate_paths_build_rule(build_rule, parent_path)
Expand Down Expand Up @@ -144,6 +161,14 @@ def generate_paths_reference_proxy(proxy, parent_path)
generate_paths(proxy.remote_ref, path) if proxy.remote_ref
end

def generate_paths_remote_swift_package_reference(reference, parent_path)
@paths_by_object[reference] = path = "#{parent_path}/XCRemoteSwiftPackageReference(#{reference.repositoryURL}/#{reference.requirement})"
end

def generate_paths_remote_swift_package_product_dependency(dependency, parent_path)
@paths_by_object[dependency] = path = "#{parent_path}/XCSwiftPackageProductDependency(#{dependency.product_name})"
end

def write_debug_paths
return if @projects.empty?

Expand Down

0 comments on commit 07e3aed

Please sign in to comment.