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
4d85f946
Commit
4d85f946
authored
Aug 09, 2012
by
Fabio Pelosin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[LocalPod] Completed fix for public headers handling. #449
parent
3c31a309
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
32 additions
and
31 deletions
+32
-31
local_pod.rb
lib/cocoapods/local_pod.rb
+11
-10
local_pod_spec.rb
spec/unit/local_pod_spec.rb
+21
-21
No files found.
lib/cocoapods/local_pod.rb
View file @
4d85f946
...
@@ -229,21 +229,21 @@ module Pod
...
@@ -229,21 +229,21 @@ module Pod
result
result
end
end
# @return [Hash{Specification => Array<Pathname>}] The paths of the public
# @return [Hash{Specification => Array<Pathname>}] The paths of the header
# header files grouped by {Specification}.
# files grouped by {Specification} that should be copied in the public
# folder.
#
#
# @TODO: decide a policy for subspecs
# If a spec does not match any public header it means that all the
# header files (i.e. the build ones) are intended to be public.
#
#
def
public_header_files_by_spec
def
public_header_files_by_spec
build_headers
=
header_files_by_spec
public_headers
=
paths_by_spec
(
:public_header_files
,
:glob
=>
'*.h'
)
public_headers
=
paths_by_spec
(
:public_header_files
,
:glob
=>
'*.h'
)
build_headers
=
header_files_by_spec
result
=
{}
result
=
{}
# If no public header files are provided we use the build
specifications
.
each
do
|
spec
|
# ones for the every spec/subspec.
if
(
public_h
=
public_headers
[
spec
])
&&
!
public_h
.
empty?
public_headers
.
each
do
|
spec
,
paths
|
result
[
spec
]
=
public_h
if
!
paths
.
empty?
result
[
spec
]
=
paths
elsif
(
build_h
=
build_headers
[
spec
])
&&
!
build_h
.
empty?
elsif
(
build_h
=
build_headers
[
spec
])
&&
!
build_h
.
empty?
result
[
spec
]
=
build_h
result
[
spec
]
=
build_h
end
end
...
@@ -345,11 +345,12 @@ module Pod
...
@@ -345,11 +345,12 @@ module Pod
#
#
def
link_headers
def
link_headers
@sandbox
.
build_headers
.
add_search_path
(
headers_sandbox
)
@sandbox
.
build_headers
.
add_search_path
(
headers_sandbox
)
@sandbox
.
public_headers
.
add_search_path
(
headers_sandbox
)
header_mappings
(
header_files_by_spec
).
each
do
|
namespaced_path
,
files
|
header_mappings
(
header_files_by_spec
).
each
do
|
namespaced_path
,
files
|
@sandbox
.
build_headers
.
add_files
(
namespaced_path
,
files
)
@sandbox
.
build_headers
.
add_files
(
namespaced_path
,
files
)
end
end
@sandbox
.
public_headers
.
add_search_path
(
headers_sandbox
)
header_mappings
(
public_header_files_by_spec
).
each
do
|
namespaced_path
,
files
|
header_mappings
(
public_header_files_by_spec
).
each
do
|
namespaced_path
,
files
|
@sandbox
.
public_headers
.
add_files
(
namespaced_path
,
files
)
@sandbox
.
public_headers
.
add_files
(
namespaced_path
,
files
)
end
end
...
...
spec/unit/local_pod_spec.rb
View file @
4d85f946
...
@@ -15,12 +15,12 @@ describe Pod::LocalPod do
...
@@ -15,12 +15,12 @@ describe Pod::LocalPod do
@pod
.
root
.
should
==
@sandbox
.
root
+
'BananaLib'
@pod
.
root
.
should
==
@sandbox
.
root
+
'BananaLib'
end
end
x
it
"creates it's own root directory if it doesn't exist"
do
it
"creates it's own root directory if it doesn't exist"
do
@pod
.
create
@pod
.
create
File
.
directory?
(
@pod
.
root
).
should
.
be
.
true
File
.
directory?
(
@pod
.
root
).
should
.
be
.
true
end
end
x
it
"can execute a block within the context of it's root"
do
it
"can execute a block within the context of it's root"
do
@pod
.
chdir
{
FileUtils
.
touch
(
"foo"
)
}
@pod
.
chdir
{
FileUtils
.
touch
(
"foo"
)
}
Pathname
(
@pod
.
root
+
"foo"
).
should
.
exist
Pathname
(
@pod
.
root
+
"foo"
).
should
.
exist
end
end
...
@@ -68,28 +68,28 @@ describe Pod::LocalPod do
...
@@ -68,28 +68,28 @@ describe Pod::LocalPod do
@pod
.
relative_resource_files
.
should
==
[
Pathname
.
new
(
"BananaLib/Resources/logo-sidebar.png"
)]
@pod
.
relative_resource_files
.
should
==
[
Pathname
.
new
(
"BananaLib/Resources/logo-sidebar.png"
)]
end
end
x
it
"can link it's headers into the sandbox"
do
it
"can link it's headers into the sandbox"
do
@pod
.
link_headers
@pod
.
link_headers
expected_header_path
=
@sandbox
.
build_headers
.
root
+
"BananaLib/Banana.h"
expected_header_path
=
@sandbox
.
build_headers
.
root
+
"BananaLib/Banana.h"
expected_header_path
.
should
.
be
.
symlink
expected_header_path
.
should
.
be
.
symlink
File
.
read
(
expected_header_path
).
should
==
(
@sandbox
.
root
+
@pod
.
header_files
[
0
]).
read
File
.
read
(
expected_header_path
).
should
==
(
@sandbox
.
root
+
@pod
.
header_files
[
0
]).
read
end
end
x
it
"can link it's public headers into the sandbox"
do
it
"can link it's public headers into the sandbox"
do
@pod
.
link_headers
@pod
.
link_headers
expected_header_path
=
@sandbox
.
public_headers
.
root
+
"BananaLib/Banana.h"
expected_header_path
=
@sandbox
.
public_headers
.
root
+
"BananaLib/Banana.h"
expected_header_path
.
should
.
be
.
symlink
expected_header_path
.
should
.
be
.
symlink
File
.
read
(
expected_header_path
).
should
==
(
@sandbox
.
root
+
@pod
.
header_files
[
0
]).
read
File
.
read
(
expected_header_path
).
should
==
(
@sandbox
.
root
+
@pod
.
header_files
[
0
]).
read
end
end
x
it
"can add it's source files to an Xcode project target"
do
it
"can add it's source files to an Xcode project target"
do
@pod
.
source_file_descriptions
.
should
==
[
@pod
.
source_file_descriptions
.
should
==
[
Xcodeproj
::
Project
::
PBXNativeTarget
::
SourceFileDescription
.
new
(
Pathname
.
new
(
"BananaLib/Classes/Banana.h"
),
""
,
nil
),
Xcodeproj
::
Project
::
PBXNativeTarget
::
SourceFileDescription
.
new
(
Pathname
.
new
(
"BananaLib/Classes/Banana.h"
),
""
,
nil
),
Xcodeproj
::
Project
::
PBXNativeTarget
::
SourceFileDescription
.
new
(
Pathname
.
new
(
"BananaLib/Classes/Banana.m"
),
""
,
nil
)
Xcodeproj
::
Project
::
PBXNativeTarget
::
SourceFileDescription
.
new
(
Pathname
.
new
(
"BananaLib/Classes/Banana.m"
),
""
,
nil
)
]
]
end
end
x
it
"can add it's source files to a target with any specially configured compiler flags"
do
it
"can add it's source files to a target with any specially configured compiler flags"
do
@pod
.
top_specification
.
compiler_flags
=
'-d some_flag'
@pod
.
top_specification
.
compiler_flags
=
'-d some_flag'
@pod
.
source_file_descriptions
.
should
==
[
@pod
.
source_file_descriptions
.
should
==
[
Xcodeproj
::
Project
::
PBXNativeTarget
::
SourceFileDescription
.
new
(
Pathname
.
new
(
"BananaLib/Classes/Banana.h"
),
'-d some_flag'
,
nil
),
Xcodeproj
::
Project
::
PBXNativeTarget
::
SourceFileDescription
.
new
(
Pathname
.
new
(
"BananaLib/Classes/Banana.h"
),
'-d some_flag'
,
nil
),
...
@@ -97,11 +97,11 @@ describe Pod::LocalPod do
...
@@ -97,11 +97,11 @@ describe Pod::LocalPod do
]
]
end
end
x
it
"returns the platform"
do
it
"returns the platform"
do
@pod
.
platform
.
should
==
:ios
@pod
.
platform
.
should
==
:ios
end
end
x
it
"raises if the files are accessed before creating the pod dir"
do
it
"raises if the files are accessed before creating the pod dir"
do
@pod
.
implode
@pod
.
implode
lambda
{
@pod
.
source_files
}.
should
.
raise
Pod
::
Informative
lambda
{
@pod
.
source_files
}.
should
.
raise
Pod
::
Informative
end
end
...
@@ -124,15 +124,15 @@ describe Pod::LocalPod do
...
@@ -124,15 +124,15 @@ describe Pod::LocalPod do
copy_fixture_to_pod
(
'chameleon'
,
@pod
)
copy_fixture_to_pod
(
'chameleon'
,
@pod
)
end
end
x
it
"identifies the top level specification"
do
it
"identifies the top level specification"
do
@pod
.
top_specification
.
name
.
should
==
'Chameleon'
@pod
.
top_specification
.
name
.
should
==
'Chameleon'
end
end
x
it
"returns the subspecs"
do
it
"returns the subspecs"
do
@pod
.
specifications
.
map
(
&
:name
).
should
==
%w[ Chameleon/UIKit Chameleon/StoreKit ]
@pod
.
specifications
.
map
(
&
:name
).
should
==
%w[ Chameleon/UIKit Chameleon/StoreKit ]
end
end
x
it
"resolve the source files"
do
it
"resolve the source files"
do
computed
=
@pod
.
relative_source_files
.
map
(
&
:to_s
)
computed
=
@pod
.
relative_source_files
.
map
(
&
:to_s
)
expected
=
%w[
expected
=
%w[
Chameleon/UIKit/Classes/UIKit.h
Chameleon/UIKit/Classes/UIKit.h
...
@@ -147,13 +147,13 @@ describe Pod::LocalPod do
...
@@ -147,13 +147,13 @@ describe Pod::LocalPod do
assert_array_equals
(
expected
,
computed
)
assert_array_equals
(
expected
,
computed
)
end
end
x
it
"resolve the resources"
do
it
"resolve the resources"
do
@pod
.
relative_resource_files
.
map
(
&
:to_s
).
sort
.
should
==
[
@pod
.
relative_resource_files
.
map
(
&
:to_s
).
sort
.
should
==
[
"Chameleon/UIKit/Resources/<UITabBar> background.png"
,
"Chameleon/UIKit/Resources/<UITabBar> background.png"
,
"Chameleon/UIKit/Resources/<UITabBar> background@2x.png"
]
"Chameleon/UIKit/Resources/<UITabBar> background@2x.png"
]
end
end
x
it
"resolve the clean paths"
do
it
"resolve the clean paths"
do
# fake_git serves to check that source control files are deleted
# fake_git serves to check that source control files are deleted
expected
=
%w[
expected
=
%w[
/.fake_git
/.fake_git
...
@@ -212,7 +212,7 @@ describe Pod::LocalPod do
...
@@ -212,7 +212,7 @@ describe Pod::LocalPod do
assert_array_equals
(
expected
,
computed
)
assert_array_equals
(
expected
,
computed
)
end
end
x
it
"resolves the used files"
do
it
"resolves the used files"
do
expected
=
%w[
expected
=
%w[
/UIKit/Classes/UIKit.h
/UIKit/Classes/UIKit.h
/UIKit/Classes/UIView.h
/UIKit/Classes/UIView.h
...
@@ -233,7 +233,7 @@ describe Pod::LocalPod do
...
@@ -233,7 +233,7 @@ describe Pod::LocalPod do
assert_array_equals
(
expected
,
computed
)
assert_array_equals
(
expected
,
computed
)
end
end
x
it
"resolved the header files"
do
it
"resolved the header files"
do
expected
=
%w[
expected
=
%w[
Chameleon/UIKit/Classes/UIKit.h
Chameleon/UIKit/Classes/UIKit.h
Chameleon/UIKit/Classes/UIView.h
Chameleon/UIKit/Classes/UIView.h
...
@@ -244,7 +244,7 @@ describe Pod::LocalPod do
...
@@ -244,7 +244,7 @@ describe Pod::LocalPod do
assert_array_equals
(
expected
,
computed
)
assert_array_equals
(
expected
,
computed
)
end
end
x
it
"resolves the header files of **every** subspec"
do
it
"resolves the header files of **every** subspec"
do
computed
=
@pod
.
all_specs_public_header_files
.
map
{
|
p
|
p
.
relative_path_from
(
@pod
.
root
).
to_s
}
computed
=
@pod
.
all_specs_public_header_files
.
map
{
|
p
|
p
.
relative_path_from
(
@pod
.
root
).
to_s
}
expected
=
%w[
expected
=
%w[
UIKit/Classes/UIKit.h
UIKit/Classes/UIKit.h
...
@@ -272,12 +272,12 @@ describe Pod::LocalPod do
...
@@ -272,12 +272,12 @@ describe Pod::LocalPod do
assert_array_equals
(
expected
,
computed
)
assert_array_equals
(
expected
,
computed
)
end
end
x
it
"merges the xcconfigs without duplicates"
do
it
"merges the xcconfigs without duplicates"
do
@pod
.
xcconfig
.
should
==
{
@pod
.
xcconfig
.
should
==
{
"OTHER_LDFLAGS"
=>
"-framework AppKit -framework Foundation -framework IOKit -framework QTKit -framework QuartzCore -framework SystemConfiguration -framework WebKit"
}
"OTHER_LDFLAGS"
=>
"-framework AppKit -framework Foundation -framework IOKit -framework QTKit -framework QuartzCore -framework SystemConfiguration -framework WebKit"
}
end
end
x
it
"returns a hash of mappings with a custom header dir prefix"
do
it
"returns a hash of mappings with a custom header dir prefix"
do
mappings
=
@pod
.
send
(
:header_mappings
,
@pod
.
header_files_by_spec
)
mappings
=
@pod
.
send
(
:header_mappings
,
@pod
.
header_files_by_spec
)
mappings
=
mappings
.
map
do
|
folder
,
headers
|
mappings
=
mappings
.
map
do
|
folder
,
headers
|
"
#{
folder
}
>
#{
headers
.
sort
.
map
{
|
p
|
p
.
relative_path_from
(
@pod
.
root
).
to_s
}
.join(' ')}"
"
#{
folder
}
>
#{
headers
.
sort
.
map
{
|
p
|
p
.
relative_path_from
(
@pod
.
root
).
to_s
}
.join(' ')}"
...
@@ -287,7 +287,7 @@ describe Pod::LocalPod do
...
@@ -287,7 +287,7 @@ describe Pod::LocalPod do
"Chameleon/UIKit > UIKit/Classes/UIKit.h UIKit/Classes/UIView.h UIKit/Classes/UIWindow.h"
]
"Chameleon/UIKit > UIKit/Classes/UIKit.h UIKit/Classes/UIView.h UIKit/Classes/UIWindow.h"
]
end
end
x
it
"respects the headers excluded from the search paths"
do
it
"respects the headers excluded from the search paths"
do
@pod
.
stubs
(
:headers_excluded_from_search_paths
).
returns
([
@pod
.
root
+
'UIKit/Classes/UIKit.h'
])
@pod
.
stubs
(
:headers_excluded_from_search_paths
).
returns
([
@pod
.
root
+
'UIKit/Classes/UIKit.h'
])
mappings
=
@pod
.
send
(
:header_mappings
,
@pod
.
header_files_by_spec
)
mappings
=
@pod
.
send
(
:header_mappings
,
@pod
.
header_files_by_spec
)
mappings
=
mappings
.
map
do
|
folder
,
headers
|
mappings
=
mappings
.
map
do
|
folder
,
headers
|
...
@@ -299,7 +299,7 @@ describe Pod::LocalPod do
...
@@ -299,7 +299,7 @@ describe Pod::LocalPod do
end
end
# @TODO: This is done by the sandbox and this test should be moved
# @TODO: This is done by the sandbox and this test should be moved
x
it
"includes the sandbox of the pod's headers while linking"
do
it
"includes the sandbox of the pod's headers while linking"
do
@sandbox
.
build_headers
.
expects
(
:add_search_path
).
with
(
Pathname
.
new
(
'Chameleon'
))
@sandbox
.
build_headers
.
expects
(
:add_search_path
).
with
(
Pathname
.
new
(
'Chameleon'
))
@sandbox
.
public_headers
.
expects
(
:add_search_path
).
with
(
Pathname
.
new
(
'Chameleon'
))
@sandbox
.
public_headers
.
expects
(
:add_search_path
).
with
(
Pathname
.
new
(
'Chameleon'
))
@pod
.
link_headers
@pod
.
link_headers
...
@@ -312,7 +312,7 @@ describe Pod::LocalPod do
...
@@ -312,7 +312,7 @@ describe Pod::LocalPod do
@pod
=
Pod
::
LocalPod
.
new
(
spec
,
@sandbox
,
Pod
::
Platform
.
new
(
:osx
))
@pod
=
Pod
::
LocalPod
.
new
(
spec
,
@sandbox
,
Pod
::
Platform
.
new
(
:osx
))
build_headers
=
@pod
.
header_files_by_spec
.
values
.
flatten
.
map
{
|
p
|
p
.
basename
.
to_s
}
build_headers
=
@pod
.
header_files_by_spec
.
values
.
flatten
.
map
{
|
p
|
p
.
basename
.
to_s
}
public_headers
=
@pod
.
public_header_files_by_spec
.
values
.
flatten
.
map
{
|
p
|
p
.
basename
.
to_s
}
public_headers
=
@pod
.
public_header_files_by_spec
.
values
.
flatten
.
map
{
|
p
|
p
.
basename
.
to_s
}
build_headers
.
should
==
%w{ UIKit.h UIView.h UIWindow.h }
build_headers
.
s
ort
.
s
hould
==
%w{ UIKit.h UIView.h UIWindow.h }
public_headers
.
should
==
%w{ UIKit.h }
public_headers
.
should
==
%w{ UIKit.h }
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