module CocoapodsCatalystSupport
Constants
- Podfile
- VERSION
Public Instance Methods
configure_podfile()
click to toggle source
# File lib/cocoapods-catalyst-support/command_helpers.rb, line 51 def configure_podfile podfile = File.read('Podfile') unless podfile.include? "require 'cocoapods-catalyst-support'" podfile = "require 'cocoapods-catalyst-support'\n\n" + podfile end config = '' unless podfile.match(/catalyst_configuration\s+do/) config += "\n# Configure your macCatalyst dependencies\n" config += "catalyst_configuration do\n" config += "\t# Uncomment the next line for a verbose output\n\t# verbose!\n\n" config += "\t# ios '<pod_name>' # This dependency will only be available for iOS\n" config += "\t# macos '<pod_name>' # This dependency will only be available for macOS\nend\n" end is_catalyst_configured = podfile.match(/post_install[\S\s]+installer[\S\s]configure_catalyst/) changed = !(is_catalyst_configured && config.empty?) unless podfile.match /post_install\s+do/ podfile += config podfile += "\n# Configure your macCatalyst App\npost_install do |installer|\n\tinstaller.configure_catalyst\nend\n" else configure_line = (podfile.include? 'configure_catalyst') ? "" : "\n\tinstaller.configure_catalyst\n" post_install_line = podfile.filter_lines do |line| line.include? 'post_install' end.first if config.empty? new_post_install_line = post_install_line + configure_line else new_post_install_line = "#{config}\n\n" + post_install_line + configure_line end podfile.gsub! post_install_line, new_post_install_line end unless podfile.nil? File.open('Podfile', "w") { |file| file << podfile } end if changed puts 'Done! Checkout your Podfile to start configuring your macCatalyst dependencies' else puts 'It seems your Podfile is ready. Go ahead and start configuring your macCatalyst dependencies' end end
loggs(string)
click to toggle source
# File lib/cocoapods-catalyst-support/utils.rb, line 17 def loggs string if $verbose puts string end return end
validate_podfile()
click to toggle source
# File lib/cocoapods-catalyst-support/command_helpers.rb, line 96 def validate_podfile podfile = File.read('Podfile') errors = [] unless podfile.match(/require\s+[('|")]cocoapods-catalyst-support[('|")]/) errors << "- Are you missing `require cocoapods-catalyst-support` in your Podfile".red end unless podfile.match(/catalyst_configuration\s+do/) errors << "- Are you missing `require cocoapods-catalyst-support` in your Podfile".red end unless podfile.match(/post_install[\S\s]+installer[\S\s]configure_catalyst/) errors << "- Are you calling `configure_catalyst` from `post_install` phase?".red end pod_errors = podfile.validate unless pod_errors.empty? errors << "#{pod_errors.reduce('') do |acc, s| "#{acc}\n#{s}" end }" end unless errors.empty? raise ValidationError.new "Your catalyst configuration seems to have some errors:\n#{errors.join}" end end