cocoapods 0.2.0 → 0.3.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.
- data/CHANGELOG.md +129 -0
- data/README.md +58 -54
- data/bin/pod +1 -0
- data/lib/cocoapods.rb +7 -10
- data/lib/cocoapods/bridge_support_generator.rb +3 -5
- data/lib/cocoapods/command.rb +1 -1
- data/lib/cocoapods/command/repo.rb +22 -12
- data/lib/cocoapods/command/setup.rb +14 -3
- data/lib/cocoapods/command/spec.rb +8 -7
- data/lib/cocoapods/config.rb +2 -2
- data/lib/cocoapods/dependency.rb +65 -3
- data/lib/cocoapods/downloader.rb +7 -2
- data/lib/cocoapods/installer.rb +244 -99
- data/lib/cocoapods/podfile.rb +145 -10
- data/lib/cocoapods/resolver.rb +10 -6
- data/lib/cocoapods/specification.rb +13 -12
- data/lib/cocoapods/specification/set.rb +34 -0
- data/lib/cocoapods/xcodeproj_ext.rb +99 -0
- metadata +32 -35
- data/lib/cocoapods/project_template.rb +0 -35
- data/lib/cocoapods/xcode/config.rb +0 -33
- data/lib/cocoapods/xcode/copy_resources_script.rb +0 -21
- data/lib/cocoapods/xcode/project.rb +0 -356
- data/lib/cocoapods/xcode/workspace.rb +0 -56
- data/xcode-project-templates/cocoa-static-library/Pods-Prefix.pch +0 -7
- data/xcode-project-templates/cocoa-static-library/Pods.xcconfig +0 -1
- data/xcode-project-templates/cocoa-static-library/Pods.xcodeproj/project.pbxproj +0 -236
- data/xcode-project-templates/cocoa-static-library/PodsResources.sh +0 -8
- data/xcode-project-templates/cocoa-touch-static-library/Pods-Prefix.pch +0 -7
- data/xcode-project-templates/cocoa-touch-static-library/Pods.xcconfig +0 -1
- data/xcode-project-templates/cocoa-touch-static-library/Pods.xcodeproj/project.pbxproj +0 -248
- data/xcode-project-templates/cocoa-touch-static-library/PodsResources.sh +0 -8
@@ -4,14 +4,14 @@ module Pod
|
|
4
4
|
def self.banner
|
5
5
|
%{Managing PodSpec files:
|
6
6
|
|
7
|
-
$ pod
|
7
|
+
$ pod spec create NAME
|
8
8
|
|
9
|
-
|
10
|
-
Creates a PodSpec, in the current working dir, called `NAME.podspec'.
|
9
|
+
Creates a PodSpec, in the current working dir, called `NAME.podspec'.
|
11
10
|
|
12
|
-
|
13
|
-
|
14
|
-
|
11
|
+
$ pod spec lint NAME.podspec
|
12
|
+
|
13
|
+
Validates `NAME.podspec'. In case `NAME.podspec' is omitted, it defaults
|
14
|
+
to `*.podspec' in the current working dir.}
|
15
15
|
end
|
16
16
|
|
17
17
|
def initialize(argv)
|
@@ -34,6 +34,7 @@ module Pod
|
|
34
34
|
Pod::Spec.new do |s|
|
35
35
|
s.name = '#{@name}'
|
36
36
|
s.version = '1.0.0'
|
37
|
+
s.license = 'MIT'
|
37
38
|
s.summary = 'A short description of #{@name}.'
|
38
39
|
s.homepage = 'http://example.com/#{@name}'
|
39
40
|
s.author = { '#{author}' => '#{email}' }
|
@@ -45,7 +46,7 @@ module Pod
|
|
45
46
|
# automatically have '*.{h,m,mm,c,cpp}' appended.
|
46
47
|
s.source_files = 'Classes', 'Classes/**/*.{h,m}'
|
47
48
|
|
48
|
-
s.
|
49
|
+
s.framework = 'SomeRequiredFramework'
|
49
50
|
|
50
51
|
s.dependency 'SomeLibraryThat#{@name}DependsOn', '>= 1.0.0'
|
51
52
|
end
|
data/lib/cocoapods/config.rb
CHANGED
@@ -10,7 +10,7 @@ module Pod
|
|
10
10
|
@instance = instance
|
11
11
|
end
|
12
12
|
|
13
|
-
attr_accessor :repos_dir, :project_pods_root, :rootspec, :clean, :verbose, :silent
|
13
|
+
attr_accessor :repos_dir, :project_root, :project_pods_root, :rootspec, :clean, :verbose, :silent
|
14
14
|
alias_method :clean?, :clean
|
15
15
|
alias_method :verbose?, :verbose
|
16
16
|
alias_method :silent?, :silent
|
@@ -23,7 +23,7 @@ module Pod
|
|
23
23
|
end
|
24
24
|
|
25
25
|
def project_root
|
26
|
-
Pathname.pwd
|
26
|
+
@project_root ||= Pathname.pwd
|
27
27
|
end
|
28
28
|
|
29
29
|
def project_pods_root
|
data/lib/cocoapods/dependency.rb
CHANGED
@@ -7,13 +7,75 @@ module Pod
|
|
7
7
|
attr_accessor :only_part_of_other_pod
|
8
8
|
alias_method :only_part_of_other_pod?, :only_part_of_other_pod
|
9
9
|
|
10
|
-
|
11
|
-
|
10
|
+
attr_accessor :external_spec_source
|
11
|
+
|
12
|
+
attr_accessor :specification
|
13
|
+
|
14
|
+
def initialize(*name_and_version_requirements, &block)
|
15
|
+
if name_and_version_requirements.empty? && block
|
16
|
+
@inline_podspec = true
|
17
|
+
@specification = Specification.new(&block)
|
18
|
+
super(@specification.name, @specification.version)
|
19
|
+
|
20
|
+
elsif !name_and_version_requirements.empty? && block.nil?
|
21
|
+
if name_and_version_requirements.last.is_a?(Hash)
|
22
|
+
@external_spec_source = name_and_version_requirements.pop
|
23
|
+
end
|
24
|
+
super(*name_and_version_requirements)
|
25
|
+
|
26
|
+
else
|
27
|
+
raise Informative, "A dependency needs either a name and version requirements, " \
|
28
|
+
"a source hash, or a block which defines a podspec."
|
29
|
+
end
|
12
30
|
@only_part_of_other_pod = false
|
13
31
|
end
|
14
32
|
|
15
33
|
def ==(other)
|
16
|
-
super &&
|
34
|
+
super &&
|
35
|
+
@only_part_of_other_pod == other.only_part_of_other_pod &&
|
36
|
+
(@specification ? @specification == other.specification : @external_spec_source == other.external_spec_source)
|
37
|
+
end
|
38
|
+
|
39
|
+
def to_s
|
40
|
+
version = ''
|
41
|
+
if source = @external_spec_source
|
42
|
+
version << "from `#{source[:git] || source[:podspec]}'"
|
43
|
+
version << ", commit `#{source[:commit]}'" if source[:commit]
|
44
|
+
version << ", tag `#{source[:tag]}'" if source[:tag]
|
45
|
+
elsif @inline_podspec
|
46
|
+
version << "defined in Podfile"
|
47
|
+
elsif @version_requirements != Gem::Requirement.default
|
48
|
+
version << @version_requirements.to_s
|
49
|
+
end
|
50
|
+
version.empty? ? @name : "#{@name} (#{version})"
|
51
|
+
end
|
52
|
+
|
53
|
+
# In case this dependency was defined with either a repo url, :podspec, or block,
|
54
|
+
# this method will return the Specification instance.
|
55
|
+
def specification
|
56
|
+
@specification ||= begin
|
57
|
+
if @external_spec_source
|
58
|
+
config = Config.instance
|
59
|
+
pod_root = config.project_pods_root + @name
|
60
|
+
spec = nil
|
61
|
+
if @external_spec_source[:podspec]
|
62
|
+
config.project_pods_root.mkpath
|
63
|
+
spec = config.project_pods_root + "#{@name}.podspec"
|
64
|
+
source = @external_spec_source[:podspec]
|
65
|
+
# can be http, file, etc
|
66
|
+
require 'open-uri'
|
67
|
+
puts " * Fetching podspec for `#{@name}' from: #{source}" unless config.silent?
|
68
|
+
open(source) do |io|
|
69
|
+
spec.open('w') { |f| f << io.read }
|
70
|
+
end
|
71
|
+
else
|
72
|
+
puts " * Pre-downloading: `#{@name}'" unless config.silent?
|
73
|
+
Downloader.for_source(pod_root, @external_spec_source).download
|
74
|
+
spec = pod_root + "#{@name}.podspec"
|
75
|
+
end
|
76
|
+
Specification.from_file(spec)
|
77
|
+
end
|
78
|
+
end
|
17
79
|
end
|
18
80
|
|
19
81
|
# Taken from a newer version of RubyGems
|
data/lib/cocoapods/downloader.rb
CHANGED
@@ -20,17 +20,22 @@ module Pod
|
|
20
20
|
executable :git
|
21
21
|
|
22
22
|
def download
|
23
|
+
@pod_root.dirname.mkpath
|
23
24
|
if @options[:tag]
|
24
25
|
download_tag
|
25
26
|
elsif @options[:commit]
|
26
27
|
download_commit
|
27
28
|
else
|
28
|
-
|
29
|
+
download_head
|
29
30
|
end
|
30
31
|
end
|
31
32
|
|
33
|
+
def download_head
|
34
|
+
git "clone '#{@url}' '#{@pod_root}'"
|
35
|
+
end
|
36
|
+
|
32
37
|
def download_tag
|
33
|
-
@pod_root.
|
38
|
+
@pod_root.mkpath
|
34
39
|
Dir.chdir(@pod_root) do
|
35
40
|
git "init"
|
36
41
|
git "remote add origin '#{@url}'"
|
data/lib/cocoapods/installer.rb
CHANGED
@@ -1,107 +1,269 @@
|
|
1
|
+
require 'yaml'
|
2
|
+
|
1
3
|
module Pod
|
2
4
|
class Installer
|
3
|
-
|
5
|
+
module Shared
|
6
|
+
def dependent_specification_sets
|
7
|
+
@dependent_specification_sets ||= Resolver.new(@podfile, @definition ? @definition.dependencies : nil).resolve
|
8
|
+
end
|
4
9
|
|
5
|
-
|
6
|
-
|
7
|
-
|
10
|
+
def build_specifications
|
11
|
+
dependent_specification_sets.reject(&:only_part_of_other_pod?).map(&:specification)
|
12
|
+
end
|
8
13
|
|
9
|
-
|
10
|
-
|
14
|
+
def download_only_specifications
|
15
|
+
dependent_specification_sets.select(&:only_part_of_other_pod?).map(&:specification)
|
16
|
+
end
|
11
17
|
end
|
12
18
|
|
13
|
-
|
14
|
-
|
15
|
-
|
19
|
+
class CopyResourcesScript
|
20
|
+
CONTENT = <<EOS
|
21
|
+
#!/bin/sh
|
16
22
|
|
17
|
-
|
18
|
-
|
19
|
-
|
23
|
+
install_resource()
|
24
|
+
{
|
25
|
+
echo "cp -R ${SRCROOT}/Pods/$1 ${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}"
|
26
|
+
cp -R ${SRCROOT}/Pods/$1 ${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}
|
27
|
+
}
|
28
|
+
EOS
|
20
29
|
|
21
|
-
|
22
|
-
@xcconfig ||= Xcode::Config.new({
|
23
|
-
# In a workspace this is where the static library headers should be found.
|
24
|
-
'USER_HEADER_SEARCH_PATHS' => '"$(BUILT_PRODUCTS_DIR)/Pods"',
|
25
|
-
'ALWAYS_SEARCH_USER_PATHS' => 'YES',
|
26
|
-
# This makes categories from static libraries work, which many libraries
|
27
|
-
# require, so we add these by default.
|
28
|
-
'OTHER_LDFLAGS' => '-ObjC -all_load',
|
29
|
-
})
|
30
|
-
end
|
30
|
+
attr_reader :resources
|
31
31
|
|
32
|
-
|
33
|
-
|
34
|
-
|
32
|
+
# A list of files relative to the project pods root.
|
33
|
+
def initialize(resources)
|
34
|
+
@resources = resources
|
35
|
+
end
|
35
36
|
|
36
|
-
|
37
|
-
|
37
|
+
def save_as(pathname)
|
38
|
+
pathname.open('w') do |script|
|
39
|
+
script.puts CONTENT
|
40
|
+
@resources.each do |resource|
|
41
|
+
script.puts "install_resource '#{resource}'"
|
42
|
+
end
|
43
|
+
end
|
44
|
+
# TODO use File api
|
45
|
+
system("chmod +x '#{pathname}'")
|
46
|
+
end
|
38
47
|
end
|
39
48
|
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
49
|
+
class TargetInstaller
|
50
|
+
include Config::Mixin
|
51
|
+
include Shared
|
52
|
+
|
53
|
+
attr_reader :target
|
54
|
+
|
55
|
+
def initialize(podfile, project, definition)
|
56
|
+
@podfile, @project, @definition = podfile, project, definition
|
57
|
+
end
|
58
|
+
|
59
|
+
def xcconfig
|
60
|
+
@xcconfig ||= Xcodeproj::Config.new({
|
61
|
+
# In a workspace this is where the static library headers should be found.
|
62
|
+
'USER_HEADER_SEARCH_PATHS' => '"$(BUILT_PRODUCTS_DIR)/Pods"',
|
63
|
+
'ALWAYS_SEARCH_USER_PATHS' => 'YES',
|
64
|
+
# This makes categories from static libraries work, which many libraries
|
65
|
+
# require, so we add these by default.
|
66
|
+
'OTHER_LDFLAGS' => '-ObjC -all_load',
|
67
|
+
})
|
68
|
+
end
|
69
|
+
|
70
|
+
def xcconfig_filename
|
71
|
+
"#{@definition.lib_name}.xcconfig"
|
72
|
+
end
|
73
|
+
|
74
|
+
def copy_resources_script
|
75
|
+
@copy_resources_script ||= CopyResourcesScript.new(build_specifications.map do |spec|
|
76
|
+
spec.expanded_resources
|
77
|
+
end.flatten)
|
78
|
+
end
|
79
|
+
|
80
|
+
def copy_resources_filename
|
81
|
+
"#{@definition.lib_name}-resources.sh"
|
82
|
+
end
|
47
83
|
|
48
|
-
|
49
|
-
|
50
|
-
|
84
|
+
def bridge_support_generator
|
85
|
+
BridgeSupportGenerator.new(build_specifications.map do |spec|
|
86
|
+
spec.header_files.map do |header|
|
87
|
+
config.project_pods_root + header
|
88
|
+
end
|
89
|
+
end.flatten)
|
90
|
+
end
|
91
|
+
|
92
|
+
def bridge_support_filename
|
93
|
+
"#{@definition.lib_name}.bridgesupport"
|
94
|
+
end
|
95
|
+
|
96
|
+
# TODO move out
|
97
|
+
def save_prefix_header_as(pathname)
|
98
|
+
pathname.open('w') do |header|
|
99
|
+
header.puts "#ifdef __OBJC__"
|
100
|
+
header.puts "#import #{@podfile.platform == :ios ? '<UIKit/UIKit.h>' : '<Cocoa/Cocoa.h>'}"
|
101
|
+
header.puts "#endif"
|
51
102
|
end
|
103
|
+
end
|
104
|
+
|
105
|
+
def prefix_header_filename
|
106
|
+
"#{@definition.lib_name}-prefix.pch"
|
107
|
+
end
|
52
108
|
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
109
|
+
# TODO move xcconfig related code into the xcconfig method, like copy_resources_script and generate_bridge_support.
|
110
|
+
def install!
|
111
|
+
# First add the target to the project
|
112
|
+
@target = @project.targets.new_static_library(@definition.lib_name)
|
113
|
+
|
114
|
+
user_header_search_paths = []
|
115
|
+
build_specifications.each do |spec|
|
116
|
+
xcconfig.merge!(spec.xcconfig)
|
117
|
+
# Only add implementation files to the compile phase
|
118
|
+
spec.implementation_files.each do |file|
|
119
|
+
@target.add_source_file(file, nil, spec.compiler_flags)
|
120
|
+
end
|
121
|
+
# Add header files to a `copy header build phase` for each destination
|
122
|
+
# directory in the pod's header directory.
|
123
|
+
spec.copy_header_mappings.each do |header_dir, files|
|
124
|
+
copy_phase = @target.copy_files_build_phases.new_pod_dir(spec.name, header_dir)
|
125
|
+
files.each do |file|
|
126
|
+
@target.add_source_file(file, copy_phase)
|
127
|
+
end
|
59
128
|
end
|
129
|
+
# Collect all header search paths
|
130
|
+
user_header_search_paths.concat(spec.user_header_search_paths)
|
60
131
|
end
|
132
|
+
xcconfig.merge!('USER_HEADER_SEARCH_PATHS' => user_header_search_paths.sort.uniq.join(" "))
|
61
133
|
|
62
|
-
#
|
63
|
-
|
134
|
+
# Add all the target related support files to the group, even the copy
|
135
|
+
# resources script although the project doesn't actually use them.
|
136
|
+
support_files_group = @project.groups.find do |group|
|
137
|
+
group.name == "Targets Support Files"
|
138
|
+
end.groups.new("name" => @definition.lib_name)
|
139
|
+
support_files_group.files.new('path' => copy_resources_filename)
|
140
|
+
prefix_file = support_files_group.files.new('path' => prefix_header_filename)
|
141
|
+
xcconfig_file = support_files_group.files.new("path" => xcconfig_filename)
|
142
|
+
# Assign the xcconfig as the base config of each config.
|
143
|
+
@target.buildConfigurations.each do |config|
|
144
|
+
config.baseConfiguration = xcconfig_file
|
145
|
+
config.buildSettings['OTHER_LDFLAGS'] = ''
|
146
|
+
config.buildSettings['GCC_PREFIX_HEADER'] = prefix_header_filename
|
147
|
+
end
|
148
|
+
end
|
149
|
+
|
150
|
+
def create_files_in(root)
|
151
|
+
xcconfig.save_as(root + xcconfig_filename)
|
152
|
+
if @podfile.generate_bridge_support?
|
153
|
+
bridge_support_generator.save_as(root + bridge_support_filename)
|
154
|
+
copy_resources_script.resources << bridge_support_filename
|
155
|
+
end
|
156
|
+
save_prefix_header_as(root + prefix_header_filename)
|
157
|
+
copy_resources_script.save_as(root + copy_resources_filename)
|
64
158
|
end
|
65
|
-
xcconfig.merge!('USER_HEADER_SEARCH_PATHS' => user_header_search_paths.sort.uniq.join(" "))
|
66
159
|
end
|
67
160
|
|
68
|
-
|
69
|
-
|
161
|
+
include Config::Mixin
|
162
|
+
include Shared
|
163
|
+
|
164
|
+
def initialize(podfile)
|
165
|
+
@podfile = podfile
|
70
166
|
end
|
71
167
|
|
72
|
-
def
|
73
|
-
|
74
|
-
|
75
|
-
|
168
|
+
def lock_file
|
169
|
+
config.project_root + 'Podfile.lock'
|
170
|
+
end
|
171
|
+
|
172
|
+
def project
|
173
|
+
return @project if @project
|
174
|
+
@project = Xcodeproj::Project.for_platform(@podfile.platform)
|
175
|
+
# First we need to resolve dependencies across *all* targets, so that the
|
176
|
+
# same correct versions of pods are being used for all targets. This
|
177
|
+
# happens when we call `build_specifications'.
|
178
|
+
build_specifications.each do |spec|
|
179
|
+
# Add all source files to the project grouped by pod
|
180
|
+
group = @project.add_pod_group(spec.name)
|
181
|
+
spec.expanded_source_files.each do |path|
|
182
|
+
group.children.new('path' => path.to_s)
|
76
183
|
end
|
77
|
-
end
|
184
|
+
end
|
185
|
+
# Add a group to hold all the target support files
|
186
|
+
@project.main_group.groups.new('name' => 'Targets Support Files')
|
187
|
+
@project
|
188
|
+
end
|
189
|
+
|
190
|
+
def target_installers
|
191
|
+
@target_installers ||= @podfile.target_definitions.values.map do |definition|
|
192
|
+
TargetInstaller.new(@podfile, project, definition)
|
193
|
+
end
|
78
194
|
end
|
79
195
|
|
80
196
|
def install!
|
81
|
-
puts "Installing dependencies of: #{@
|
197
|
+
puts "Installing dependencies of: #{@podfile.defined_in_file}" unless config.silent?
|
82
198
|
build_specifications.each(&:install!)
|
83
|
-
generate_project
|
84
|
-
|
85
199
|
root = config.project_pods_root
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
200
|
+
|
201
|
+
puts "==> Generating support files" unless config.silent?
|
202
|
+
target_installers.each do |target_installer|
|
203
|
+
target_installer.install!
|
204
|
+
target_installer.create_files_in(root)
|
205
|
+
end
|
206
|
+
generate_lock_file!
|
207
|
+
|
208
|
+
puts "==> Running post install hooks" unless config.silent?
|
209
|
+
# Post install hooks run _before_ saving of project, so that they can alter it before saving.
|
210
|
+
target_installers.each do |target_installer|
|
211
|
+
target_installer.build_specifications.each { |spec| spec.post_install(target_installer) }
|
212
|
+
end
|
213
|
+
@podfile.post_install!(self)
|
214
|
+
|
215
|
+
puts "==> Generating Xcode project" unless config.silent?
|
216
|
+
projpath = File.join(root, 'Pods.xcodeproj')
|
217
|
+
puts " * Writing Xcode project file to `#{projpath}'" if config.verbose?
|
218
|
+
project.save_as(projpath)
|
219
|
+
end
|
220
|
+
|
221
|
+
def generate_lock_file!
|
222
|
+
lock_file.open('w') do |file|
|
223
|
+
file.puts "PODS:"
|
224
|
+
pods = build_specifications.map do |spec|
|
225
|
+
[spec.to_s, spec.dependencies.map(&:to_s).sort]
|
226
|
+
end.sort_by(&:first).each do |name, deps|
|
227
|
+
if deps.empty?
|
228
|
+
file.puts " - #{name}"
|
229
|
+
else
|
230
|
+
file.puts " - #{name}:"
|
231
|
+
deps.each { |dep| file.puts " - #{dep}" }
|
232
|
+
end
|
233
|
+
end
|
234
|
+
|
235
|
+
unless download_only_specifications.empty?
|
236
|
+
file.puts
|
237
|
+
file.puts "DOWNLOAD_ONLY:"
|
238
|
+
download_only_specifications.map(&:to_s).sort.each do |name|
|
239
|
+
file.puts " - #{name}"
|
240
|
+
end
|
241
|
+
end
|
242
|
+
|
243
|
+
file.puts
|
244
|
+
file.puts "DEPENDENCIES:"
|
245
|
+
@podfile.dependencies.map(&:to_s).sort.each do |dep|
|
246
|
+
file.puts " - #{dep}"
|
247
|
+
end
|
248
|
+
end
|
99
249
|
end
|
100
|
-
|
250
|
+
|
251
|
+
# For now this assumes just one pods target, i.e. only libPods.a.
|
252
|
+
# Not sure yet if we should try to be smart with apps that have multiple
|
253
|
+
# targets and try to map pod targets to those app targets.
|
254
|
+
#
|
255
|
+
# Possible options are:
|
256
|
+
# 1. Only cater to the most simple setup
|
257
|
+
# 2. Try to automagically figure it out by name. For example, a pod target
|
258
|
+
# called `:some_target' could map to an app target called `SomeTarget'.
|
259
|
+
# (A variation would be to not even camelize the target name, but simply
|
260
|
+
# let the user specify it with the proper case.)
|
261
|
+
# 3. Let the user specify the app target name as an extra argument, but this
|
262
|
+
# seems to be a less good version of the variation on #2.
|
101
263
|
def configure_project(projpath)
|
102
264
|
root = File.dirname(projpath)
|
103
265
|
xcworkspace = File.join(root, File.basename(projpath, '.xcodeproj') + '.xcworkspace')
|
104
|
-
workspace =
|
266
|
+
workspace = Xcodeproj::Workspace.new_from_xcworkspace(xcworkspace)
|
105
267
|
pods_projpath = File.join(config.project_pods_root, 'Pods.xcodeproj')
|
106
268
|
root = Pathname.new(root).expand_path
|
107
269
|
[projpath, pods_projpath].each do |path|
|
@@ -110,41 +272,24 @@ module Pod
|
|
110
272
|
end
|
111
273
|
workspace.save_as(xcworkspace)
|
112
274
|
|
113
|
-
app_project =
|
275
|
+
app_project = Xcodeproj::Project.new(projpath)
|
114
276
|
return if app_project.files.find { |file| file.path =~ /libPods\.a$/ }
|
115
277
|
|
116
|
-
configfile = app_project.files.new(
|
117
|
-
'path' => 'Pods/Pods.xcconfig',
|
118
|
-
'lastKnownFileType' => 'text.xcconfig'
|
119
|
-
})
|
278
|
+
configfile = app_project.files.new('path' => 'Pods/Pods.xcconfig')
|
120
279
|
app_project.targets.each do |target|
|
121
|
-
target.
|
122
|
-
config.
|
280
|
+
target.buildConfigurations.each do |config|
|
281
|
+
config.baseConfiguration = configfile
|
123
282
|
end
|
124
283
|
end
|
125
|
-
app_project.main_group << configfile
|
126
284
|
|
127
|
-
libfile = app_project.files.
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
})
|
133
|
-
app_project.objects.select_by_class(Xcode::Project::PBXFrameworksBuildPhase).each do |build_phase|
|
134
|
-
build_phase.files << libfile.build_file
|
135
|
-
end
|
136
|
-
app_project.main_group << libfile
|
285
|
+
libfile = app_project.files.new_static_library('Pods')
|
286
|
+
libfile.group = app_project.main_group.groups.find { |g| g.name == 'Frameworks' }
|
287
|
+
app_project.objects.select_by_class(Xcodeproj::Project::PBXFrameworksBuildPhase).each do |build_phase|
|
288
|
+
build_phase.files << libfile.buildFiles.new
|
289
|
+
end
|
137
290
|
|
138
|
-
copy_resources = app_project.
|
139
|
-
|
140
|
-
'buildActionMask' => '2147483647',
|
141
|
-
'files' => [],
|
142
|
-
'inputPaths' => [],
|
143
|
-
'outputPaths' => [],
|
144
|
-
'runOnlyForDeploymentPostprocessing' => '0',
|
145
|
-
'shellPath' => '/bin/sh',
|
146
|
-
'shellScript' => "${SRCROOT}/Pods/PodsResources.sh\n"
|
147
|
-
})
|
291
|
+
copy_resources = app_project.add_shell_script_build_phase('Copy Pods Resources',
|
292
|
+
%{"${SRCROOT}/Pods/Pods-resources.sh"\n})
|
148
293
|
app_project.targets.each { |target| target.buildPhases << copy_resources }
|
149
294
|
|
150
295
|
app_project.save_as(projpath)
|