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
83787fab
Commit
83787fab
authored
Jan 24, 2018
by
Samuel Giddins
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Ensure Swift static library pods work
parent
8c98adf3
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
57 additions
and
40 deletions
+57
-40
xcconfig_helper.rb
lib/cocoapods/generator/xcconfig/xcconfig_helper.rb
+22
-0
pod_target_installer.rb
...ller/xcode/pods_project_generator/pod_target_installer.rb
+29
-39
aggregate_xcconfig_spec.rb
spec/unit/generator/xcconfig/aggregate_xcconfig_spec.rb
+1
-1
pod_target_installer_spec.rb
...xcode/pods_project_generator/pod_target_installer_spec.rb
+5
-0
No files found.
lib/cocoapods/generator/xcconfig/xcconfig_helper.rb
View file @
83787fab
...
@@ -329,19 +329,41 @@ module Pod
...
@@ -329,19 +329,41 @@ module Pod
build_settings
[
'CONFIGURATION_BUILD_DIR'
]
=
target
.
configuration_build_dir
(
CONFIGURATION_BUILD_DIR_VARIABLE
)
build_settings
[
'CONFIGURATION_BUILD_DIR'
]
=
target
.
configuration_build_dir
(
CONFIGURATION_BUILD_DIR_VARIABLE
)
end
end
module_map_files
=
[]
unless
dependent_targets
.
empty?
unless
dependent_targets
.
empty?
framework_search_paths
=
[]
framework_search_paths
=
[]
library_search_paths
=
[]
library_search_paths
=
[]
swift_import_paths
=
[]
dependent_targets
.
each
do
|
dependent_target
|
dependent_targets
.
each
do
|
dependent_target
|
if
dependent_target
.
requires_frameworks?
if
dependent_target
.
requires_frameworks?
framework_search_paths
<<
dependent_target
.
configuration_build_dir
(
CONFIGURATION_BUILD_DIR_VARIABLE
)
framework_search_paths
<<
dependent_target
.
configuration_build_dir
(
CONFIGURATION_BUILD_DIR_VARIABLE
)
else
else
library_search_paths
<<
dependent_target
.
configuration_build_dir
(
CONFIGURATION_BUILD_DIR_VARIABLE
)
library_search_paths
<<
dependent_target
.
configuration_build_dir
(
CONFIGURATION_BUILD_DIR_VARIABLE
)
module_map_file
=
if
dependent_target
.
uses_swift?
# for swift, we have a custom build phase that copies in the module map, appending the .Swift module
"${PODS_CONFIGURATION_BUILD_DIR}/
#{
dependent_target
.
label
}
/
#{
dependent_target
.
product_module_name
}
.modulemap"
else
"${PODS_ROOT}/
#{
dependent_target
.
module_map_path
.
relative_path_from
(
dependent_target
.
sandbox
.
root
)
}
"
end
module_map_files
<<
%(-fmodule-map-file="#{module_map_file}")
end
end
swift_import_paths
<<
dependent_target
.
configuration_build_dir
(
CONFIGURATION_BUILD_DIR_VARIABLE
)
end
end
build_settings
[
'FRAMEWORK_SEARCH_PATHS'
]
=
XCConfigHelper
.
quote
(
framework_search_paths
.
uniq
)
build_settings
[
'FRAMEWORK_SEARCH_PATHS'
]
=
XCConfigHelper
.
quote
(
framework_search_paths
.
uniq
)
build_settings
[
'LIBRARY_SEARCH_PATHS'
]
=
XCConfigHelper
.
quote
(
library_search_paths
.
uniq
)
build_settings
[
'LIBRARY_SEARCH_PATHS'
]
=
XCConfigHelper
.
quote
(
library_search_paths
.
uniq
)
build_settings
[
'SWIFT_INCLUDE_PATHS'
]
=
XCConfigHelper
.
quote
(
swift_import_paths
.
uniq
)
end
other_swift_flags
=
module_map_files
.
tap
(
&
:uniq!
).
flat_map
{
|
f
|
[
'-Xcc'
,
f
]
}
if
target
.
is_a?
(
PodTarget
)
&&
!
target
.
requires_frameworks?
# make it possible for a mixed swift/objc static library to be able to import the objc from within swift
other_swift_flags
+=
[
'-import-underlying-module'
,
'-Xcc'
,
'-fmodule-map-file="${SRCROOT}/${MODULEMAP_FILE}"'
]
end
end
# unconditionally set these, because of (the possibility of) having to add the pod targets own module map file
build_settings
[
'OTHER_CFLAGS'
]
=
module_map_files
.
join
(
' '
)
build_settings
[
'OTHER_SWIFT_FLAGS'
]
=
other_swift_flags
.
join
(
' '
)
build_settings
build_settings
end
end
...
...
lib/cocoapods/installer/xcode/pods_project_generator/pod_target_installer.rb
View file @
83787fab
...
@@ -27,6 +27,8 @@ module Pod
...
@@ -27,6 +27,8 @@ module Pod
add_files_to_build_phases
add_files_to_build_phases
create_xcconfig_file
create_xcconfig_file
create_test_xcconfig_files
if
target
.
contains_test_specifications?
create_test_xcconfig_files
if
target
.
contains_test_specifications?
# TODO: determine if it is safe to unconditionally create (& 'link') module maps & umbrella
# headers for _all_ static libraries -- we've caused bugs by trying to do this in the past
create_module_map
create_module_map
create_umbrella_header
do
|
generator
|
create_umbrella_header
do
|
generator
|
file_accessors
=
target
.
file_accessors
file_accessors
=
target
.
file_accessors
...
@@ -47,9 +49,8 @@ module Pod
...
@@ -47,9 +49,8 @@ module Pod
if
target
.
static_framework?
if
target
.
static_framework?
create_build_phase_to_move_static_framework_archive
create_build_phase_to_move_static_framework_archive
end
end
else
elsif
target
.
uses_swift?
add_copy_module_map_build_phase
add_swift_static_library_compatibility_header_phase
add_copy_umbrella_header_build_phase
end
end
unless
skip_pch?
(
target
.
non_test_specs
)
unless
skip_pch?
(
target
.
non_test_specs
)
path
=
target
.
prefix_header_path
path
=
target
.
prefix_header_path
...
@@ -99,6 +100,11 @@ module Pod
...
@@ -99,6 +100,11 @@ module Pod
if
target
.
swift_version
if
target
.
swift_version
settings
[
'SWIFT_VERSION'
]
=
target
.
swift_version
settings
[
'SWIFT_VERSION'
]
=
target
.
swift_version
end
end
if
target
.
requires_frameworks?
||
target
.
uses_swift?
settings
[
'DEFINES_MODULE'
]
=
'YES'
end
settings
settings
end
end
...
@@ -589,10 +595,7 @@ module Pod
...
@@ -589,10 +595,7 @@ module Pod
# @return [PBXFileReference] the file reference of the added file.
# @return [PBXFileReference] the file reference of the added file.
#
#
def
add_file_to_support_group
(
path
)
def
add_file_to_support_group
(
path
)
pod_name
=
target
.
pod_name
support_files_group
.
new_file
(
path
)
dir
=
target
.
support_files_dir
group
=
project
.
pod_support_files_group
(
pod_name
,
dir
)
group
.
new_file
(
path
)
end
end
def
apply_xcconfig_file_ref_to_resource_bundle_targets
(
resource_bundle_targets
,
xcconfig_file_ref
)
def
apply_xcconfig_file_ref_to_resource_bundle_targets
(
resource_bundle_targets
,
xcconfig_file_ref
)
...
@@ -664,14 +667,6 @@ module Pod
...
@@ -664,14 +667,6 @@ module Pod
copy_phase
.
symbol_dst_subfolder_spec
=
:products_directory
copy_phase
.
symbol_dst_subfolder_spec
=
:products_directory
copy_phase
.
dst_path
=
"$(
#{
acl
.
upcase
}
_HEADERS_FOLDER_PATH)/
#{
sub_dir
}
"
copy_phase
.
dst_path
=
"$(
#{
acl
.
upcase
}
_HEADERS_FOLDER_PATH)/
#{
sub_dir
}
"
copy_phase
.
add_file_reference
(
file_ref
,
true
)
copy_phase
.
add_file_reference
(
file_ref
,
true
)
elsif
acl
!=
'Project'
relative_path
=
file_ref
.
real_path
.
basename
copy_phase_name
=
"Copy
#{
acl
}
Headers"
copy_phase
=
native_target
.
copy_files_build_phases
.
find
{
|
bp
|
bp
.
name
==
copy_phase_name
}
||
native_target
.
new_copy_files_build_phase
(
copy_phase_name
)
copy_phase
.
symbol_dst_subfolder_spec
=
:products_directory
copy_phase
.
dst_path
=
'Headers/'
copy_phase
.
add_file_reference
(
file_ref
,
true
)
else
else
build_file
.
settings
||=
{}
build_file
.
settings
||=
{}
build_file
.
settings
[
'ATTRIBUTES'
]
=
[
acl
]
build_file
.
settings
[
'ATTRIBUTES'
]
=
[
acl
]
...
@@ -679,33 +674,28 @@ module Pod
...
@@ -679,33 +674,28 @@ module Pod
end
end
def
support_files_group
def
support_files_group
pod_name
=
target
.
pod_name
pod_name
=
target
.
pod_name
dir
=
target
.
support_files_dir
dir
=
target
.
support_files_dir
project
.
pod_support_files_group
(
pod_name
,
dir
)
project
.
pod_support_files_group
(
pod_name
,
dir
)
end
end
def
add_copy_module_map_build_phase
(
path
=
target
.
module_map_path
.
relative_path_from
(
target
.
support_files_dir
))
# Adds a shell script phase, intended only for static library targets that contain swift,
if
!
target
.
requires_frameworks?
&&
!
target
.
uses_swift?
# to copy the ObjC compatibility header (the -Swift.h file that the swift compiler generates)
file_ref
=
support_files_group
.
find_file_by_path
(
path
.
to_s
)
# to the built products directory. Additionally, the script phase copies the module map, appending a `.Swift`
copy_phase_name
=
'Copy modulemap'
# submodule that references the (moved) compatibility header.
copy_phase
=
native_target
.
copy_files_build_phases
.
find
{
|
bp
|
bp
.
name
==
copy_phase_name
}
||
#
native_target
.
new_copy_files_build_phase
(
copy_phase_name
)
# @return [Void]
copy_phase
.
symbol_dst_subfolder_spec
=
:products_directory
#
copy_phase
.
add_file_reference
(
file_ref
,
false
)
def
add_swift_static_library_compatibility_header_phase
end
build_phase
=
native_target
.
new_shell_script_build_phase
(
'Copy generated compatibility header'
)
end
build_phase
.
shell_script
=
<<-
SH
.
strip_heredoc
COMPATIBILITY_HEADER_PATH="${BUILT_PRODUCTS_DIR}/Swift Compatibility Header/${PRODUCT_MODULE_NAME}-Swift.h"
MODULE_MAP_PATH="${BUILT_PRODUCTS_DIR}/${PRODUCT_MODULE_NAME}.modulemap"
# FIXME: Umbrella header should be copied as part of copy public headers?
ditto "${DERIVED_SOURCES_DIR}/${PRODUCT_MODULE_NAME}-Swift.h" "${COMPATIBILITY_HEADER_PATH}"
def
add_copy_umbrella_header_build_phase
(
path
=
target
.
umbrella_header_path
.
relative_path_from
(
target
.
support_files_dir
))
ditto "${PODS_ROOT}/
#{
target
.
module_map_path
.
relative_path_from
(
target
.
sandbox
.
root
)
}
" "${MODULE_MAP_PATH}"
if
!
target
.
requires_frameworks?
&&
!
target
.
uses_swift?
printf "
\\
n
\\
nmodule ${PRODUCT_MODULE_NAME}.Swift {
\\
n header
\\
"${COMPATIBILITY_HEADER_PATH}
\\
"
\\
n requires objc
\\
n}
\\
n" >> "${MODULE_MAP_PATH}"
file_ref
=
support_files_group
.
find_file_by_path
(
path
.
to_s
)
SH
copy_phase_name
=
'Copy umbrella header'
copy_phase
=
native_target
.
copy_files_build_phases
.
find
{
|
bp
|
bp
.
name
==
copy_phase_name
}
||
native_target
.
new_copy_files_build_phase
(
copy_phase_name
)
copy_phase
.
symbol_dst_subfolder_spec
=
:products_directory
copy_phase
.
dst_path
=
'Headers/'
copy_phase
.
add_file_reference
(
file_ref
,
false
)
end
end
end
#-----------------------------------------------------------------------#
#-----------------------------------------------------------------------#
...
...
spec/unit/generator/xcconfig/aggregate_xcconfig_spec.rb
View file @
83787fab
...
@@ -146,7 +146,7 @@ module Pod
...
@@ -146,7 +146,7 @@ module Pod
end
end
it
'adds the sandbox public headers search paths to the xcconfig, with quotes, as system headers'
do
it
'adds the sandbox public headers search paths to the xcconfig, with quotes, as system headers'
do
expected
=
'$(inherited) -isystem "${PODS_ROOT}/Headers/Public/BananaLib"'
expected
=
'$(inherited) -
fmodule-map-file="${PODS_ROOT}/Target Support Files/BananaLib/BananaLib.modulemap" -
isystem "${PODS_ROOT}/Headers/Public/BananaLib"'
@xcconfig
.
to_hash
[
'OTHER_CFLAGS'
].
should
==
expected
@xcconfig
.
to_hash
[
'OTHER_CFLAGS'
].
should
==
expected
end
end
...
...
spec/unit/installer/xcode/pods_project_generator/pod_target_installer_spec.rb
View file @
83787fab
...
@@ -479,6 +479,7 @@ module Pod
...
@@ -479,6 +479,7 @@ module Pod
'BananaLib-Pods-SampleProject-dummy.m'
,
'BananaLib-Pods-SampleProject-dummy.m'
,
'BananaLib-Pods-SampleProject-prefix.pch'
,
'BananaLib-Pods-SampleProject-prefix.pch'
,
'BananaLib-Pods-SampleProject.xcconfig'
,
'BananaLib-Pods-SampleProject.xcconfig'
,
'BananaLib.modulemap'
,
]
]
end
end
...
@@ -490,6 +491,7 @@ module Pod
...
@@ -490,6 +491,7 @@ module Pod
'BananaLib-Pods-SampleProject-dummy.m'
,
'BananaLib-Pods-SampleProject-dummy.m'
,
'BananaLib-Pods-SampleProject-prefix.pch'
,
'BananaLib-Pods-SampleProject-prefix.pch'
,
'BananaLib-Pods-SampleProject.xcconfig'
,
'BananaLib-Pods-SampleProject.xcconfig'
,
'BananaLib.modulemap'
,
]
]
end
end
...
@@ -500,6 +502,7 @@ module Pod
...
@@ -500,6 +502,7 @@ module Pod
group
.
children
.
map
(
&
:display_name
).
sort
.
should
==
[
group
.
children
.
map
(
&
:display_name
).
sort
.
should
==
[
'BananaLib-Pods-SampleProject-dummy.m'
,
'BananaLib-Pods-SampleProject-dummy.m'
,
'BananaLib-Pods-SampleProject.xcconfig'
,
'BananaLib-Pods-SampleProject.xcconfig'
,
'BananaLib.modulemap'
,
]
]
end
end
...
@@ -567,6 +570,7 @@ module Pod
...
@@ -567,6 +570,7 @@ module Pod
group
.
children
.
map
(
&
:display_name
).
sort
.
should
==
[
group
.
children
.
map
(
&
:display_name
).
sort
.
should
==
[
'BananaLib-dummy.m'
,
'BananaLib-dummy.m'
,
'BananaLib-prefix.pch'
,
'BananaLib-prefix.pch'
,
'BananaLib.modulemap'
,
'BananaLib.xcconfig'
,
'BananaLib.xcconfig'
,
]
]
end
end
...
@@ -577,6 +581,7 @@ module Pod
...
@@ -577,6 +581,7 @@ module Pod
group
=
@project
[
'Pods/BananaLib/Support Files'
]
group
=
@project
[
'Pods/BananaLib/Support Files'
]
group
.
children
.
map
(
&
:display_name
).
sort
.
should
==
[
group
.
children
.
map
(
&
:display_name
).
sort
.
should
==
[
'BananaLib-dummy.m'
,
'BananaLib-dummy.m'
,
'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