I have a project with multiple app targets and need to be able to add an existing English localized string file to one of the targets for development use only.
Here is my scenario:
- Target A uses English + multiple non-English localized strings files.
- Target B uses only 1 non-English localized strings file.
- Target B cannot have English strings included in App Store builds.
However, to help during development we currently manually add the English strings to Target B's localization files (using the existing file from Target A when prompted), and remove it prior to App Store submission.
Since we run Fastlane setup/teardown scripts already, I would like to automate adding/removing the English strings from the scripts so we don't have to do it manually every time.
In the Fastfile, I know how to add a file to Target B, but since the Localization files/references are structured a bit differently in Xcode than regular files I am not sure what the proper way to do it is.
Here is what I have so far:
def add_english_localization()
require 'xcodeproj'
project = Xcodeproj::Project.open("../Code/#{XCODE_PROJ}")
app_target = project.targets.first #Target B
english_file_ref = project.main_group.new_file('../Code/TargetA/Application/Supporting Files/en.lproj') #Existing english file in Target A's directory
app_target.add_file_references([english_file_ref]) #This adds the file but doesn't properly update Xcode's Localization references...?
project.save
end
Screenshots:
project.pbxproj
file. – Iulian Onofrei