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
19203fc0
Commit
19203fc0
authored
Aug 10, 2017
by
Danielle Tomlinson
Committed by
GitHub
Aug 10, 2017
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #6811 from paulb777/static_framework
Add support for source static library frameworks
parents
ef57aecc
bf7a2e66
Show whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
88 additions
and
6 deletions
+88
-6
CHANGELOG.md
CHANGELOG.md
+4
-1
pods_project_generator.rb
lib/cocoapods/installer/xcode/pods_project_generator.rb
+2
-1
pod_target_installer.rb
...ller/xcode/pods_project_generator/pod_target_installer.rb
+21
-0
target_installer.rb
...nstaller/xcode/pods_project_generator/target_installer.rb
+5
-1
target_validator.rb
lib/cocoapods/installer/xcode/target_validator.rb
+1
-1
target.rb
lib/cocoapods/target.rb
+7
-1
pod_target.rb
lib/cocoapods/target/pod_target.rb
+1
-1
aggregate_target_installer_spec.rb
...pods_project_generator/aggregate_target_installer_spec.rb
+10
-0
pod_target_installer_spec.rb
...xcode/pods_project_generator/pod_target_installer_spec.rb
+12
-0
target_installer_spec.rb
...ler/xcode/pods_project_generator/target_installer_spec.rb
+12
-0
target_validator_spec.rb
spec/unit/installer/xcode/target_validator_spec.rb
+13
-0
No files found.
CHANGELOG.md
View file @
19203fc0
...
...
@@ -12,6 +12,10 @@ To install release candidates run `[sudo] gem install cocoapods --pre`
dependency resolution.
[
Samuel Giddins
](
https://github.com/segiddins
)
*
Add support for source static library frameworks
[
Paul Beusterien
](
https://github.com/paulb777
)
[
#6811
](
https://github.com/CocoaPods/CocoaPods/pull/6811
)
##### Bug Fixes
*
None.
...
...
@@ -111,7 +115,6 @@ To install release candidates run `[sudo] gem install cocoapods --pre`
## 1.3.0.beta.2 (2017-06-22)
##### Enhancements
*
Add inputs and outputs for resources script phase
[
Dimitris Koutsogiorgas
](
https://github.com/dnkoutso
)
[
#6806
](
https://github.com/CocoaPods/CocoaPods/pull/6806
)
...
...
lib/cocoapods/installer/xcode/pods_project_generator.rb
View file @
19203fc0
...
...
@@ -225,12 +225,13 @@ module Pod
aggregate_target
.
native_target
.
add_dependency
(
pod_target
.
native_target
)
configure_app_extension_api_only_for_target
(
pod_target
)
if
is_app_extension
unless
pod_target
.
static_framework?
add_dependent_targets_to_native_target
(
pod_target
.
dependent_targets
,
pod_target
.
native_target
,
is_app_extension
,
pod_target
.
requires_frameworks?
,
frameworks_group
)
add_pod_target_test_dependencies
(
pod_target
,
frameworks_group
)
end
end
end
end
# @param [String] pod The root name of the development pod.
#
...
...
lib/cocoapods/installer/xcode/pods_project_generator/pod_target_installer.rb
View file @
19203fc0
...
...
@@ -25,7 +25,9 @@ module Pod
create_xcconfig_file
create_test_xcconfig_files
if
target
.
contains_test_specifications?
if
target
.
requires_frameworks?
unless
target
.
static_framework?
create_info_plist_file
end
create_module_map
create_umbrella_header
do
|
generator
|
file_accessors
=
target
.
file_accessors
...
...
@@ -39,6 +41,9 @@ module Pod
end
end
create_build_phase_to_symlink_header_folders
if
target
.
static_framework?
create_build_phase_to_move_static_framework_archive
end
end
create_prefix_header
create_dummy_source
...
...
@@ -388,6 +393,22 @@ module Pod
eos
end
# Creates a build phase to put the static framework archive in the appropriate framework location
# Since Xcode does not provide template support for static library frameworks, we've built a static library
# of the form lib{LibraryName}.a. We need to move that to the framework location -
# {LibraryName}.framework/{LibraryName}.
#
# @return [void]
#
def
create_build_phase_to_move_static_framework_archive
build_phase
=
native_target
.
new_shell_script_build_phase
(
'Setup Static Framework Archive'
)
build_phase
.
shell_script
=
<<-
eos
.
strip_heredoc
mkdir -p "${BUILT_PRODUCTS_DIR}/${PRODUCT_NAME}.framework/Modules"
cp "${BUILT_PRODUCTS_DIR}/lib${PRODUCT_NAME}.a" "${BUILT_PRODUCTS_DIR}/${PRODUCT_NAME}.framework/${PRODUCT_NAME}"
cp "${MODULEMAP_FILE}" "${BUILT_PRODUCTS_DIR}/${PRODUCT_NAME}.framework/Modules/module.modulemap"
eos
end
# Creates a prefix header file which imports `UIKit` or `Cocoa` according
# to the platform of the target. This file also include any prefix header
# content reported by the specification of the pods.
...
...
lib/cocoapods/installer/xcode/pods_project_generator/target_installer.rb
View file @
19203fc0
...
...
@@ -81,7 +81,11 @@ module Pod
end
if
target
.
requires_frameworks?
settings
[
'PRODUCT_NAME'
]
=
target
.
product_module_name
framework_name
=
target
.
product_module_name
settings
[
'PRODUCT_NAME'
]
=
framework_name
if
target
.
static_framework?
settings
[
'PUBLIC_HEADERS_FOLDER_PATH'
]
=
framework_name
+
'.framework'
+
'/Headers'
end
else
settings
.
merge!
(
'OTHER_LDFLAGS'
=>
''
,
'OTHER_LIBTOOLFLAGS'
=>
''
)
end
...
...
lib/cocoapods/installer/xcode/target_validator.rb
View file @
19203fc0
...
...
@@ -73,7 +73,7 @@ module Pod
aggregate_target
.
user_build_configurations
.
keys
.
each
do
|
config
|
pod_targets
=
aggregate_target
.
pod_targets_for_build_configuration
(
config
)
dependencies
=
pod_targets
.
select
(
&
:should_build?
).
flat_map
(
&
:dependencies
)
dependencies
=
pod_targets
.
select
(
&
:should_build?
).
reject
(
&
:static_framework?
).
flat_map
(
&
:dependencies
)
depended_upon_targets
=
pod_targets
.
select
{
|
t
|
dependencies
.
include?
(
t
.
pod_name
)
&&
!
t
.
should_build?
}
static_libs
=
depended_upon_targets
.
flat_map
(
&
:file_accessors
).
flat_map
(
&
:vendored_static_artifacts
)
...
...
lib/cocoapods/target.rb
View file @
19203fc0
...
...
@@ -72,7 +72,7 @@ module Pod
# #requires_frameworks?.
#
def
product_type
requires_frameworks?
?
:
framework
:
:static_library
requires_frameworks?
&&
!
static_framework?
?
:
framework
:
:static_library
end
# @return [String] A string suitable for debugging.
...
...
@@ -90,6 +90,12 @@ module Pod
host_requires_frameworks?
||
false
end
# @return [Boolean] Whether the target should build a static framework.
#
def
static_framework?
!
is_a?
(
Pod
::
AggregateTarget
)
&&
specs
.
any?
&&
specs
.
all?
(
&
:static_framework
)
end
#-------------------------------------------------------------------------#
# @!group Information storage
...
...
lib/cocoapods/target/pod_target.rb
View file @
19203fc0
...
...
@@ -219,7 +219,7 @@ module Pod
end
frameworks
<<
framework
end
if
should_build?
&&
requires_frameworks?
if
should_build?
&&
requires_frameworks?
&&
!
static_framework?
frameworks
<<
{
:name
=>
product_name
,
:input_path
=>
build_product_path
(
'${BUILT_PRODUCTS_DIR}'
),
:output_path
=>
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/
#{
product_name
}
"
}
...
...
spec/unit/installer/xcode/pods_project_generator/aggregate_target_installer_spec.rb
View file @
19203fc0
...
...
@@ -207,6 +207,16 @@ module Pod
script
.
read
.
should
.
not
.
include?
(
'BananaLib.framework'
)
end
it
'does not add pods to the embed frameworks script if they are static'
do
@pod_target
.
stubs
(
:static_framework?
=>
true
)
@pod_target
.
stubs
(
:requires_frameworks?
=>
true
)
@target
.
stubs
(
:requires_frameworks?
=>
true
)
@installer
.
install!
support_files_dir
=
config
.
sandbox
.
target_support_files_dir
(
'Pods-SampleProject'
)
script
=
support_files_dir
+
'Pods-SampleProject-frameworks.sh'
script
.
read
.
should
.
not
.
include?
(
'BananaLib.framework'
)
end
it
'creates the acknowledgements files '
do
@installer
.
install!
support_files_dir
=
config
.
sandbox
.
target_support_files_dir
(
'Pods-SampleProject'
)
...
...
spec/unit/installer/xcode/pods_project_generator/pod_target_installer_spec.rb
View file @
19203fc0
...
...
@@ -603,6 +603,18 @@ module Pod
end
build_phase
.
should
.
not
.
be
.
nil
end
it
'creates a build phase to set up a static library framework'
do
@pod_target
.
stubs
(
:static_framework?
).
returns
(
true
)
@installer
.
install!
target
=
@project
.
native_targets
.
first
build_phase
=
target
.
shell_script_build_phases
.
find
do
|
bp
|
bp
.
name
==
'Setup Static Framework Archive'
end
build_phase
.
should
.
not
.
be
.
nil
end
end
it
"doesn't create a build phase to symlink header folders by default on OS X"
do
...
...
spec/unit/installer/xcode/pods_project_generator/target_installer_spec.rb
View file @
19203fc0
...
...
@@ -60,6 +60,18 @@ module Pod
'AppStore'
=>
nil
,
}
end
it
'verify header path for a static library framework'
do
@pod_target
.
stubs
(
:requires_frameworks?
).
returns
(
true
)
@pod_target
.
stubs
(
:static_framework?
).
returns
(
true
)
@installer
.
send
(
:add_target
)
@installer
.
send
(
:native_target
).
resolved_build_setting
(
'PUBLIC_HEADERS_FOLDER_PATH'
).
should
==
{
'Release'
=>
'BananaLib.framework/Headers'
,
'Debug'
=>
'BananaLib.framework/Headers'
,
'Test'
=>
'BananaLib.framework/Headers'
,
'AppStore'
=>
'BananaLib.framework/Headers'
,
}
end
end
end
end
...
...
spec/unit/installer/xcode/target_validator_spec.rb
View file @
19203fc0
...
...
@@ -133,6 +133,7 @@ module Pod
project
'SampleProject/SampleProject'
use_frameworks!
pod
'BananaLib'
,
:path
=>
(
fixture_path
+
'banana-lib'
).
to_s
pod
'CoconutLib'
,
:path
=>
(
fixture_path
+
'coconut-lib'
).
to_s
pod
'OrangeFramework'
,
:path
=>
(
fixture_path
+
'orange-framework'
).
to_s
pod
'matryoshka'
,
:path
=>
(
fixture_path
+
'matryoshka'
).
to_s
pod
'monkey'
,
:path
=>
(
fixture_path
+
'monkey'
).
to_s
...
...
@@ -148,6 +149,11 @@ module Pod
end
it
'detects transitive static dependencies which are linked directly to the user target'
do
@validator
=
create_validator
(
config
.
sandbox
,
@podfile
,
@lockfile
)
should
.
raise
(
Informative
)
{
@validator
.
validate!
}.
message
.
should
.
match
/transitive.*monkey.a/
end
it
'detects transitive static dependencies which are linked directly to the user target with stubbing'
do
Sandbox
::
FileAccessor
.
any_instance
.
stubs
(
:vendored_libraries
).
returns
([
@lib_thing
])
@validator
=
create_validator
(
config
.
sandbox
,
@podfile
,
@lockfile
)
should
.
raise
(
Informative
)
{
@validator
.
validate!
}.
message
.
should
.
match
/transitive.*libThing/
...
...
@@ -166,6 +172,13 @@ module Pod
@validator
=
create_validator
(
config
.
sandbox
,
@podfile
,
@lockfile
)
should
.
not
.
raise
(
Informative
)
{
@validator
.
validate!
}
end
it
'allows transitive static dependencies when building a static framework'
do
PodTarget
.
any_instance
.
stubs
(
:static_framework?
=>
true
)
Sandbox
::
FileAccessor
.
any_instance
.
stubs
(
:vendored_libraries
).
returns
([
@lib_thing
])
@validator
=
create_validator
(
config
.
sandbox
,
@podfile
,
@lockfile
)
should
.
not
.
raise
(
Informative
)
{
@validator
.
validate!
}
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