class Swiftproj::Core
Public Class Methods
new(ui:, shell:, file:)
click to toggle source
# File lib/swiftproj/core.rb, line 3 def initialize(ui:, shell:, file:) @ui = ui @shell = shell @file = file end
Public Instance Methods
add_system_framework(project, target_name, framework_path)
click to toggle source
# File lib/swiftproj/core.rb, line 34 def add_system_framework(project, target_name, framework_path) target = project.targets.find { |t| t.name == target_name } if target.nil? raise Swiftproj::NoSuchTargetError.new end build_phase = target.frameworks_build_phase if build_phase.nil? raise Swiftproj::NoFrameworksBuildPhaseError.new end file = project.new_file(framework_path) build_phase.add_file_reference(file) project.save end
configure_scheme_with_buildable_targets(scheme, buildable_target_names)
click to toggle source
# File lib/swiftproj/core.rb, line 70 def configure_scheme_with_buildable_targets(scheme, buildable_target_names) action = Xcodeproj::XCScheme::BuildAction.new for entry in scheme.build_action.entries blueprint_name = entry.buildable_references[0].blueprint_name if buildable_target_names.include? blueprint_name action.add_entry(entry) end end scheme.build_action = action scheme.save! end
generate_xcconfig(podspec)
click to toggle source
# File lib/swiftproj/core.rb, line 17 def generate_xcconfig(podspec) config = "CURRENT_PROJECT_VERSION = #{podspec.version}\n" if target = podspec.ios.deployment_target config += "IPHONEOS_DEPLOYMENT_TARGET = #{target}\n" end if target = podspec.osx.deployment_target config += "MACOSX_DEPLOYMENT_TARGET = #{target}\n" end if target = podspec.tvos.deployment_target config += "TVOS_DEPLOYMENT_TARGET = #{target}\n" end if target = podspec.watchos.deployment_target config += "WATCHOS_DEPLOYMENT_TARGET = #{target}\n" end @file.write("Config.xcconfig", config) end
generate_xcodeproj(argv=nil)
click to toggle source
# File lib/swiftproj/core.rb, line 9 def generate_xcodeproj(argv=nil) command = "swift package generate-xcodeproj" if argv command += " " + argv.join(" ") end @shell.run(command) end
remove_framework(project, target_name, framework_name)
click to toggle source
# File lib/swiftproj/core.rb, line 50 def remove_framework(project, target_name, framework_name) target = project.targets.find { |t| t.name == target_name } if target.nil? raise Swiftproj::NoSuchTargetError.new end build_phase = target.frameworks_build_phase if build_phase.nil? raise Swiftproj::NoFrameworksBuildPhaseError.new end file = build_phase.files_references.find { |f| f.path == framework_name } if file.nil? raise Swiftproj::NoFrameworkError.new end build_phase.remove_file_reference(file) project.save end