Last active
January 6, 2019 02:03
-
-
Save arpitdsoni/a618077d61aba79511e3e7a50a6c17c3 to your computer and use it in GitHub Desktop.
Adding lproj folder reference in xcodeproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'xcodeproj' | |
require 'dotenv' | |
# Dotenv.load('.env.lprojs') | |
localizations = ENV['LOCALIZATIONS'].split(',') | |
puts "Localizations: " + localizations.inspect | |
project = Xcodeproj::Project.open('LocalizationPrototype.xcodeproj') | |
target = project.targets.first | |
parent_group = project.groups.first | |
existing_lprojs = target.resources_build_phase.files.map { |f| f.display_name if f.display_name.include? ".lproj" }.compact | |
# puts existing_lprojs | |
appConfig_path = '../AppConfig/' | |
lproj_refs = [] | |
for localization in localizations do | |
lproj = localization + ".lproj" | |
unless existing_lprojs.include? lproj | |
lproj_path = appConfig_path + lproj | |
lproj_refs << parent_group.new_reference(lproj_path, :group) | |
puts "Adding folder reference " + lproj | |
else | |
puts "Folder reference " + lproj + " already exist." | |
end | |
end | |
if lproj_refs.any? | |
target.add_resources(lproj_refs) | |
end | |
project.save() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'xcodeproj' | |
# src = ARGV[0] | |
# project = Xcodeproj::Project.open("#{src}/LocalizationPrototype.xcodeproj") | |
project = Xcodeproj::Project.open("LocalizationPrototype.xcodeproj") | |
target = project.targets.first | |
parent_group = project.groups.first | |
target.resources_build_phase.files.each do |f| | |
if f.display_name.include? ".lproj" | |
puts "Removing folder reference " + f.display_name | |
f.file_ref.remove_from_project | |
end | |
end | |
project.save() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment