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
19029672
Commit
19029672
authored
Oct 19, 2011
by
Eloy Duran
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add an Xcode post build script which copies pod resources into the app bundle.
parent
ee704471
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
111 additions
and
8 deletions
+111
-8
project.pbxproj
examples/SSCatalog/SSCatalog.xcodeproj/project.pbxproj
+18
-0
cocoapods.rb
lib/cocoapods.rb
+1
-0
installer.rb
lib/cocoapods/installer.rb
+8
-0
specification.rb
lib/cocoapods/specification.rb
+22
-1
set.rb
lib/cocoapods/specification/set.rb
+2
-1
copy_resources_script.rb
lib/cocoapods/xcode/copy_resources_script.rb
+19
-0
integration_spec.rb
spec/integration_spec.rb
+16
-5
specification_spec.rb
spec/unit/specification_spec.rb
+9
-1
PodsResources.sh
...e-project-templates/cocoa-static-library/PodsResources.sh
+8
-0
PodsResources.sh
...ect-templates/cocoa-touch-static-library/PodsResources.sh
+8
-0
No files found.
examples/SSCatalog/SSCatalog.xcodeproj/project.pbxproj
View file @
19029672
...
@@ -257,6 +257,7 @@
...
@@ -257,6 +257,7 @@
1D60588D0D05DD3D006BFB54
/* Resources */
,
1D60588D0D05DD3D006BFB54
/* Resources */
,
1D60588E0D05DD3D006BFB54
/* Sources */
,
1D60588E0D05DD3D006BFB54
/* Sources */
,
1D60588F0D05DD3D006BFB54
/* Frameworks */
,
1D60588F0D05DD3D006BFB54
/* Frameworks */
,
513D6140144F6D3600A8A360
/* ShellScript */
,
);
);
buildRules
=
(
buildRules
=
(
);
);
...
@@ -317,6 +318,23 @@
...
@@ -317,6 +318,23 @@
};
};
/* End PBXResourcesBuildPhase section */
/* End PBXResourcesBuildPhase section */
/* Begin PBXShellScriptBuildPhase section */
513D6140144F6D3600A8A360
/* ShellScript */
=
{
isa
=
PBXShellScriptBuildPhase
;
buildActionMask
=
2147483647
;
files
=
(
);
inputPaths
=
(
);
outputPaths
=
(
);
runOnlyForDeploymentPostprocessing
=
0
;
shellPath
=
/bin/sh
;
shellScript
=
"${SRCROOT}/Pods/PodsResources.sh"
;
showEnvVarsInLog
=
0
;
};
/* End PBXShellScriptBuildPhase section */
/* Begin PBXSourcesBuildPhase section */
/* Begin PBXSourcesBuildPhase section */
1D60588E0D05DD3D006BFB54
/* Sources */
=
{
1D60588E0D05DD3D006BFB54
/* Sources */
=
{
isa
=
PBXSourcesBuildPhase
;
isa
=
PBXSourcesBuildPhase
;
...
...
lib/cocoapods.rb
View file @
19029672
...
@@ -19,6 +19,7 @@ module Pod
...
@@ -19,6 +19,7 @@ module Pod
module
Xcode
module
Xcode
autoload
:Config
,
'cocoapods/xcode/config'
autoload
:Config
,
'cocoapods/xcode/config'
autoload
:CopyResourcesScript
,
'cocoapods/xcode/copy_resources_script'
autoload
:Project
,
'cocoapods/xcode/project'
autoload
:Project
,
'cocoapods/xcode/project'
end
end
...
...
lib/cocoapods/installer.rb
View file @
19029672
...
@@ -32,6 +32,7 @@ module Pod
...
@@ -32,6 +32,7 @@ module Pod
@xcodeproj
||=
Xcode
::
Project
.
static_library
(
@specification
.
platform
)
@xcodeproj
||=
Xcode
::
Project
.
static_library
(
@specification
.
platform
)
end
end
# TODO move xcconfig related code into the xcconfig method, like copy_resources_script and generate_bridge_support.
def
generate_project
def
generate_project
puts
"==> Generating Xcode project and xcconfig"
unless
config
.
silent?
puts
"==> Generating Xcode project and xcconfig"
unless
config
.
silent?
user_header_search_paths
=
[]
user_header_search_paths
=
[]
...
@@ -59,6 +60,10 @@ module Pod
...
@@ -59,6 +60,10 @@ module Pod
xcconfig
.
merge!
(
'USER_HEADER_SEARCH_PATHS'
=>
user_header_search_paths
.
sort
.
uniq
.
join
(
" "
))
xcconfig
.
merge!
(
'USER_HEADER_SEARCH_PATHS'
=>
user_header_search_paths
.
sort
.
uniq
.
join
(
" "
))
end
end
def
copy_resources_script
Xcode
::
CopyResourcesScript
.
new
(
build_specifications
.
map
{
|
spec
|
spec
.
expanded_resources
}.
flatten
)
end
def
bridge_support_generator
def
bridge_support_generator
BridgeSupportGenerator
.
new
(
build_specifications
.
map
do
|
spec
|
BridgeSupportGenerator
.
new
(
build_specifications
.
map
do
|
spec
|
spec
.
header_files
.
map
do
|
header
|
spec
.
header_files
.
map
do
|
header
|
...
@@ -71,10 +76,13 @@ module Pod
...
@@ -71,10 +76,13 @@ module Pod
puts
"Installing dependencies of:
#{
@specification
.
defined_in_file
}
"
unless
config
.
silent?
puts
"Installing dependencies of:
#{
@specification
.
defined_in_file
}
"
unless
config
.
silent?
build_specifications
.
each
(
&
:install!
)
build_specifications
.
each
(
&
:install!
)
generate_project
generate_project
root
=
config
.
project_pods_root
root
=
config
.
project_pods_root
xcodeproj
.
create_in
(
root
)
xcodeproj
.
create_in
(
root
)
xcconfig
.
create_in
(
root
)
xcconfig
.
create_in
(
root
)
copy_resources_script
.
create_in
(
root
)
bridge_support_generator
.
create_in
(
root
)
if
@specification
.
generate_bridge_support
bridge_support_generator
.
create_in
(
root
)
if
@specification
.
generate_bridge_support
build_specifications
.
each
(
&
:post_install
)
build_specifications
.
each
(
&
:post_install
)
end
end
end
end
...
...
lib/cocoapods/specification.rb
View file @
19029672
...
@@ -68,6 +68,12 @@ module Pod
...
@@ -68,6 +68,12 @@ module Pod
end
end
attr_reader
:source_files
attr_reader
:source_files
def
resources
=
(
*
patterns
)
@resources
=
patterns
.
flatten
end
attr_reader
:resources
alias_method
:resource
=
,
:resources
=
def
clean_paths
=
(
*
patterns
)
def
clean_paths
=
(
*
patterns
)
@clean_paths
=
patterns
.
flatten
.
map
{
|
p
|
Pathname
.
new
(
p
)
}
@clean_paths
=
patterns
.
flatten
.
map
{
|
p
|
Pathname
.
new
(
p
)
}
end
end
...
@@ -169,7 +175,22 @@ module Pod
...
@@ -169,7 +175,22 @@ module Pod
platform
.
nil?
platform
.
nil?
end
end
# Returns all source files of this pod including header files.
# Returns all resource files of this pod, but relative to the
# project pods root.
def
expanded_resources
files
=
[]
[
*
resources
].
each
do
|
pattern
|
pattern
=
pod_destroot
+
pattern
pattern
=
pattern
+
'*'
if
pattern
.
directory?
pattern
.
glob
.
each
do
|
file
|
files
<<
file
.
relative_path_from
(
config
.
project_pods_root
)
end
end
files
end
# Returns all source files of this pod including header files,
# but relative to the project pods root.
def
expanded_source_files
def
expanded_source_files
files
=
[]
files
=
[]
[
*
source_files
].
each
do
|
pattern
|
[
*
source_files
].
each
do
|
pattern
|
...
...
lib/cocoapods/specification/set.rb
View file @
19029672
...
@@ -32,6 +32,7 @@ module Pod
...
@@ -32,6 +32,7 @@ module Pod
"but already activated version `
#{
required_version
}
' "
\
"but already activated version `
#{
required_version
}
' "
\
"by
#{
@required_by
.
join
(
', '
)
}
."
"by
#{
@required_by
.
join
(
', '
)
}
."
end
end
@specification
=
nil
@required_by
<<
specification
@required_by
<<
specification
end
end
...
@@ -54,7 +55,7 @@ module Pod
...
@@ -54,7 +55,7 @@ module Pod
end
end
def
specification
def
specification
Specification
.
from_file
(
specification_path
)
@specification
||=
Specification
.
from_file
(
specification_path
)
end
end
# Return the first version that matches the current dependency.
# Return the first version that matches the current dependency.
...
...
lib/cocoapods/xcode/copy_resources_script.rb
0 → 100644
View file @
19029672
module
Pod
module
Xcode
class
CopyResourcesScript
# A list of files relative to the project pods root.
def
initialize
(
resources
)
@resources
=
resources
end
def
create_in
(
root
)
return
if
@resources
.
empty?
(
root
+
'PodsResources.sh'
).
open
(
'a'
)
do
|
script
|
@resources
.
each
do
|
resource
|
script
.
puts
"install_resource '
#{
resource
}
'"
end
end
end
end
end
end
spec/integration_spec.rb
View file @
19029672
...
@@ -35,11 +35,6 @@ else
...
@@ -35,11 +35,6 @@ else
config
.
repos_dir
=
fixture
(
'spec-repos'
)
config
.
repos_dir
=
fixture
(
'spec-repos'
)
config
.
project_pods_root
=
temporary_directory
+
'Pods'
config
.
project_pods_root
=
temporary_directory
+
'Pods'
FileUtils
.
cp_r
(
fixture
(
'integration/.'
),
config
.
project_pods_root
)
FileUtils
.
cp_r
(
fixture
(
'integration/.'
),
config
.
project_pods_root
)
Dir
.
chdir
(
config
.
project_pods_root
.
to_s
)
do
FileUtils
.
mv
(
'ASIHTTPRequest'
,
'ASIHTTPRequest-1.8.1'
)
FileUtils
.
mv
(
'JSONKit'
,
'JSONKit-1.4'
)
FileUtils
.
mv
(
'SSZipArchive'
,
'SSZipArchive-1.0'
)
end
end
end
after
do
after
do
...
@@ -91,6 +86,22 @@ else
...
@@ -91,6 +86,22 @@ else
(
config
.
project_pods_root
+
'ASIHTTPRequest.podspec'
).
should
.
not
.
exist
(
config
.
project_pods_root
+
'ASIHTTPRequest.podspec'
).
should
.
not
.
exist
end
end
it
"adds resources to the xcode copy script"
do
spec
=
Pod
::
File
.
new
do
|
s
|
s
.
platform
=
platform
s
.
dependency
'SSZipArchive'
end
installer
=
SpecHelper
::
Installer
.
new
(
spec
)
dependency_spec
=
installer
.
build_specifications
.
first
dependency_spec
.
resources
=
'LICEN*'
,
'Readme.*'
installer
.
install!
contents
=
(
config
.
project_pods_root
+
'PodsResources.sh'
).
read
contents
.
should
.
include
"install_resource 'SSZipArchive/LICENSE'
\n
"
\
"install_resource 'SSZipArchive/Readme.markdown'"
end
# TODO we need to do more cleaning and/or add a --prune task
# TODO we need to do more cleaning and/or add a --prune task
it
"overwrites an existing project.pbxproj file"
do
it
"overwrites an existing project.pbxproj file"
do
spec
=
Pod
::
File
.
new
do
|
s
|
spec
=
Pod
::
File
.
new
do
|
s
|
...
...
spec/unit/specification_spec.rb
View file @
19029672
...
@@ -174,7 +174,7 @@ describe "A Pod::Specification, with installed source," do
...
@@ -174,7 +174,7 @@ describe "A Pod::Specification, with installed source," do
config
.
project_pods_root
=
nil
config
.
project_pods_root
=
nil
end
end
it
"returns the list of files that the source_files pattern expand
s
to"
do
it
"returns the list of files that the source_files pattern expand to"
do
files
=
@destroot
.
glob
(
'**/*.{h,c,m}'
)
files
=
@destroot
.
glob
(
'**/*.{h,c,m}'
)
files
=
files
.
map
{
|
file
|
file
.
relative_path_from
(
config
.
project_pods_root
)
}
files
=
files
.
map
{
|
file
|
file
.
relative_path_from
(
config
.
project_pods_root
)
}
@spec
.
expanded_source_files
.
sort
.
should
==
files
.
sort
@spec
.
expanded_source_files
.
sort
.
should
==
files
.
sort
...
@@ -251,6 +251,14 @@ describe "A Pod::Specification, with installed source," do
...
@@ -251,6 +251,14 @@ describe "A Pod::Specification, with installed source," do
"$(BUILT_PRODUCTS_DIR)/Pods/AnotherRoot/ns"
"$(BUILT_PRODUCTS_DIR)/Pods/AnotherRoot/ns"
}
}
end
end
it
"returns the list of files that the resources pattern expand to"
do
@spec
.
expanded_resources
.
should
==
[]
@spec
.
resource
=
'LICEN*'
@spec
.
expanded_resources
.
map
(
&
:to_s
).
should
==
%w{ SSZipArchive/LICENSE }
@spec
.
resources
=
'LICEN*'
,
'Readme.*'
@spec
.
expanded_resources
.
map
(
&
:to_s
).
should
==
%w{ SSZipArchive/LICENSE SSZipArchive/Readme.markdown }
end
end
end
describe
"A Pod::Specification, in general,"
do
describe
"A Pod::Specification, in general,"
do
...
...
xcode-project-templates/cocoa-static-library/PodsResources.sh
0 → 100755
View file @
19029672
#!/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
0 → 100755
View file @
19029672
#!/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