Class: GoNative::Plugins::IOS::AddFiles
- Inherits:
-
Object
- Object
- GoNative::Plugins::IOS::AddFiles
- Extended by:
- DSL::Serviceable
- Defined in:
- lib/gonative/plugins/ios/add_files.rb
Instance Attribute Summary collapse
-
#file_paths ⇒ Object
readonly
Returns the value of attribute file_paths.
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(path) ⇒ AddFiles
constructor
A new instance of AddFiles.
Constructor Details
#initialize(path) ⇒ AddFiles
Returns a new instance of AddFiles.
13 14 15 |
# File 'lib/gonative/plugins/ios/add_files.rb', line 13 def initialize(path) @file_paths = Dir.glob(path) end |
Instance Attribute Details
#file_paths ⇒ Object (readonly)
Returns the value of attribute file_paths.
11 12 13 |
# File 'lib/gonative/plugins/ios/add_files.rb', line 11 def file_paths @file_paths end |
Instance Method Details
#call ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/gonative/plugins/ios/add_files.rb', line 17 def call return if file_paths.empty? project = Xcodeproj::Project.open('MedianIOS.xcodeproj') target = project.native_targets.first resources_directory = File.join(FileUtils.pwd, 'Resources') FileUtils.mkdir_p(resources_directory) resources_group = project.main_group['Resources'] || project.main_group.new_group('Resources') file_paths.each do |file_path| file_name = File.basename(file_path) destination_path = File.join(resources_directory, file_name) FileUtils.cp(file_path, destination_path) relative_path = File.join('Resources', file_name) file_ref = resources_group.new_file(relative_path) target.resources_build_phase.add_file_reference(file_ref) end project.save end |