cocoapods-packager 1.3.0 → 1.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.rubocop-cocoapods.yml +1 -0
- data/.rubocop.yml +19 -0
- data/.travis.yml +4 -1
- data/Gemfile +2 -1
- data/Gemfile.lock +54 -41
- data/Rakefile +2 -2
- data/cocoapods-packager.gemspec +1 -1
- data/lib/cocoapods-packager/builder.rb +135 -44
- data/lib/cocoapods-packager/framework.rb +1 -1
- data/lib/cocoapods-packager/mangle.rb +4 -4
- data/lib/cocoapods-packager/pod_utils.rb +175 -21
- data/lib/cocoapods-packager/spec_builder.rb +13 -17
- data/lib/cocoapods-packager/symbols.rb +4 -3
- data/lib/cocoapods_packager.rb +1 -1
- data/lib/pod/command/package.rb +40 -15
- data/spec/command/error_spec.rb +7 -0
- data/spec/command/package_spec.rb +189 -13
- data/spec/command/subspecs_spec.rb +2 -2
- data/spec/fixtures/KFData.podspec +2 -2
- data/spec/fixtures/LibraryConsumerDemo/LibraryConsumer.xcodeproj/project.pbxproj +39 -23
- data/spec/fixtures/LibraryConsumerDemo/LibraryConsumer/AppDelegate.m +2 -1
- data/spec/fixtures/LibraryConsumerDemo/Podfile +4 -0
- data/spec/fixtures/LibraryDemo.podspec +4 -2
- data/spec/fixtures/NikeKit.podspec +1 -1
- data/spec/fixtures/PackagerTest/PackagerTest.xcodeproj/project.pbxproj +36 -20
- data/spec/fixtures/PackagerTest/Podfile.lock +3 -1
- data/spec/fixtures/a.podspec +1 -1
- data/spec/fixtures/foo-bar.podspec +1 -1
- data/spec/integration/project_spec.rb +24 -3
- data/spec/pod/utils_spec.rb +40 -9
- data/spec/specification/builder_spec.rb +7 -7
- data/spec/specification/spec_builder_spec.rb +1 -1
- metadata +10 -4
| @@ -8,8 +8,8 @@ module Symbols | |
| 8 8 | 
             
              # 	- put defines into `GCC_PREPROCESSOR_DEFINITIONS` for passing to Xcode
         | 
| 9 9 | 
             
              #
         | 
| 10 10 | 
             
              def mangle_for_pod_dependencies(pod_name, sandbox_root)
         | 
| 11 | 
            -
                pod_libs = Dir.glob("#{sandbox_root}/build/lib*.a").select do
         | 
| 12 | 
            -
                   | 
| 11 | 
            +
                pod_libs = Dir.glob("#{sandbox_root}/build/lib*.a").select do |file|
         | 
| 12 | 
            +
                  file !~ /lib#{pod_name}.a$/
         | 
| 13 13 | 
             
                end
         | 
| 14 14 |  | 
| 15 15 | 
             
                dummy_alias = alias_symbol "PodsDummy_#{pod_name}", pod_name
         | 
| @@ -20,11 +20,11 @@ module Symbols | |
| 20 20 | 
             
                  all_syms += syms.map! { |sym| alias_symbol sym, pod_name }
         | 
| 21 21 | 
             
                end
         | 
| 22 22 |  | 
| 23 | 
            -
                "GCC_PREPROCESSOR_DEFINITIONS='$ | 
| 23 | 
            +
                "GCC_PREPROCESSOR_DEFINITIONS='$(inherited) #{all_syms.uniq.join(' ')}'"
         | 
| 24 24 | 
             
              end
         | 
| 25 25 |  | 
| 26 26 | 
             
              def alias_symbol(sym, pod_name)
         | 
| 27 | 
            -
                pod_name = pod_name. | 
| 27 | 
            +
                pod_name = pod_name.tr('-', '_')
         | 
| 28 28 | 
             
                sym + "=Pod#{pod_name}_" + sym
         | 
| 29 29 | 
             
              end
         | 
| 30 30 |  | 
| @@ -1,48 +1,70 @@ | |
| 1 1 | 
             
            module Pod
         | 
| 2 2 | 
             
              class Command
         | 
| 3 3 | 
             
                class Package < Command
         | 
| 4 | 
            -
                   | 
| 4 | 
            +
                  private
         | 
| 5 | 
            +
             | 
| 6 | 
            +
                  def build_static_sandbox(dynamic)
         | 
| 7 | 
            +
                    static_sandbox_root = if dynamic
         | 
| 8 | 
            +
                                            Pathname.new(config.sandbox_root + '/Static')
         | 
