0

参考Xcodeproj gem

如何通过上面的 gem 'Xcodeproj' 正确执行 xcode 项目目标的重命名?

class AnnoyingClass
    attr_reader(:target, :project)
    def setProductName(name)
       puts %Q'I will rename product to #{name}'
       @target.product_name = name
       puts %Q'I did it! name now: #{@target.product_name}' #ok here
    end

    # project directory is a /path/to/*.xcodeproj
    def openProject(project_directory)
      @project = Xcodeproj::Project.open(project_directory)
      @target  = @project.targets.select{|target| target.name !~ /Tests/}.first

      if @target
          self.setProductName('Wow')
      end

      #@project.save doesn't help, the same result

      #but here is something strange with 'PRODUCT NAME' value
      #old value 'PRODUCT NAME' appears 
      puts "uh, everything is not fine enough #{@target.pretty_print}"

    end
end
4

0 回答 0