class Rubygems::XcodeprojGenerator::Project
Attributes
build_command[RW]
name[RW]
Public Class Methods
new(name = nil)
click to toggle source
# File lib/rubygems/xcodeproj_generator/project.rb, line 10 def initialize(name = nil) @name = name end
Public Instance Methods
path()
click to toggle source
# File lib/rubygems/xcodeproj_generator/project.rb, line 14 def path project.path end
save()
click to toggle source
# File lib/rubygems/xcodeproj_generator/project.rb, line 18 def save configure_header_search_paths configure_groups configure_build_phase project.save end
Private Instance Methods
configure_build_phase()
click to toggle source
# File lib/rubygems/xcodeproj_generator/project.rb, line 47 def configure_build_phase return unless build_command build_phase = target.new_shell_script_build_phase build_phase.shell_path = '/usr/bin/ruby' # Xcode automatically sets a number of environment variables from the Xcode project's build # settings and clang refers them. However we configure the build settings only for code # completion in Xcode and they may be wrong for the real build. So we reset the Xcode's # environments variables and restore the current variables before invoking the external # build command. build_phase.shell_script = <<-END.gsub(/^\s+\|/, '') |ENV.clear |ENV.update(#{ENV.to_hash.inspect}) |system(#{build_command.inspect}) END end
configure_groups()
click to toggle source
# File lib/rubygems/xcodeproj_generator/project.rb, line 66 def configure_groups project.main_group.clear group = project.new_group('Sources') file_references = Dir['ext/**/*.{h,c}'].map do |path| group.new_reference(path, :project) end # Xcode's code completion is enabled only in files that are compiled in the active target. target.add_file_references(file_references) group.sort end
configure_header_search_paths()
click to toggle source
# File lib/rubygems/xcodeproj_generator/project.rb, line 41 def configure_header_search_paths target.build_configurations.each do |config| config.build_settings['HEADER_SEARCH_PATHS'] = ruby_header_paths.join(' ') end end
project()
click to toggle source
# File lib/rubygems/xcodeproj_generator/project.rb, line 27 def project @project ||= Xcodeproj::Project.new("#{name}.xcodeproj") end
rbenv()
click to toggle source
# File lib/rubygems/xcodeproj_generator/project.rb, line 89 def rbenv @rbenv ||= Rbenv.new end
ruby_header_paths()
click to toggle source
# File lib/rubygems/xcodeproj_generator/project.rb, line 81 def ruby_header_paths if rbenv.available? rbenv.ruby_header_paths else xcode.ruby_header_paths end end
target()
click to toggle source
# File lib/rubygems/xcodeproj_generator/project.rb, line 31 def target # We don't use the PBXLegacyTarget class (a.k.a External Build System) since it cannot have # build settings and the Xcode's code completion cannot be enabled. @target ||= project.new_target(:static_library, name, :osx).tap do |target| target.product_reference = nil target.build_phases.clear project.targets << target end end
xcode()
click to toggle source
# File lib/rubygems/xcodeproj_generator/project.rb, line 93 def xcode @xcode ||= Xcode.new end