Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot save project after removing subproject #158

Closed
jpsim opened this issue Jun 16, 2014 · 4 comments
Closed

Cannot save project after removing subproject #158

jpsim opened this issue Jun 16, 2014 · 4 comments

Comments

@jpsim
Copy link
Contributor

jpsim commented Jun 16, 2014

Subprojects in Xcode look like PBXFileReferences to Xcodeproj. So they should be removable in the same way as a regular file, by calling remove_from_project.

Unfortunately, this doesn't work.

project = Xcodeproj::Project.open('MyProject.xcodeproj')

project.objects.each do |object|
    if object.respond_to?(:name) && object.name == "MySubProject.xcodeproj"
        puts object.path # => object is there and has the correct path
        object.remove_from_project
    end
end

project.save

Output:

../../MySubProject.xcodeproj
/usr/local/opt/rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/xcodeproj-0.17.0/lib/xcodeproj/project/object_dictionary.rb:113:in `block in to_hash': undefined method `uuid' for nil:NilClass (NoMethodError)
    from /usr/local/opt/rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/xcodeproj-0.17.0/lib/xcodeproj/project/object_dictionary.rb:113:in `each'
    from /usr/local/opt/rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/xcodeproj-0.17.0/lib/xcodeproj/project/object_dictionary.rb:113:in `to_hash'
    from /usr/local/opt/rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/xcodeproj-0.17.0/lib/xcodeproj/project/object.rb:373:in `block (2 levels) in to_hash'
    from /usr/local/opt/rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/xcodeproj-0.17.0/lib/xcodeproj/project/object.rb:373:in `map'
    from /usr/local/opt/rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/xcodeproj-0.17.0/lib/xcodeproj/project/object.rb:373:in `block in to_hash'
    from /usr/local/opt/rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/xcodeproj-0.17.0/lib/xcodeproj/project/object.rb:371:in `each'
    from /usr/local/opt/rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/xcodeproj-0.17.0/lib/xcodeproj/project/object.rb:371:in `to_hash'
    from /usr/local/opt/rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/xcodeproj-0.17.0/lib/xcodeproj/project.rb:240:in `block in to_hash'
    from /usr/local/opt/rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/xcodeproj-0.17.0/lib/xcodeproj/project.rb:240:in `each'
    from /usr/local/opt/rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/xcodeproj-0.17.0/lib/xcodeproj/project.rb:240:in `to_hash'
    from /usr/local/opt/rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/xcodeproj-0.17.0/lib/xcodeproj/project.rb:303:in `save'
    from ./test.rb:14:in `<main>'

Doing the same thing with a regular file saves without a hitch. Any thoughts?

@fabiopelosin
Copy link
Member

Issue confirmed

@alloy
Copy link
Member

alloy commented Jul 21, 2014

This should be fixed by 9ce8ac2.

Thanks @jpsim !

@alloy alloy closed this as completed Jul 21, 2014
@alloy
Copy link
Member

alloy commented Jul 21, 2014

@jpsim PS, please verify that it works in your case.

@jpsim
Copy link
Contributor Author

jpsim commented Jul 21, 2014

This is fantastic, @alloy. Thanks so much for getting this in!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants