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
b9b9d5fa
Commit
b9b9d5fa
authored
Jun 30, 2014
by
Marius Rackwitz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add the Embed Pods Framework Build Phase in TargetIntegrator
Embed frameworks with a run script build phase
parent
58219eca
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
156 additions
and
0 deletions
+156
-0
cocoapods.rb
lib/cocoapods.rb
+1
-0
embed_frameworks_script.rb
lib/cocoapods/generator/embed_frameworks_script.rb
+66
-0
aggregate_target_installer.rb
.../installer/target_installer/aggregate_target_installer.rb
+23
-0
target_integrator.rb
...ds/installer/user_project_integrator/target_integrator.rb
+19
-0
aggregate_target.rb
lib/cocoapods/target/aggregate_target.rb
+13
-0
embed_frameworks_script_spec.rb
spec/unit/generator/embed_frameworks_script_spec.rb
+26
-0
aggregate_target_spec.rb
spec/unit/target/aggregate_target_spec.rb
+8
-0
No files found.
lib/cocoapods.rb
View file @
b9b9d5fa
...
...
@@ -56,6 +56,7 @@ module Pod
autoload
:BridgeSupport
,
'cocoapods/generator/bridge_support'
autoload
:CopyResourcesScript
,
'cocoapods/generator/copy_resources_script'
autoload
:DummySource
,
'cocoapods/generator/dummy_source'
autoload
:EmbedFrameworksScript
,
'cocoapods/generator/embed_frameworks_script'
autoload
:Header
,
'cocoapods/generator/header'
autoload
:InfoPlistFile
,
'cocoapods/generator/info_plist_file'
autoload
:PrefixHeader
,
'cocoapods/generator/prefix_header'
...
...
lib/cocoapods/generator/embed_frameworks_script.rb
0 → 100644
View file @
b9b9d5fa
module
Pod
module
Generator
class
EmbedFrameworksScript
# @return [Hash{String, Array{String}] Multiple lists of frameworks per
# configuration.
#
attr_reader
:frameworks_by_config
# @param [Hash{String, Array{String}] frameworks_by_config
# @see frameworks_by_config
#
def
initialize
(
frameworks_by_config
)
@frameworks_by_config
=
frameworks_by_config
end
# Saves the resource script to the given pathname.
#
# @param [Pathname] pathname
# The path where the embed frameworks script should be saved.
#
# @return [void]
#
def
save_as
(
pathname
)
pathname
.
open
(
'w'
)
do
|
file
|
file
.
puts
(
script
)
end
File
.
chmod
(
0755
,
pathname
.
to_s
)
end
private
# @!group Private Helpers
# @return [String] The contents of the embed frameworks script.
#
def
script
script
=
INSTALL_FRAMEWORKS_FUNCTION
script
+=
"
\n
"
unless
frameworks_by_config
.
values
.
all?
(
&
:empty?
)
frameworks_by_config
.
each
do
|
config
,
frameworks
|
unless
frameworks
.
empty?
script
+=
%(if [[ "$CONFIGURATION" == "#{config}" ]]; then\n)
frameworks
.
each
do
|
framework
|
script
+=
" install_framework '
#{
framework
}
'
\n
"
end
script
+=
"fi
\n
"
end
end
script
end
INSTALL_FRAMEWORKS_FUNCTION
=
<<
EOS
#!/bin/sh
set -e
echo "mkdir -p ${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}"
mkdir -p "${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}"
install_framework()
{
echo "rsync --exclude '*.h' -av ${PODS_ROOT}/$1 ${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}"
rsync -av "${BUILT_PRODUCTS_DIR}/$1" "${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}"
}
EOS
end
end
end
lib/cocoapods/installer/target_installer/aggregate_target_installer.rb
View file @
b9b9d5fa
...
...
@@ -17,6 +17,7 @@ module Pod
if
target
.
requires_framework?
create_info_plist_file
create_umbrella_header
create_embed_frameworks_script
end
create_target_environment_header
create_bridge_support_file
...
...
@@ -108,6 +109,28 @@ module Pod
add_file_to_support_group
(
path
)
end
# Creates a script that embeds the frameworks to the bundle of the client
# target.
#
# @note We can't use Xcode default copy bundle resource phase, because
# we need to ensure that we only copy the resources, which are
# relevant for the current build configuration.
#
# @return [void]
#
def
create_embed_frameworks_script
path
=
target
.
embed_frameworks_script_path
frameworks_by_config
=
{}
target
.
user_build_configurations
.
keys
.
each
do
|
config
|
frameworks_by_config
[
config
]
=
target
.
pod_targets
.
select
do
|
pod_target
|
pod_target
.
include_in_build_config?
(
config
)
end
.
map
(
&
:product_name
)
end
generator
=
Generator
::
EmbedFrameworksScript
.
new
(
frameworks_by_config
)
generator
.
save_as
(
path
)
add_file_to_support_group
(
path
)
end
# Generates the acknowledgement files (markdown and plist) for the target.
#
# @return [void]
...
...
lib/cocoapods/installer/user_project_integrator/target_integrator.rb
View file @
b9b9d5fa
...
...
@@ -33,6 +33,7 @@ module Pod
update_to_cocoapods_0_34
,
unless
native_targets_to_integrate
.
empty?
add_pods_library
add_embed_frameworks_script_phase
if
target
.
requires_framework?
add_copy_resources_script_phase
add_check_manifest_lock_script_phase
true
...
...
@@ -122,6 +123,24 @@ module Pod
end
end
# Find or create a 'Embed Pods Frameworks' Copy Files Build Phase
#
# @return [void]
#
def
add_embed_frameworks_script_phase
phase_name
=
'Embed Pods Frameworks'
native_targets_to_integrate
.
each
do
|
native_target
|
embed_build_phase
=
native_target
.
shell_script_build_phases
.
select
{
|
bp
|
bp
.
name
==
phase_name
}.
first
unless
embed_build_phase
.
present?
UI
.
message
(
"Add Build Phase '
#{
phase_name
}
' to project."
)
embed_build_phase
=
native_target
.
new_shell_script_build_phase
(
phase_name
)
end
script_path
=
target
.
embed_frameworks_script_relative_path
embed_build_phase
.
shell_script
=
%("#{script_path}"\n)
embed_build_phase
.
show_env_vars_in_log
=
'0'
end
end
# Adds a shell script build phase responsible to copy the resources
# generated by the TargetDefinition to the bundle of the product of the
# targets.
...
...
lib/cocoapods/target/aggregate_target.rb
View file @
b9b9d5fa
...
...
@@ -129,6 +129,12 @@ module Pod
support_files_dir
+
"
#{
label
}
-resources.sh"
end
# @return [Pathname] The absolute path of the embed frameworks script.
#
def
embed_frameworks_script_path
support_files_dir
+
"
#{
label
}
-frameworks.sh"
end
# @return [String] The xcconfig path of the root from the `$(SRCROOT)`
# variable of the user's project.
#
...
...
@@ -151,6 +157,13 @@ module Pod
"${SRCROOT}/
#{
relative_to_srcroot
(
copy_resources_script_path
)
}
"
end
# @return [String] The path of the embed frameworks relative to the
# root of the user project.
#
def
embed_frameworks_script_relative_path
"${SRCROOT}/
#{
relative_to_srcroot
(
embed_frameworks_script_path
)
}
"
end
private
# @!group Private Helpers
...
...
spec/unit/generator/embed_frameworks_script_spec.rb
0 → 100644
View file @
b9b9d5fa
require
File
.
expand_path
(
'../../../spec_helper'
,
__FILE__
)
module
Pod
describe
Generator
::
EmbedFrameworksScript
do
it
'returns the embed frameworks script'
do
frameworks
=
{
'Debug'
=>
%w(Loopback.framework Reveal.framework)
,
'Release'
=>
%w(CrashlyticsFramework.framework)
}
generator
=
Pod
::
Generator
::
EmbedFrameworksScript
.
new
(
frameworks
)
generator
.
send
(
:script
).
should
.
include
<<-
eos
.
strip_heredoc
if [[ "$CONFIGURATION" == "Debug" ]]; then
install_framework 'Loopback.framework'
install_framework 'Reveal.framework'
fi
eos
generator
.
send
(
:script
).
should
.
include
<<-
eos
.
strip_heredoc
if [[ "$CONFIGURATION" == "Release" ]]; then
install_framework 'CrashlyticsFramework.framework'
fi
eos
end
end
end
spec/unit/target/aggregate_target_spec.rb
View file @
b9b9d5fa
...
...
@@ -51,6 +51,10 @@ module Pod
@target
.
copy_resources_script_path
.
to_s
.
should
.
include?
(
'Pods/Target Support Files/Pods/Pods-resources.sh'
)
end
it
'returns the absolute path of the frameworks script'
do
@target
.
embed_frameworks_script_path
.
to_s
.
should
.
include?
(
'Pods/Target Support Files/Pods/Pods-frameworks.sh'
)
end
it
'returns the absolute path of the target header file'
do
@target
.
target_environment_header_path
.
to_s
.
should
.
include?
(
'Pods/Target Support Files/Pods/Pods-environment.h'
)
end
...
...
@@ -71,6 +75,10 @@ module Pod
@target
.
copy_resources_script_relative_path
.
should
==
'${SRCROOT}/Pods/Target Support Files/Pods/Pods-resources.sh'
end
it
'returns the path of the frameworks script relative to the user project'
do
@target
.
embed_frameworks_script_relative_path
.
should
==
'${SRCROOT}/Pods/Target Support Files/Pods/Pods-frameworks.sh'
end
it
'returns the path of the xcconfig file relative to the user project'
do
@target
.
xcconfig_relative_path
(
'Release'
).
should
==
'Pods/Target Support Files/Pods/Pods.release.xcconfig'
end
...
...
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