Sha256: c2055d388957c6ee48ddba1f6ae1c709334ce23857ea3df3019e9d524a3c7199
Contents?: true
Size: 1.42 KB
Versions: 10
Compression:
Stored size: 1.42 KB
Contents
# frozen_string_literal: true require 'yaml' require 'xcodeproj' module GoNative module Plugins module IOS class EmbedScripts TARGET_SCRIPTS_FILE_NAME = 'target_scripts.yml' extend DSL::Serviceable autoload :FileUtils, 'fileutils' attr_reader :scripts def call prepare_scripts return unless scripts? embed_in_project end def scripts? !scripts.empty? end def prepare_scripts scripts_paths = `find ./Pods -name #{TARGET_SCRIPTS_FILE_NAME}`.split("\n") @scripts = scripts_paths .map { |path| YAML.load_file(path)['scripts'] } .flatten end def embed_in_project proj = Xcodeproj::Project.open('MedianIOS.xcodeproj') app_target = proj.native_targets.first scripts.each do |script| app_target.project.new(Xcodeproj::Project::Object::PBXShellScriptBuildPhase).tap do |phase| phase.name = script['name'] || 'New Run Script Phase' phase.input_paths = script['input_paths'] phase.output_paths = script['output_paths'] phase.shell_path = script['shell_path'] phase.shell_script = script['shell_script'] app_target.build_phases << phase end end proj.save end end end end end
Version data entries
10 entries across 10 versions & 1 rubygems