27 lines
1.0 KiB
Ruby
27 lines
1.0 KiB
Ruby
#!/usr/bin/env ruby
|
|
# frozen_string_literal: true
|
|
|
|
require 'xcodeproj'
|
|
|
|
ROOT = File.expand_path('..', __dir__)
|
|
PROJECT_PATH = File.join(ROOT, 'QuickLocation.xcodeproj')
|
|
project = Xcodeproj::Project.open(PROJECT_PATH)
|
|
main_target = project.targets.find { |t| t.name == 'QuickLocation' }
|
|
raise 'QuickLocation target not found' unless main_target
|
|
|
|
section_group = project.main_group.find_subpath('QuickLocation/Section', true)
|
|
lock_group = section_group['LockDistract'] || section_group.new_group('LockDistract', 'LockDistract')
|
|
|
|
%w[LockDistractView.swift LockDistractVC.swift].each do |name|
|
|
abs = File.join(ROOT, 'QuickLocation/Section/LockDistract', name)
|
|
raise "Missing #{abs}" unless File.exist?(abs)
|
|
ref = lock_group.files.find { |f| f.path == name || f.real_path.to_s == abs }
|
|
ref ||= lock_group.new_file(abs)
|
|
unless main_target.source_build_phase.files_references.include?(ref)
|
|
main_target.source_build_phase.add_file_reference(ref)
|
|
end
|
|
end
|
|
|
|
project.save
|
|
puts 'Added LockDistract sources to QuickLocation target'
|