Class: Pod::Command::Lib::Archive
- Inherits:
-
Pod::Command::Lib
- Object
- Pod::Command::Lib
- Pod::Command::Lib::Archive
- Defined in:
- lib/pod/command/lib/archive.rb
Constant Summary collapse
- BUILD_ROOT =
Pathname.new("/tmp/CocoaPods/Archive")
Instance Attribute Summary collapse
-
#spec ⇒ Object
Returns the value of attribute spec.
Instance Method Summary collapse
- #build_project ⇒ Object
- #compress_project ⇒ Object
- #create_installer ⇒ Object
- #create_podfile ⇒ Object
- #create_project ⇒ Object
- #create_sandbox ⇒ Object
- #create_scheme ⇒ Object
- #create_spec ⇒ Object
- #generate_readme ⇒ Object
-
#initialize(argv) ⇒ Archive
constructor
A new instance of Archive.
- #output_pathname ⇒ Object
- #output_static_library ⇒ Object
- #run ⇒ Object
- #sandbox_pathname ⇒ Object
- #validate! ⇒ Object
Constructor Details
#initialize(argv) ⇒ Archive
Returns a new instance of Archive.
33 34 35 36 |
# File 'lib/pod/command/lib/archive.rb', line 33 def initialize(argv) @podspec_pathname = argv.shift_argument || Pathname.glob(Pathname.pwd + '*.podspec').first super end |
Instance Attribute Details
#spec ⇒ Object
Returns the value of attribute spec.
31 32 33 |
# File 'lib/pod/command/lib/archive.rb', line 31 def spec @spec end |
Instance Method Details
#build_project ⇒ Object
105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 |
# File 'lib/pod/command/lib/archive.rb', line 105 def build_project output_pathname.mkdir UI. %x{cd #{@sandbox.root} && xcodebuild -sdk iphoneos && xcodebuild -sdk iphonesimulator} platform_specific_static_libraries = Pathname.glob(@sandbox.root + "build" + "Release-*" + "**" + @installer.aggregate_targets.first.product_name) UI. %x{lipo -create #{platform_specific_static_libraries.join(" ")} -output #{output_static_library}} UI.puts "Built static library file in #{output_pathname}" headers = Pathname.glob(@spec.consumer(:ios).public_header_files) headers.each do |header_pathname| FileUtils.cp(header_pathname, output_pathname) end FileUtils.cp((sandbox_pathname + @installer.aggregate_targets.first.acknowledgements_basepath).to_path + ".markdown", output_pathname) FileUtils.cp((sandbox_pathname + @installer.aggregate_targets.first.acknowledgements_basepath).to_path + ".plist", output_pathname) FileUtils.cp((sandbox_pathname + @installer.aggregate_targets.first.xcconfig_path), output_pathname) end |
#compress_project ⇒ Object
190 191 192 193 194 |
# File 'lib/pod/command/lib/archive.rb', line 190 def compress_project UI.puts "Creating compressed archives" UI. %x{tar -cvzf "#{output_pathname.to_path + ".tar.gz"}" "#{output_pathname}" 2>&1} UI. %x{zip -r "#{output_pathname.to_path + ".zip"}" "#{output_pathname}" 2>&1} end |
#create_installer ⇒ Object
92 93 94 95 96 97 |
# File 'lib/pod/command/lib/archive.rb', line 92 def create_installer config.integrate_targets = false @installer = Installer.new(@sandbox, @podfile) @installer.update = false @installer end |
#create_podfile ⇒ Object
79 80 81 82 83 84 85 86 87 88 89 90 |
# File 'lib/pod/command/lib/archive.rb', line 79 def create_podfile podfile = { "target_definitions" => [{ "name"=> spec.name, "platform" => { "ios" => "7.1" }, "link_with_first_target" => true, "user_project_path" => @sandbox.project_path, "dependencies"=> [{ spec.name => [ { :path => @podspec_pathname.to_s } ] }] }] } @podfile = Podfile.from_hash(podfile) end |
#create_project ⇒ Object
73 74 75 76 77 |
# File 'lib/pod/command/lib/archive.rb', line 73 def create_project @project = Xcodeproj::Project.new(@sandbox.project_path) @project.save @project end |
#create_sandbox ⇒ Object
66 67 68 69 70 71 |
# File 'lib/pod/command/lib/archive.rb', line 66 def create_sandbox FileUtils.rm_rf BUILD_ROOT if BUILD_ROOT.exist? BUILD_ROOT.mkdir unless BUILD_ROOT.exist? sandbox_pathname.mkdir @sandbox = Sandbox.new(sandbox_pathname.to_s) end |
#create_scheme ⇒ Object
99 100 101 102 103 |
# File 'lib/pod/command/lib/archive.rb', line 99 def create_scheme @scheme = Xcodeproj::XCScheme.new @scheme.add_build_target(@installer.aggregate_targets.first.target, true) @scheme.save_as(@sandbox.project_path, "Archive", true) end |
#create_spec ⇒ Object
62 63 64 |
# File 'lib/pod/command/lib/archive.rb', line 62 def create_spec self.spec = Specification.from_file(@podspec_pathname) end |
#generate_readme ⇒ Object
124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 |
# File 'lib/pod/command/lib/archive.rb', line 124 def generate_readme readme = <<-EOF # #{@spec.to_s} This directory contains the [#{@spec.name}](#{@spec.homepage}) Pod compiled as a static library. Although CocoaPods is the recommended integration technique, you can use this package to vendor the library in your project statically. ## Manual Integration Instructions 1. Drag this folder into your Xcode Project. 2. Check the box next to your app's name under "Add to targets". 3. You may need to tweak your build settings, adding libraries, frameworks and custom build settings. EOF if @spec.consumer(:ios).frameworks.count > 0 readme << <<-EOF * Add these frameworks: ``` #{@spec.consumer(:ios).frameworks.join("\n")} ``` EOF end if @spec.consumer(:ios).frameworks.count > 0 readme << <<-EOF * Add these libraries: ``` #{@spec.consumer(:ios).libraries.join("\n")} ``` EOF end if @spec.consumer(:ios).xcconfig.count > 0 readme << <<-EOF * Add these build settings: ``` #{@spec.consumer(:ios).xcconfig} ``` EOF end readme << <<-EOF ## CocoaPods Integration If you'd like to use CocoaPods afterall, add this line to your `Podfile`: ```ruby pod "#{@spec.name}" ``` ## Note This folder and README were generated by CocoaPods-Archive. EOF readme.strip! (output_pathname + "README.md").write(readme) end |
#output_pathname ⇒ Object
196 197 198 |
# File 'lib/pod/command/lib/archive.rb', line 196 def output_pathname BUILD_ROOT + "#{spec.name}-#{spec.version}" end |
#output_static_library ⇒ Object
204 205 206 |
# File 'lib/pod/command/lib/archive.rb', line 204 def output_static_library output_pathname + "lib#{spec.name.camelize}.a" end |
#run ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/pod/command/lib/archive.rb', line 43 def run create_spec UI.puts "Archiving #{spec.name} into #{BUILD_ROOT.to_s}" create_sandbox create_project create_podfile create_installer @installer.install! create_scheme build_project generate_readme compress_project UI.notice "Check #{output_pathname} for the compiled version of #{@spec.name}." UI.notice "All Done 📬" end |
#sandbox_pathname ⇒ Object
200 201 202 |
# File 'lib/pod/command/lib/archive.rb', line 200 def sandbox_pathname BUILD_ROOT + "sandbox" end |
#validate! ⇒ Object
38 39 40 41 |
# File 'lib/pod/command/lib/archive.rb', line 38 def validate! super help! "Unable to find a podspec in the working directory" unless @podspec_pathname.try(:exist?) end |