Skip to content

Instantly share code, notes, and snippets.

@neonichu
Created May 27, 2015 18:47
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save neonichu/e7d761c8293b62536176 to your computer and use it in GitHub Desktop.
Save neonichu/e7d761c8293b62536176 to your computer and use it in GitHub Desktop.
Do a development Pod install and archive the corresponding framework via Carthage automatically.
#!/usr/bin/env ruby
require 'cocoapods'
require 'fileutils'
def podfile_from_spec(spec)
podfile = File.open('Podfile', 'w')
podfile.write(<<-EOF
platform :ios, '8.0'
use_frameworks!
EOF
)
spec.available_platforms.each do |platform|
podfile.write(<<-EOF
target '#{platform.name}' do
platform :#{platform.name}, '#{platform.deployment_target}'
pod '#{spec.name}', :path => '..'
end
EOF
)
end
podfile.close
end
TMPDIR = 'Zama'.freeze
spec = Pod::Specification.from_file(Dir.glob("*.podspec").first)
FileUtils.mkdir_p(TMPDIR)
Dir.chdir(TMPDIR) do
podfile_from_spec(spec)
puts `pod install --no-repo-update --no-integrate`
FileUtils.ln_sf('Pods/Pods.xcodeproj', '_.xcodeproj')
puts `carthage build --no-skip-current`
frameworks = Dir.glob('Carthage/**/*.framework').map { |f| Pathname.new(f).basename.sub_ext('') }.uniq
frameworks.each do |framework|
puts `carthage archive #{framework}`
FileUtils.mv("#{framework}.framework.zip", '..')
end
end
FileUtils.rm_rf(TMPDIR)
@segiddins
Copy link

Use Pod::Executable instead of backticks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment