Dir.glob("#{__dir__}/*.rb").each { |file| require file } require 'singleton' require 'pathname' class IOSFilePathManager include Singleton def initialize @platform = SolaraSettingsManager.instance.platform @project_root = SolaraSettingsManager.instance.project_root end def xcode_project path = ProjectSettingsManager.instance.value('xcodeproj', Platform::IOS) File.join(@project_root, path) end def xcode_project_directory Pathname.new(xcode_project).parent.to_s end def brand_assets(brand_key) File.join(FilePath.brands, brand_key, FilePath.ios, 'assets') end def brand_xcconfig File.join(artifacts, 'Brand.xcconfig') end def artifacts case @platform when Platform::Flutter return File.join(@project_root, FilePath.ios, 'Flutter', 'Artifacts') when Platform::IOS return File.join(xcode_project_directory, 'Artifacts') else raise ArgumentError, "Invalid platform: #{@platform}" end end def info_plist path = ProjectSettingsManager.instance.value('Info.plist', Platform::IOS) File.join(@project_root, path) end def assets path = ProjectSettingsManager.instance.value('Assets.xcassets', Platform::IOS) File.join(@project_root, path) end def assets_directory File.dirname(assets) end def assets_artifacts File.join(assets_directory, 'Assets.xcassets', 'Artifacts') end def assets_artifcats File.join(assets, 'Artifacts') end def app_xcconfig(name) case @platform when Platform::Flutter return File.join(@project_root, FilePath.ios, 'Flutter', name) when Platform::IOS return File.join(xcode_project_directory, 'XCConfig', name) else raise ArgumentError, "Invalid platform: #{@platform}" end end def app_xcconfig_directory Pathname.new(app_xcconfig('Debug.xcconfig')).parent.to_s end def brand_app_icon(brand_key) File.join(FilePath.brands, brand_key, FilePath.ios, 'assets', 'AppIcon.appiconset') end def brand_app_icon_image(brand_key) appicon_set_path = brand_app_icon(brand_key) if appicon_set_path.nil? raise "Error: AppIcon.appiconset not found for brand #{brand_key}" end contents_json_path = File.join(appicon_set_path, 'Contents.json') unless File.exist?(contents_json_path) raise "Error: Contents.json not found in AppIcon.appiconset for brand #{brand_key}" end contents = JSON.parse(File.read(contents_json_path)) largest_image = contents['images'].max_by do |img| size = img['size'].scan(/(\d+)x(\d+)/).first&.map(&:to_i) size ? size[0] * size[1] : 0 end if largest_image File.join(appicon_set_path, largest_image['filename']) else raise "No images found in Contents.json for brand #{brand_key}" end end end