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
0aefe207
Commit
0aefe207
authored
Mar 24, 2015
by
AliSoftware
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[xcassets] Remove resources from Resource Build Phase of *deintegrated* targets
parent
f4c64317
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
66 additions
and
12 deletions
+66
-12
user_project_integrator.rb
lib/cocoapods/installer/user_project_integrator.rb
+46
-3
target_integrator.rb
...ds/installer/user_project_integrator/target_integrator.rb
+20
-9
No files found.
lib/cocoapods/installer/user_project_integrator.rb
View file @
0aefe207
...
@@ -113,13 +113,56 @@ module Pod
...
@@ -113,13 +113,56 @@ module Pod
targets_to_integrate
.
sort_by
(
&
:name
).
each
do
|
target
|
targets_to_integrate
.
sort_by
(
&
:name
).
each
do
|
target
|
TargetIntegrator
.
new
(
target
).
integrate!
TargetIntegrator
.
new
(
target
).
integrate!
end
end
# TODO: If a previously integrated target is removed from the Podfile,
# we should remove its resources from the deintegrated target
target_uuids_to_integrate
=
targets_to_integrate
.
flat_map
(
&
:user_target_uuids
).
uniq
user_project_paths
.
each
do
|
user_project_path
|
project
=
Xcodeproj
::
Project
.
open
(
user_project_path
)
# TODO: Remove xcconfig files from targets_not_integrated
# targets_not_integrated = project.targets.reject do |user_target|
# target_uuids_to_integrate.include?(user_target.uuid)
# end
clean_deintegrated_targets_resources
(
project
,
target_uuids_to_integrate
)
end
end
def
clean_deintegrated_targets_resources
(
project
,
target_uuids_to_keep
)
is_dirty
=
false
TargetIntegrator
.
each_pods_resources
(
project
)
do
|
file_ref
|
puts
"Analyzing Pods/Resources/
#{
file_ref
}
"
file_in_at_least_one_target
=
false
project
.
targets
.
each
do
|
user_target
|
# Seems like user_target.resources_build_phase.include?(file_ref) does not work as expected here :(
file_is_in_target
=
user_target
.
resources_build_phase
.
files_references
.
any?
{
|
f
|
f
.
path
==
file_ref
.
path
}
next
unless
file_is_in_target
if
target_uuids_to_keep
.
include?
(
user_target
.
uuid
)
# This target is one to integrate, the resource will be kept in there
file_in_at_least_one_target
=
true
UI
.
puts
" - Should be kept in for target
#{
user_target
}
"
else
UI
.
puts
" - Removing
#{
file_ref
}
from
#{
user_target
}
because target not integrated anymore."
user_target
.
resources_build_phase
.
remove_file_reference
(
file_ref
)
is_dirty
=
true
end
end
unless
file_in_at_least_one_target
# TODO: Remove the file_refs in Pods/Resources if they are not linked
# TODO: Remove the file_refs in Pods/Resources if they are not linked
# to any native_target anymore (which can happen after a target deintegration)
# to any native_target anymore (which can happen after a target deintegration)
UI
.
puts
" -> File
#{
file_ref
}
is not in any user target anymore, remove it from the project"
file_ref
.
remove_from_project
is_dirty
=
true
end
end
# TODO: Iterate over each subgroup of the Pods/Resources group, removing them if empty.
# TODO: Also remove Pods/Resources group itself if it ends up empty.
# TODO: Remove the Pods/Resources group if empty
if
is_dirty
project
.
save
end
end
end
# Warns the user if the podfile is empty.
# Warns the user if the podfile is empty.
...
...
lib/cocoapods/installer/user_project_integrator/target_integrator.rb
View file @
0aefe207
...
@@ -182,7 +182,6 @@ module Pod
...
@@ -182,7 +182,6 @@ module Pod
refs_to_remove
.
each
do
|
file_ref
|
refs_to_remove
.
each
do
|
file_ref
|
native_targets
.
each
do
|
user_target
|
native_targets
.
each
do
|
user_target
|
UI
.
puts
" - Removing
#{
file_ref
}
from
#{
user_target
}
because it is no longer needed."
UI
.
puts
" - Removing
#{
file_ref
}
from
#{
user_target
}
because it is no longer needed."
# FIXME: XcodeProj issue? The PBXBuildFile is replaced with (null) instead of being removed
user_target
.
resources_build_phase
.
remove_file_reference
(
file_ref
)
user_target
.
resources_build_phase
.
remove_file_reference
(
file_ref
)
dirty
=
true
dirty
=
true
end
end
...
@@ -195,23 +194,35 @@ module Pod
...
@@ -195,23 +194,35 @@ module Pod
dirty
dirty
end
end
# Remove the
'Pods/Resources' group and all the pods resources from the user target
# Remove the
pods resources from the user target's Copy Resource Build Phase
#
#
# @return [Boolean] true if user project has been modified
# @return [Boolean] true if user project has been modified
#
#
def
remove_pods_resources
def
remove_pods_resources
pods_group
=
user_project
[
'Pods'
]
TargetIntegrator
.
each_pods_resources
(
user_project
)
do
|
file_ref
|
native_targets
.
each
do
|
user_target
|
UI
.
puts
" - Removing
#{
file_ref
}
from
#{
user_target
}
because it is no longer needed."
user_target
.
resources_build_phase
.
remove_file_reference
(
file_ref
)
end
end
end
# Iterate over each file in the 'Pods/Resources' group of the given `project`
#
# @param [XcodeProj::Project] project
# The user project
#
# TODO: Probably move this elsewhere
#
def
self
.
each_pods_resources
(
project
)
return
false
unless
block_given?
pods_group
=
project
[
'Pods'
]
return
false
unless
pods_group
return
false
unless
pods_group
resources_group
=
pods_group
[
'Resources'
]
resources_group
=
pods_group
[
'Resources'
]
return
false
unless
resources_group
return
false
unless
resources_group
# Remove each resource from every "Copy Bundle Resources" phases (as XcodeProj does not to it itself)
resources_files
=
resources_group
.
groups
.
flat_map
(
&
:files
)
resources_files
=
resources_group
.
groups
.
flat_map
(
&
:files
)
native_targets
.
each
do
|
user_target
|
resources_files
.
each
do
|
file_ref
|
resources_files
.
each
do
|
file_ref
|
UI
.
puts
" - Removing
#{
file_ref
}
from
#{
user_target
}
because it is no longer needed."
yield
file_ref
# FIXME: XcodeProj issue? The PBXBuildFile is replaced with (null) instead of being removed
user_target
.
resources_build_phase
.
remove_file_reference
(
file_ref
)
end
end
end
true
true
end
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