cocoapods-packager-mls 1.5.0.21

Sign up to get free protection for your applications and to get access to all the features.
Files changed (79) hide show
  1. checksums.yaml +7 -0
  2. data/.coveralls.yml +1 -0
  3. data/.gitignore +5 -0
  4. data/.rubocop-cocoapods.yml +71 -0
  5. data/.rubocop.yml +38 -0
  6. data/.travis.yml +17 -0
  7. data/Gemfile +12 -0
  8. data/Gemfile.lock +131 -0
  9. data/LICENSE +22 -0
  10. data/README.md +42 -0
  11. data/Rakefile +29 -0
  12. data/cocoapods-packager.gemspec +22 -0
  13. data/lib/cocoapods-packager/builder.rb +457 -0
  14. data/lib/cocoapods-packager/framework.rb +66 -0
  15. data/lib/cocoapods-packager/mangle.rb +32 -0
  16. data/lib/cocoapods-packager/pod_utils.rb +324 -0
  17. data/lib/cocoapods-packager/spec_builder.rb +171 -0
  18. data/lib/cocoapods-packager/symbols.rb +42 -0
  19. data/lib/cocoapods-packager/tal_installer.rb +33 -0
  20. data/lib/cocoapods-packager/tal_target_validator.rb +62 -0
  21. data/lib/cocoapods-packager/user_interface/build_failed_report.rb +15 -0
  22. data/lib/cocoapods_packager.rb +5 -0
  23. data/lib/cocoapods_plugin.rb +16 -0
  24. data/lib/pod/command/package.rb +243 -0
  25. data/scripts/lstconst.sh +9 -0
  26. data/scripts/lstsym.sh +8 -0
  27. data/spec/command/error_spec.rb +81 -0
  28. data/spec/command/package_spec.rb +420 -0
  29. data/spec/command/subspecs_spec.rb +30 -0
  30. data/spec/fixtures/Archs.podspec +13 -0
  31. data/spec/fixtures/Builder.podspec +25 -0
  32. data/spec/fixtures/CPDColors.podspec +19 -0
  33. data/spec/fixtures/FH.podspec +18 -0
  34. data/spec/fixtures/KFData.podspec +73 -0
  35. data/spec/fixtures/LibraryConsumerDemo/.gitignore +22 -0
  36. data/spec/fixtures/LibraryConsumerDemo/LibraryConsumer.xcodeproj/project.pbxproj +311 -0
  37. data/spec/fixtures/LibraryConsumerDemo/LibraryConsumer.xcodeproj/project.xcworkspace/contents.xcworkspacedata +7 -0
  38. data/spec/fixtures/LibraryConsumerDemo/LibraryConsumer.xcodeproj/xcshareddata/xcschemes/LibraryConsumer.xcscheme +100 -0
  39. data/spec/fixtures/LibraryConsumerDemo/LibraryConsumer/AppDelegate.h +17 -0
  40. data/spec/fixtures/LibraryConsumerDemo/LibraryConsumer/AppDelegate.m +27 -0
  41. data/spec/fixtures/LibraryConsumerDemo/LibraryConsumer/Info.plist +40 -0
  42. data/spec/fixtures/LibraryConsumerDemo/LibraryConsumer/main.m +16 -0
  43. data/spec/fixtures/LibraryConsumerDemo/Podfile +5 -0
  44. data/spec/fixtures/LibraryDemo.podspec +14 -0
  45. data/spec/fixtures/LocalSources/LICENSE +0 -0
  46. data/spec/fixtures/LocalSources/LocalNikeKit.h +4 -0
  47. data/spec/fixtures/LocalSources/LocalNikeKit.m +9 -0
  48. data/spec/fixtures/LocalSources/LocalNikeKit.podspec +19 -0
  49. data/spec/fixtures/NikeKit.podspec +19 -0
  50. data/spec/fixtures/OpenSans.podspec +18 -0
  51. data/spec/fixtures/PackagerTest/.gitignore +21 -0
  52. data/spec/fixtures/PackagerTest/PackagerTest.xcodeproj/project.pbxproj +507 -0
  53. data/spec/fixtures/PackagerTest/PackagerTest.xcodeproj/project.xcworkspace/contents.xcworkspacedata +7 -0
  54. data/spec/fixtures/PackagerTest/PackagerTest.xcodeproj/xcshareddata/xcschemes/PackagerTest.xcscheme +110 -0
  55. data/spec/fixtures/PackagerTest/PackagerTest.xcworkspace/contents.xcworkspacedata +1 -0
  56. data/spec/fixtures/PackagerTest/PackagerTest/CPDAppDelegate.h +15 -0
  57. data/spec/fixtures/PackagerTest/PackagerTest/CPDAppDelegate.m +49 -0
  58. data/spec/fixtures/PackagerTest/PackagerTest/Images.xcassets/AppIcon.appiconset/Contents.json +23 -0
  59. data/spec/fixtures/PackagerTest/PackagerTest/Images.xcassets/LaunchImage.launchimage/Contents.json +23 -0
  60. data/spec/fixtures/PackagerTest/PackagerTest/PackagerTest-Info.plist +38 -0
  61. data/spec/fixtures/PackagerTest/PackagerTest/PackagerTest-Prefix.pch +16 -0
  62. data/spec/fixtures/PackagerTest/PackagerTest/en.lproj/InfoPlist.strings +2 -0
  63. data/spec/fixtures/PackagerTest/PackagerTest/main.m +18 -0
  64. data/spec/fixtures/PackagerTest/PackagerTestTests/PackagerTestTests-Info.plist +22 -0
  65. data/spec/fixtures/PackagerTest/PackagerTestTests/PackagerTestTests.m +34 -0
  66. data/spec/fixtures/PackagerTest/PackagerTestTests/en.lproj/InfoPlist.strings +2 -0
  67. data/spec/fixtures/PackagerTest/Podfile +10 -0
  68. data/spec/fixtures/PackagerTest/Podfile.lock +36 -0
  69. data/spec/fixtures/Weakly.podspec +13 -0
  70. data/spec/fixtures/a.podspec +19 -0
  71. data/spec/fixtures/foo-bar.podspec +19 -0
  72. data/spec/fixtures/layer-client-messaging-schema.podspec +13 -0
  73. data/spec/integration/project_spec.rb +70 -0
  74. data/spec/spec_helper.rb +79 -0
  75. data/spec/unit/pod/utils_spec.rb +58 -0
  76. data/spec/unit/specification/builder_spec.rb +62 -0
  77. data/spec/unit/specification/spec_builder_spec.rb +61 -0
  78. data/spec/unit/user_interface/build_failed_report_spec.rb +11 -0
  79. metadata +223 -0
@@ -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
@@ -0,0 +1,420 @@
1
+ require File.expand_path('../../spec_helper', __FILE__)
2
+
3
+ module Pod
4
+
5
+ DONT_CODESIGN = true
6
+
7
+ describe Command::Spec::Package do
8
+ describe 'CLAide' do
9
+ after do
10
+ Dir.glob("Archs-*").each { |dir| Pathname.new(dir).rmtree }
11
+ Dir.glob("CPDColors-*").each { |dir| Pathname.new(dir).rmtree }
12
+ Dir.glob("KFData-*").each { |dir| Pathname.new(dir).rmtree }
13
+ Dir.glob("NikeKit-*").each { |dir| Pathname.new(dir).rmtree }
14
+ Dir.glob("LocalNikeKit-*").each { |dir| Pathname.new(dir).rmtree }
15
+ Dir.glob("foo-bar-*").each { |dir| Pathname.new(dir).rmtree }
16
+ Dir.glob("a-*").each { |dir| Pathname.new(dir).rmtree }
17
+ Dir.glob("FH-*").each { |dir| Pathname.new(dir).rmtree }
18
+ Dir.glob("FirebaseAnalytics-*").each { |dir| Pathname.new(dir).rmtree }
19
+ end
20
+
21
+ def reject_block_symbols(symbols)
22
+ symbols
23
+ .reject { |e| e =~ /__block_descriptor.*/ }
24
+ .reject { |e| e =~ /__destroy_helper_block.*/ }
25
+ .reject { |e| e =~ /__copy_helper_block.*/ }
26
+ end
27
+
28
+ it 'registers itself' do
29
+ Command.parse(%w{ package }).should.be.instance_of Command::Package
30
+ end
31
+
32
+ it 'presents the help if no spec is provided' do
33
+ command = Command.parse(%w{ package })
34
+ should.raise CLAide::Help do
35
+ command.validate!
36
+ end.message.should.match /required/
37
+ end
38
+
39
+ it "errors if it cannot find a spec" do
40
+ Pod::Config.instance.sources_manager.stubs(:search).returns(nil)
41
+
42
+ command = Command.parse(%w{ package KFData })
43
+ should.raise CLAide::Help do
44
+ command.run
45
+ end.message.should.match /Unable to find/
46
+ end
47
+
48
+
49
+ it "should produce a dynamic library when dynamic is specified" do
50
+ Pod::Config.instance.sources_manager.stubs(:search).returns(nil)
51
+
52
+ command = Command.parse(['package', fixture('NikeKit.podspec'), '--dynamic'])
53
+ command.run
54
+
55
+ lib = Dir.glob("NikeKit-*/ios/NikeKit.framework/NikeKit").first
56
+ file_command = "file #{lib}"
57
+ output = `#{file_command}`.lines.to_a
58
+
59
+ output[0].should.match /Mach-O universal binary with 5 architectures/
60
+ output[1].should.match /Mach-O dynamically linked shared library i386/
61
+ end
62
+
63
+ it "should produce a dSYM when dynamic is specified" do
64
+ Pod::Config.instance.sources_manager.stubs(:search).returns(nil)
65
+
66
+ command = Command.parse(['package', fixture('NikeKit.podspec'), '--dynamic'])
67
+ command.run
68
+
69
+ lib = Dir.glob("NikeKit-*/ios/NikeKit.framework.dSYM/Contents/Resources/DWARF/NikeKit").first
70
+ file_command = "file #{lib}"
71
+ output = `#{file_command}`.lines.to_a
72
+
73
+ output[0].should.match /Mach-O universal binary with 3 architectures/
74
+ output[1].should.match /Mach-O dSYM companion file arm/
75
+ end
76
+
77
+ it "should link category symbols when dynamic is specified" do
78
+ Pod::Config.instance.sources_manager.stubs(:search).returns(nil)
79
+
80
+ command = Command.parse(['package', fixture('NikeKit.podspec'), '--dynamic'])
81
+ command.run
82
+
83
+ lib = Dir.glob("NikeKit-*/ios/NikeKit.framework/NikeKit").first
84
+ file_command = "nm #{lib}"
85
+ output = `#{file_command}`.lines.to_a
86
+
87
+ match = output.detect { |line| line =~ /UIButton\(AFNetworking\)/ }
88
+ match.should.not.be.empty
89
+ end
90
+
91
+ it "should produce a dynamic library for OSX when dynamic is specified" do
92
+ Pod::Config.instance.sources_manager.stubs(:search).returns(nil)
93
+
94
+ command = Command.parse(['package', fixture('KFData.podspec'), '--dynamic'])
95
+ command.run
96
+
97
+ lib = Dir.glob("KFData-*/osx/KFData.framework/KFData").first
98
+ file_command = "file #{lib}"
99
+ output = `#{file_command}`.lines.to_a
100
+
101
+ output[0].should.match /Mach-O 64-bit dynamically linked shared library x86_64/
102
+ end
103
+
104
+ it "should produce a dSYM for OSX when dynamic is specified" do
105
+ Pod::Config.instance.sources_manager.stubs(:search).returns(nil)
106
+
107
+ command = Command.parse(['package', fixture('KFData.podspec'), '--dynamic'])
108
+ command.run
109
+
110
+ lib = Dir.glob("KFData-*/osx/KFData.framework.dSYM/Contents/Resources/DWARF/KFData").first
111
+ file_command = "file #{lib}"
112
+ output = `#{file_command}`.lines.to_a
113
+
114
+ output[0].should.match /Mach-O 64-bit dSYM companion file x86_64/
115
+ end
116
+
117
+ it "should produce the default plist for iOS and OSX when --dynamic is specified but --bundle-identifier is not" do
118
+ Pod::Config.instance.sources_manager.stubs(:search).returns(nil)
119
+
120
+ command = Command.parse(['package', fixture('KFData.podspec'), '--dynamic'])
121
+ command.run
122
+
123
+ ios_plist = File.expand_path(Dir.glob("KFData-*/ios/KFData.framework/Info.plist").first)
124
+ osx_plist = File.expand_path(Dir.glob("KFData-*/osx/KFData.framework/Resources/Info.plist").first)
125
+
126
+ ios_bundle_id = `defaults read #{ios_plist} CFBundleIdentifier`
127
+ osx_bundle_id = `defaults read #{osx_plist} CFBundleIdentifier`
128
+
129
+ ios_bundle_id.should.match /org.cocoapods.KFData/
130
+ osx_bundle_id.should.match /org.cocoapods.KFData/
131
+ end
132
+
133
+ it "should produce the correct plist for iOS and OSX when --dynamic and --bundle-identifier are specified" do
134
+ Pod::Config.instance.sources_manager.stubs(:search).returns(nil)
135
+
136
+ command = Command.parse(['package', fixture('KFData.podspec'), '--dynamic', '--bundle-identifier=com.example.KFData'])
137
+ command.run
138
+
139
+ ios_plist = File.expand_path(Dir.glob("KFData-*/ios/KFData.framework/Info.plist").first)
140
+ osx_plist = File.expand_path(Dir.glob("KFData-*/osx/KFData.framework/Resources/Info.plist").first)
141
+
142
+ ios_bundle_id = `defaults read #{ios_plist} CFBundleIdentifier`
143
+ osx_bundle_id = `defaults read #{osx_plist} CFBundleIdentifier`
144
+
145
+ ios_bundle_id.should.match /com.example.KFData/
146
+ osx_bundle_id.should.match /com.example.KFData/
147
+ end
148
+
149
+ it "should produce a static library when dynamic is not specified" do
150
+ Pod::Config.instance.sources_manager.stubs(:search).returns(nil)
151
+
152
+ command = Command.parse(['package', fixture('NikeKit.podspec')])
153
+ command.run
154
+
155
+ lib = Dir.glob("NikeKit-*/ios/NikeKit.framework/NikeKit").first
156
+ file_command = "file #{lib}"
157
+ output = `#{file_command}`.lines.to_a
158
+
159
+ output[0].should.match /Mach-O universal binary with 5 architectures/
160
+ output[1].should.match /current ar archive/
161
+ end
162
+
163
+ it "produces package using local sources when --local is specified" do
164
+ Pod::Config.instance.sources_manager.stubs(:search).returns(nil)
165
+
166
+ command = Command.parse(['package', fixture('LocalSources/LocalNikeKit.podspec'), '--local'])
167
+ command.run
168
+
169
+ lib = Dir.glob("LocalNikeKit-*/ios/LocalNikeKit.framework/LocalNikeKit").first
170
+ symbols = Symbols.symbols_from_library(lib)
171
+ symbols.should.include('LocalNikeKit')
172
+ symbols.should.not.include('BBUNikePlusActivity')
173
+ end
174
+
175
+ it "includes vendor symbols both from itself and pod dependencies" do
176
+ command = Command.parse(%w{ package FirebaseAnalytics --no-mangle })
177
+ command.run
178
+
179
+ lib = Dir.glob("FirebaseAnalytics-*/ios/FirebaseAnalytics.framework/FirebaseAnalytics").first
180
+ symbols = Symbols.symbols_from_library(lib)
181
+ # from itself
182
+ symbols.should.include('FIRAnalytics')
183
+ # from pod dependency
184
+ symbols.should.include('FIRApp')
185
+ end
186
+
187
+ it "does not include vendor symbols from pod dependencies if option --exclude-deps is specified" do
188
+ command = Command.parse(%w{ package FirebaseAnalytics --no-mangle --exclude-deps})
189
+ command.run
190
+
191
+ lib = Dir.glob("FirebaseAnalytics-*/ios/FirebaseAnalytics.framework/FirebaseAnalytics").first
192
+ symbols = Symbols.symbols_from_library(lib)
193
+ # from itself
194
+ symbols.should.include('FIRAnalytics')
195
+ # from pod dependency
196
+ symbols.should.not.include('FIRApp')
197
+ end
198
+
199
+ it "includes only available architectures when packaging an iOS Pod with binary dependencies" do
200
+ Pod::Config.instance.sources_manager.stubs(:search).returns(nil)
201
+
202
+ command = Command.parse(['package', fixture('Archs.podspec'), '--no-mangle'])
203
+ command.run
204
+
205
+ lib = Dir.glob("Archs-*/ios/Archs.framework/Archs").first
206
+ `lipo #{lib} -verify_arch x86_64 i386 armv7 arm64`
207
+ $?.success?.should == true
208
+ end
209
+
210
+ it "mangles symbols if the Pod has dependencies" do
211
+ Pod::Config.instance.sources_manager.stubs(:search).returns(nil)
212
+
213
+ command = Command.parse(['package', fixture('NikeKit.podspec')])
214
+ command.run
215
+
216
+ lib = Dir.glob("NikeKit-*/ios/NikeKit.framework/NikeKit").first
217
+ symbols = Symbols.symbols_from_library(lib).uniq.sort.reject { |e| e =~ /PodNikeKit/ }
218
+ symbols = reject_block_symbols(symbols)
219
+
220
+ symbols.should == %w{ BBUNikePlusActivity BBUNikePlusSessionManager
221
+ BBUNikePlusTag }
222
+ end
223
+
224
+ it "mangles symbols if the Pod has dependencies and framework is dynamic" do
225
+ Pod::Config.instance.sources_manager.stubs(:search).returns(nil)
226
+
227
+ command = Command.parse(['package', fixture('NikeKit.podspec'), '--dynamic'])
228
+ command.run
229
+
230
+ lib = Dir.glob("NikeKit-*/ios/NikeKit.framework/NikeKit").first
231
+ symbols = Symbols.symbols_from_library(lib).uniq.sort.reject { |e| e =~ /PodNikeKit/ }
232
+ symbols = reject_block_symbols(symbols)
233
+
234
+ symbols.should == %w{ BBUNikePlusActivity BBUNikePlusSessionManager
235
+ BBUNikePlusTag NikeKitVersionNumber NikeKitVersionString }
236
+ end
237
+
238
+ it "mangles symbols if the Pod has dependencies regardless of name" do
239
+ Pod::Config.instance.sources_manager.stubs(:search).returns(nil)
240
+
241
+ command = Command.parse(['package', fixture('a.podspec')])
242
+ command.run
243
+
244
+ lib = Dir.glob("a-*/ios/a.framework/a").first
245
+ symbols = Symbols.symbols_from_library(lib).uniq.sort.reject { |e| e =~ /Poda/ }
246
+ symbols = reject_block_symbols(symbols)
247
+ symbols.should == %w{ BBUNikePlusActivity BBUNikePlusSessionManager
248
+ BBUNikePlusTag }
249
+ end
250
+
251
+ it "does not mangle symbols if option --no-mangle is specified" do
252
+ Pod::Config.instance.sources_manager.stubs(:search).returns(nil)
253
+
254
+ command = Command.parse(['package', fixture('NikeKit.podspec'), '--no-mangle'])
255
+ command.run
256
+
257
+ lib = Dir.glob("NikeKit-*/ios/NikeKit.framework/NikeKit").first
258
+ symbols = Symbols.symbols_from_library(lib).uniq.sort.select { |e| e =~ /PodNikeKit/ }
259
+ symbols.should == []
260
+ end
261
+
262
+ it "does not mangle symbols if option --no-mangle and --dynamic are specified" do
263
+ Pod::Config.instance.sources_manager.stubs(:search).returns(nil)
264
+
265
+ command = Command.parse(['package', fixture('NikeKit.podspec'), '--no-mangle', '--dynamic'])
266
+ command.run
267
+
268
+ lib = Dir.glob("NikeKit-*/ios/NikeKit.framework/NikeKit").first
269
+ symbols = Symbols.symbols_from_library(lib).uniq.sort.select { |e| e =~ /PodNikeKit/ }
270
+ symbols.should == []
271
+ end
272
+
273
+ it "does not include symbols from dependencies if option --exclude-deps is specified" do
274
+ Pod::Config.instance.sources_manager.stubs(:search).returns(nil)
275
+
276
+ command = Command.parse(['package', fixture('NikeKit.podspec'), '--exclude-deps'])
277
+ command.run
278
+
279
+ lib = Dir.glob("NikeKit-*/ios/NikeKit.framework/NikeKit").first
280
+ symbols = Symbols.symbols_from_library(lib).uniq.sort.select { |e| e =~ /AFNetworking|ISO8601DateFormatter|KZPropertyMapper/ }
281
+ symbols.should == []
282
+ end
283
+
284
+ it "includes the correct architectures when packaging an iOS Pod" do
285
+ Pod::Config.instance.sources_manager.stubs(:search).returns(nil)
286
+
287
+ command = Command.parse(['package', fixture('NikeKit.podspec')])
288
+ command.run
289
+
290
+ lib = Dir.glob("NikeKit-*/ios/NikeKit.framework/NikeKit").first
291
+ `lipo #{lib} -verify_arch x86_64 i386 armv7 armv7s arm64`
292
+ $?.success?.should == true
293
+ end
294
+
295
+ it "includes the correct architectures when packaging an iOS Pod as --dynamic" do
296
+ Pod::Config.instance.sources_manager.stubs(:search).returns(nil)
297
+
298
+ command = Command.parse(['package', fixture('NikeKit.podspec'), '--dynamic'])
299
+ command.run
300
+
301
+ lib = Dir.glob("NikeKit-*/ios/NikeKit.framework/NikeKit").first
302
+ `lipo #{lib} -verify_arch armv7 armv7s arm64`
303
+ $?.success?.should == true
304
+ end
305
+
306
+ it "includes Bitcode for device arch slices when packaging an iOS Pod" do
307
+ Pod::Config.instance.sources_manager.stubs(:search).returns(nil)
308
+
309
+ command = Command.parse(['package', fixture('NikeKit.podspec')])
310
+ command.run
311
+
312
+ lib = Dir.glob("NikeKit-*/ios/NikeKit.framework/NikeKit").first
313
+
314
+ #Check for __LLVM segment in each device architecture
315
+ `lipo -extract armv7 #{lib} -o armv7.a && otool -l armv7.a`.should.match /__LLVM/
316
+ `lipo -extract armv7s #{lib} -o armv7s.a && otool -l armv7s.a`.should.match /__LLVM/
317
+ `lipo -extract arm64 #{lib} -o arm64.a && otool -l arm64.a`.should.match /__LLVM/
318
+ `rm armv7.a armv7s.a arm64.a`
319
+ end
320
+
321
+ it "includes Bitcode for device arch slices when packaging an dynamic iOS Pod" do
322
+ Pod::Config.instance.sources_manager.stubs(:search).returns(nil)
323
+
324
+ command = Command.parse(['package', fixture('NikeKit.podspec'), '--dynamic'])
325
+ command.run
326
+
327
+ lib = Dir.glob("NikeKit-*/ios/NikeKit.framework/NikeKit").first
328
+
329
+ #Check for __LLVM segment in each device architecture
330
+ `lipo -extract armv7 #{lib} -o armv7.a && otool -l armv7.a`.should.match /__LLVM/
331
+ `lipo -extract armv7s #{lib} -o armv7s.a && otool -l armv7s.a`.should.match /__LLVM/
332
+ `lipo -extract arm64 #{lib} -o arm64.a && otool -l arm64.a`.should.match /__LLVM/
333
+ `rm armv7.a armv7s.a arm64.a`
334
+ end
335
+
336
+ it "does not include Bitcode for simulator arch slices when packaging an iOS Pod" do
337
+ Pod::Config.instance.sources_manager.stubs(:search).returns(nil)
338
+
339
+ command = Command.parse(['package', fixture('NikeKit.podspec')])
340
+ command.run
341
+
342
+ lib = Dir.glob("NikeKit-*/ios/NikeKit.framework/NikeKit").first
343
+
344
+ #Check for __LLVM segment in each simulator architecture
345
+ `lipo -extract i386 #{lib} -o i386.a && otool -l i386.a`.should.not.match /__LLVM/
346
+ `lipo -extract x86_64 #{lib} -o x86_64.a && otool -l x86_64.a`.should.not.match /__LLVM/
347
+ `rm i386.a x86_64.a`
348
+ end
349
+
350
+ it "does not include Bitcode for simulator arch slices when packaging an dynamic iOS Pod" do
351
+ Pod::Config.instance.sources_manager.stubs(:search).returns(nil)
352
+
353
+ command = Command.parse(['package', fixture('NikeKit.podspec'), '--dynamic'])
354
+ command.run
355
+
356
+ lib = Dir.glob("NikeKit-*/ios/NikeKit.framework/NikeKit").first
357
+
358
+ #Check for __LLVM segment in each simulator architecture
359
+ `lipo -extract i386 #{lib} -o i386.a && otool -l i386.a`.should.not.match /__LLVM/
360
+ `lipo -extract x86_64 #{lib} -o x86_64.a && otool -l x86_64.a`.should.not.match /__LLVM/
361
+ `rm i386.a x86_64.a`
362
+ end
363
+
364
+ it "does not include local ModuleCache references" do
365
+ Pod::Config.instance.sources_manager.stubs(:search).returns(nil)
366
+
367
+ command = Command.parse(['package', fixture('NikeKit.podspec')])
368
+ command.run
369
+
370
+ lib = Dir.glob("NikeKit-*/ios/NikeKit.framework/NikeKit").first
371
+
372
+ #Check for ModuleCache references
373
+ `strings #{lib}`.should.not.match /ModuleCache/
374
+ end
375
+
376
+ it "does not fail when the pod name contains a dash" do
377
+ Pod::Config.instance.sources_manager.stubs(:search).returns(nil)
378
+
379
+ command = Command.parse(['package', fixture('foo-bar.podspec')])
380
+ command.run
381
+
382
+ true.should == true # To make the test pass without any shoulds
383
+ end
384
+
385
+ it "runs with a path to a spec" do
386
+ Pod::Config.instance.sources_manager.stubs(:search).returns(nil)
387
+
388
+ command = Command.parse(['package', fixture('KFData.podspec')])
389
+ command.run
390
+
391
+ true.should == true # To make the test pass without any shoulds
392
+ end
393
+
394
+ it "it respects module_map directive" do
395
+ Pod::Config.instance.sources_manager.stubs(:search).returns(nil)
396
+
397
+ command = Command.parse(['package', fixture('FH.podspec')])
398
+ command.run
399
+
400
+ modulemap_contents = File.read(Dir.glob("FH-*/ios/FH.framework/Modules/module.modulemap").first)
401
+ module_map = <<MAP
402
+ framework module FH {
403
+ umbrella header "FeedHenry.h"
404
+
405
+ export *
406
+ module * { export * }
407
+ }
408
+ MAP
409
+ modulemap_contents.should == module_map
410
+ end
411
+
412
+ it "runs with a spec in the master repository" do
413
+ command = Command.parse(%w{ package KFData })
414
+ command.run
415
+
416
+ true.should == true # To make the test pass without any shoulds
417
+ end
418
+ end
419
+ end
420
+ end