| 9 | 
            +
                                          else
         | 
| 10 | 
            +
                                            Pathname.new(config.sandbox_root)
         | 
| 11 | 
            +
                                          end
         | 
| 12 | 
            +
                    Sandbox.new(static_sandbox_root)
         | 
| 13 | 
            +
                  end
         | 
| 5 14 |  | 
| 6 | 
            -
                  def install_pod(platform_name)
         | 
| 15 | 
            +
                  def install_pod(platform_name, sandbox)
         | 
| 7 16 | 
             
                    podfile = podfile_from_spec(
         | 
| 8 17 | 
             
                      File.basename(@path),
         | 
| 9 18 | 
             
                      @spec.name,
         | 
| 10 19 | 
             
                      platform_name,
         | 
| 11 20 | 
             
                      @spec.deployment_target(platform_name),
         | 
| 12 21 | 
             
                      @subspecs,
         | 
| 13 | 
            -
                      @spec_sources | 
| 22 | 
            +
                      @spec_sources
         | 
| 14 23 | 
             
                    )
         | 
| 15 24 |  | 
| 16 | 
            -
                     | 
| 17 | 
            -
                     | 
| 18 | 
            -
                    installer.install!
         | 
| 25 | 
            +
                    static_installer = Installer.new(sandbox, podfile)
         | 
| 26 | 
            +
                    static_installer.install!
         | 
| 19 27 |  | 
| 20 | 
            -
                    unless  | 
| 21 | 
            -
                       | 
| 28 | 
            +
                    unless static_installer.nil?
         | 
| 29 | 
            +
                      static_installer.pods_project.targets.each do |target|
         | 
| 22 30 | 
             
                        target.build_configurations.each do |config|
         | 
| 23 31 | 
             
                          config.build_settings['CLANG_MODULES_AUTOLINK'] = 'NO'
         | 
| 32 | 
            +
                          config.build_settings['GCC_GENERATE_DEBUGGING_SYMBOLS'] = 'NO'
         | 
| 24 33 | 
             
                        end
         | 
| 25 34 | 
             
                      end
         | 
| 26 | 
            -
                       | 
| 35 | 
            +
                      static_installer.pods_project.save
         | 
| 27 36 | 
             
                    end
         | 
| 28 37 |  | 
| 29 | 
            -
                     | 
| 38 | 
            +
                    static_installer
         | 
| 30 39 | 
             
                  end
         | 
| 31 40 |  | 
| 32 41 | 
             
                  def podfile_from_spec(path, spec_name, platform_name, deployment_target, subspecs, sources)
         | 
| 42 | 
            +
                    options = {}
         | 
| 43 | 
            +
                    if path
         | 
| 44 | 
            +
                      options[:podspec] = path
         | 
| 45 | 
            +
                    else
         | 
| 46 | 
            +
                      options[:path] = '.'
         | 
| 47 | 
            +
                    end
         | 
| 48 | 
            +
                    options[:subspecs] = subspecs if subspecs
         | 
| 33 49 | 
             
                    Pod::Podfile.new do
         | 
| 34 50 | 
             
                      sources.each { |s| source s }
         | 
| 35 51 | 
             
                      platform(platform_name, deployment_target)
         | 
| 36 | 
            -
                       | 
| 37 | 
            -
             | 
| 38 | 
            -
             | 
| 39 | 
            -
             | 
| 52 | 
            +
                      pod(spec_name, options)
         | 
| 53 | 
            +
             | 
| 54 | 
            +
                      install!('cocoapods',
         | 
| 55 | 
            +
                               :integrate_targets => false,
         | 
| 56 | 
            +
                               :deterministic_uuids => false)
         | 
| 57 | 
            +
             | 
| 58 | 
            +
                      target('packager') do
         | 
| 59 | 
            +
                        if path
         | 
| 60 | 
            +
                          if subspecs
         | 
| 61 | 
            +
                            subspecs.each do |subspec|
         | 
| 62 | 
            +
                              pod spec_name + '/' + subspec, :podspec => path
         | 
| 63 | 
            +
                            end
         | 
| 64 | 
            +
                          else
         | 
| 65 | 
            +
                            pod spec_name, :podspec => path
         | 
| 40 66 | 
             
                          end
         | 
| 41 | 
            -
                         | 
| 42 | 
            -
                          pod spec_name, :podspec => path
         | 
| 43 | 
            -
                        end
         | 
| 44 | 
            -
                      else
         | 
| 45 | 
            -
                        if subspecs
         | 
| 67 | 
            +
                        elsif subspecs
         | 
