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
d56aac94
Commit
d56aac94
authored
Aug 12, 2014
by
Fabio Pelosin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[UserProjectIntegrator] Warn about xcconfig override after every installation
parent
c68ce09a
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
82 additions
and
39 deletions
+82
-39
user_project_integrator.rb
lib/cocoapods/installer/user_project_integrator.rb
+50
-1
xcconfig_integrator.rb
...oject_integrator/target_integrator/xcconfig_integrator.rb
+0
-23
xcconfig_integrator_spec.rb
..._integrator/target_integrator/xcconfig_integrator_spec.rb
+0
-15
user_project_integrator_spec.rb
spec/unit/installer/user_project_integrator_spec.rb
+32
-0
No files found.
lib/cocoapods/installer/user_project_integrator.rb
View file @
d56aac94
...
...
@@ -62,6 +62,7 @@ module Pod
create_workspace
integrate_user_targets
warn_about_empty_podfile
warn_about_xcconfig_overrides
end
#-----------------------------------------------------------------------#
...
...
@@ -133,6 +134,28 @@ module Pod
end
end
# Checks whether the settings of the CocoaPods generated xcconfig are
# overridden by the build configuration of a target and prints a
# warning to inform the user if needed.
#
def
warn_about_xcconfig_overrides
targets
.
each
do
|
aggregate_target
|
aggregate_target
.
user_targets
.
each
do
|
user_target
|
user_target
.
build_configurations
.
each
do
|
config
|
xcconfig
=
aggregate_target
.
xcconfigs
[
config
.
name
]
if
xcconfig
xcconfig
.
attributes
.
keys
.
each
do
|
key
|
target_value
=
config
.
build_settings
[
key
]
if
target_value
&&
!
target_value
.
include?
(
'$(inherited)'
)
print_override_warning
(
aggregate_target
,
user_target
,
config
,
key
)
end
end
end
end
end
end
end
private
# @!group Private Helpers
...
...
@@ -169,11 +192,37 @@ module Pod
end
.
compact
.
uniq
end
def
targets_to_integrate
targets
.
reject
{
|
target
|
target
.
target_definition
.
empty?
}
end
# Prints a warning informing the user that a build configuration of
# the integrated target is overriding the CocoaPods build settings.
#
# @param [Target::AggregateTarget] aggregate_target
# The umbrella target.
#
# @param [XcodeProj::PBXNativeTarget] user_target
# The native target.
#
# @param [Xcodeproj::XCBuildConfiguration] config
# The build configuration.
#
# @param [String] key
# The key of the overridden build setting.
#
def
print_override_warning
(
aggregate_target
,
user_target
,
config
,
key
)
actions
=
[
"Use the `$(inherited)` flag, or"
,
"Remove the build settings from the target."
]
message
=
"The `
#{
user_target
.
name
}
[
#{
config
.
name
}
]` "
\
"target overrides the `
#{
key
}
` build setting defined in "
\
"`
#{
aggregate_target
.
xcconfig_relative_path
(
config
.
name
)
}
'. "
\
"This can lead to problems with the CocoaPods installation"
UI
.
warn
(
message
,
actions
)
end
#-----------------------------------------------------------------------#
end
...
...
lib/cocoapods/installer/user_project_integrator/target_integrator/xcconfig_integrator.rb
View file @
d56aac94
...
...
@@ -20,7 +20,6 @@ module Pod
target
.
build_configurations
.
each
do
|
config
|
update_from_cocoapods_0_33_1
(
pod_bundle
,
targets
)
set_target_xcconfig
(
pod_bundle
,
config
)
check_overrides
(
pod_bundle
,
target
,
config
)
end
end
end
...
...
@@ -72,28 +71,6 @@ module Pod
config
.
base_configuration_reference
=
file_ref
end
# Checks whether the settings of the CocoaPods generated xcconfig are
# overridden by the build configuration of a target and prints a
# warning to inform the user if needed.
#
# @param [Target::AggregateTarget] pod_bundle
# The Pods bundle.
#
# @param [XcodeProj::PBXNativeTarget] target
# The native target.
#
# @param [Xcodeproj::XCBuildConfiguration] config
# The build configuration.
#
def
self
.
check_overrides
(
pod_bundle
,
target
,
config
)
xcconfig
=
pod_bundle
.
xcconfigs
[
config
.
name
]
xcconfig
.
attributes
.
keys
.
each
do
|
key
|
target_value
=
config
.
build_settings
[
key
]
if
target_value
&&
!
target_value
.
include?
(
'$(inherited)'
)
print_override_warning
(
pod_bundle
,
target
,
config
,
key
)
end
end
end
private
...
...
spec/unit/installer/user_project_integrator/target_integrator/xcconfig_integrator_spec.rb
View file @
d56aac94
...
...
@@ -50,22 +50,7 @@ module Pod
config
.
base_configuration_reference
.
should
.
equal
existing
end
it
'check that the integrated target does not override the CocoaPods build settings'
do
UI
.
warnings
=
''
config
=
@target
.
build_configuration_list
[
'Release'
]
config
.
build_settings
[
'GCC_PREPROCESSOR_DEFINITIONS'
]
=
'FLAG=1'
XCConfigIntegrator
.
integrate
(
@pod_bundle
,
[
@target
])
UI
.
warnings
.
should
.
include
'The `SampleProject [Release]` target '
\
'overrides the `GCC_PREPROCESSOR_DEFINITIONS` build setting'
end
it
'allows build settings which inherit the settings form the CocoaPods xcconfig'
do
UI
.
warnings
=
''
config
=
@target
.
build_configuration_list
[
'Release'
]
config
.
build_settings
[
'GCC_PREPROCESSOR_DEFINITIONS'
]
=
'$(inherited)'
XCConfigIntegrator
.
integrate
(
@pod_bundle
,
[
@target
])
UI
.
warnings
.
should
.
not
.
include
'GCC_PREPROCESSOR_DEFINITIONS'
end
end
end
spec/unit/installer/user_project_integrator_spec.rb
View file @
d56aac94
...
...
@@ -29,6 +29,9 @@ module Pod
#-----------------------------------------------------------------------#
describe
"In general"
do
before
do
@integrator
.
stubs
(
:warn_about_xcconfig_overrides
)
end
it
"adds the Pods project to the workspace"
do
UserProjectIntegrator
::
TargetIntegrator
.
any_instance
.
stubs
(
:integrate!
)
...
...
@@ -52,6 +55,35 @@ module Pod
UI
.
warnings
.
should
.
include?
(
'The Podfile does not contain any dependencies'
)
end
it
'check that the integrated target does not override the CocoaPods build settings'
do
UI
.
warnings
=
''
target_config
=
stub
(
:name
=>
'Release'
,
:build_settings
=>
{
'GCC_PREPROCESSOR_DEFINITIONS'
=>
'FLAG=1'
})
user_target
=
stub
(
:name
=>
'SampleProject'
,
:build_configurations
=>
[
target_config
])
@library
.
stubs
(
:user_targets
).
returns
([
user_target
])
@library
.
xcconfigs
[
'Release'
]
=
stub
(
:attributes
=>
{
'GCC_PREPROCESSOR_DEFINITIONS'
=>
'COCOAPODS=1'
})
@integrator
=
UserProjectIntegrator
.
new
(
@podfile
,
config
.
sandbox
,
temporary_directory
,
[
@library
])
@integrator
.
unstub
(
:warn_about_xcconfig_overrides
)
@integrator
.
send
(
:warn_about_xcconfig_overrides
)
UI
.
warnings
.
should
.
include
'The `SampleProject [Release]` target '
\
'overrides the `GCC_PREPROCESSOR_DEFINITIONS` build setting'
end
it
'allows build settings which inherit the settings form the CocoaPods xcconfig'
do
UI
.
warnings
=
''
target_config
=
stub
(
:name
=>
'Release'
,
:build_settings
=>
{
'GCC_PREPROCESSOR_DEFINITIONS'
=>
'FLAG=1 $(inherited)'
})
user_target
=
stub
(
:name
=>
'SampleProject'
,
:build_configurations
=>
[
target_config
])
@library
.
stubs
(
:user_targets
).
returns
([
user_target
])
@library
.
xcconfigs
[
'Release'
]
=
stub
(
:attributes
=>
{
'GCC_PREPROCESSOR_DEFINITIONS'
=>
'COCOAPODS=1'
})
@integrator
=
UserProjectIntegrator
.
new
(
@podfile
,
config
.
sandbox
,
temporary_directory
,
[
@library
])
@integrator
.
unstub
(
:warn_about_xcconfig_overrides
)
@integrator
.
send
(
:warn_about_xcconfig_overrides
)
UI
.
warnings
.
should
.
not
.
include
'GCC_PREPROCESSOR_DEFINITIONS'
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