CocoaPods / CocoaPods/Xcodeproj

Should `create_xml_element_with_fallback` clone the passed in xml element

Open
#830 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Ruby
Stars
2.4k
Forks
488
PR merge metrics
No merged PRs in 30d

Description

Got a xcode crash trying to open a generated project, root cause is because when trying to add a xml element to the tree, it moves the source element to the new location even though I am creating a new instance for the xml element. After tracing the code, this ultimately goes down to `create_xml_element_with_fallback` method creating a new REXML::Element instance given a tag name, but not when a existing xml element is passed in:
```
def create_xml_element_with_fallback(node, tag_name)
if node && node.is_a?(REXML::Element)
raise Informative, 'Wrong XML tag name' unless node.name == tag_name
@xml_element = node
else
@xml_element = REXML::Element.new(tag_name)
yield if block_given?
end
end
```
Should we do `@xml_element = node.clone` instead?

Contributor guide

No contributing guide indexed for this repository

Research direction

Start at create_xml_element_with_fallback and trace callers that pass an existing REXML::Element, then reproduce the tree-move behavior described when adding it to a generated project. Compare the existing-element and tag-name paths and add a regression test showing the source remains in place; done means generated projects no longer move the passed element.

Written by the indexing model from the issue text.

Assessment

Tech stack
ruby
Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.