cocoapods-gd 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/Gemfile +13 -0
- data/Gemfile.lock +131 -0
- data/LICENSE +22 -0
- data/README.md +42 -0
- data/Rakefile +29 -0
- data/cocoapods-gd.gemspec +22 -0
- data/lib/cocoapods-gd.rb +5 -0
- data/lib/cocoapods-gd/builder.rb +393 -0
- data/lib/cocoapods-gd/framework.rb +66 -0
- data/lib/cocoapods-gd/install_frameworks.rb +77 -0
- data/lib/cocoapods-gd/mangle.rb +32 -0
- data/lib/cocoapods-gd/pod_utils.rb +246 -0
- data/lib/cocoapods-gd/podfile_env.rb +26 -0
- data/lib/cocoapods-gd/spec_builder.rb +72 -0
- data/lib/cocoapods-gd/symbols.rb +42 -0
- data/lib/cocoapods-gd/uploader.rb +70 -0
- data/lib/cocoapods-gd/user_interface/build_failed_report.rb +15 -0
- data/lib/cocoapods_plugin.rb +10 -0
- data/lib/pod/command/gd.rb +185 -0
- data/scripts/lstconst.sh +9 -0
- data/scripts/lstsym.sh +8 -0
- data/spec/command/error_spec.rb +81 -0
- data/spec/command/gd_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.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/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/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.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/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/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 +217 -0
@@ -0,0 +1,72 @@
|
|
1
|
+
module Pod
|
2
|
+
class SpecBuilder
|
3
|
+
def initialize(spec, source, embedded, dynamic, git_sources)
|
4
|
+
@spec = spec
|
5
|
+
@source = source.nil? ? '{ :path => \'.\' }' : source
|
6
|
+
@embedded = embedded
|
7
|
+
@dynamic = dynamic
|
8
|
+
@git_sources = git_sources
|
9
|
+
end
|
10
|
+
|
11
|
+
def framework_path
|
12
|
+
if @embedded
|
13
|
+
@spec.name + '.embeddedframework' + '/' + @spec.name + '.framework'
|
14
|
+
else
|
15
|
+
@spec.name + '.framework'
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def spec_platform(platform)
|
20
|
+
fwk_base = platform.name.to_s + '/' + framework_path
|
21
|
+
if File.exist?("#{Dir.pwd}/ios/#{@spec.name}.bundle")
|
22
|
+
spec = <<RB
|
23
|
+
s.#{platform.name}.deployment_target = '#{platform.deployment_target}'
|
24
|
+
s.#{platform.name}.vendored_framework = '#{@spec.name}-#{@spec.version}/#{fwk_base}'
|
25
|
+
s.#{platform.name}.resource = '#{@spec.name}-#{@spec.version}/#{platform.name.to_s}/#{@spec.name}.bundle'
|
26
|
+
RB
|
27
|
+
else
|
28
|
+
spec = <<RB
|
29
|
+
s.#{platform.name}.deployment_target = '#{platform.deployment_target}'
|
30
|
+
s.#{platform.name}.vendored_framework = '#{@spec.name}-#{@spec.version}/#{fwk_base}'
|
31
|
+
RB
|
32
|
+
end
|
33
|
+
|
34
|
+
%w(frameworks weak_frameworks libraries requires_arc xcconfig).each do |attribute|
|
35
|
+
attributes_hash = @spec.attributes_hash[platform.name.to_s]
|
36
|
+
next if attributes_hash.nil?
|
37
|
+
value = attributes_hash[attribute]
|
38
|
+
next if value.nil?
|
39
|
+
|
40
|
+
value = "'#{value}'" if value.class == String
|
41
|
+
spec += " s.#{platform.name}.#{attribute} = #{value}\n"
|
42
|
+
end
|
43
|
+
spec
|
44
|
+
end
|
45
|
+
|
46
|
+
def spec_metadata
|
47
|
+
spec = spec_header
|
48
|
+
spec
|
49
|
+
end
|
50
|
+
|
51
|
+
def spec_close
|
52
|
+
"end\n"
|
53
|
+
end
|
54
|
+
|
55
|
+
private
|
56
|
+
|
57
|
+
def spec_header
|
58
|
+
spec = "Pod::Spec.new do |s|\n"
|
59
|
+
|
60
|
+
%w(name version summary license authors homepage description social_media_url
|
61
|
+
docset_url documentation_url screenshots frameworks weak_frameworks libraries requires_arc
|
62
|
+
deployment_target xcconfig).each do |attribute|
|
63
|
+
value = @spec.attributes_hash[attribute]
|
64
|
+
next if value.nil?
|
65
|
+
value = value.dump if value.class == String
|
66
|
+
spec += " s.#{attribute} = #{value}\n"
|
67
|
+
end
|
68
|
+
|
69
|
+
spec + " s.source = { :http => '#{@git_sources}/#{@spec.name}/#{@spec.name}-#{@spec.version}.zip' }\n\n"
|
70
|
+
end
|
71
|
+
end
|
72
|
+
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,70 @@
|
|
1
|
+
require 'zip'
|
2
|
+
|
3
|
+
module Pod
|
4
|
+
class Uploader
|
5
|
+
def initialize(spec, upload_spec_name, upload_local_path, spec_sources)
|
6
|
+
@spec = spec
|
7
|
+
@work_dir = Dir.pwd
|
8
|
+
@upload_spec_name = upload_spec_name
|
9
|
+
@upload_local_path = upload_local_path
|
10
|
+
@spec_sources = spec_sources
|
11
|
+
build
|
12
|
+
git_push
|
13
|
+
push_repo
|
14
|
+
end
|
15
|
+
|
16
|
+
def build
|
17
|
+
filename = "#{@spec.name}-#{@spec.version}"
|
18
|
+
add_to_zip_file("#{Dir.pwd}/#{filename}/#{filename}.zip", "#{Dir.pwd}/#{filename}")
|
19
|
+
end
|
20
|
+
|
21
|
+
def git_push
|
22
|
+
filename = "#{@spec.name}-#{@spec.version}"
|
23
|
+
framworks_path = @upload_local_path
|
24
|
+
zip_path = "#{framworks_path}/#{@spec.name}"
|
25
|
+
FileUtils.mkdir_p(zip_path) unless File.exists?(zip_path)
|
26
|
+
FileUtils.cp("#{Dir.pwd}/#{filename}/#{filename}.zip", "#{zip_path}")
|
27
|
+
Dir.chdir(framworks_path)
|
28
|
+
git_add_command = "git add ."
|
29
|
+
git_output = `#{git_add_command}`.lines.to_a
|
30
|
+
commit_add_command = "git commit -s -m 'add #{filename} framework'"
|
31
|
+
commit_output = `#{commit_add_command}`.lines.to_a
|
32
|
+
push_add_command = "git push origin master"
|
33
|
+
push_commit_output = `#{push_add_command}`.lines.to_a
|
34
|
+
end
|
35
|
+
|
36
|
+
def push_repo
|
37
|
+
filename = "#{@spec.name}-#{@spec.version}"
|
38
|
+
UI.puts("准备发布 #{@work_dir}/#{filename}")
|
39
|
+
Dir.chdir("#{@work_dir}/#{filename}")
|
40
|
+
source = @spec_sources.join(",")
|
41
|
+
command = "pod repo push #{@upload_spec_name} #{@work_dir}/#{filename}/#{@spec.name}.podspec --allow-warnings --use-libraries --use-modular-headers --verbose --skip-import-validation --sources=#{source}"
|
42
|
+
output = `#{command}`.lines.to_a
|
43
|
+
end
|
44
|
+
|
45
|
+
# 压缩文件方法
|
46
|
+
def add_to_zip_file(zip_file_name,file_path)
|
47
|
+
def add_file(start_path,file_path,zip)
|
48
|
+
if File.directory?(file_path)
|
49
|
+
zip.mkdir(file_path)
|
50
|
+
Dir.foreach(file_path) do |filename|
|
51
|
+
add_file("#{start_path}/#{filename}","#{file_path}/#{filename}",zip) unless filename=="." or filename==".."
|
52
|
+
end
|
53
|
+
else
|
54
|
+
zip.add(start_path,file_path)
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
if File.exist?(zip_file_name)
|
59
|
+
File.delete(zip_file_name)
|
60
|
+
end
|
61
|
+
|
62
|
+
chdir,tardir = File.split(file_path)
|
63
|
+
Dir.chdir(chdir) do
|
64
|
+
Zip::File.open(zip_file_name,Zip::File::CREATE) do |zipfile|
|
65
|
+
add_file(tardir,tardir,zipfile)
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
@@ -0,0 +1,10 @@
|
|
1
|
+
require 'pod/command/gd'
|
2
|
+
require 'cocoapods-gd/user_interface/build_failed_report'
|
3
|
+
require 'cocoapods-gd/builder'
|
4
|
+
require 'cocoapods-gd/framework'
|
5
|
+
require 'cocoapods-gd/mangle'
|
6
|
+
require 'cocoapods-gd/pod_utils'
|
7
|
+
require 'cocoapods-gd/spec_builder'
|
8
|
+
require 'cocoapods-gd/symbols'
|
9
|
+
require 'cocoapods-gd/uploader'
|
10
|
+
require 'cocoapods-gd/install_frameworks'
|
@@ -0,0 +1,185 @@
|
|
1
|
+
require 'tmpdir'
|
2
|
+
module Pod
|
3
|
+
class Command
|
4
|
+
class Gd < 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
|
+
['--spec-sources=private,https://github.com/CocoaPods/Specs.git', '指定source源'],
|
14
|
+
['--upload', '是否上传,默认上传'],
|
15
|
+
['--upload-spec-name', '上传仓库必要参数,二进制源对应的spec版本仓库名称'],
|
16
|
+
['--upload-git-sources', '上传仓库必要参数,二进制源对应的git源码仓库名称'],
|
17
|
+
['--upload-local-path', '上传仓库必要参数,git源码仓库映射的本地路径'],
|
18
|
+
]
|
19
|
+
end
|
20
|
+
|
21
|
+
def initialize(argv)
|
22
|
+
@gd_type = :static_framework
|
23
|
+
@name = argv.shift_argument
|
24
|
+
@source = argv.shift_argument
|
25
|
+
|
26
|
+
@config = argv.option('configuration', 'Release')
|
27
|
+
|
28
|
+
@source_dir = Dir.pwd
|
29
|
+
@is_spec_from_path = false
|
30
|
+
@spec = spec_with_path(@name)
|
31
|
+
@is_spec_from_path = true if @spec
|
32
|
+
@spec ||= spec_with_name(@name)
|
33
|
+
# source源
|
34
|
+
@spec_sources = argv.option('spec-sources', 'https://gitlab.gaodun.com/iOSLibs/CocoaPods.git').split(',')
|
35
|
+
# 'https://github.com/CocoaPods/Specs.git'
|
36
|
+
@spec_sources.push('https://gitlab.gaodun.com/iOSLibs/Specs.git')
|
37
|
+
|
38
|
+
# 是否上传
|
39
|
+
@upload = argv.option('upload')
|
40
|
+
|
41
|
+
# 上传二进制源仓库名称
|
42
|
+
@upload_spec_name = argv.option('upload-spec-name')
|
43
|
+
|
44
|
+
# 上传二进制源仓库地址
|
45
|
+
@upload_git_sources = argv.option('upload-git-sources')
|
46
|
+
|
47
|
+
# 二进制源本地仓库地址
|
48
|
+
@upload_local_path = argv.option('upload-local-path')
|
49
|
+
|
50
|
+
if @upload.nil?
|
51
|
+
@upload = 1
|
52
|
+
end
|
53
|
+
|
54
|
+
if @upload_spec_name.nil?
|
55
|
+
@upload_spec_name = "frameworks-specs"
|
56
|
+
end
|
57
|
+
if @upload_git_sources.nil?
|
58
|
+
@upload_git_sources = "https://gitlab.gaodun.com/iOSLibs/Frameworks/raw/master"
|
59
|
+
end
|
60
|
+
if @upload_local_path.nil?
|
61
|
+
@upload_local_path = "/Users/lizuba/Desktop/Framework/Frameworks"
|
62
|
+
end
|
63
|
+
super
|
64
|
+
end
|
65
|
+
|
66
|
+
def validate!
|
67
|
+
super
|
68
|
+
end
|
69
|
+
|
70
|
+
def run
|
71
|
+
if @name == "install"
|
72
|
+
# pod install走这里
|
73
|
+
Pod::InstallFramework.new.install()
|
74
|
+
return
|
75
|
+
end
|
76
|
+
if @spec.nil?
|
77
|
+
help! "Unable to find a podspec with path or name `#{@name}`."
|
78
|
+
return
|
79
|
+
end
|
80
|
+
target_dir, work_dir = create_working_directory
|
81
|
+
return if target_dir.nil?
|
82
|
+
build_gd
|
83
|
+
build_path="#{Dir.pwd}/build"
|
84
|
+
if File.exist?("#{build_path}")
|
85
|
+
FileUtils.rm_rf('build/')
|
86
|
+
end
|
87
|
+
`mv "#{work_dir}" "#{target_dir}"`
|
88
|
+
Dir.chdir(@source_dir)
|
89
|
+
|
90
|
+
if @upload == 1
|
91
|
+
uploader = Uploader.new(@spec, @upload_spec_name, @upload_local_path, @spec_sources)
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
private
|
96
|
+
|
97
|
+
def build_in_sandbox(platform)
|
98
|
+
config.installation_root = Pathname.new(Dir.pwd)
|
99
|
+
config.sandbox_root = 'Pods'
|
100
|
+
|
101
|
+
static_sandbox = build_static_sandbox(@dynamic)
|
102
|
+
static_installer = install_pod(platform.name, static_sandbox)
|
103
|
+
|
104
|
+
if @dynamic
|
105
|
+
dynamic_sandbox = build_dynamic_sandbox(static_sandbox, static_installer)
|
106
|
+
install_dynamic_pod(dynamic_sandbox, static_sandbox, static_installer, platform)
|
107
|
+
end
|
108
|
+
|
109
|
+
begin
|
110
|
+
perform_build(platform, static_sandbox, dynamic_sandbox, static_installer)
|
111
|
+
ensure # in case the build fails; see Builder#xcodebuild.
|
112
|
+
Pathname.new(config.sandbox_root).rmtree
|
113
|
+
FileUtils.rm_f('Podfile.lock')
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
117
|
+
def build_gd
|
118
|
+
builder = SpecBuilder.new(@spec, @source, @embedded, @dynamic, @upload_git_sources)
|
119
|
+
newspec = builder.spec_metadata
|
120
|
+
|
121
|
+
@spec.available_platforms.each do |platform|
|
122
|
+
if platform.name == :ios
|
123
|
+
build_in_sandbox(platform)
|
124
|
+
newspec += builder.spec_platform(platform)
|
125
|
+
end
|
126
|
+
end
|
127
|
+
|
128
|
+
newspec += builder.spec_close
|
129
|
+
File.open(@spec.name + '.podspec', 'w') { |file| file.write(newspec) }
|
130
|
+
end
|
131
|
+
|
132
|
+
def create_target_directory
|
133
|
+
target_dir = "#{@source_dir}/#{@spec.name}-#{@spec.version}"
|
134
|
+
if File.exist? target_dir
|
135
|
+
if @force
|
136
|
+
Pathname.new(target_dir).rmtree
|
137
|
+
else
|
138
|
+
UI.puts "Target directory '#{target_dir}' already exists."
|
139
|
+
return nil
|
140
|
+
end
|
141
|
+
end
|
142
|
+
target_dir
|
143
|
+
end
|
144
|
+
|
145
|
+
def create_working_directory
|
146
|
+
target_dir = create_target_directory
|
147
|
+
return if target_dir.nil?
|
148
|
+
|
149
|
+
work_dir = Dir.tmpdir + '/cocoapods-' + Array.new(8) { rand(36).to_s(36) }.join
|
150
|
+
Pathname.new(work_dir).mkdir
|
151
|
+
Dir.chdir(work_dir)
|
152
|
+
|
153
|
+
[target_dir, work_dir]
|
154
|
+
end
|
155
|
+
|
156
|
+
def perform_build(platform, static_sandbox, dynamic_sandbox, static_installer)
|
157
|
+
static_sandbox_root = config.sandbox_root.to_s
|
158
|
+
if @dynamic
|
159
|
+
static_sandbox_root = "#{static_sandbox_root}/#{static_sandbox.root.to_s.split('/').last}"
|
160
|
+
dynamic_sandbox_root = "#{config.sandbox_root}/#{dynamic_sandbox.root.to_s.split('/').last}"
|
161
|
+
end
|
162
|
+
|
163
|
+
builder = Pod::GDBuilder.new(
|
164
|
+
platform,
|
165
|
+
static_installer,
|
166
|
+
@source_dir,
|
167
|
+
static_sandbox_root,
|
168
|
+
static_sandbox.public_headers.root,
|
169
|
+
@spec,
|
170
|
+
@embedded,
|
171
|
+
@mangle,
|
172
|
+
@dynamic,
|
173
|
+
@config,
|
174
|
+
@bundle_identifier,
|
175
|
+
@exclude_deps
|
176
|
+
)
|
177
|
+
|
178
|
+
builder.build(@gd_type)
|
179
|
+
|
180
|
+
return unless @embedded
|
181
|
+
builder.link_embedded_resources
|
182
|
+
end
|
183
|
+
end
|
184
|
+
end
|
185
|
+
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 'Gd' 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{ gd 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{ gd 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{ gd 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{ gd 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{ gd 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{ gd 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 gd a podspec with only resources' do
|
53
|
+
command = Command.parse(%w{ gd 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 gd a podspec with binary-only dependencies if --no-mangle is specified' do
|
60
|
+
command = Command.parse(%w{ gd 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 gd a podspec with resource bundles' do
|
67
|
+
command = Command.parse(%w{ gd 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 gd a podspec with weak frameworks without strong linking' do
|
75
|
+
command = Command.parse(%w{ gd 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
|