diff --git a/Gemfile b/Gemfile
index 78ecfa2..2449702 100644
--- a/Gemfile
+++ b/Gemfile
@@ -9,6 +9,8 @@ gem 'plist'
gem 'rest-client'
gem 'yard'
gem 'net/ftp'
+gem 'net/ssh'
+gem 'net/scp'
group :test do
gem 'rspec'
diff --git a/lib/xcode/builder/base_builder.rb b/lib/xcode/builder/base_builder.rb
index a833ba3..0382998 100644
--- a/lib/xcode/builder/base_builder.rb
+++ b/lib/xcode/builder/base_builder.rb
@@ -108,7 +108,7 @@ def web(protocol)
web = Xcode::Deploy::Web.new(protocol)
yield(web) if block_given?
- web.prepare(ipa_name, app_path, configuration_build_path, product_name)
+ web.prepare(ipa_name, app_path, configuration_build_path, @config.product_name, @config.info_plist, ipa_path)
web.deploy
end
diff --git a/lib/xcode/deploy/web.rb b/lib/xcode/deploy/web.rb
index 9c92f0e..8ec10fd 100644
--- a/lib/xcode/deploy/web.rb
+++ b/lib/xcode/deploy/web.rb
@@ -1,9 +1,11 @@
require 'net/ftp'
+require 'net/ssh'
+require 'net/scp'
module Xcode
module Deploy
class Web
- attr_accessor :protocol, :remote_host, :deploy_to, :username, :password, :remote_directory, :product_name, :ipa_name, :dist_path
+ attr_accessor :protocol, :remote_host, :deploy_to, :username, :password, :remote_directory, :product_name, :ipa_name, :dist_path, :ipa_path
def initialize(protocol)
@protocol = protocol
@@ -21,13 +23,14 @@ def remote_installation_path
File.join(@remote_directory, @product_name.downcase)
end
- def prepare(ipa_name, app_path, configuration_build_path, product_name)
+ def prepare(ipa_name, app_path, configuration_build_path, product_name, info_plist, ipa_path)
@product_name = product_name
@ipa_name = ipa_name
@dist_path = "#{configuration_build_path}/dist"
- File.mkdir(@dist_path)
- plist = CFPropertyList::List.new(:file => "#{app_path}/Info.plist")
- plist_data = CFPropertyList.native_types(plist.value)
+ @ipa_path = ipa_path
+ Dir.mkdir(@dist_path) unless File.exists?(@dist_path)
+ #plist = CFPropertyList::List.new(:file => "#{app_path}/Info.plist")
+ #plist_data = CFPropertyList.native_types(plist.value)
File.open("#{@dist_path}/manifest.plist", "w") do |io|
io << %{
@@ -49,13 +52,13 @@ def prepare(ipa_name, app_path, configuration_build_path, product_name)
metadata
bundle-identifier
- #{plist_data['CFBundleIdentifier']}
+ #{info_plist.identifier}
bundle-version
- #{plist_data['CFBundleVersion']}
+ #{info_plist.version}
kind
software
title
- #{plist_data['CFBundleDisplayName']}
+ #{product_name}
@@ -93,7 +96,20 @@ def prepare(ipa_name, app_path, configuration_build_path, product_name)
def deploy
if @protocol == "ssh" then
- system("scp #{@dist_path}/* #{@remote_host}:#{remote_installation_path}")
+ puts "Copying files to #{@remote_host}:#{remote_installation_path}"
+ #system("scp #{@dist_path}/* #{@remote_host}:#{remote_installation_path}")
+ Net::SSH.start(@remote_host, @username, :password => @password) do |ssh|
+ puts "Creating folder with mkdir #{remote_installation_path}"
+ ssh.exec!("mkdir #{remote_installation_path}")
+ end
+ Net::SCP.start(@remote_host, @username, :password => @password) do |scp|
+ puts "Copying files from folder #{@dist_path}"
+ Dir["#{@dist_path}/*"].each do |f|
+ puts "Copying #{f} to remote host in folder #{remote_installation_path}"
+ scp.upload! "#{f}", "#{remote_installation_path}"
+ end
+ scp.upload! "#{@ipa_path}", "#{remote_installation_path}"
+ end
elsif @protocol == "ftp" then
puts "Connecting to #{@remote_host} with username #{@username}"
Net::FTP.open(@remote_host, @username, @password) do |ftp|
@@ -105,11 +121,14 @@ def deploy
end
puts "Changing to remote folder #{remote_installation_path}"
files = ftp.chdir(remote_installation_path)
- Dir['#{@dist_path}/*'].each do |f|
+ Dir["#{@dist_path}/*"].each do |f|
filename = File.basename(f)
puts "Uploading #{filename}"
ftp.putbinaryfile(f, filename, 1024)
end
+ filename = File.basename("#{@ipa_path}")
+ puts "Uploading #{filename}"
+ ftp.putbinaryfile("#{@ipa_path}", filename, 1024)
end
else
diff --git a/lib/xcode/info_plist.rb b/lib/xcode/info_plist.rb
index 4a1d615..701eaac 100644
--- a/lib/xcode/info_plist.rb
+++ b/lib/xcode/info_plist.rb
@@ -34,6 +34,22 @@ def version=(version)
@plist['CFBundleVersion'] = version.to_s
end
+ def identifier
+ @plist['CFBundleIdentifier']
+ end
+
+ def identifier=(identifier)
+ @plist['CFBundleIdentifier'] = identifier
+ end
+
+ def display_name
+ @plist['CFBundleDisplayName']
+ end
+
+ def display_name=(name)
+ @plist['CFBundleDisplayName'] = name
+ end
+
def save
File.open(@plist_location, 'w') {|f| f << @plist.to_plist}
end