#!/usr/bin/env ruby require 'xcodeproj' project_path = 'jellypig.xcodeproj' project = Xcodeproj::Project.open(project_path) # Find the main target target = project.targets.find { |t| t.name == 'jellypig tvOS' } # Files to add with their paths and group locations files_to_add = [ { path: 'Shared/ViewModels/EPGViewModel.swift', group_path: ['jellypig', 'Shared', 'ViewModels'] }, { path: 'jellypig tvOS/Views/ProgramGuideView/Components/EPGProgramCell.swift', group_path: ['jellypig', 'jellypig tvOS', 'Views', 'ProgramGuideView', 'Components'] }, { path: 'jellypig tvOS/Views/ProgramGuideView/Components/EPGChannelRow.swift', group_path: ['jellypig', 'jellypig tvOS', 'Views', 'ProgramGuideView', 'Components'] }, { path: 'jellypig tvOS/Views/ProgramGuideView/Components/EPGTimelineHeader.swift', group_path: ['jellypig', 'jellypig tvOS', 'Views', 'ProgramGuideView', 'Components'] }, { path: 'jellypig tvOS/Views/ProgramGuideView/Components/EPGCurrentTimeIndicator.swift', group_path: ['jellypig', 'jellypig tvOS', 'Views', 'ProgramGuideView', 'Components'] } ] files_to_add.each do |file_info| file_path = file_info[:path] absolute_path = File.join(Dir.pwd, file_path) # Navigate to the correct group group = project.main_group file_info[:group_path].each do |group_name| group = group.groups.find { |g| g.name == group_name || g.path == group_name } || group.new_group(group_name) end # Check if file already exists existing_file = group.files.find { |f| f.path == File.basename(file_path) } if existing_file puts "File already exists: #{file_path}" else # Add file reference with absolute path, Xcode will convert to relative file_ref = group.new_reference(absolute_path) # Add to target's source build phase target.source_build_phase.add_file_reference(file_ref) puts "Added: #{file_path}" end end # Save the project project.save puts "\nProject updated successfully!"