cocoapods-packager-next 2.0.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 +7 -0
- data/.coveralls.yml +1 -0
- data/.gitignore +4 -0
- data/.rubocop-cocoapods.yml +71 -0
- data/.rubocop.yml +38 -0
- data/.travis.yml +17 -0
- data/Gemfile +12 -0
- data/Gemfile.lock +129 -0
- data/LICENSE +22 -0
- data/README.md +39 -0
- data/Rakefile +29 -0
- data/cocoapods-packager-next.gemspec +22 -0
- data/lib/cocoapods-packager/builder.rb +334 -0
- data/lib/cocoapods-packager/framework.rb +66 -0
- data/lib/cocoapods-packager/mangle.rb +32 -0
- data/lib/cocoapods-packager/pod_utils.rb +250 -0
- data/lib/cocoapods-packager/spec_builder.rb +63 -0
- data/lib/cocoapods-packager/symbols.rb +42 -0
- data/lib/cocoapods-packager/user_interface/build_failed_report.rb +15 -0
- data/lib/cocoapods_packager.rb +5 -0
- data/lib/cocoapods_plugin.rb +8 -0
- data/lib/pod/command/package.rb +177 -0
- data/scripts/lstconst.sh +9 -0
- data/scripts/lstsym.sh +8 -0
- data/spec/command/error_spec.rb +81 -0
- data/spec/command/package_spec.rb +420 -0
- data/spec/command/subspecs_spec.rb +30 -0
- data/spec/fixtures/Archs.podspec +13 -0
- data/spec/fixtures/Builder.podspec +25 -0
- data/spec/fixtures/CPDColors.podspec +19 -0
- data/spec/fixtures/FH.podspec +18 -0
- data/spec/fixtures/KFData.podspec +73 -0
- data/spec/fixtures/LibraryConsumerDemo/.gitignore +22 -0
- data/spec/fixtures/LibraryConsumerDemo/LibraryConsumer/AppDelegate.h +17 -0
- data/spec/fixtures/LibraryConsumerDemo/LibraryConsumer/AppDelegate.m +27 -0
- data/spec/fixtures/LibraryConsumerDemo/LibraryConsumer/Info.plist +40 -0
- data/spec/fixtures/LibraryConsumerDemo/LibraryConsumer/main.m +16 -0
- data/spec/fixtures/LibraryConsumerDemo/LibraryConsumer.xcodeproj/project.pbxproj +311 -0
- data/spec/fixtures/LibraryConsumerDemo/LibraryConsumer.xcodeproj/project.xcworkspace/contents.xcworkspacedata +7 -0
- data/spec/fixtures/LibraryConsumerDemo/LibraryConsumer.xcodeproj/xcshareddata/xcschemes/LibraryConsumer.xcscheme +100 -0
- data/spec/fixtures/LibraryConsumerDemo/LibraryConsumer.xcworkspace/contents.xcworkspacedata +10 -0
- data/spec/fixtures/LibraryConsumerDemo/Podfile +5 -0
- data/spec/fixtures/LibraryDemo.podspec +14 -0
- data/spec/fixtures/LocalSources/LICENSE +0 -0
- data/spec/fixtures/LocalSources/LocalNikeKit.h +4 -0
- data/spec/fixtures/LocalSources/LocalNikeKit.m +9 -0
- data/spec/fixtures/LocalSources/LocalNikeKit.podspec +19 -0
- data/spec/fixtures/NikeKit.podspec +19 -0
- data/spec/fixtures/OpenSans.podspec +18 -0
- data/spec/fixtures/PackagerTest/.gitignore +21 -0
- data/spec/fixtures/PackagerTest/PackagerTest/CPDAppDelegate.h +15 -0
- data/spec/fixtures/PackagerTest/PackagerTest/CPDAppDelegate.m +49 -0
- data/spec/fixtures/PackagerTest/PackagerTest/Images.xcassets/AppIcon.appiconset/Contents.json +23 -0
- data/spec/fixtures/PackagerTest/PackagerTest/Images.xcassets/LaunchImage.launchimage/Contents.json +23 -0
- data/spec/fixtures/PackagerTest/PackagerTest/PackagerTest-Info.plist +38 -0
- data/spec/fixtures/PackagerTest/PackagerTest/PackagerTest-Prefix.pch +16 -0
- data/spec/fixtures/PackagerTest/PackagerTest/en.lproj/InfoPlist.strings +2 -0
- data/spec/fixtures/PackagerTest/PackagerTest/main.m +18 -0
- data/spec/fixtures/PackagerTest/PackagerTest.xcodeproj/project.pbxproj +507 -0
- data/spec/fixtures/PackagerTest/PackagerTest.xcodeproj/project.xcworkspace/contents.xcworkspacedata +7 -0
- data/spec/fixtures/PackagerTest/PackagerTest.xcodeproj/xcshareddata/xcschemes/PackagerTest.xcscheme +110 -0
- data/spec/fixtures/PackagerTest/PackagerTest.xcworkspace/contents.xcworkspacedata +1 -0
- data/spec/fixtures/PackagerTest/PackagerTestTests/PackagerTestTests-Info.plist +22 -0
- data/spec/fixtures/PackagerTest/PackagerTestTests/PackagerTestTests.m +34 -0
- data/spec/fixtures/PackagerTest/PackagerTestTests/en.lproj/InfoPlist.strings +2 -0
- data/spec/fixtures/PackagerTest/Podfile +10 -0
- data/spec/fixtures/PackagerTest/Podfile.lock +36 -0
- data/spec/fixtures/Weakly.podspec +13 -0
- data/spec/fixtures/a.podspec +19 -0
- data/spec/fixtures/foo-bar.podspec +19 -0
- data/spec/fixtures/layer-client-messaging-schema.podspec +13 -0
- data/spec/integration/project_spec.rb +70 -0
- data/spec/spec_helper.rb +79 -0
- data/spec/unit/pod/utils_spec.rb +58 -0
- data/spec/unit/specification/builder_spec.rb +62 -0
- data/spec/unit/specification/spec_builder_spec.rb +61 -0
- data/spec/unit/user_interface/build_failed_report_spec.rb +11 -0
- metadata +223 -0
@@ -0,0 +1,63 @@
|
|
1
|
+
module Pod
|
2
|
+
class SpecBuilder
|
3
|
+
def initialize(spec, source, embedded, dynamic)
|
4
|
+
@spec = spec
|
5
|
+
@source = source.nil? ? '{ :path => \'.\' }' : source
|
6
|
+
@embedded = embedded
|
7
|
+
@dynamic = dynamic
|
8
|
+
end
|
9
|
+
|
10
|
+
def framework_path
|
11
|
+
if @embedded
|
12
|
+
@spec.name + '.embeddedframework' + '/' + @spec.name + '.framework'
|
13
|
+
else
|
14
|
+
@spec.name + '.framework'
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def spec_platform(platform)
|
19
|
+
fwk_base = platform.name.to_s + '/' + framework_path
|
20
|
+
spec = <<RB
|
21
|
+
s.#{platform.name}.deployment_target = '#{platform.deployment_target}'
|
22
|
+
s.#{platform.name}.vendored_framework = '#{fwk_base}'
|
23
|
+
RB
|
24
|
+
|
25
|
+
%w(frameworks weak_frameworks libraries requires_arc xcconfig).each do |attribute|
|
26
|
+
attributes_hash = @spec.attributes_hash[platform.name.to_s]
|
27
|
+
next if attributes_hash.nil?
|
28
|
+
value = attributes_hash[attribute]
|
29
|
+
next if value.nil?
|
30
|
+
|
31
|
+
value = "'#{value}'" if value.class == String
|
32
|
+
spec += " s.#{platform.name}.#{attribute} = #{value}\n"
|
33
|
+
end
|
34
|
+
spec
|
35
|
+
end
|
36
|
+
|
37
|
+
def spec_metadata
|
38
|
+
spec = spec_header
|
39
|
+
spec
|
40
|
+
end
|
41
|
+
|
42
|
+
def spec_close
|
43
|
+
"end\n"
|
44
|
+
end
|
45
|
+
|
46
|
+
private
|
47
|
+
|
48
|
+
def spec_header
|
49
|
+
spec = "Pod::Spec.new do |s|\n"
|
50
|
+
|
51
|
+
%w(name version summary license authors homepage description social_media_url
|
52
|
+
docset_url documentation_url screenshots frameworks weak_frameworks libraries requires_arc
|
53
|
+
deployment_target xcconfig).each do |attribute|
|
54
|
+
value = @spec.attributes_hash[attribute]
|
55
|
+
next if value.nil?
|
56
|
+
value = value.dump if value.class == String
|
57
|
+
spec += " s.#{attribute} = #{value}\n"
|
58
|
+
end
|
59
|
+
|
60
|
+
spec + " s.source = #{@source}\n\n"
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
module Symbols
|
2
|
+
def symbols_from_library(library)
|
3
|
+
syms = `nm -defined-only -extern-only #{library}`.split("\n")
|
4
|
+
result = classes_from_symbols(syms)
|
5
|
+
result += constants_from_symbols(syms)
|
6
|
+
|
7
|
+
result.select do |e|
|
8
|
+
case e
|
9
|
+
when 'llvm.cmdline', 'llvm.embedded.module', '__clang_at_available_requires_core_foundation_framework'
|
10
|
+
false
|
11
|
+
else
|
12
|
+
true
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
module_function :symbols_from_library
|
18
|
+
|
19
|
+
private
|
20
|
+
|
21
|
+
def classes_from_symbols(syms)
|
22
|
+
classes = syms.select { |klass| klass[/OBJC_CLASS_\$_/] }
|
23
|
+
classes = classes.uniq
|
24
|
+
classes.map! { |klass| klass.gsub(/^.*\$_/, '') }
|
25
|
+
end
|
26
|
+
|
27
|
+
def constants_from_symbols(syms)
|
28
|
+
consts = syms.select { |const| const[/ S /] }
|
29
|
+
consts = consts.select { |const| const !~ /OBJC|\.eh/ }
|
30
|
+
consts = consts.uniq
|
31
|
+
consts = consts.map! { |const| const.gsub(/^.* _/, '') }
|
32
|
+
|
33
|
+
other_consts = syms.select { |const| const[/ T /] }
|
34
|
+
other_consts = other_consts.uniq
|
35
|
+
other_consts = other_consts.map! { |const| const.gsub(/^.* _/, '') }
|
36
|
+
|
37
|
+
consts + other_consts
|
38
|
+
end
|
39
|
+
|
40
|
+
module_function :classes_from_symbols
|
41
|
+
module_function :constants_from_symbols
|
42
|
+
end
|
@@ -0,0 +1,8 @@
|
|
1
|
+
require 'pod/command/package'
|
2
|
+
require 'cocoapods-packager/user_interface/build_failed_report'
|
3
|
+
require 'cocoapods-packager/builder'
|
4
|
+
require 'cocoapods-packager/framework'
|
5
|
+
require 'cocoapods-packager/mangle'
|
6
|
+
require 'cocoapods-packager/pod_utils'
|
7
|
+
require 'cocoapods-packager/spec_builder'
|
8
|
+
require 'cocoapods-packager/symbols'
|
@@ -0,0 +1,177 @@
|
|
1
|
+
require 'tmpdir'
|
2
|
+
module Pod
|
3
|
+
class Command
|
4
|
+
class Package < Command
|
5
|
+
self.summary = 'Package a podspec into a static library.'
|
6
|
+
self.arguments = [
|
7
|
+
CLAide::Argument.new('NAME', true),
|
8
|
+
CLAide::Argument.new('SOURCE', false)
|
9
|
+
]
|
10
|
+
|
11
|
+
def self.options
|
12
|
+
[
|
13
|
+
['--force', 'Overwrite existing files.'],
|
14
|
+
['--no-mangle', 'Do not mangle symbols of depedendant Pods.'],
|
15
|
+
['--embedded', 'Generate embedded frameworks.'],
|
16
|
+
['--library', 'Generate static libraries.'],
|
17
|
+
['--dynamic', 'Generate dynamic framework.'],
|
18
|
+
['--local', 'Use local state rather than published versions.'],
|
19
|
+
['--bundle-identifier', 'Bundle identifier for dynamic framework'],
|
20
|
+
['--exclude-deps', 'Exclude symbols from dependencies.'],
|
21
|
+
['--configuration', 'Build the specified configuration (e.g. Debug). Defaults to Release'],
|
22
|
+
['--subspecs', 'Only include the given subspecs'],
|
23
|
+
['--spec-sources=private,https://github.com/CocoaPods/Specs.git', 'The sources to pull dependent ' \
|
24
|
+
'pods from (defaults to https://github.com/CocoaPods/Specs.git)']
|
25
|
+
]
|
26
|
+
end
|
27
|
+
|
28
|
+
def initialize(argv)
|
29
|
+
@embedded = argv.flag?('embedded')
|
30
|
+
@library = argv.flag?('library')
|
31
|
+
@dynamic = argv.flag?('dynamic')
|
32
|
+
@local = argv.flag?('local', false)
|
33
|
+
@package_type = if @embedded
|
34
|
+
:static_framework
|
35
|
+
elsif @dynamic
|
36
|
+
:dynamic_framework
|
37
|
+
elsif @library
|
38
|
+
:static_library
|
39
|
+
else
|
40
|
+
:static_framework
|
41
|
+
end
|
42
|
+
@force = argv.flag?('force')
|
43
|
+
@mangle = argv.flag?('mangle', true)
|
44
|
+
@bundle_identifier = argv.option('bundle-identifier', nil)
|
45
|
+
@exclude_deps = argv.flag?('exclude-deps', false)
|
46
|
+
@name = argv.shift_argument
|
47
|
+
@source = argv.shift_argument
|
48
|
+
@spec_sources = argv.option('spec-sources', 'https://github.com/CocoaPods/Specs.git').split(',')
|
49
|
+
|
50
|
+
subspecs = argv.option('subspecs')
|
51
|
+
@subspecs = subspecs.split(',') unless subspecs.nil?
|
52
|
+
|
53
|
+
@config = argv.option('configuration', 'Release')
|
54
|
+
|
55
|
+
@source_dir = Dir.pwd
|
56
|
+
@is_spec_from_path = false
|
57
|
+
@spec = spec_with_path(@name)
|
58
|
+
@is_spec_from_path = true if @spec
|
59
|
+
@spec ||= spec_with_name(@name)
|
60
|
+
super
|
61
|
+
end
|
62
|
+
|
63
|
+
def validate!
|
64
|
+
super
|
65
|
+
help! 'A podspec name or path is required.' unless @spec
|
66
|
+
help! 'podspec has binary-only depedencies, mangling not possible.' if @mangle && binary_only?(@spec)
|
67
|
+
help! '--bundle-identifier option can only be used for dynamic frameworks' if @bundle_identifier && !@dynamic
|
68
|
+
help! '--exclude-deps option can only be used for static libraries' if @exclude_deps && @dynamic
|
69
|
+
help! '--local option can only be used when a local `.podspec` path is given.' if @local && !@is_spec_from_path
|
70
|
+
end
|
71
|
+
|
72
|
+
def run
|
73
|
+
if @spec.nil?
|
74
|
+
help! "Unable to find a podspec with path or name `#{@name}`."
|
75
|
+
return
|
76
|
+
end
|
77
|
+
|
78
|
+
target_dir, work_dir = create_working_directory
|
79
|
+
return if target_dir.nil?
|
80
|
+
build_package
|
81
|
+
|
82
|
+
`mv "#{work_dir}" "#{target_dir}"`
|
83
|
+
Dir.chdir(@source_dir)
|
84
|
+
end
|
85
|
+
|
86
|
+
private
|
87
|
+
|
88
|
+
def build_in_sandbox(platform)
|
89
|
+
config.installation_root = Pathname.new(Dir.pwd)
|
90
|
+
config.sandbox_root = 'Pods'
|
91
|
+
|
92
|
+
static_sandbox = build_static_sandbox(@dynamic)
|
93
|
+
static_installer = install_pod(platform.name, static_sandbox)
|
94
|
+
|
95
|
+
if @dynamic
|
96
|
+
dynamic_sandbox = build_dynamic_sandbox(static_sandbox, static_installer)
|
97
|
+
install_dynamic_pod(dynamic_sandbox, static_sandbox, static_installer, platform)
|
98
|
+
end
|
99
|
+
|
100
|
+
begin
|
101
|
+
perform_build(platform, static_sandbox, dynamic_sandbox, static_installer)
|
102
|
+
ensure # in case the build fails; see Builder#xcodebuild.
|
103
|
+
Pathname.new(config.sandbox_root).rmtree
|
104
|
+
FileUtils.rm_f('Podfile.lock')
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
108
|
+
def build_package
|
109
|
+
builder = SpecBuilder.new(@spec, @source, @embedded, @dynamic)
|
110
|
+
newspec = builder.spec_metadata
|
111
|
+
|
112
|
+
@spec.available_platforms.each do |platform|
|
113
|
+
build_in_sandbox(platform)
|
114
|
+
|
115
|
+
newspec += builder.spec_platform(platform)
|
116
|
+
end
|
117
|
+
|
118
|
+
newspec += builder.spec_close
|
119
|
+
File.open(@spec.name + '.podspec', 'w') { |file| file.write(newspec) }
|
120
|
+
end
|
121
|
+
|
122
|
+
def create_target_directory
|
123
|
+
target_dir = "#{@source_dir}/#{@spec.name}-#{@spec.version}"
|
124
|
+
if File.exist? target_dir
|
125
|
+
if @force
|
126
|
+
Pathname.new(target_dir).rmtree
|
127
|
+
else
|
128
|
+
UI.puts "Target directory '#{target_dir}' already exists."
|
129
|
+
return nil
|
130
|
+
end
|
131
|
+
end
|
132
|
+
target_dir
|
133
|
+
end
|
134
|
+
|
135
|
+
def create_working_directory
|
136
|
+
target_dir = create_target_directory
|
137
|
+
return if target_dir.nil?
|
138
|
+
|
139
|
+
work_dir = Dir.tmpdir + '/cocoapods-' + Array.new(8) { rand(36).to_s(36) }.join
|
140
|
+
Pathname.new(work_dir).mkdir
|
141
|
+
Dir.chdir(work_dir)
|
142
|
+
|
143
|
+
[target_dir, work_dir]
|
144
|
+
end
|
145
|
+
|
146
|
+
def perform_build(platform, static_sandbox, dynamic_sandbox, static_installer)
|
147
|
+
static_sandbox_root = config.sandbox_root.to_s
|
148
|
+
|
149
|
+
if @dynamic
|
150
|
+
static_sandbox_root = "#{static_sandbox_root}/#{static_sandbox.root.to_s.split('/').last}"
|
151
|
+
dynamic_sandbox_root = "#{config.sandbox_root}/#{dynamic_sandbox.root.to_s.split('/').last}"
|
152
|
+
end
|
153
|
+
|
154
|
+
builder = Pod::Builder.new(
|
155
|
+
platform,
|
156
|
+
static_installer,
|
157
|
+
@source_dir,
|
158
|
+
static_sandbox_root,
|
159
|
+
dynamic_sandbox_root,
|
160
|
+
static_sandbox.public_headers.root,
|
161
|
+
@spec,
|
162
|
+
@embedded,
|
163
|
+
@mangle,
|
164
|
+
@dynamic,
|
165
|
+
@config,
|
166
|
+
@bundle_identifier,
|
167
|
+
@exclude_deps
|
168
|
+
)
|
169
|
+
|
170
|
+
builder.build(@package_type)
|
171
|
+
|
172
|
+
return unless @embedded
|
173
|
+
builder.link_embedded_resources
|
174
|
+
end
|
175
|
+
end
|
176
|
+
end
|
177
|
+
end
|
data/scripts/lstconst.sh
ADDED
data/scripts/lstsym.sh
ADDED
@@ -0,0 +1,81 @@
|
|
1
|
+
require File.expand_path('../../spec_helper', __FILE__)
|
2
|
+
|
3
|
+
module Pod
|
4
|
+
describe 'Packager' do
|
5
|
+
after do
|
6
|
+
Dir.glob("CPDColors-*").each { |dir| Pathname.new(dir).rmtree }
|
7
|
+
Dir.glob("layer-client-messaging-schema-*").each { |dir| Pathname.new(dir).rmtree }
|
8
|
+
Dir.glob("OpenSans-*").each { |dir| Pathname.new(dir).rmtree }
|
9
|
+
Dir.glob("Weakly-*").each { |dir| Pathname.new(dir).rmtree }
|
10
|
+
end
|
11
|
+
|
12
|
+
it 'presents the help if a directory is provided' do
|
13
|
+
should.raise CLAide::Help do
|
14
|
+
command = Command.parse(%w{ package spec })
|
15
|
+
end.message.should.match /is a directory/
|
16
|
+
end
|
17
|
+
|
18
|
+
it 'presents the help if a random file is provided instead of a specification' do
|
19
|
+
should.raise CLAide::Help do
|
20
|
+
command = Command.parse(%w{ package README.md })
|
21
|
+
end.message.should.match /is not a podspec/
|
22
|
+
end
|
23
|
+
|
24
|
+
it 'presents the help if a podspec with binary-only dependencies is used' do
|
25
|
+
command = Command.parse(%w{ package spec/fixtures/CPDColors.podspec })
|
26
|
+
should.raise CLAide::Help do
|
27
|
+
command.validate!
|
28
|
+
end.message.should.match /binary-only/
|
29
|
+
end
|
30
|
+
|
31
|
+
it 'presents the help if only --bundle-identifier is specified' do
|
32
|
+
command = Command.parse(%w{ package spec/fixtures/NikeKit.podspec --bundle-identifier=com.example.NikeKit })
|
33
|
+
should.raise CLAide::Help do
|
34
|
+
command.validate!
|
35
|
+
end.message.should.match /--bundle-identifier option can only be used for dynamic frameworks/
|
36
|
+
end
|
37
|
+
|
38
|
+
it 'presents the help if both --exclude-deps and --dynamic are specified' do
|
39
|
+
command = Command.parse(%w{ package spec/fixtures/NikeKit.podspec --exclude-deps --dynamic })
|
40
|
+
should.raise CLAide::Help do
|
41
|
+
command.validate!
|
42
|
+
end.message.should.match /--exclude-deps option can only be used for static libraries/
|
43
|
+
end
|
44
|
+
|
45
|
+
it 'presents the help if --local is specified without .podspec path' do
|
46
|
+
command = Command.parse(%w{ package AFNetworking --local })
|
47
|
+
should.raise CLAide::Help do
|
48
|
+
command.validate!
|
49
|
+
end.message.should.match /--local option can only be used when a local `.podspec` path is given/
|
50
|
+
end
|
51
|
+
|
52
|
+
it 'can package a podspec with only resources' do
|
53
|
+
command = Command.parse(%w{ package spec/fixtures/layer-client-messaging-schema.podspec --no-mangle })
|
54
|
+
command.run
|
55
|
+
|
56
|
+
true.should == true # To make the test pass without any shoulds
|
57
|
+
end
|
58
|
+
|
59
|
+
it 'can package a podspec with binary-only dependencies if --no-mangle is specified' do
|
60
|
+
command = Command.parse(%w{ package spec/fixtures/CPDColors.podspec --no-mangle })
|
61
|
+
command.run
|
62
|
+
|
63
|
+
true.should == true # To make the test pass without any shoulds
|
64
|
+
end
|
65
|
+
|
66
|
+
it 'can package a podspec with resource bundles' do
|
67
|
+
command = Command.parse(%w{ package spec/fixtures/OpenSans.podspec })
|
68
|
+
command.run
|
69
|
+
|
70
|
+
bundles = Dir.glob('OpenSans-*/ios/OpenSans.framework/Versions/A/Resources/*.bundle')
|
71
|
+
bundles.count.should == 1
|
72
|
+
end
|
73
|
+
|
74
|
+
it 'can package a podspec with weak frameworks without strong linking' do
|
75
|
+
command = Command.parse(%w{ package spec/fixtures/Weakly.podspec })
|
76
|
+
command.run
|
77
|
+
|
78
|
+
`otool -l Weakly-*/ios/Weakly.framework/Weakly`.should.not.match /AssetsLibrary/
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|