| 46 68 | 
             
                          subspecs.each do |subspec|
         | 
| 47 69 | 
             
                            pod spec_name + '/' + subspec, :path => '.'
         | 
| 48 70 | 
             
                          end
         | 
| @@ -55,7 +77,6 @@ module Pod | |
| 55 77 |  | 
| 56 78 | 
             
                  def binary_only?(spec)
         | 
| 57 79 | 
             
                    deps = spec.dependencies.map { |dep| spec_with_name(dep.name) }
         | 
| 58 | 
            -
             | 
| 59 80 | 
             
                    [spec, *deps].each do |specification|
         | 
| 60 81 | 
             
                      %w(vendored_frameworks vendored_libraries).each do |attrib|
         | 
| 61 82 | 
             
                        if specification.attributes_hash[attrib]
         | 
| @@ -70,7 +91,7 @@ module Pod | |
| 70 91 | 
             
                  def spec_with_name(name)
         | 
| 71 92 | 
             
                    return if name.nil?
         | 
| 72 93 |  | 
| 73 | 
            -
                    set =  | 
| 94 | 
            +
                    set = Pod::Config.instance.sources_manager.search(Dependency.new(name))
         | 
| 74 95 | 
             
                    return nil if set.nil?
         | 
| 75 96 |  | 
| 76 97 | 
             
                    set.specification.root
         | 
| @@ -93,6 +114,139 @@ module Pod | |
| 93 114 |  | 
| 94 115 | 
             
                    Specification.from_file(path)
         | 
| 95 116 | 
             
                  end
         | 
| 117 | 
            +
             | 
| 118 | 
            +
                  #----------------------
         | 
| 119 | 
            +
                  # Dynamic Project Setup
         | 
| 120 | 
            +
                  #----------------------
         | 
| 121 | 
            +
             | 
| 122 | 
            +
                  def build_dynamic_sandbox(_static_sandbox, _static_installer)
         | 
| 123 | 
            +
                    dynamic_sandbox_root = Pathname.new(config.sandbox_root + '/Dynamic')
         | 
| 124 | 
            +
                    dynamic_sandbox = Sandbox.new(dynamic_sandbox_root)
         | 
| 125 | 
            +
             | 
| 126 | 
            +
                    dynamic_sandbox
         | 
| 127 | 
            +
                  end
         | 
| 128 | 
            +
             | 
| 129 | 
            +
                  def install_dynamic_pod(dynamic_sandbox, static_sandbox, static_installer)
         | 
| 130 | 
            +
                    # 1 Create a dynamic target for only the spec pod.
         | 
| 131 | 
            +
                    dynamic_target = build_dynamic_target(dynamic_sandbox, static_installer)
         | 
| 132 | 
            +
             | 
| 133 | 
            +
                    # 2. Build a new xcodeproj in the dynamic_sandbox with only the spec pod as a target.
         | 
| 134 | 
            +
                    project = prepare_pods_project(dynamic_sandbox, dynamic_target.name, static_installer)
         | 
| 135 | 
            +
             | 
| 136 | 
            +
                    # 3. Copy the source directory for the dynamic framework from the static sandbox.
         | 
| 137 | 
            +
                    copy_dynamic_target(static_sandbox, dynamic_target, dynamic_sandbox)
         | 
| 138 | 
            +
             | 
| 139 | 
            +
                    # 4. Copy the supporting files for the dynamic framework from the static sandbox.
         | 
| 140 | 
            +
                    copy_dynamic_supporting_files(static_sandbox, dynamic_target, dynamic_sandbox)
         | 
| 141 | 
            +
             | 
| 142 | 
            +
                    # 5. Update the file accecssors.
         | 
| 143 | 
            +
                    dynamic_target = update_file_accessors(dynamic_target, dynamic_sandbox)
         | 
| 144 | 
            +
             | 
| 145 | 
            +
                    # 6. Create the file references.
         | 
| 146 | 
            +
                    install_file_references(dynamic_sandbox, [dynamic_target], project)
         | 
| 147 | 
            +
             | 
| 148 | 
            +
                    # 7. Install the target.
         | 
| 149 | 
            +
                    install_library(dynamic_sandbox, dynamic_target)
         | 
| 150 | 
            +
             | 
| 151 | 
            +
                    # 9. Write the actual Xcodeproject to the dynamic sandbox.
         | 
| 152 | 
            +
                    write_pod_project(project, dynamic_sandbox)
         | 
| 153 | 
            +
                  end
         | 
| 154 | 
            +
             | 
| 155 | 
            +
                  def build_dynamic_target(dynamic_sandbox, static_installer)
         | 
| 156 | 
            +
                    spec_targets = static_installer.pod_targets.select do |target|
         | 
| 157 | 
            +
                      target.name == @spec.name
         | 
| 158 | 
            +
                    end
         | 
| 159 | 
            +
                    static_target = spec_targets[0]
         | 
| 160 | 
            +
             | 
| 161 | 
            +
                    dynamic_target = Pod::PodTarget.new(static_target.specs, static_target.target_definitions, dynamic_sandbox)
         | 
| 162 | 
            +
                    dynamic_target.host_requires_frameworks = true
         | 
| 163 | 
            +
                    dynamic_target.user_build_configurations = static_target.user_build_configurations
         | 
| 164 | 
            +
                    dynamic_target
         | 
| 165 | 
            +
                  end
         | 
| 166 | 
            +
             | 
| 167 | 
            +
                  def prepare_pods_project(dynamic_sandbox, spec_name, installer)
         | 
| 168 | 
            +
                    # Create a new pods project
         | 
| 169 | 
            +
                    pods_project = Pod::Project.new(dynamic_sandbox.project_path)
         | 
| 170 | 
            +
             | 
| 171 | 
            +
                    # Update build configurations
         | 
| 172 | 
            +
                    installer.analysis_result.all_user_build_configurations.each do |name, type|
         | 
| 173 | 
            +
                      pods_project.add_build_configuration(name, type)
         | 
| 174 | 
            +
                    end
         | 
| 175 | 
            +
             | 
| 176 | 
            +
                    # Add the pod group for only the dynamic framework
         | 
| 177 | 
            +
                    local = dynamic_sandbox.local?(spec_name)
         | 
| 178 | 
            +
                    path = dynamic_sandbox.pod_dir(spec_name)
         | 
| 179 | 
            +
                    was_absolute = dynamic_sandbox.local_path_was_absolute?(spec_name)
         | 
| 180 | 
            +
                    pods_project.add_pod_group(spec_name, path, local, was_absolute)
         | 
| 181 | 
            +
             | 
| 182 | 
            +
                    dynamic_sandbox.project = pods_project
         | 
| 183 | 
            +
                    pods_project
         | 
| 184 | 
            +
                  end
         | 
| 185 | 
            +
             | 
| 186 | 
            +
                  def copy_dynamic_target(static_sandbox, _dynamic_target, dynamic_sandbox)
         | 
| 187 | 
            +
                    command = "cp -a #{static_sandbox.root}/#{@spec.name} #{dynamic_sandbox.root}"
         | 
| 188 | 
            +
                    `#{command}`
         | 
| 189 | 
            +
                  end
         | 
| 190 | 
            +
             | 
| 191 | 
            +
                  def copy_dynamic_supporting_files(_static_sandbox, dynamic_target, _dynamic_sandbox)
         | 
| 192 | 
            +
                    support_dir = Pathname.new(dynamic_target.support_files_dir.to_s.chomp("/#{dynamic_target.name}"))
         | 
| 193 | 
            +
                    support_dir.mkdir
         | 
| 194 | 
            +
                  end
         | 
| 195 | 
            +
             | 
| 196 | 
            +
                  def update_file_accessors(dynamic_target, dynamic_sandbox)
         | 
| 197 | 
            +
                    pod_root = dynamic_sandbox.pod_dir(dynamic_target.root_spec.name)
         | 
| 198 | 
            +
             | 
| 199 | 
            +
                    path_list = Sandbox::PathList.new(pod_root)
         | 
| 200 | 
            +
                    file_accessors = dynamic_target.specs.map do |spec|
         | 
| 201 | 
            +
                      Sandbox::FileAccessor.new(path_list, spec.consumer(dynamic_target.platform))
         | 
| 202 | 
            +
                    end
         | 
| 203 | 
            +
             | 
| 204 | 
            +
                    dynamic_target.file_accessors = file_accessors
         | 
| 205 | 
            +
                    dynamic_target
         | 
| 206 | 
            +
                  end
         | 
| 207 | 
            +
             | 
| 208 | 
            +
                  def install_file_references(dynamic_sandbox, pod_targets, pods_project)
         | 
| 209 | 
            +
                    installer = Pod::Installer::FileReferencesInstaller.new(dynamic_sandbox, pod_targets, pods_project)
         | 
| 210 | 
            +
                    installer.install!
         | 
| 211 | 
            +
                  end
         | 
| 212 | 
            +
             | 
| 213 | 
            +
                  def install_library(dynamic_sandbox, dynamic_target)
         | 
| 214 | 
            +
                    return if dynamic_target.target_definitions.flat_map(&:dependencies).empty?
         | 
| 215 | 
            +
                    target_installer = Pod::Installer::PodTargetInstaller.new(dynamic_sandbox, dynamic_target)
         | 
| 216 | 
            +
                    target_installer.install!
         | 
| 217 | 
            +
             | 
| 218 | 
            +
                    # Installs System Frameworks
         | 
| 219 | 
            +
                    dynamic_target.file_accessors.each do |file_accessor|
         | 
| 220 | 
            +
                      file_accessor.spec_consumer.frameworks.each do |framework|
         | 
| 221 | 
            +
                        if dynamic_target.should_build?
         | 
| 222 | 
            +
                          dynamic_target.native_target.add_system_framework(framework)
         | 
| 223 | 
            +
                        end
         | 
| 224 | 
            +
                      end
         | 
| 225 | 
            +
             | 
| 226 | 
            +
                      file_accessor.spec_consumer.libraries.each do |library|
         | 
| 227 | 
            +
                        if dynamic_target.should_build?
         | 
| 228 | 
            +
                          dynamic_target.native_target.add_system_library(library)
         | 
| 229 | 
            +
                        end
         | 
| 230 | 
            +
                      end
         | 
| 231 | 
            +
                    end
         | 
| 232 | 
            +
                  end
         | 
| 233 | 
            +
             | 
| 234 | 
            +
                  def write_pod_project(dynamic_project, dynamic_sandbox)
         | 
| 235 | 
            +
                    UI.message "- Writing Xcode project file to #{UI.path dynamic_sandbox.project_path}" do
         | 
| 236 | 
            +
                      dynamic_project.pods.remove_from_project if dynamic_project.pods.empty?
         | 
| 237 | 
            +
                      dynamic_project.development_pods.remove_from_project if dynamic_project.development_pods.empty?
         | 
| 238 | 
            +
                      dynamic_project.sort(:groups_position => :below)
         | 
| 239 | 
            +
                      dynamic_project.recreate_user_schemes(false)
         | 
| 240 | 
            +
             | 
| 241 | 
            +
                      # Edit search paths so that we can find our dependency headers
         | 
| 242 | 
            +
                      dynamic_project.targets.first.build_configuration_list.build_configurations.each do |config|
         | 
| 243 | 
            +
                        config.build_settings['HEADER_SEARCH_PATHS'] = "$(inherited) #{Dir.pwd}/Pods/Static/Headers/**"
         | 
| 244 | 
            +
                        config.build_settings['USER_HEADER_SEARCH_PATHS'] = "$(inherited) #{Dir.pwd}/Pods/Static/Headers/**"
         | 
| 245 | 
            +
                        config.build_settings['OTHER_LDFLAGS'] = '$(inherited) -ObjC'
         | 
| 246 | 
            +
                      end
         | 
| 247 | 
            +
                      dynamic_project.save
         | 
| 248 | 
            +
                    end
         | 
| 249 | 
            +
                  end
         | 
| 96 250 | 
             
                end
         | 
| 97 251 | 
             
              end
         | 
| 98 252 | 
             
            end
         | 
| @@ -1,9 +1,10 @@ | |
| 1 1 | 
             
            module Pod
         | 
| 2 2 | 
             
              class SpecBuilder
         | 
| 3 | 
            -
                def initialize(spec, source, embedded)
         | 
| 3 | 
            +
                def initialize(spec, source, embedded, dynamic)
         | 
| 4 4 | 
             
                  @spec = spec
         | 
| 5 | 
            -
                  @source = source.nil? ? '{}' : source
         | 
| 5 | 
            +
                  @source = source.nil? ? '{ :path => \'.\' }' : source
         | 
| 6 6 | 
             
                  @embedded = embedded
         | 
| 7 | 
            +
                  @dynamic = dynamic
         | 
| 7 8 | 
             
                end
         | 
| 8 9 |  | 
| 9 10 | 
             
                def framework_path
         | 
| @@ -16,13 +17,20 @@ module Pod | |
| 16 17 |  | 
| 17 18 | 
             
                def spec_platform(platform)
         | 
| 18 19 | 
             
                  fwk_base = platform.name.to_s + '/' + framework_path
         | 
| 19 | 
            -
                  spec =  | 
| 20 | 
            -
             | 
| 20 | 
            +
                  spec = if @dynamic
         | 
| 21 | 
            +
                           <<RB
         | 
| 22 | 
            +
              s.#{platform.name}.deployment_target    = '#{platform.deployment_target}'
         | 
| 23 | 
            +
              s.#{platform.name}.vendored_framework   = '#{fwk_base}'
         | 
| 24 | 
            +
            RB
         | 
| 25 | 
            +
                         else
         | 
| 26 | 
            +
                           <<SPEC
         | 
| 27 | 
            +
              s.#{platform.name}.deployment_target    = '#{platform.deployment_target}'
         | 
| 21 28 | 
             
              s.#{platform.name}.preserve_paths       = '#{fwk_base}'
         | 
| 22 29 | 
             
              s.#{platform.name}.public_header_files  = '#{fwk_base}/Versions/A/Headers/*.h'
         | 
| 23 30 | 
             
              s.#{platform.name}.resource             = '#{fwk_base}/Versions/A/Resources/**/*'
         | 
| 24 31 | 
             
              s.#{platform.name}.vendored_frameworks  = '#{fwk_base}'
         | 
| 25 32 | 
             
            SPEC
         | 
| 33 | 
            +
                         end
         | 
| 26 34 |  | 
| 27 35 | 
             
                  %w(frameworks libraries requires_arc xcconfig).each do |attribute|
         | 
| 28 36 | 
             
                    attributes_hash = @spec.attributes_hash[platform.name.to_s]
         | 
| @@ -33,13 +41,11 @@ SPEC | |
| 33 41 | 
             
                    value = "'#{value}'" if value.class == String
         | 
| 34 42 | 
             
                    spec += "  s.#{platform.name}.#{attribute} = #{value}\n"
         | 
| 35 43 | 
             
                  end
         | 
| 36 | 
            -
             | 
| 37 44 | 
             
                  spec
         | 
| 38 45 | 
             
                end
         | 
| 39 46 |  | 
| 40 47 | 
             
                def spec_metadata
         | 
| 41 48 | 
             
                  spec = spec_header
         | 
| 42 | 
            -
                  spec += spec_single_platform_fix
         | 
| 43 49 | 
             
                  spec
         | 
| 44 50 | 
             
                end
         | 
| 45 51 |  | 
| @@ -47,7 +53,7 @@ SPEC | |
| 47 53 | 
             
                  "end\n"
         | 
| 48 54 | 
             
                end
         | 
| 49 55 |  | 
| 50 | 
            -
                 | 
| 56 | 
            +
                private
         | 
| 51 57 |  | 
| 52 58 | 
             
                def spec_header
         | 
| 53 59 | 
             
                  spec = "Pod::Spec.new do |s|\n"
         | 
| @@ -64,15 +70,5 @@ SPEC | |
| 64 70 |  | 
| 65 71 | 
             
                  spec + "  s.source = #{@source}\n\n"
         | 
| 66 72 | 
             
                end
         | 
| 67 | 
            -
             | 
| 68 | 
            -
                def spec_single_platform_fix
         | 
| 69 | 
            -
                  return '' if @spec.available_platforms.length > 1
         | 
| 70 | 
            -
             | 
| 71 | 
            -
                  platform = @spec.available_platforms.first
         | 
| 72 | 
            -
             | 
| 73 | 
            -
                  <<SPEC
         | 
| 74 | 
            -
              s.platform = :#{platform.symbolic_name}, '#{platform.deployment_target}'
         | 
| 75 | 
            -
            SPEC
         | 
| 76 | 
            -
                end
         | 
| 77 73 | 
             
              end
         | 
| 78 74 | 
             
            end
         | 
| @@ -1,14 +1,15 @@ | |
| 1 1 | 
             
            module Symbols
         | 
| 2 2 | 
             
              def symbols_from_library(library)
         | 
| 3 3 | 
             
                syms = `nm -gU #{library}`.split("\n")
         | 
| 4 | 
            -
             | 
| 5 4 | 
             
                result = classes_from_symbols(syms)
         | 
| 6 | 
            -
                result  | 
| 5 | 
            +
                result += constants_from_symbols(syms)
         | 
| 6 | 
            +
             | 
| 7 | 
            +
                result.reject { |e| e == 'llvm.cmdline' || e == 'llvm.embedded.module' }
         | 
| 7 8 | 
             
              end
         | 
| 8 9 |  | 
| 9 10 | 
             
              module_function :symbols_from_library
         | 
| 10 11 |  | 
| 11 | 
            -
               | 
| 12 | 
            +
              private
         | 
| 12 13 |  | 
| 13 14 | 
             
              def classes_from_symbols(syms)
         | 
| 14 15 | 
             
                classes = syms.select { |klass| klass[/OBJC_CLASS_\$_/] }
         | 
    
        data/lib/cocoapods_packager.rb
    CHANGED
    
    
    
        data/lib/pod/command/package.rb
    CHANGED
    
    | @@ -1,12 +1,11 @@ | |
| 1 1 | 
             
            require 'tmpdir'
         | 
| 2 | 
            -
             | 
| 3 2 | 
             
            module Pod
         | 
| 4 3 | 
             
              class Command
         | 
| 5 4 | 
             
                class Package < Command
         | 
| 6 5 | 
             
                  self.summary = 'Package a podspec into a static library.'
         | 
| 7 6 | 
             
                  self.arguments = [
         | 
| 8 7 | 
             
                    CLAide::Argument.new('NAME', true),
         | 
| 9 | 
            -
                    CLAide::Argument.new('SOURCE', false) | 
| 8 | 
            +
                    CLAide::Argument.new('SOURCE', false)
         | 
| 10 9 | 
             
                  ]
         | 
| 11 10 |  | 
| 12 11 | 
             
                  def self.options
         | 
| @@ -15,9 +14,12 @@ module Pod | |
| 15 14 | 
             
                      ['--no-mangle', 'Do not mangle symbols of depedendant Pods.'],
         | 
| 16 15 | 
             
                      ['--embedded',  'Generate embedded frameworks.'],
         | 
| 17 16 | 
             
                      ['--library',   'Generate static libraries.'],
         | 
| 18 | 
            -
                      ['-- | 
| 17 | 
            +
                      ['--dynamic',   'Generate dynamic framework.'],
         | 
| 18 | 
            +
                      ['--exclude-deps', 'Exclude symbols from dependencies.'],
         | 
| 19 | 
            +
                      ['--configuration', 'Build the specified configuration (e.g. Debug). Defaults to Release'],
         | 
| 20 | 
            +
                      ['--subspecs', 'Only include the given subspecs'],
         | 
| 19 21 | 
             
                      ['--spec-sources=private,https://github.com/CocoaPods/Specs.git', 'The sources to pull dependant ' \
         | 
| 20 | 
            -
                        'pods from (defaults to https://github.com/CocoaPods/Specs.git)'] | 
| 22 | 
            +
                        'pods from (defaults to https://github.com/CocoaPods/Specs.git)']
         | 
| 21 23 | 
             
                    ]
         | 
| 22 24 | 
             
                  end
         | 
| 23 25 |  | 
| @@ -25,7 +27,9 @@ module Pod | |
| 25 27 | 
             
                    @embedded = argv.flag?('embedded')
         | 
| 26 28 | 
             
                    @force = argv.flag?('force')
         | 
| 27 29 | 
             
                    @library = argv.flag?('library')
         | 
| 30 | 
            +
                    @dynamic = argv.flag?('dynamic')
         | 
| 28 31 | 
             
                    @mangle = argv.flag?('mangle', true)
         | 
| 32 | 
            +
                    @exclude_deps = argv.flag?('exclude-deps', false)
         | 
| 29 33 | 
             
                    @name = argv.shift_argument
         | 
| 30 34 | 
             
                    @source = argv.shift_argument
         | 
| 31 35 | 
             
                    @spec_sources = argv.option('spec-sources', 'https://github.com/CocoaPods/Specs.git').split(',')
         | 
| @@ -33,6 +37,8 @@ module Pod | |
| 33 37 | 
             
                    subspecs = argv.option('subspecs')
         | 
| 34 38 | 
             
                    @subspecs = subspecs.split(',') unless subspecs.nil?
         | 
| 35 39 |  | 
| 40 | 
            +
                    @config = argv.option('configuration', 'Release')
         | 
| 41 | 
            +
             | 
| 36 42 | 
             
                    @source_dir = Dir.pwd
         | 
| 37 43 | 
             
                    @spec = spec_with_path(@name)
         | 
| 38 44 | 
             
                    @spec = spec_with_name(@name) unless @spec
         | 
| @@ -42,7 +48,8 @@ module Pod | |
| 42 48 | 
             
                  def validate!
         | 
| 43 49 | 
             
                    super
         | 
| 44 50 | 
             
                    help! 'A podspec name or path is required.' unless @spec
         | 
| 45 | 
            -
                    help! 'podspec has binary-only depedencies, mangling not possible.' if binary_only? | 
| 51 | 
            +
                    help! 'podspec has binary-only depedencies, mangling not possible.' if @mangle && binary_only?(@spec)
         | 
| 52 | 
            +
                    help! '--exclude-deps option can only be used for static libraries' if @exclude_deps && @dynamic
         | 
| 46 53 | 
             
                  end
         | 
| 47 54 |  | 
| 48 55 | 
             
                  def run
         | 
| @@ -54,21 +61,27 @@ module Pod | |
| 54 61 | 
             
                    target_dir, work_dir = create_working_directory
         | 
| 55 62 | 
             
                    return if target_dir.nil?
         | 
| 56 63 | 
             
                    build_package
         | 
| 64 | 
            +
             | 
| 57 65 | 
             
                    `mv "#{work_dir}" "#{target_dir}"`
         | 
| 58 66 | 
             
                    Dir.chdir(@source_dir)
         | 
| 59 67 | 
             
                  end
         | 
| 60 68 |  | 
| 61 | 
            -
                   | 
| 69 | 
            +
                  private
         | 
| 62 70 |  | 
| 63 71 | 
             
                  def build_in_sandbox(platform)
         | 
| 72 | 
            +
                    config.installation_root  = Pathname.new(Dir.pwd)
         | 
| 64 73 | 
             
                    config.sandbox_root       = 'Pods'
         | 
| 65 | 
            -
                    config.integrate_targets  = false
         | 
| 66 | 
            -
                    config.skip_repo_update   = true
         | 
| 67 74 |  | 
| 68 | 
            -
                     | 
| 75 | 
            +
                    static_sandbox = build_static_sandbox(@dynamic)
         | 
| 76 | 
            +
                    static_installer = install_pod(platform.name, static_sandbox)
         | 
| 77 | 
            +
             | 
| 78 | 
            +
                    if @dynamic
         | 
| 79 | 
            +
                      dynamic_sandbox = build_dynamic_sandbox(static_sandbox, static_installer)
         | 
| 80 | 
            +
                      install_dynamic_pod(dynamic_sandbox, static_sandbox, static_installer)
         | 
| 81 | 
            +
                    end
         | 
| 69 82 |  | 
| 70 83 | 
             
                    begin
         | 
| 71 | 
            -
                      perform_build(platform,  | 
| 84 | 
            +
                      perform_build(platform, static_sandbox, dynamic_sandbox)
         | 
| 72 85 |  | 
| 73 86 | 
             
                    ensure # in case the build fails; see Builder#xcodebuild.
         | 
| 74 87 | 
             
                      Pathname.new(config.sandbox_root).rmtree
         | 
| @@ -77,7 +90,7 @@ module Pod | |
| 77 90 | 
             
                  end
         | 
| 78 91 |  | 
| 79 92 | 
             
                  def build_package
         | 
| 80 | 
            -
                    builder = SpecBuilder.new(@spec, @source, @embedded)
         | 
| 93 | 
            +
                    builder = SpecBuilder.new(@spec, @source, @embedded, @dynamic)
         | 
| 81 94 | 
             
                    newspec = builder.spec_metadata
         | 
| 82 95 |  | 
| 83 96 | 
             
                    @spec.available_platforms.each do |platform|
         | 
| @@ -115,14 +128,26 @@ module Pod | |
| 115 128 | 
             
                    [target_dir, work_dir]
         | 
| 116 129 | 
             
                  end
         | 
| 117 130 |  | 
| 118 | 
            -
                  def perform_build(platform,  | 
| 131 | 
            +
                  def perform_build(platform, static_sandbox, dynamic_sandbox)
         | 
| 132 | 
            +
                    static_sandbox_root = config.sandbox_root.to_s
         | 
| 133 | 
            +
             | 
| 134 | 
            +
                    if @dynamic
         | 
| 135 | 
            +
                      static_sandbox_root = "#{static_sandbox_root}/#{static_sandbox.root.to_s.split('/').last}"
         | 
| 136 | 
            +
                      dynamic_sandbox_root = "#{config.sandbox_root}/#{dynamic_sandbox.root.to_s.split('/').last}"
         | 
| 137 | 
            +
                    end
         | 
| 138 | 
            +
             | 
| 119 139 | 
             
                    builder = Pod::Builder.new(
         | 
| 120 140 | 
             
                      @source_dir,
         | 
| 121 | 
            -
                       | 
| 122 | 
            -
                       | 
| 141 | 
            +
                      static_sandbox_root,
         | 
| 142 | 
            +
                      dynamic_sandbox_root,
         | 
| 143 | 
            +
                      static_sandbox.public_headers.root,
         | 
| 123 144 | 
             
                      @spec,
         | 
| 124 145 | 
             
                      @embedded,
         | 
| 125 | 
            -
                      @mangle | 
| 146 | 
            +
                      @mangle,
         | 
| 147 | 
            +
                      @dynamic,
         | 
| 148 | 
            +
                      @config,
         | 
| 149 | 
            +
                      @exclude_deps
         | 
| 150 | 
            +
                    )
         | 
| 126 151 |  | 
| 127 152 | 
             
                    builder.build(platform, @library)
         | 
| 128 153 |  |