Skip to content

Instantly share code, notes, and snippets.

@orta
Last active December 19, 2015 15:09
Show Gist options
  • Save orta/5974581 to your computer and use it in GitHub Desktop.
Save orta/5974581 to your computer and use it in GitHub Desktop.
require 'cocoapods-downloader'
require 'cocoapods-core'
require 'cocoapods'
$active_folder = "active"
@download_location = $active_folder + "/download/#{spec.name}/#{spec.version}/#{spec.name}"
@spec = Pod::Spec.new do |s|
s.name = "MSActiveConfig"
s.version = "1.0.1"
s.summary = "Remote configuration and A/B Testing framework for iOS."
s.homepage = "https://github.com/mindsnacks/MSActiveConfig"
s.license = { :type => 'MIT', :file => 'LICENSE' }
s.author = { "Javier Soto" => "[email protected]" }
s.source = { :git => "https://github.com/mindsnacks/MSActiveConfig.git", :tag => "v1.0.1" }
s.platform = :ios, '6.0'
s.source_files = 'MSActiveConfig/Classes/*.{h,m}'
s.private_header_files = 'MSActiveConfig/Classes/*+Private.h'
s.requires_arc = true
end
# download
downloader = Pod::Downloader.for_target(@download_location, @spec.source)
downloader.cache_root = @cache_path
downloader.download
# extract headers from sandbox'd download files
download_location = $active_folder + "/download/#{@spec.name}/#{@spec.version}/#{@spec.name}"
pathlist = Pod::Sandbox::PathList.new( Pathname.new(download_location) )
headers = []
[@spec, *@spec.subspecs].each do |internal_spec|
if internal_spec.attributes_hash["source_files"]
internal_spec.available_platforms.each do |platform|
consumer = Pod::Specification::Consumer.new(internal_spec, platform)
accessor = Pod::Sandbox::FileAccessor.new(pathlist, consumer)
headers += accessor.public_headers.map{ |filepath| filepath.to_s }
end
else
puts "Skipping headers for #{internal_spec}".blue
end
end
p headers.uniq
@alloy
Copy link

alloy commented Jul 11, 2013

@alloy
Copy link

alloy commented Jul 11, 2013

So with the broken spec, as it’s currently in the master spec repo, the private headers are included:

~/t/TestPrivateHeaders » ruby t.rb
 > GitHub download
["active/download/MSActiveConfig/1.0.1/MSActiveConfig/MSActiveConfig/Classes/MSActiveConfig+Private.h", "active/download/MSActiveConfig/1.0.1/MSActiveConfig/MSActiveConfig/Classes/MSActiveConfig.h", "active/download/MSActiveConfig/1.0.1/MSActiveConfig/MSActiveConfig/Classes/MSActiveConfigConfigurationState+MSLazyLoadedState.h", "active/download/MSActiveConfig/1.0.1/MSActiveConfig/MSActiveConfig/Classes/MSActiveConfigConfigurationState+Private.h", "active/download/MSActiveConfig/1.0.1/MSActiveConfig/MSActiveConfig/Classes/MSActiveConfigConfigurationState.h", "active/download/MSActiveConfig/1.0.1/MSActiveConfig/MSActiveConfig/Classes/MSActiveConfigDownloader.h", "active/download/MSActiveConfig/1.0.1/MSActiveConfig/MSActiveConfig/Classes/MSActiveConfigListener.h", "active/download/MSActiveConfig/1.0.1/MSActiveConfig/MSActiveConfig/Classes/MSActiveConfigMutableConfigurationState.h", "active/download/MSActiveConfig/1.0.1/MSActiveConfig/MSActiveConfig/Classes/MSActiveConfigSection+Private.h", "active/download/MSActiveConfig/1.0.1/MSActiveConfig/MSActiveConfig/Classes/MSActiveConfigSection.h", "active/download/MSActiveConfig/1.0.1/MSActiveConfig/MSActiveConfig/Classes/MSActiveConfigStore.h", "active/download/MSActiveConfig/1.0.1/MSActiveConfig/MSActiveConfig/Classes/MSJSONURLRequestActiveConfigDownloader.h", "active/download/MSActiveConfig/1.0.1/MSActiveConfig/MSActiveConfig/Classes/MSUserDefaultsActiveConfigStore.h"]

@alloy
Copy link

alloy commented Jul 11, 2013

With the fixed spec, i.e. by adding the MSActiveConfig prefix, the private headers are excluded as expected:

~/t/TestPrivateHeaders » ruby t.rb
 > GitHub download
["active/download/MSActiveConfig/1.0.1/MSActiveConfig/MSActiveConfig/Classes/MSActiveConfig.h", "active/download/MSActiveConfig/1.0.1/MSActiveConfig/MSActiveConfig/Classes/MSActiveConfigConfigurationState+MSLazyLoadedState.h", "active/download/MSActiveConfig/1.0.1/MSActiveConfig/MSActiveConfig/Classes/MSActiveConfigConfigurationState.h", "active/download/MSActiveConfig/1.0.1/MSActiveConfig/MSActiveConfig/Classes/MSActiveConfigDownloader.h", "active/download/MSActiveConfig/1.0.1/MSActiveConfig/MSActiveConfig/Classes/MSActiveConfigListener.h", "active/download/MSActiveConfig/1.0.1/MSActiveConfig/MSActiveConfig/Classes/MSActiveConfigMutableConfigurationState.h", "active/download/MSActiveConfig/1.0.1/MSActiveConfig/MSActiveConfig/Classes/MSActiveConfigSection.h", "active/download/MSActiveConfig/1.0.1/MSActiveConfig/MSActiveConfig/Classes/MSActiveConfigStore.h", "active/download/MSActiveConfig/1.0.1/MSActiveConfig/MSActiveConfig/Classes/MSJSONURLRequestActiveConfigDownloader.h", "active/download/MSActiveConfig/1.0.1/MSActiveConfig/MSActiveConfig/Classes/MSUserDefaultsActiveConfigStore.h"]

@orta
Copy link
Author

orta commented Jul 11, 2013

👍 aceness

@orta
Copy link
Author

orta commented Jul 11, 2013

You get a free wine-glass from me at NSSpain.

@orta
Copy link
Author

orta commented Jul 11, 2013

Or maybe I'll ask Danger to bring something british over next week.

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