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
c3d79897
Commit
c3d79897
authored
Oct 05, 2017
by
Dimitris Koutsogiorgas
Committed by
GitHub
Oct 05, 2017
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #7101 from dnkoutso/script_phase_execution_placement
Integrate execution position for shell script phases
parents
9b013470
039f98d9
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
66 additions
and
24 deletions
+66
-24
CHANGELOG.md
CHANGELOG.md
+4
-0
Gemfile.lock
Gemfile.lock
+1
-1
target_integrator.rb
...ds/installer/user_project_integrator/target_integrator.rb
+17
-9
target_integrator_spec.rb
...staller/user_project_integrator/target_integrator_spec.rb
+44
-14
No files found.
CHANGELOG.md
View file @
c3d79897
...
...
@@ -8,6 +8,10 @@ To install release candidates run `[sudo] gem install cocoapods --pre`
##### Enhancements
*
Integrate execution position for shell script phases
[
Dimitris Koutsogiorgas
](
https://github.com/dnkoutso
)
[
#7101
](
https://github.com/CocoaPods/CocoaPods/pull/7101
)
*
Add support to integrate script phases from podspecs
[
Dimitris Koutsogiorgas
](
https://github.com/dnkoutso
)
[
#7092
](
https://github.com/CocoaPods/CocoaPods/pull/7092
)
...
...
Gemfile.lock
View file @
c3d79897
...
...
@@ -7,7 +7,7 @@ GIT
GIT
remote: https://github.com/CocoaPods/Core.git
revision:
3f98bce41fd8eb6d385441eef4e5611665d13e64
revision:
153c5dfdd02eaac8bec160f6a3b3bc49b07ecf48
branch: master
specs:
cocoapods-core (1.4.0.beta.1)
...
...
lib/cocoapods/installer/user_project_integrator/target_integrator.rb
View file @
c3d79897
...
...
@@ -165,21 +165,29 @@ module Pod
end
# Create or update the ones that are expected to be.
script_phases
.
each
do
|
td_script_phase
|
phase
=
TargetIntegrator
.
create_or_update_build_phase
(
native_target
,
USER_BUILD_PHASE_PREFIX
+
td_script_phase
[
:name
])
name_with_prefix
=
USER_BUILD_PHASE_PREFIX
+
td_script_phase
[
:name
]
phase
=
TargetIntegrator
.
create_or_update_build_phase
(
native_target
,
name_with_prefix
)
phase
.
shell_script
=
td_script_phase
[
:script
]
phase
.
shell_path
=
td_script_phase
[
:shell_path
]
if
td_script_phase
.
key?
(
:shell_path
)
phase
.
input_paths
=
td_script_phase
[
:input_files
]
if
td_script_phase
.
key?
(
:input_files
)
phase
.
output_paths
=
td_script_phase
[
:output_files
]
if
td_script_phase
.
key?
(
:output_files
)
phase
.
show_env_vars_in_log
=
td_script_phase
[
:show_env_vars_in_log
]
?
'1'
:
'0'
if
td_script_phase
.
key?
(
:show_env_vars_in_log
)
end
# Move script phases to their correct index if the order has changed.
offset
=
native_target
.
build_phases
.
count
-
script_phases
.
count
script_phases
.
each_with_index
do
|
td_script_phase
,
index
|
current_index
=
native_target
.
build_phases
.
index
do
|
bp
|
bp
.
is_a?
(
Xcodeproj
::
Project
::
Object
::
PBXShellScriptBuildPhase
)
&&
bp
.
name
.
sub
(
USER_BUILD_PHASE_PREFIX
,
''
)
==
td_script_phase
[
:name
]
execution_position
=
td_script_phase
[
:execution_position
]
unless
execution_position
==
:any
compile_build_phase_index
=
native_target
.
build_phases
.
index
do
|
bp
|
bp
.
is_a?
(
Xcodeproj
::
Project
::
Object
::
PBXSourcesBuildPhase
)
end
unless
compile_build_phase_index
.
nil?
script_phase_index
=
native_target
.
build_phases
.
index
do
|
bp
|
bp
.
is_a?
(
Xcodeproj
::
Project
::
Object
::
PBXShellScriptBuildPhase
)
&&
!
bp
.
name
.
nil?
&&
bp
.
name
==
name_with_prefix
end
if
(
execution_position
==
:before_compile
&&
script_phase_index
>
compile_build_phase_index
)
||
(
execution_position
==
:after_compile
&&
script_phase_index
<
compile_build_phase_index
)
native_target
.
build_phases
.
move_from
(
script_phase_index
,
compile_build_phase_index
)
end
end
end
expected_index
=
offset
+
index
native_target
.
build_phases
.
insert
(
expected_index
,
native_target
.
build_phases
.
delete_at
(
current_index
))
if
current_index
!=
expected_index
end
end
end
...
...
spec/unit/installer/user_project_integrator/target_integrator_spec.rb
View file @
c3d79897
...
...
@@ -388,32 +388,50 @@ module Pod
target
.
shell_script_build_phases
.
find
{
|
bp
|
bp
.
name
==
@user_script_phase_name
}.
should
.
be
.
nil
end
it
'moves custom shell scripts
to their correct index
'
do
shell_script_one
=
{
:name
=>
'Custom Script'
,
:script
=>
'echo "Hello World"'
}
it
'moves custom shell scripts
according to their execution position
'
do
shell_script_one
=
{
:name
=>
'Custom Script'
,
:script
=>
'echo "Hello World"'
,
:execution_position
=>
:before_compile
}
shell_script_two
=
{
:name
=>
'Custom Script 2'
,
:script
=>
'echo "Hello Aliens"'
}
@pod_bundle
.
target_definition
.
stubs
(
:script_phases
).
returns
([
shell_script_one
,
shell_script_two
])
@target_integrator
.
integrate!
target
=
@target_integrator
.
send
(
:native_targets
).
first
target
.
shell_script_build_phases
.
map
(
&
:
name
).
should
==
[
target
.
build_phases
.
map
(
&
:display_
name
).
should
==
[
'[CP] Check Pods Manifest.lock'
,
'[CP-User] Custom Script'
,
'Sources'
,
'Frameworks'
,
'Resources'
,
'[CP] Embed Pods Frameworks'
,
'[CP] Copy Pods Resources'
,
'[CP-User] Custom Script'
,
'[CP-User] Custom Script 2'
,
]
shell_script_one
_uuid
=
target
.
shell_script_build_phases
[
3
].
uuid
shell_script_two
_uuid
=
target
.
shell_script_build_phases
[
4
].
uuid
@pod_bundle
.
target_definition
.
stubs
(
:script_phases
).
returns
([
shell_script_
two
,
shell_script_one
])
shell_script_one
=
{
:name
=>
'Custom Script'
,
:script
=>
'echo "Hello World"'
,
:execution_position
=>
:after_compile
}
shell_script_two
=
{
:name
=>
'Custom Script 2'
,
:script
=>
'echo "Hello Aliens"'
,
:execution_position
=>
:before_compile
}
@pod_bundle
.
target_definition
.
stubs
(
:script_phases
).
returns
([
shell_script_
one
,
shell_script_two
])
@target_integrator
.
integrate!
target
.
shell_script_build_phases
.
map
(
&
:
name
).
should
==
[
target
.
build_phases
.
map
(
&
:display_
name
).
should
==
[
'[CP] Check Pods Manifest.lock'
,
'[CP-User] Custom Script 2'
,
'Sources'
,
'[CP-User] Custom Script'
,
'Frameworks'
,
'Resources'
,
'[CP] Embed Pods Frameworks'
,
'[CP] Copy Pods Resources'
,
]
shell_script_one
=
{
:name
=>
'Custom Script'
,
:script
=>
'echo "Hello World"'
}
shell_script_two
=
{
:name
=>
'Custom Script 2'
,
:script
=>
'echo "Hello Aliens"'
}
@pod_bundle
.
target_definition
.
stubs
(
:script_phases
).
returns
([
shell_script_one
,
shell_script_two
])
@target_integrator
.
integrate!
target
.
build_phases
.
map
(
&
:display_name
).
should
==
[
'[CP] Check Pods Manifest.lock'
,
'[CP-User] Custom Script 2'
,
'Sources'
,
'[CP-User] Custom Script'
,
'Frameworks'
,
'Resources'
,
'[CP] Embed Pods Frameworks'
,
'[CP] Copy Pods Resources'
,
]
target
.
shell_script_build_phases
[
3
].
uuid
.
should
==
shell_script_two_uuid
target
.
shell_script_build_phases
[
4
].
uuid
.
should
==
shell_script_one_uuid
end
it
'adds, removes and moves custom shell script phases'
do
...
...
@@ -424,8 +442,11 @@ module Pod
@pod_bundle
.
target_definition
.
stubs
(
:script_phases
).
returns
([
shell_script_one
,
shell_script_two
,
shell_script_three
])
@target_integrator
.
integrate!
target
=
@target_integrator
.
send
(
:native_targets
).
first
target
.
shell_script_build_phases
.
map
(
&
:
name
).
should
==
[
target
.
build_phases
.
map
(
&
:display_
name
).
should
==
[
'[CP] Check Pods Manifest.lock'
,
'Sources'
,
'Frameworks'
,
'Resources'
,
'[CP] Embed Pods Frameworks'
,
'[CP] Copy Pods Resources'
,
'[CP-User] Custom Script'
,
...
...
@@ -434,8 +455,11 @@ module Pod
]
@pod_bundle
.
target_definition
.
stubs
(
:script_phases
).
returns
([
shell_script_two
,
shell_script_four
])
@target_integrator
.
integrate!
target
.
shell_script_build_phases
.
map
(
&
:
name
).
should
==
[
target
.
build_phases
.
map
(
&
:display_
name
).
should
==
[
'[CP] Check Pods Manifest.lock'
,
'Sources'
,
'Frameworks'
,
'Resources'
,
'[CP] Embed Pods Frameworks'
,
'[CP] Copy Pods Resources'
,
'[CP-User] Custom Script 2'
,
...
...
@@ -449,8 +473,11 @@ module Pod
target
.
new_shell_script_build_phase
(
'User Script Phase 1'
)
target
.
new_shell_script_build_phase
(
'User Script Phase 2'
)
@target_integrator
.
integrate!
target
.
shell_script_build_phases
.
map
(
&
:
name
).
should
==
[
target
.
build_phases
.
map
(
&
:display_
name
).
should
==
[
'[CP] Check Pods Manifest.lock'
,
'Sources'
,
'Frameworks'
,
'Resources'
,
'User Script Phase 1'
,
'User Script Phase 2'
,
'[CP] Embed Pods Frameworks'
,
...
...
@@ -459,8 +486,11 @@ module Pod
]
@pod_bundle
.
target_definition
.
stubs
(
:script_phases
).
returns
([])
@target_integrator
.
integrate!
target
.
shell_script_build_phases
.
map
(
&
:
name
).
should
==
[
target
.
build_phases
.
map
(
&
:display_
name
).
should
==
[
'[CP] Check Pods Manifest.lock'
,
'Sources'
,
'Frameworks'
,
'Resources'
,
'User Script Phase 1'
,
'User Script Phase 2'
,
'[CP] Embed Pods Frameworks'
,
...
...
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