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