CocoaPods / CocoaPods/Xcodeproj
it seems link with new external target is not work due to add sub project can not work properly
- Dominant language
- Ruby
- Stars
- 2.4k
- Forks
- 488
- PR merge metrics
- No merged PRs in 30d
Description
file :xcodeproj/project/object/helpers/file_references_factory.rb
function:def new_subproject(group, path, source_tree)
can not work properly,so i changed it:
```
def new_subproject(group, path, source_tree)
ref = new_file_reference(group.project.main_group, path, source_tree)
ref.include_in_index = nil
product_group_ref = find_products_group_ref(group, true)
#add project ref to main group
#create a Products group to hold proxy targets and remove it from project add it only to project_reference
if group == group.project.main_group
product_group_ref = group.project.new_group("Products")
product_group_ref.remove_from_project
end
subproj = Project.open(path)
subproj.products_group.files.each do |product_reference|
container_proxy = group.project.new(PBXContainerItemProxy)
container_proxy.container_portal = ref.uuid
container_proxy.proxy_type = Constants::PROXY_TYPES[:reference]
container_proxy.remote_global_id_string = product_reference.uuid
container_proxy.remote_info = 'Subproject'
reference_proxy = group.project.new(PBXReferenceProxy)
extension = File.extname(product_reference.path)[1..-1]
reference_proxy.file_type = product_reference.explicit_file_type#Constants::FILE_TYPES_BY_EXTENSION[extension]
reference_proxy.remote_ref = container_proxy
reference_proxy.source_tree = product_reference.source_tree #'BUILT_PRODUCTS_DIR'
#just for correct name
old_path = product_reference.path.to_s
name = old_path
path = old_path
puts old_path.split('/').first
if old_path.split('/').first.end_with?(".framework")
name = old_path # Get last part after "/"
path = old_path.split('/').first # Get the framework name
elsif old_path.split('/').first.end_with?(".app")
name = File.basename(old_path, ".app") # Remove .app extension
path = old_path
end
reference_proxy.name = name
reference_proxy.path = path
#just for correct name end
product_group_ref << reference_proxy
end
attribute = PBXProject.references_by_keys_attributes.find { |attrb| attrb.name == :project_references }
project_reference = ObjectDictionary.new(attribute, group.project.root_object)
project_reference[:project_ref] = ref
project_reference[:product_group] = product_group_ref
group.project.root_object.project_references << project_reference
ref
end
```
usage:
```
# Add subprojects
def add_subproject(main_project, subproject_path)
# Check if project reference already exists
existing_ref = main_project.root_object.project_references.find { |ref| ref[:project_ref].path == subproject_path }
return existing_ref[:project_ref] if existing_ref
#here should use main_group,in new_reference should create a Products Group
reference = main_project.main_group.new_reference(subproject_path)
#puts "reference: #{reference.class}"
main_project.save()
return reference
end
```
Contributor guide
No contributing guide indexed for this repository
Research direction
Start in xcodeproj/project/object/helpers/file_references_factory.rb at new_subproject(group, path, source_tree), then trace the add_subproject usage shown in the issue. Reproduce how an external target or subproject is added and inspect the generated project references, Products group, container proxies, and reference proxies. Done means adding the subproject works correctly and produces usable external target links.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- ruby
- Domain
- build-system, tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100