Skip to content

Commit

Permalink
bug: handle SwiftPM target dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
igor-makarov committed May 19, 2024
1 parent b3449ee commit 78f9924
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
13 changes: 9 additions & 4 deletions lib/censorius.rb
Original file line number Diff line number Diff line change
Expand Up @@ -143,10 +143,15 @@ def generate_paths_file_reference(file_reference)
end

def generate_paths_target_dependency(dependency, parent_path)
raise "Unsupported: #{dependency}" unless dependency.target_proxy

@paths_by_object[dependency] = path = "#{parent_path}/PBXTargetDependency(#{dependency.name})"
generate_paths(dependency.target_proxy, path)
if dependency.target_proxy
@paths_by_object[dependency] = path = "#{parent_path}/PBXTargetDependency(#{dependency.name})"
generate_paths(dependency.target_proxy, path)
elsif dependency.product_ref
product_ref_path = generate_paths(dependency.product_ref)
@paths_by_object[dependency] = "#{parent_path}/PBXTargetDependency(#{product_ref_path})"
else
raise "Unsupported: #{dependency}"
end
end

def generate_paths_container_item_proxy(proxy, parent_path)
Expand Down
5 changes: 5 additions & 0 deletions spec/censorius_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,10 @@ def add_build_rule(target, rule_name)
build_file.product_ref = dependency
target.frameworks_build_phase.files << build_file

target_dependency = @project.new(Xcodeproj::Project::PBXTargetDependency)
target_dependency.product_ref = dependency
target.dependencies << target_dependency

@generator.generate!

expect(@project.sorted_md5s).to eq (%W[
Expand All @@ -321,6 +325,7 @@ def add_build_rule(target, rule_name)
PBXProject(#{@spec_safe_name})/PBXNativeTarget(AppTarget)/PBXFrameworksBuildPhase(Frameworks)
PBXProject(#{@spec_safe_name})/PBXNativeTarget(AppTarget)/PBXFrameworksBuildPhase(Frameworks)/PBXBuildFile(/XCSwiftPackageProductDependency(Product1))
PBXProject(#{@spec_safe_name})/PBXNativeTarget(AppTarget)/PBXFrameworksBuildPhase(Frameworks)/PBXBuildFile(PBXProject(#{@spec_safe_name})/PBXFileReference(${DEVELOPER_DIR}/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS14.0.sdk/System/Library/Frameworks/Foundation.framework))
PBXProject(#{@spec_safe_name})/PBXNativeTarget(AppTarget)/PBXTargetDependency(/XCSwiftPackageProductDependency(Product1))
PBXProject(#{@spec_safe_name})/PBXNativeTarget(AppTarget)/XCConfigurationList
PBXProject(#{@spec_safe_name})/PBXNativeTarget(AppTarget)/XCConfigurationList/XCBuildConfiguration(Debug)
PBXProject(#{@spec_safe_name})/PBXNativeTarget(AppTarget)/XCConfigurationList/XCBuildConfiguration(Release)
Expand Down

0 comments on commit 78f9924

Please sign in to comment.