Skip to content

Commit

Permalink
Add Carthage support
Browse files Browse the repository at this point in the history
Added carthage as a dependency manager.

What it does:

- Adds an empty `Cartfile`
- Runs `carthage update`
- Adds the `copy-frameworks.sh` build phase to the project
- Adds `carthage update` to `bin/setup` script
  • Loading branch information
jakecraige committed Jun 12, 2015
1 parent 8625e6e commit aca9304
Show file tree
Hide file tree
Showing 9 changed files with 63 additions and 4 deletions.
1 change: 1 addition & 0 deletions lib/liftoff.rb
Expand Up @@ -11,6 +11,7 @@
require 'liftoff/cli'
require "liftoff/dependency_manager_coordinator"
require "liftoff/dependency_manager"
require "liftoff/dependency_managers/carthage"
require "liftoff/dependency_managers/cocoapods"
require "liftoff/dependency_managers/null_dependency_manager"
require 'liftoff/settings_generator'
Expand Down
2 changes: 1 addition & 1 deletion lib/liftoff/cli.rb
Expand Up @@ -35,7 +35,7 @@ def global_options
@options[:strict_prompts] = strict_prompts
end

opts.on('--dependency-managers [NAME(s)]', 'Comma separated list of dependency managers to enable. Available options: cocoapods') do |list|
opts.on('--dependency-managers [NAME(s)]', 'Comma separated list of dependency managers to enable. Available options: cocoapods,carthage') do |list|
@options[:dependency_managers] = (list || "").split(",")
end

Expand Down
41 changes: 41 additions & 0 deletions lib/liftoff/dependency_managers/carthage.rb
@@ -0,0 +1,41 @@
module Liftoff
class Carthage < DependencyManager
def setup
if carthage_installed?
move_cartfile
else
puts 'Please install Carthage or disable carthage from liftoff'
end
end

def install
if carthage_installed?
run_carthage_update
end
end

def run_script_phases
[
{
"file" => "copy_frameworks.sh",
"name" => "Copy framworks (Carthage)",
}
]
end

private

def carthage_installed?
system('which carthage > /dev/null')
end

def move_cartfile
FileManager.new.generate('Cartfile', 'Cartfile', @config)
end

def run_carthage_update
puts 'Running carthage update'
system('carthage update')
end
end
end
14 changes: 11 additions & 3 deletions lib/liftoff/launchpad.rb
Expand Up @@ -16,7 +16,7 @@ def liftoff(options)
setup_dependency_managers
generate_templates
generate_settings
install_dependency_managers
install_dependencies
perform_project_actions
open_project
end
Expand Down Expand Up @@ -51,7 +51,7 @@ def setup_dependency_managers
dependency_manager_coordinator.setup_dependencies
end

def install_dependency_managers
def install_dependencies
dependency_manager_coordinator.install_dependencies
end

Expand Down Expand Up @@ -124,7 +124,7 @@ def dependency_manager_coordinator
end

def dependency_managers
@dependency_managers ||= [cocoapods]
@dependency_managers ||= [cocoapods, carthage]
end

def cocoapods
Expand All @@ -134,5 +134,13 @@ def cocoapods
NullDependencyManager.new(@config)
end
end

def carthage
if @config.dependency_manager_enabled?("carthage")
Carthage.new(@config)
else
NullDependencyManager.new(@config)
end
end
end
end
Empty file added templates/Cartfile
Empty file.
2 changes: 2 additions & 0 deletions templates/Gemfile.rb
@@ -1,4 +1,6 @@
source 'https://rubygems.org'

<% if enable_settings && dependency_manager_enabled?("cocoapods") %>
gem 'cocoapods'
<% end %>
gem 'xcpretty'
1 change: 1 addition & 0 deletions templates/copy_frameworks.sh
@@ -0,0 +1 @@
/usr/local/bin/carthage copy-frameworks
1 change: 1 addition & 0 deletions templates/gitignore
Expand Up @@ -26,6 +26,7 @@ build/

# Cocoapods
Pods
Carthage

# AppCode specific files
.idea/
Expand Down
5 changes: 5 additions & 0 deletions templates/setup.sh
@@ -1,4 +1,9 @@
#!/usr/bin/env bash

bundle install
<% if enable_settings && dependency_manager_enabled?("cocoapods") %>
pod install
<% end %>
<% if dependency_manager_enabled?("carthage") %>
carthage update
<% end %>

0 comments on commit aca9304

Please sign in to comment.