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
10abfd7c
Commit
10abfd7c
authored
Sep 21, 2011
by
Luke Redpath
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Support the setting of file-specific compiler flags when adding source files to the project.
We'll need this to support #8.
parent
6f5233ac
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
2 deletions
+16
-2
project.rb
lib/cocoapods/xcode/project.rb
+3
-2
project_spec.rb
spec/unit/xcode/project_spec.rb
+13
-0
No files found.
lib/cocoapods/xcode/project.rb
View file @
10abfd7c
...
...
@@ -50,14 +50,15 @@ module Pod
end
.
compact
end
def
add_source_file
(
file
)
def
add_source_file
(
file
,
compiler_flags
=
nil
)
file_ref_uuid
=
add_file_reference
(
file
,
'SOURCE_ROOT'
)
add_file_to_group
(
file_ref_uuid
,
'Pods'
)
if
file
.
extname
==
'.h'
build_file_uuid
=
add_build_file
(
file_ref_uuid
,
"settings"
=>
{
"ATTRIBUTES"
=>
[
"Public"
]
})
add_file_to_list
(
'PBXHeadersBuildPhase'
,
build_file_uuid
)
else
build_file_uuid
=
add_build_file
(
file_ref_uuid
)
extra
=
compiler_flags
?
{
"settings"
=>
{
"COMPILER_FLAGS"
=>
compiler_flags
}}
:
{}
build_file_uuid
=
add_build_file
(
file_ref_uuid
,
extra
)
add_file_to_list
(
'PBXSourcesBuildPhase'
,
build_file_uuid
)
end
file_ref_uuid
...
...
spec/unit/xcode/project_spec.rb
View file @
10abfd7c
...
...
@@ -38,6 +38,19 @@ describe "Pod::Xcode::Project" do
end
end
it
"adds custom compiler flags to the PBXBuildFile object if specified"
do
build_file_uuids
=
[]
%w{ m mm c cpp }
.
each
do
|
ext
|
path
=
Pathname
.
new
(
"path/to/file.
#{
ext
}
"
)
file_ref_uuid
=
@project
.
add_source_file
(
path
,
'-fno-obj-arc'
)
@project
.
find_object
({
'isa'
=>
'PBXBuildFile'
,
'fileRef'
=>
file_ref_uuid
,
'settings'
=>
{
'COMPILER_FLAGS'
=>
'-fno-obj-arc'
}
}).
should
.
not
==
nil
end
end
it
"adds a `h' file as a build file and adds it to the `headers build' phase list"
do
path
=
Pathname
.
new
(
"path/to/file.h"
)
file_ref_uuid
=
@project
.
add_source_file
(
path
)
...
...
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