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
5121dff5
Commit
5121dff5
authored
Jul 08, 2015
by
Tomas Linhart
Committed by
Samuel E. Giddins
Jul 24, 2015
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add modules support for static libraries
parent
c5657e4f
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
80 additions
and
6 deletions
+80
-6
CHANGELOG.md
CHANGELOG.md
+3
-0
module_map.rb
lib/cocoapods/generator/module_map.rb
+2
-1
pod_target_installer.rb
...oapods/installer/target_installer/pod_target_installer.rb
+31
-1
headers_store.rb
lib/cocoapods/sandbox/headers_store.rb
+25
-3
module_map_spec.rb
spec/unit/generator/module_map_spec.rb
+17
-1
pod_target_installer_spec.rb
...t/installer/target_installer/pod_target_installer_spec.rb
+2
-0
No files found.
CHANGELOG.md
View file @
5121dff5
...
@@ -64,6 +64,9 @@ To install release candidates run `[sudo] gem install cocoapods --pre`
...
@@ -64,6 +64,9 @@ To install release candidates run `[sudo] gem install cocoapods --pre`
##### Enhancements
##### Enhancements
*
Add modules support for static libraries.
[
Tomas Linhart
](
https://github.com/TomasLinhart
)
*
The resolver will now take supported platform deployment targets into account
*
The resolver will now take supported platform deployment targets into account
when resolving dependencies.
when resolving dependencies.
[
Samuel Giddins
](
https://github.com/segiddins
)
[
Samuel Giddins
](
https://github.com/segiddins
)
...
...
lib/cocoapods/generator/module_map.rb
View file @
5121dff5
...
@@ -42,8 +42,9 @@ module Pod
...
@@ -42,8 +42,9 @@ module Pod
# @return [String]
# @return [String]
#
#
def
generate
def
generate
module_declaration_qualifier
=
target
.
requires_frameworks?
?
"framework "
:
""
result
=
<<-
eos
.
strip_heredoc
result
=
<<-
eos
.
strip_heredoc
framework
module
#{
target
.
product_module_name
}
{
#{
module_declaration_qualifier
}
module
#{
target
.
product_module_name
}
{
umbrella header "
#{
target
.
umbrella_header_path
.
basename
}
"
umbrella header "
#{
target
.
umbrella_header_path
.
basename
}
"
export *
export *
...
...
lib/cocoapods/installer/target_installer/pod_target_installer.rb
View file @
5121dff5
...
@@ -22,13 +22,15 @@ module Pod
...
@@ -22,13 +22,15 @@ module Pod
create_xcconfig_file
create_xcconfig_file
if
target
.
requires_frameworks?
if
target
.
requires_frameworks?
create_info_plist_file
create_info_plist_file
end
create_module_map
do
|
generator
|
create_module_map
do
|
generator
|
generator
.
private_headers
+=
target
.
file_accessors
.
flat_map
(
&
:private_headers
).
map
(
&
:basename
)
generator
.
private_headers
+=
target
.
file_accessors
.
flat_map
(
&
:private_headers
).
map
(
&
:basename
)
end
end
create_umbrella_header
do
|
generator
|
create_umbrella_header
do
|
generator
|
generator
.
imports
+=
target
.
file_accessors
.
flat_map
(
&
:public_headers
).
map
(
&
:basename
)
generator
.
imports
+=
target
.
file_accessors
.
flat_map
(
&
:public_headers
).
map
(
&
:basename
)
end
end
end
link_module_map
link_umbrella_header
create_prefix_header
create_prefix_header
create_dummy_source
create_dummy_source
end
end
...
@@ -183,6 +185,26 @@ module Pod
...
@@ -183,6 +185,26 @@ module Pod
end
end
end
end
# Links a module map to Public headers.
#
# @return [void]
#
def
link_module_map
module_map_path_name
=
Pathname
.
new
(
target
.
module_map_path
)
sandbox
.
public_headers
.
add_file
(
target
.
name
,
module_map_path_name
,
"module.modulemap"
,
target
.
platform
)
end
# Links a an umbrella header to Public headers.
#
# @return [void]
#
def
link_umbrella_header
return
if
custom_module_map
umbrella_header_path_name
=
Pathname
.
new
(
target
.
umbrella_header_path
)
sandbox
.
public_headers
.
add_files
(
target
.
name
,
[
umbrella_header_path_name
],
target
.
platform
)
end
# Creates a prefix header file which imports `UIKit` or `Cocoa` according
# Creates a prefix header file which imports `UIKit` or `Cocoa` according
# to the platform of the target. This file also include any prefix header
# to the platform of the target. This file also include any prefix header
# content reported by the specification of the pods.
# content reported by the specification of the pods.
...
@@ -280,6 +302,14 @@ module Pod
...
@@ -280,6 +302,14 @@ module Pod
FileUtils
.
cp
(
custom_module_map
,
path
)
FileUtils
.
cp
(
custom_module_map
,
path
)
add_file_to_support_group
(
path
)
add_file_to_support_group
(
path
)
unless
target
.
requires_frameworks?
File
.
open
(
path
)
do
|
source_file
|
contents
=
source_file
.
read
contents
.
gsub!
(
/^\s*framework\s+module/
,
'module'
)
File
.
open
(
path
,
"w"
)
{
|
f
|
f
.
write
(
contents
)
}
end
end
native_target
.
build_configurations
.
each
do
|
c
|
native_target
.
build_configurations
.
each
do
|
c
|
relative_path
=
path
.
relative_path_from
(
sandbox
.
root
)
relative_path
=
path
.
relative_path_from
(
sandbox
.
root
)
c
.
build_settings
[
'MODULEMAP_FILE'
]
=
relative_path
.
to_s
c
.
build_settings
[
'MODULEMAP_FILE'
]
=
relative_path
.
to_s
...
...
lib/cocoapods/sandbox/headers_store.rb
View file @
5121dff5
...
@@ -71,19 +71,41 @@ module Pod
...
@@ -71,19 +71,41 @@ module Pod
# @return [Array<Pathname>]
# @return [Array<Pathname>]
#
#
def
add_files
(
namespace
,
relative_header_paths
,
platform
)
def
add_files
(
namespace
,
relative_header_paths
,
platform
)
relative_header_paths
.
map
do
|
relative_header_path
|
add_file
(
namespace
,
relative_header_path
,
relative_header_path
.
basename
,
platform
)
end
end
# Adds a header to the directory under different name.
#
# @param [Pathname] namespace
# the path where the header file should be stored relative to the
# headers directory.
#
# @param [Pathname] relative_header_path
# the path of the header file relative to the Pods project
# (`PODS_ROOT` variable of the xcconfigs).
#
# @param [String] final_name
# the name under which the file should be available in the
# headers directory.
#
# @note This method adds the file to the search paths.
#
# @return [Pathname]
#
def
add_file
(
namespace
,
relative_header_path
,
final_name
,
platform
)
add_search_path
(
namespace
,
platform
)
add_search_path
(
namespace
,
platform
)
namespaced_path
=
root
+
namespace
namespaced_path
=
root
+
namespace
namespaced_path
.
mkpath
unless
File
.
exist?
(
namespaced_path
)
namespaced_path
.
mkpath
unless
File
.
exist?
(
namespaced_path
)
relative_header_paths
.
map
do
|
relative_header_path
|
absolute_source
=
(
sandbox
.
root
+
relative_header_path
)
absolute_source
=
(
sandbox
.
root
+
relative_header_path
)
source
=
absolute_source
.
relative_path_from
(
namespaced_path
)
source
=
absolute_source
.
relative_path_from
(
namespaced_path
)
Dir
.
chdir
(
namespaced_path
)
do
Dir
.
chdir
(
namespaced_path
)
do
FileUtils
.
ln_sf
(
source
,
relative_header_path
.
base
name
)
FileUtils
.
ln_sf
(
source
,
final_
name
)
end
end
namespaced_path
+
relative_header_path
.
basename
namespaced_path
+
relative_header_path
.
basename
end
end
end
# Adds an header search path to the sandbox.
# Adds an header search path to the sandbox.
#
#
...
...
spec/unit/generator/module_map_spec.rb
View file @
5121dff5
...
@@ -9,8 +9,9 @@ module Pod
...
@@ -9,8 +9,9 @@ module Pod
@gen
=
Generator
::
ModuleMap
.
new
(
@pod_target
)
@gen
=
Generator
::
ModuleMap
.
new
(
@pod_target
)
end
end
it
'writes the module map to the disk'
do
it
'writes the
framework
module map to the disk'
do
path
=
temporary_directory
+
'BananaLib.modulemap'
path
=
temporary_directory
+
'BananaLib.modulemap'
@pod_target
.
stubs
(
:requires_frameworks?
=>
true
)
@gen
.
save_as
(
path
)
@gen
.
save_as
(
path
)
path
.
read
.
should
==
<<-
EOS
.
strip_heredoc
path
.
read
.
should
==
<<-
EOS
.
strip_heredoc
framework module BananaLib {
framework module BananaLib {
...
@@ -22,8 +23,23 @@ module Pod
...
@@ -22,8 +23,23 @@ module Pod
EOS
EOS
end
end
it
'writes the library module map to the disk'
do
path
=
temporary_directory
+
'BananaLib.modulemap'
@pod_target
.
stubs
(
:requires_frameworks?
=>
false
)
@gen
.
save_as
(
path
)
path
.
read
.
should
==
<<-
EOS
.
strip_heredoc
module BananaLib {
umbrella header "BananaLib-umbrella.h"
export *
module * { export * }
}
EOS
end
it
'correctly adds private headers'
do
it
'correctly adds private headers'
do
@gen
.
stubs
(
:private_headers
).
returns
([
'Private.h'
])
@gen
.
stubs
(
:private_headers
).
returns
([
'Private.h'
])
@pod_target
.
stubs
(
:requires_frameworks?
=>
true
)
@gen
.
generate
.
should
==
<<-
EOS
.
strip_heredoc
@gen
.
generate
.
should
==
<<-
EOS
.
strip_heredoc
framework module BananaLib {
framework module BananaLib {
umbrella header "BananaLib-umbrella.h"
umbrella header "BananaLib-umbrella.h"
...
...
spec/unit/installer/target_installer/pod_target_installer_spec.rb
View file @
5121dff5
...
@@ -103,6 +103,7 @@ module Pod
...
@@ -103,6 +103,7 @@ module Pod
'Pods-BananaLib-Private.xcconfig'
,
'Pods-BananaLib-Private.xcconfig'
,
'Pods-BananaLib-dummy.m'
,
'Pods-BananaLib-dummy.m'
,
'Pods-BananaLib-prefix.pch'
,
'Pods-BananaLib-prefix.pch'
,
'Pods-BananaLib.modulemap'
,
'Pods-BananaLib.xcconfig'
,
'Pods-BananaLib.xcconfig'
,
]
]
end
end
...
@@ -145,6 +146,7 @@ module Pod
...
@@ -145,6 +146,7 @@ module Pod
'BananaLib-Private.xcconfig'
,
'BananaLib-Private.xcconfig'
,
'BananaLib-dummy.m'
,
'BananaLib-dummy.m'
,
'BananaLib-prefix.pch'
,
'BananaLib-prefix.pch'
,
'BananaLib.modulemap'
,
'BananaLib.xcconfig'
,
'BananaLib.xcconfig'
,
]
]
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