CocoaPods / Xcodeproj

Create and modify Xcode projects from Ruby.
http://rubygems.org/gems/xcodeproj
MIT License
2.35k stars 453 forks source link

error using xcode projects 5.1 #146

Closed pellicus closed 10 years ago

pellicus commented 10 years ago

Hi there! I tried to use Xcodeproj , It's my first time with ruby :D. anyway I tried to modify programmatically my project using this script:

!/usr/bin/env ruby

require 'xcodeproj' if FILE == $0 puts "TEST XCODE INJECTOR" project = Xcodeproj::Project.open("reflex_test.xcodeproj") main_target = project.targets.first phase = main_target.new_shell_script_build_phase("Build Phase") phase.shell_script = "echo \"${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/your.file\"" project.save() end

i run it with this command line : ruby inject.rb

and I get this:

TEST XCODE INJECTOR /Library/Ruby/Gems/2.0.0/gems/xcodeproj-0.16.0/lib/xcodeproj/project/object.rb:300:in configure_with_plist': [!] Xcodeproj doesn't know about the following attributes {"name"=>"Compile Sources"} for the 'PBXSourcesBuildPhase' isa. (RuntimeError) Please file an issue: https://github.com/CocoaPods/Xcodeproj/issues/new from /Library/Ruby/Gems/2.0.0/gems/xcodeproj-0.16.0/lib/xcodeproj/project.rb:230:innew_from_plist' from /Library/Ruby/Gems/2.0.0/gems/xcodeproj-0.16.0/lib/xcodeproj/project/object.rb:328:in object_with_uuid' from /Library/Ruby/Gems/2.0.0/gems/xcodeproj-0.16.0/lib/xcodeproj/project/object.rb:279:inblock (2 levels) in configure_with_plist' from /Library/Ruby/Gems/2.0.0/gems/xcodeproj-0.16.0/lib/xcodeproj/project/object.rb:278:in each' from /Library/Ruby/Gems/2.0.0/gems/xcodeproj-0.16.0/lib/xcodeproj/project/object.rb:278:inblock in configure_with_plist' from /Library/Ruby/Gems/2.0.0/gems/xcodeproj-0.16.0/lib/xcodeproj/project/object.rb:275:in each' from /Library/Ruby/Gems/2.0.0/gems/xcodeproj-0.16.0/lib/xcodeproj/project/object.rb:275:inconfigure_with_plist' from /Library/Ruby/Gems/2.0.0/gems/xcodeproj-0.16.0/lib/xcodeproj/project.rb:230:in new_from_plist' from /Library/Ruby/Gems/2.0.0/gems/xcodeproj-0.16.0/lib/xcodeproj/project/object.rb:328:inobject_with_uuid' from /Library/Ruby/Gems/2.0.0/gems/xcodeproj-0.16.0/lib/xcodeproj/project/object.rb:279:in block (2 levels) in configure_with_plist' from /Library/Ruby/Gems/2.0.0/gems/xcodeproj-0.16.0/lib/xcodeproj/project/object.rb:278:ineach' from /Library/Ruby/Gems/2.0.0/gems/xcodeproj-0.16.0/lib/xcodeproj/project/object.rb:278:in block in configure_with_plist' from /Library/Ruby/Gems/2.0.0/gems/xcodeproj-0.16.0/lib/xcodeproj/project/object.rb:275:ineach' from /Library/Ruby/Gems/2.0.0/gems/xcodeproj-0.16.0/lib/xcodeproj/project/object.rb:275:in configure_with_plist' from /Library/Ruby/Gems/2.0.0/gems/xcodeproj-0.16.0/lib/xcodeproj/project.rb:230:innew_from_plist' from /Library/Ruby/Gems/2.0.0/gems/xcodeproj-0.16.0/lib/xcodeproj/project.rb:175:in initialize_from_file' from /Library/Ruby/Gems/2.0.0/gems/xcodeproj-0.16.0/lib/xcodeproj/project.rb:93:inopen' from inject.rb:5:in `

'

Considering how much it's easy to install and use your library .. Should be very cool to have it working even on xcode 5 projects files! :D

thanks for your time.

Dario Pelella - CTO @ xplored.com

fabiopelosin commented 10 years ago

This library works fine on Xcode projects as it powers CocoaPods. The issue that you are seeing is the result of a design decision to abort when unrecognised attributes are detected (otherwise there is the risk of information loss in the user project).

[!] Xcodeproj doesn't know about the following attributes {"name"=>"Compile Sources"} for the 'PBXSourcesBuildPhase' isa.

As to my knowledge there is no name attribute in the PBXSourcesBuildPhase I consider this the result of some form of programmatic editing/generation of the project (different than Xcode).

I would recommend to remove that attribute manually from the reflex_test.xcodeproj/project.pbxproj file.