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
b2589060
Commit
b2589060
authored
Sep 25, 2011
by
Eloy Duran
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add specs for adding individual pods to groups in the Xcode project.
parent
0d580d52
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
77 additions
and
50 deletions
+77
-50
installer.rb
lib/cocoapods/installer.rb
+5
-6
project.rb
lib/cocoapods/xcode/project.rb
+11
-7
installer_spec.rb
spec/unit/installer_spec.rb
+35
-30
project_spec.rb
spec/unit/xcode/project_spec.rb
+26
-7
No files found.
lib/cocoapods/installer.rb
View file @
b2589060
...
...
@@ -17,18 +17,17 @@ module Pod
end
def
source_files
source_files
=
Hash
.
new
source_files
=
{}
build_specification_sets
.
each
do
|
set
|
spec
=
set
.
specification
s
pec_files
=
[]
s
ource_files
[
spec
.
name
]
=
[]
spec
.
source_files
.
each
do
|
pattern
|
pattern
=
spec
.
pod_destroot
+
pattern
pattern
=
pattern
+
'*.{h,m,mm,c,cpp}'
if
pattern
.
directory?
pattern
.
glob
.
each
do
|
file
|
s
pec_files
<<
file
.
relative_path_from
(
config
.
project_pods_root
)
s
ource_files
[
spec
.
name
]
<<
file
.
relative_path_from
(
config
.
project_pods_root
)
end
end
source_files
[
spec
.
name
]
=
spec_files
end
source_files
end
...
...
@@ -48,10 +47,10 @@ module Pod
end
def
generate_project
source_files
.
each
do
|
group
,
files
|
source_files
.
each
do
|
group
,
files
|
xcodeproj
.
add_group
(
group
)
files
.
each
do
|
file
|
xcodeproj
.
add_source_file
(
file
,
group
)
xcodeproj
.
add_source_file
(
file
,
group
)
end
end
build_specification_sets
.
each
do
|
set
|
...
...
lib/cocoapods/xcode/project.rb
View file @
b2589060
...
...
@@ -41,16 +41,19 @@ module Pod
find_objects
(
conditions
).
first
end
IGNORE_GROUPS
=
[
'Pods'
,
'Frameworks'
,
'Products'
,
'Supporting Files'
]
def
source_files
conditions
=
{
'isa'
=>
'PBXFileReference'
,
'sourceTree'
=>
'SOURCE_ROOT'
}
find_objects
(
conditions
).
map
do
|
_
,
object
|
if
%w{ .h .m .mm .c .cpp }
.
include?
(
File
.
extname
(
object
[
'path'
]))
Pathname
.
new
(
object
[
'path'
])
end
end
.
compact
source_files
=
{}
find_objects
(
'isa'
=>
'PBXGroup'
).
each
do
|
_
,
object
|
next
if
object
[
'name'
].
nil?
||
IGNORE_GROUPS
.
include?
(
object
[
'name'
])
source_files
[
object
[
'name'
]]
=
object
[
'children'
].
map
do
|
uuid
|
Pathname
.
new
(
objects
[
uuid
][
'path'
])
end
end
source_files
end
def
add_source_file
(
file
,
group
=
'Pods'
,
compiler_flags
=
nil
)
def
add_source_file
(
file
,
group
,
compiler_flags
=
nil
)
file_ref_uuid
=
add_file_reference
(
file
,
'SOURCE_ROOT'
)
add_object_to_group
(
file_ref_uuid
,
group
)
if
file
.
extname
==
'.h'
...
...
@@ -75,6 +78,7 @@ module Pod
"children"
=>
[]
})
add_object_to_group
(
group_uuid
,
'Pods'
)
group_uuid
end
def
create_in
(
pods_root
)
...
...
spec/unit/installer_spec.rb
View file @
b2589060
...
...
@@ -17,7 +17,7 @@ describe "Pod::Installer" do
[
'ASIHTTPRequest'
,
[
'Classes'
],
"{Classes,External/Reachability}/*.{h,m}"
,
{
'ASIHTTPRequest'
=>
"Classes/*.{h,m}"
,
'Reachability'
=>
"External/Reachability/*.{h,m}"
}
,
{
"USER_HEADER_SEARCH_PATHS"
=>
"$(BUILT_PRODUCTS_DIR)/Pods"
,
"ALWAYS_SEARCH_USER_PATHS"
=>
"YES"
,
...
...
@@ -25,39 +25,44 @@ describe "Pod::Installer" do
"-framework MobileCoreServices -l z.1"
}
],
[
'Reachability'
,
[
"External/Reachability/*.h"
,
"External/Reachability/*.m"
],
"External/Reachability/*.{h,m}"
,
{
"USER_HEADER_SEARCH_PATHS"
=>
"$(BUILT_PRODUCTS_DIR)/Pods"
,
"ALWAYS_SEARCH_USER_PATHS"
=>
"YES"
}
],
[
'ASIWebPageRequest'
,
[
'**/ASIWebPageRequest.*'
],
"{Classes,Classes/ASIWebPageRequest,External/Reachability}/*.{h,m}"
,
{
"USER_HEADER_SEARCH_PATHS"
=>
"$(BUILT_PRODUCTS_DIR)/Pods"
,
"ALWAYS_SEARCH_USER_PATHS"
=>
"YES"
,
"HEADER_SEARCH_PATHS"
=>
"$(SDKROOT)/usr/include/libxml2"
,
"OTHER_LDFLAGS"
=>
"-l xml2.2.7.3 -framework SystemConfiguration "
\
"-framework CFNetwork -framework MobileCoreServices -l z.1"
}
],
].
each
do
|
name
,
patterns
,
expected_pattern
,
xcconfig
|
#
[
#
'Reachability',
#
["External/Reachability/*.h", "External/Reachability/*.m"],
#{ 'Reachability' => "External/Reachability/*.{h,m}", }
,
#
{
#
"USER_HEADER_SEARCH_PATHS" => "$(BUILT_PRODUCTS_DIR)/Pods",
#
"ALWAYS_SEARCH_USER_PATHS" => "YES"
#
}
#
],
#
[
#
'ASIWebPageRequest',
#
['**/ASIWebPageRequest.*'],
#{ 'ASIHTTPRequest' => "Classes/*.{h,m}", 'ASIWebPageRequest' => "Classes/ASIWebPageRequest/*.{h,m}", 'Reachability' => "External/Reachability/*.{h,m}" }
,
#
{
#
"USER_HEADER_SEARCH_PATHS" => "$(BUILT_PRODUCTS_DIR)/Pods",
#
"ALWAYS_SEARCH_USER_PATHS" => "YES",
#
"HEADER_SEARCH_PATHS" => "$(SDKROOT)/usr/include/libxml2",
#
"OTHER_LDFLAGS" => "-l xml2.2.7.3 -framework SystemConfiguration " \
#
"-framework CFNetwork -framework MobileCoreServices -l z.1"
#
}
#
],
].
each
do
|
name
,
patterns
,
expected_pattern
s
,
xcconfig
|
Pod
::
Source
.
reset!
Pod
::
Spec
::
Set
.
reset!
installer
=
Pod
::
Installer
.
new
(
Pod
::
Spec
.
new
{
|
s
|
s
.
dependency
(
name
);
s
.
source_files
=
*
patterns
})
expected
=
(
stubbed_destroot
(
installer
)
+
expected_pattern
).
glob
.
map
do
|
file
|
file
.
relative_path_from
(
config
.
project_pods_root
)
end
destroot
=
stubbed_destroot
(
installer
)
installer
.
generate_project
installer
.
source_files
.
size
.
should
==
expected
.
size
installer
.
source_files
.
sort
.
should
==
expected
.
sort
installer
.
xcodeproj
.
source_files
.
size
.
should
==
expected
.
size
installer
.
xcodeproj
.
source_files
.
sort
.
should
==
expected
.
sort
expected_patterns
.
each
do
|
name
,
pattern
|
expected
=
(
destroot
+
pattern
).
glob
.
map
do
|
file
|
file
.
relative_path_from
(
config
.
project_pods_root
)
end
installer
.
source_files
[
name
].
size
.
should
==
expected
.
size
installer
.
source_files
[
name
].
sort
.
should
==
expected
.
sort
installer
.
xcodeproj
.
source_files
[
name
].
size
.
should
==
expected
.
size
installer
.
xcodeproj
.
source_files
[
name
].
sort
.
should
==
expected
.
sort
end
installer
.
xcconfig
.
to_hash
.
should
==
xcconfig
end
end
...
...
spec/unit/xcode/project_spec.rb
View file @
b2589060
...
...
@@ -13,23 +13,40 @@ describe "Pod::Xcode::Project" do
@project
.
to_hash
.
should
==
NSDictionary
.
dictionaryWithContentsOfFile
(
template_file
)
end
it
"adds an `m' or `c' file as a build file and adds it to the `sources build' phase list"
do
build_file_uuids
=
[]
it
"adds a group to the `Pods' group"
do
@project
.
add_group
(
'JSONKit'
)
@project
.
find_object
({
'isa'
=>
'PBXGroup'
,
'name'
=>
'JSONKit'
,
'sourceTree'
=>
'<group>'
,
'children'
=>
[]
}).
should
.
not
==
nil
end
it
"adds an `m' or `c' file as a build file, adds it to the specified group, and adds it to the `sources build' phase list"
do
file_ref_uuids
,
build_file_uuids
=
[],
[]
group_uuid
=
@project
.
add_group
(
'SomeGroup'
)
group
=
@project
.
to_hash
[
'objects'
][
group_uuid
]
%w{ m mm c cpp }
.
each
do
|
ext
|
path
=
Pathname
.
new
(
"path/to/file.
#{
ext
}
"
)
file_ref_uuid
=
@project
.
add_source_file
(
path
)
file_ref_uuid
=
@project
.
add_source_file
(
path
,
'SomeGroup'
)
@project
.
to_hash
[
'objects'
][
file_ref_uuid
].
should
==
{
'name'
=>
path
.
basename
.
to_s
,
'isa'
=>
'PBXFileReference'
,
'sourceTree'
=>
'SOURCE_ROOT'
,
'path'
=>
path
.
to_s
}
file_ref_uuids
<<
file_ref_uuid
build_file_uuid
,
_
=
@project
.
find_object
({
'isa'
=>
'PBXBuildFile'
,
'fileRef'
=>
file_ref_uuid
})
build_file_uuids
<<
build_file_uuid
group
[
'children'
].
should
==
file_ref_uuids
_
,
object
=
@project
.
find_object
(
'isa'
=>
'PBXSourcesBuildPhase'
)
object
[
'files'
].
should
==
build_file_uuids
...
...
@@ -42,7 +59,7 @@ describe "Pod::Xcode::Project" 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'
)
file_ref_uuid
=
@project
.
add_source_file
(
path
,
'
Pods'
,
'
-fno-obj-arc'
)
@project
.
find_object
({
'isa'
=>
'PBXBuildFile'
,
'fileRef'
=>
file_ref_uuid
,
...
...
@@ -52,8 +69,9 @@ describe "Pod::Xcode::Project" do
end
it
"adds a `h' file as a build file and adds it to the `headers build' phase list"
do
@project
.
add_group
(
'SomeGroup'
)
path
=
Pathname
.
new
(
"path/to/file.h"
)
file_ref_uuid
=
@project
.
add_source_file
(
path
)
file_ref_uuid
=
@project
.
add_source_file
(
path
,
'SomeGroup'
)
@project
.
to_hash
[
'objects'
][
file_ref_uuid
].
should
==
{
'name'
=>
path
.
basename
.
to_s
,
'isa'
=>
'PBXFileReference'
,
...
...
@@ -82,8 +100,9 @@ describe "Pod::Xcode::Project" do
end
it
"returns all source files"
do
@project
.
add_group
(
'SomeGroup'
)
files
=
[
Pathname
.
new
(
'/some/file.h'
),
Pathname
.
new
(
'/some/file.m'
)]
files
.
each
{
|
file
|
@project
.
add_source_file
(
file
)
}
@project
.
source_files
.
sort
.
should
==
files
.
sort
files
.
each
{
|
file
|
@project
.
add_source_file
(
file
,
'SomeGroup'
)
}
@project
.
source_files
[
'SomeGroup'
]
.
sort
.
should
==
files
.
sort
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