Sha256: 46c5fbee9dbf8ad3212d4574ee95798b1c7e99168a48c90d4c2fc77ff6a136ef

Contents?: true

Size: 1.3 KB

Versions: 1

Compression:

Stored size: 1.3 KB

Contents

#!/usr/bin/env ruby -W

module WeexBuilder
  module IOSProject
    
    module_function
    
    def create(project_name)
      # Clone the ios template project 
      template_url = "http://git.yanzijia.cn/huzhitui/__WEEX_TEMPLATE__iOS.git"
      project_dir = File.join(Dir.pwd, 'Platforms/iOS', "#{project_name}")
      return unless system "git clone #{template_url} #{project_dir}"

      # Change the dir name
      Dir.glob("#{project_dir}/__WEEX_TEMPLATE__*").each do |name|
        cmd = "mv #{name} #{project_dir}/#{project_name}"
        if /.xcodeproj$/ =~ name
          cmd << ".xcodeproj"
        end
        system cmd
      end

      podfile = File.join(project_dir, "Podfile")
      File.open(podfile, 'r') do |output|
        buffer = output.read.gsub(/__WEEX_TEMPLATE__/, "#{project_name}")
        File.open(podfile, 'w') { |input| input.write(buffer) }
      end

      # Update the project info.
      pbxproj = File.join(project_dir, "#{project_name}.xcodeproj", 'project.pbxproj')
      File.open(pbxproj, 'r') do |output|
        buffer = output.read.gsub(/__WEEX_TEMPLATE__/, "#{project_name}")
        File.open(pbxproj, 'w') { |input| input.write(buffer) }
      end

      # Open the project
      puts 'The Xcode Project has been Created Successfully.'

      # system 'pod install'

    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
weexbuilder-0.0.4 lib/platform_ios.rb