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
b233a8a9
Commit
b233a8a9
authored
Aug 09, 2014
by
Fabio Pelosin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Project] Add preprocessor definition for build configurations
parent
55a8c912
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
62 additions
and
2 deletions
+62
-2
Gemfile.lock
Gemfile.lock
+1
-1
project.rb
lib/cocoapods/project.rb
+30
-0
cocoapods-integration-specs
spec/cocoapods-integration-specs
+1
-1
project_spec.rb
spec/unit/project_spec.rb
+30
-0
No files found.
Gemfile.lock
View file @
b233a8a9
...
@@ -18,7 +18,7 @@ GIT
...
@@ -18,7 +18,7 @@ GIT
GIT
GIT
remote: https://github.com/CocoaPods/Xcodeproj.git
remote: https://github.com/CocoaPods/Xcodeproj.git
revision: 7
30a09310e986bb2ec5430ef303f8453537d01ac
revision: 7
dd77ed01ce5e2cfddc2dc9307a8cfdf9ce78e52
branch: master
branch: master
specs:
specs:
xcodeproj (0.18.0)
xcodeproj (0.18.0)
...
...
lib/cocoapods/project.rb
View file @
b233a8a9
...
@@ -193,6 +193,36 @@ module Pod
...
@@ -193,6 +193,36 @@ module Pod
podfile_ref
podfile_ref
end
end
# Adds a new build configuration to the project and populates its with
# default settings according to the provided type.
#
# @note This method extends the original Xcodeproj implementation to
# include a preprocessor definition named after the build
# setting. This is done to support the TargetEnvironmentHeader
# specification of Pods available only on certain build
# configurations.
#
# @param [String] name
# The name of the build configuration.
#
# @param [Symbol] type
# The type of the build configuration used to populate the build
# settings, must be :debug or :release.
#
# @return [XCBuildConfiguration] The new build configuration.
#
def
add_build_configuration
(
name
,
type
)
build_configuration
=
super
values
=
[
"
#{
name
.
gsub
(
' '
,
'_'
).
upcase
}
=1"
]
settings
=
build_configuration
.
build_settings
values
.
each
do
|
value
|
definitions
=
settings
[
'GCC_PREPROCESSOR_DEFINITIONS'
]
||=
[]
unless
definitions
.
include?
(
value
)
definitions
<<
value
end
end
build_configuration
end
private
private
...
...
cocoapods-integration-specs
@
f10519fd
Subproject commit
3200e10190c6892b837e5ef3b87c2a2a612f69b6
Subproject commit
f10519fd4b3e699dfee488edf761b0ebe675f5b2
spec/unit/project_spec.rb
View file @
b233a8a9
...
@@ -225,6 +225,36 @@ module Pod
...
@@ -225,6 +225,36 @@ module Pod
f
.
path
.
should
==
'../Podfile'
f
.
path
.
should
==
'../Podfile'
end
end
#----------------------------------------#
describe
"#add_build_configuration"
do
it
"adds a preprocessor definition for build configurations"
do
configuration
=
@project
.
add_build_configuration
(
'Release'
,
:release
)
settings
=
configuration
.
build_settings
settings
[
'GCC_PREPROCESSOR_DEFINITIONS'
].
should
.
include
(
'RELEASE=1'
)
end
it
"doesn't duplicate values"
do
original
=
@project
.
build_configuration_list
[
'Debug'
]
original_settings
=
original
.
build_settings
original_settings
[
'GCC_PREPROCESSOR_DEFINITIONS'
].
should
==
[
"DEBUG=1"
,
"$(inherited)"
]
configuration
=
@project
.
add_build_configuration
(
'Debug'
,
:debug
)
settings
=
configuration
.
build_settings
settings
[
'GCC_PREPROCESSOR_DEFINITIONS'
].
should
==
[
"DEBUG=1"
,
"$(inherited)"
]
end
it
"normalizes the name of the configuration"
do
configuration
=
@project
.
add_build_configuration
(
'My Awesome Configuration'
,
:release
)
settings
=
configuration
.
build_settings
settings
[
'GCC_PREPROCESSOR_DEFINITIONS'
].
should
==
[
"MY_AWESOME_CONFIGURATION=1"
]
end
end
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