CocoaPods / CocoaPods/Xcodeproj
Unexcepted additional .git keyword in XCRemoteSwiftPackageReference
- Dominant language
- Ruby
- Stars
- 2.4k
- Forks
- 488
- PR merge metrics
- No merged PRs in 30d
Description
Xcodeproj version: `1.20.0`
I want to update the version of a swift package. Hence I emulated the objects and found the package. Then I modified the version and saved it. But I couldn't open my Xcode project. It seems my `.pbxproj` format is incorrect.

Here is my code:
``` ruby
project_path = './myproject.xcodeproj'
if !File.exist?(project_path)
print "Didn't find .xcodeproj file at '#{project_path}'\n"
exit(1)
end
project = Xcodeproj::Project.open(project_path)
project.objects.each do |object|
next unless 'some_package' == object.display_name && object.is_a?(Xcodeproj::Project::Object::XCSwiftPackageProductDependency)
object.package.requirement["version"] = '456'
print "display_name: #{object.display_name}, requirement: #{object.package.requirement["version"]}\n"
end
project.save
```
Contributor guide
No contributing guide indexed for this repository
Research direction
Reproduce the problem with the Ruby script in the issue, using Xcodeproj 1.20.0 and an Xcode project containing the affected Swift package reference. Inspect how XCRemoteSwiftPackageReference objects are serialized during project.save; done means the saved .pbxproj no longer contains the unexpected additional .git keyword and opens in Xcode.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- ruby, swift
- Domain
- build-system, devtools
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100