Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
C
cocoapods
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
gengmeiios
cocoapods
Commits
10befd83
Commit
10befd83
authored
Nov 03, 2011
by
Eloy Duran
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Generate copy resources scripts for each target.
parent
644e4190
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
73 additions
and
76 deletions
+73
-76
installer.rb
lib/cocoapods/installer.rb
+46
-50
copy_resources_script.rb
lib/cocoapods/xcode/copy_resources_script.rb
+15
-3
integration_spec.rb
spec/integration_spec.rb
+12
-7
PodsResources.sh
...e-project-templates/cocoa-static-library/PodsResources.sh
+0
-8
PodsResources.sh
...ect-templates/cocoa-touch-static-library/PodsResources.sh
+0
-8
No files found.
lib/cocoapods/installer.rb
View file @
10befd83
module
Pod
class
Installer
class
Target
attr_reader
:target
def
initialize
(
podfile
,
xcodeproj
,
definition
)
@podfile
,
@xcodeproj
,
@definition
=
podfile
,
xcodeproj
,
definition
end
module
Shared
def
dependent_specification_sets
@dependent_specification_sets
||=
Resolver
.
new
(
@podfile
,
@definition
.
dependencies
).
resolve
@dependent_specification_sets
||=
Resolver
.
new
(
@podfile
,
@definition
?
@definition
.
dependencies
:
nil
).
resolve
end
def
build_specification_sets
...
...
@@ -18,6 +12,16 @@ module Pod
def
build_specifications
build_specification_sets
.
map
(
&
:specification
)
end
end
class
Target
include
Shared
attr_reader
:target
def
initialize
(
podfile
,
xcodeproj
,
definition
)
@podfile
,
@xcodeproj
,
@definition
=
podfile
,
xcodeproj
,
definition
end
def
xcconfig
@xcconfig
||=
Xcode
::
Config
.
new
({
...
...
@@ -34,6 +38,16 @@ module Pod
"
#{
@definition
.
lib_name
}
.xcconfig"
end
def
copy_resources_script
@copy_resources_script
||=
Xcode
::
CopyResourcesScript
.
new
(
build_specifications
.
map
do
|
spec
|
spec
.
expanded_resources
end
.
flatten
)
end
def
copy_resources_filename
"
#{
@definition
.
lib_name
}
-resources.sh"
end
# TODO move xcconfig related code into the xcconfig method, like copy_resources_script and generate_bridge_support.
def
install!
# First add the target to the project
...
...
@@ -64,57 +78,28 @@ module Pod
@target
.
buildConfigurations
.
each
do
|
config
|
config
.
baseConfiguration
=
xcconfig_file
end
self
end
def
create_files_in
(
root
)
xcconfig
.
save_as
(
root
+
xcconfig_filename
)
copy_resources_script
.
save_as
(
root
+
copy_resources_filename
)
end
end
include
Config
::
Mixin
include
Shared
def
initialize
(
podfile
)
@podfile
=
podfile
end
def
dependent_specification_sets
@dependent_specification_sets
||=
Resolver
.
new
(
@podfile
).
resolve
end
def
build_specification_sets
dependent_specification_sets
.
reject
(
&
:only_part_of_other_pod?
)
end
def
build_specifications
build_specification_sets
.
map
(
&
:specification
)
end
def
template
@template
||=
ProjectTemplate
.
new
(
@podfile
.
platform
)
end
def
xcodeproj
@xcodeproj
||=
Xcode
::
Project
.
new
(
template
.
xcodeproj_path
)
end
def
copy_resources_script
@copy_resources_script
||=
Xcode
::
CopyResourcesScript
.
new
(
build_specifications
.
map
do
|
spec
|
spec
.
expanded_resources
end
.
flatten
)
end
def
bridge_support_generator
BridgeSupportGenerator
.
new
(
build_specifications
.
map
do
|
spec
|
spec
.
header_files
.
map
do
|
header
|
config
.
project_pods_root
+
header
end
end
.
flatten
)
end
def
generate_project
puts
"==> Generating Xcode project and xcconfig"
unless
config
.
silent?
unless
@xcodeproj
@xcodeproj
=
Xcode
::
Project
.
new
(
template
.
xcodeproj_path
)
# First we need to resolve dependencies across *all* targets, so that the
# same correct versions of pods are being used for all targets. This
# happens when we call `build_specifications'.
...
...
@@ -125,10 +110,21 @@ module Pod
group
.
children
.
new
(
'path'
=>
path
.
to_s
)
end
end
end
@xcodeproj
end
def
bridge_support_generator
BridgeSupportGenerator
.
new
(
build_specifications
.
map
do
|
spec
|
spec
.
header_files
.
map
do
|
header
|
config
.
project_pods_root
+
header
end
end
.
flatten
)
end
# Now we can generate the individual
targets
@podfile
.
targets
.
values
.
map
do
|
target_definition
|
Target
.
new
(
@podfile
,
xcodeproj
,
target_definition
)
.
install!
def
targets
@
targets
||=
@
podfile
.
targets
.
values
.
map
do
|
target_definition
|
Target
.
new
(
@podfile
,
xcodeproj
,
target_definition
)
end
end
...
...
@@ -143,14 +139,14 @@ module Pod
# This has to happen before we generate the individual targets to make the specs pass.
# TODO However, this will move into the Target installer class as well, because each
# target needs its own xcconfig and bridgesupport.
if
@podfile
.
generate_bridge_support?
path
=
bridge_support_generator
.
create_in
(
root
)
copy_resources_script
.
resources
<<
path
.
relative_path_from
(
config
.
project_pods_root
)
end
copy_resources_script
.
create_in
(
root
)
#if @podfile.generate_bridge_support?
#path = bridge_support_generator.create_in(root)
#copy_resources_script.resources << path.relative_path_from(config.project_pods_root)
#end
targets
=
generate_project
puts
"==> Generating Xcode project and xcconfig"
unless
config
.
silent?
targets
.
each
do
|
target
|
target
.
install!
target
.
create_files_in
(
root
)
end
pbxproj
=
File
.
join
(
root
,
'Pods.xcodeproj'
)
...
...
lib/cocoapods/xcode/copy_resources_script.rb
View file @
10befd83
module
Pod
module
Xcode
class
CopyResourcesScript
CONTENT
=
<<
EOS
#!/bin/sh
install_resource()
{
echo "cp -R ${SRCROOT}/Pods/$1 ${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}"
cp -R ${SRCROOT}/Pods/$1 ${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}
}
EOS
attr_reader
:resources
# A list of files relative to the project pods root.
...
...
@@ -8,13 +18,15 @@ module Pod
@resources
=
resources
end
def
create_in
(
root
)
return
if
@resources
.
empty?
(
root
+
'PodsResources.sh'
).
open
(
'a'
)
do
|
script
|
def
save_as
(
pathname
)
pathname
.
open
(
'w'
)
do
|
script
|
script
.
puts
CONTENT
@resources
.
each
do
|
resource
|
script
.
puts
"install_resource '
#{
resource
}
'"
end
end
# TODO use File api
system
(
"chmod +x '
#{
pathname
}
'"
)
end
end
end
...
...
spec/integration_spec.rb
View file @
10befd83
...
...
@@ -68,7 +68,7 @@ else
(
root
+
'JSONKit.podspec'
).
should
.
exist
(
root
+
'SSZipArchive.podspec'
).
should
.
exist
#(root + 'Pods.xcconfig').read.should == installer
.xcconfig.to_s
(
root
+
'Pods.xcconfig'
).
read
.
should
==
installer
.
targets
.
first
.
xcconfig
.
to_s
project_file
=
(
root
+
'Pods.xcodeproj/project.pbxproj'
).
to_s
NSDictionary
.
dictionaryWithContentsOfFile
(
project_file
).
should
==
installer
.
xcodeproj
.
to_hash
...
...
@@ -106,11 +106,10 @@ else
end
installer
=
SpecHelper
::
Installer
.
new
(
spec
)
dependency_spec
=
installer
.
build_specifications
.
first
dependency_spec
.
resources
=
'LICEN*'
,
'Readme.*'
installer
.
targets
.
first
.
build_specifications
.
first
.
resources
=
'LICEN*'
,
'Readme.*'
installer
.
install!
contents
=
(
config
.
project_pods_root
+
'Pods
R
esources.sh'
).
read
contents
=
(
config
.
project_pods_root
+
'Pods
-r
esources.sh'
).
read
contents
.
should
.
include
"install_resource 'SSZipArchive/LICENSE'
\n
"
\
"install_resource 'SSZipArchive/Readme.markdown'"
end
...
...
@@ -139,8 +138,6 @@ else
installer
=
SpecHelper
::
Installer
.
new
(
spec
)
installer
.
install!
installer
=
Pod
::
Installer
.
new
(
spec
)
installer
.
generate_project
project
=
Pod
::
Xcode
::
Project
.
new
(
config
.
project_pods_root
+
'Pods.xcodeproj'
)
project
.
source_files
.
should
==
installer
.
xcodeproj
.
source_files
end
...
...
@@ -160,12 +157,20 @@ else
installer
=
Pod
::
Installer
.
new
(
podfile
)
installer
.
install!
#exit
#project = Pod::Xcode::Project.new(config.project_pods_root + 'Pods.xcodeproj')
#p project
#project.targets.each do |target|
#target.source_build_phases.
#end
root
=
config
.
project_pods_root
(
root
+
'Pods.xcconfig'
).
should
.
exist
(
root
+
'Pods-debug.xcconfig'
).
should
.
exist
(
root
+
'Pods-test.xcconfig'
).
should
.
exist
(
root
+
'Pods-resources.sh'
).
should
.
exist
(
root
+
'Pods-debug-resources.sh'
).
should
.
exist
(
root
+
'Pods-test-resources.sh'
).
should
.
exist
Dir
.
chdir
(
config
.
project_pods_root
)
do
puts
"
\n
[!] Compiling static library `Pods'..."
...
...
xcode-project-templates/cocoa-static-library/PodsResources.sh
deleted
100755 → 0
View file @
644e4190
#!/bin/sh
install_resource
()
{
echo
"cp -R
${
SRCROOT
}
/Pods/
$1
${
CONFIGURATION_BUILD_DIR
}
/
${
UNLOCALIZED_RESOURCES_FOLDER_PATH
}
"
cp
-R
${
SRCROOT
}
/Pods/
$1
${
CONFIGURATION_BUILD_DIR
}
/
${
UNLOCALIZED_RESOURCES_FOLDER_PATH
}
}
xcode-project-templates/cocoa-touch-static-library/PodsResources.sh
deleted
100755 → 0
View file @
644e4190
#!/bin/sh
install_resource
()
{
echo
"cp -R
${
SRCROOT
}
/Pods/
$1
${
CONFIGURATION_BUILD_DIR
}
/
${
UNLOCALIZED_RESOURCES_FOLDER_PATH
}
"
cp
-R
${
SRCROOT
}
/Pods/
$1
${
CONFIGURATION_BUILD_DIR
}
/
${
UNLOCALIZED_RESOURCES_FOLDER_PATH
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment