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
fcdc97c7
Commit
fcdc97c7
authored
May 08, 2015
by
Marius Rackwitz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[PodTarget] Allow to be scoped
parent
8b972f10
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
202 additions
and
69 deletions
+202
-69
pod_target.rb
lib/cocoapods/target/pod_target.rb
+8
-0
module_map_spec.rb
spec/unit/generator/module_map_spec.rb
+2
-2
aggregate_xcconfig_spec.rb
spec/unit/generator/xcconfig/aggregate_xcconfig_spec.rb
+41
-8
pod_target_installer_spec.rb
...t/installer/target_installer/pod_target_installer_spec.rb
+89
-44
installer_spec.rb
spec/unit/installer_spec.rb
+9
-5
pod_target_spec.rb
spec/unit/target/pod_target_spec.rb
+53
-10
No files found.
lib/cocoapods/target/pod_target.rb
View file @
fcdc97c7
...
...
@@ -30,6 +30,14 @@ module Pod
@resource_bundle_targets
=
[]
end
# @return [PodTarget] the same target, but scoped.
#
def
scoped
clone
.
tap
do
|
scoped_target
|
scoped_target
.
scoped
=
true
end
end
# @return [String] the label for the target.
#
def
label
...
...
spec/unit/generator/module_map_spec.rb
View file @
fcdc97c7
...
...
@@ -14,7 +14,7 @@ module Pod
@gen
.
save_as
(
path
)
path
.
read
.
should
==
<<-
EOS
.
strip_heredoc
framework module BananaLib {
umbrella header "
Pods-default-
BananaLib-umbrella.h"
umbrella header "BananaLib-umbrella.h"
export *
module * { export * }
...
...
@@ -26,7 +26,7 @@ module Pod
@gen
.
stubs
(
:private_headers
).
returns
([
'Private.h'
])
@gen
.
generate
.
should
==
<<-
EOS
.
strip_heredoc
framework module BananaLib {
umbrella header "
Pods-default-
BananaLib-umbrella.h"
umbrella header "BananaLib-umbrella.h"
export *
module * { export * }
...
...
spec/unit/generator/xcconfig/aggregate_xcconfig_spec.rb
View file @
fcdc97c7
...
...
@@ -8,9 +8,13 @@ module Pod
fixture_spec
(
'banana-lib/BananaLib.podspec'
)
end
def
pod_target
(
spec
)
fixture_pod_target
(
spec
)
end
before
do
@spec
=
spec
@pod_target
=
fixture_
pod_target
(
@spec
)
@pod_target
=
pod_target
(
@spec
)
@consumer
=
@pod_target
.
spec_consumers
.
last
@target
=
fixture_aggregate_target
([
@pod_target
])
@target
.
target_definition
.
should
==
@pod_target
.
target_definition
...
...
@@ -103,8 +107,20 @@ module Pod
@xcconfig
.
to_hash
[
'OTHER_CFLAGS'
].
should
==
expected
end
it
'links the pod targets with the aggregate target'
do
@xcconfig
.
to_hash
[
'OTHER_LDFLAGS'
].
should
.
include
'-l"Pods-BananaLib"'
describe
'with a scoped pod target'
do
def
pod_target
(
spec
)
fixture_pod_target
(
spec
).
scoped
end
it
'links the pod targets with the aggregate target'
do
@xcconfig
.
to_hash
[
'OTHER_LDFLAGS'
].
should
.
include
'-l"Pods-BananaLib"'
end
end
describe
'with an unscoped pod target'
do
it
'links the pod targets with the aggregate target'
do
@xcconfig
.
to_hash
[
'OTHER_LDFLAGS'
].
should
.
include
'-l"BananaLib"'
end
end
it
'does not links the pod targets with the aggregate target for non-whitelisted configuration'
do
...
...
@@ -139,13 +155,30 @@ module Pod
@xcconfig
.
to_hash
[
'PODS_FRAMEWORK_BUILD_PATH'
].
should
==
'$(BUILD_DIR)/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)/Pods'
end
it
'adds the framework build path to the xcconfig, with quotes, as framework search paths'
do
@xcconfig
.
to_hash
[
'FRAMEWORK_SEARCH_PATHS'
].
should
==
'$(inherited) "$PODS_FRAMEWORK_BUILD_PATH"'
describe
'with a scoped pod target'
do
def
pod_target
(
spec
)
fixture_pod_target
(
spec
).
scoped
end
it
'adds the framework build path to the xcconfig, with quotes, as framework search paths'
do
@xcconfig
.
to_hash
[
'FRAMEWORK_SEARCH_PATHS'
].
should
==
'$(inherited) "$PODS_FRAMEWORK_BUILD_PATH"'
end
it
'adds the framework header paths to the xcconfig, with quotes, as local headers'
do
expected
=
'$(inherited) -iquote "$PODS_FRAMEWORK_BUILD_PATH/OrangeFramework.framework/Headers"'
@xcconfig
.
to_hash
[
'OTHER_CFLAGS'
].
should
==
expected
end
end
it
'adds the framework header paths to the xcconfig, with quotes, as local headers'
do
expected
=
'$(inherited) -iquote "$PODS_FRAMEWORK_BUILD_PATH/OrangeFramework.framework/Headers"'
@xcconfig
.
to_hash
[
'OTHER_CFLAGS'
].
should
==
expected
describe
'with an unscoped pod target'
do
it
'adds the framework build path to the xcconfig, with quotes, as framework search paths'
do
@xcconfig
.
to_hash
[
'FRAMEWORK_SEARCH_PATHS'
].
should
.
be
.
nil
end
it
'adds the framework header paths to the xcconfig, with quotes, as local headers'
do
expected
=
'$(inherited) -iquote "$CONFIGURATION_BUILD_DIR/OrangeFramework.framework/Headers"'
@xcconfig
.
to_hash
[
'OTHER_CFLAGS'
].
should
==
expected
end
end
it
'links the pod targets with the aggregate target'
do
...
...
spec/unit/installer/target_installer/pod_target_installer_spec.rb
View file @
fcdc97c7
...
...
@@ -34,26 +34,6 @@ module Pod
@spec
.
prefix_header_contents
=
'#import "BlocksKit.h"'
end
it
'adds file references for the support files of the target'
do
@installer
.
install!
@project
.
support_files_group
group
=
@project
[
'Pods/BananaLib/Support Files'
]
group
.
children
.
map
(
&
:display_name
).
sort
.
should
==
[
'Pods-BananaLib-Private.xcconfig'
,
'Pods-BananaLib-dummy.m'
,
'Pods-BananaLib-prefix.pch'
,
'Pods-BananaLib.xcconfig'
,
]
end
#--------------------------------------#
it
'adds the target for the static library to the project'
do
@installer
.
install!
@project
.
targets
.
count
.
should
==
1
@project
.
targets
.
first
.
name
.
should
==
'Pods-BananaLib'
end
it
'sets the platform and the deployment target for iOS targets'
do
@installer
.
install!
target
=
@project
.
targets
.
first
...
...
@@ -100,15 +80,6 @@ module Pod
#--------------------------------------#
it
'adds the resource bundle targets'
do
@pod_target
.
file_accessors
.
first
.
stubs
(
:resource_bundles
).
returns
(
'banana_bundle'
=>
[])
@installer
.
install!
bundle_target
=
@project
.
targets
.
find
{
|
t
|
t
.
name
==
'Pods-BananaLib-banana_bundle'
}
bundle_target
.
should
.
be
.
an
.
instance_of
Xcodeproj
::
Project
::
Object
::
PBXNativeTarget
bundle_target
.
product_reference
.
name
.
should
==
'banana_bundle.bundle'
bundle_target
.
product_reference
.
path
.
should
==
'banana_bundle.bundle'
end
it
'adds framework resources to the framework target'
do
@pod_target
.
stubs
(
:requires_frameworks?
=>
true
)
@installer
.
install!
...
...
@@ -118,14 +89,91 @@ module Pod
resource
.
should
.
be
.
not
.
nil
end
it
'adds the build configurations to the resources bundle targets'
do
@pod_target
.
file_accessors
.
first
.
stubs
(
:resource_bundles
).
returns
(
'banana_bundle'
=>
[])
@installer
.
install!
bundle_target
=
@project
.
targets
.
find
{
|
t
|
t
.
name
==
'Pods-BananaLib-banana_bundle'
}
#--------------------------------------#
file
=
config
.
sandbox
.
root
+
@pod_target
.
xcconfig_private_path
bundle_target
.
build_configurations
.
each
do
|
bc
|
bc
.
base_configuration_reference
.
real_path
.
should
==
file
describe
'with a scoped pod target'
do
before
do
@pod_target
.
scoped
=
true
end
it
'adds file references for the support files of the target'
do
@installer
.
install!
@project
.
support_files_group
group
=
@project
[
'Pods/BananaLib/Support Files'
]
group
.
children
.
map
(
&
:display_name
).
sort
.
should
==
[
'Pods-BananaLib-Private.xcconfig'
,
'Pods-BananaLib-dummy.m'
,
'Pods-BananaLib-prefix.pch'
,
'Pods-BananaLib.xcconfig'
,
]
end
it
'adds the target for the static library to the project'
do
@installer
.
install!
@project
.
targets
.
count
.
should
==
1
@project
.
targets
.
first
.
name
.
should
==
'Pods-BananaLib'
end
it
'adds the resource bundle targets'
do
@pod_target
.
file_accessors
.
first
.
stubs
(
:resource_bundles
).
returns
(
'banana_bundle'
=>
[])
@installer
.
install!
bundle_target
=
@project
.
targets
.
find
{
|
t
|
t
.
name
==
'Pods-BananaLib-banana_bundle'
}
bundle_target
.
should
.
be
.
an
.
instance_of
Xcodeproj
::
Project
::
Object
::
PBXNativeTarget
bundle_target
.
product_reference
.
name
.
should
==
'banana_bundle.bundle'
bundle_target
.
product_reference
.
path
.
should
==
'banana_bundle.bundle'
end
it
'adds the build configurations to the resources bundle targets'
do
@pod_target
.
file_accessors
.
first
.
stubs
(
:resource_bundles
).
returns
(
'banana_bundle'
=>
[])
@installer
.
install!
bundle_target
=
@project
.
targets
.
find
{
|
t
|
t
.
name
==
'Pods-BananaLib-banana_bundle'
}
file
=
config
.
sandbox
.
root
+
@pod_target
.
xcconfig_private_path
bundle_target
.
build_configurations
.
each
do
|
bc
|
bc
.
base_configuration_reference
.
real_path
.
should
==
file
end
end
end
#--------------------------------------#
describe
'with an unscoped pod target'
do
it
'adds file references for the support files of the target'
do
@installer
.
install!
@project
.
support_files_group
group
=
@project
[
'Pods/BananaLib/Support Files'
]
group
.
children
.
map
(
&
:display_name
).
sort
.
should
==
[
'BananaLib-Private.xcconfig'
,
'BananaLib-dummy.m'
,
'BananaLib-prefix.pch'
,
'BananaLib.xcconfig'
,
]
end
it
'adds the target for the static library to the project'
do
@installer
.
install!
@project
.
targets
.
count
.
should
==
1
@project
.
targets
.
first
.
name
.
should
==
'BananaLib'
end
it
'adds the resource bundle targets'
do
@pod_target
.
file_accessors
.
first
.
stubs
(
:resource_bundles
).
returns
(
'banana_bundle'
=>
[])
@installer
.
install!
bundle_target
=
@project
.
targets
.
find
{
|
t
|
t
.
name
==
'BananaLib-banana_bundle'
}
bundle_target
.
should
.
be
.
an
.
instance_of
Xcodeproj
::
Project
::
Object
::
PBXNativeTarget
bundle_target
.
product_reference
.
name
.
should
==
'banana_bundle.bundle'
bundle_target
.
product_reference
.
path
.
should
==
'banana_bundle.bundle'
end
it
'adds the build configurations to the resources bundle targets'
do
@pod_target
.
file_accessors
.
first
.
stubs
(
:resource_bundles
).
returns
(
'banana_bundle'
=>
[])
@installer
.
install!
bundle_target
=
@project
.
targets
.
find
{
|
t
|
t
.
name
==
'BananaLib-banana_bundle'
}
file
=
config
.
sandbox
.
root
+
@pod_target
.
xcconfig_private_path
bundle_target
.
build_configurations
.
each
do
|
bc
|
bc
.
base_configuration_reference
.
real_path
.
should
==
file
end
end
end
...
...
@@ -141,9 +189,7 @@ module Pod
it
"creates a prefix header, including the contents of the specification's prefix header"
do
@spec
.
prefix_header_contents
=
'#import "BlocksKit.h"'
@installer
.
install!
support_files_dir
=
config
.
sandbox
.
target_support_files_dir
(
'Pods-BananaLib'
)
prefix_header
=
support_files_dir
+
'Pods-BananaLib-prefix.pch'
generated
=
prefix_header
.
read
generated
=
@pod_target
.
prefix_header_path
.
read
expected
=
<<-
EOS
.
strip_heredoc
#ifdef __OBJC__
#import <UIKit/UIKit.h>
...
...
@@ -157,13 +203,12 @@ module Pod
it
'creates a dummy source to ensure the compilation of libraries with only categories'
do
@installer
.
install!
dummy_source_basename
=
@pod_target
.
dummy_source_path
.
basename
.
to_s
build_files
=
@installer
.
target
.
native_target
.
source_build_phase
.
files
build_file
=
build_files
.
find
{
|
bf
|
bf
.
file_ref
.
display_name
==
'Pods-BananaLib-dummy.m'
}
build_file
=
build_files
.
find
{
|
bf
|
bf
.
file_ref
.
display_name
==
dummy_source_basename
}
build_file
.
should
.
be
.
not
.
nil
build_file
.
file_ref
.
path
.
should
==
'Pods-BananaLib-dummy.m'
support_files_dir
=
config
.
sandbox
.
target_support_files_dir
(
'Pods-BananaLib'
)
dummy
=
support_files_dir
+
'Pods-BananaLib-dummy.m'
dummy
.
read
.
should
.
include?
(
'@interface PodsDummy_Pods'
)
build_file
.
file_ref
.
path
.
should
==
dummy_source_basename
@pod_target
.
dummy_source_path
.
read
.
should
.
include?
(
'@interface PodsDummy_BananaLib'
)
end
#--------------------------------------------------------------------------------#
...
...
spec/unit/installer_spec.rb
View file @
fcdc97c7
...
...
@@ -130,6 +130,10 @@ module Pod
pod
'BananaLib'
,
:path
=>
(
fixture_path
+
'banana-lib'
).
to_s
pod
'OrangeFramework'
,
:path
=>
(
fixture_path
+
'orange-framework'
).
to_s
pod
'monkey'
,
:path
=>
(
fixture_path
+
'monkey'
).
to_s
target
'TestRunner'
,
:exclusive
=>
true
do
pod
'monkey'
,
:path
=>
(
fixture_path
+
'monkey'
).
to_s
end
end
lockfile
=
generate_lockfile
config
.
integrate_targets
=
false
...
...
@@ -140,9 +144,9 @@ module Pod
target
=
@installer
.
aggregate_targets
.
first
target
.
requires_frameworks?
.
should
==
true
target
.
pod_targets
.
select
(
&
:requires_frameworks?
).
map
(
&
:name
).
sort
.
should
==
[
'
Pods-
BananaLib'
,
'
Pods-
OrangeFramework'
,
'
Pods-
monkey'
,
'BananaLib'
,
'OrangeFramework'
,
'monkey'
,
]
end
end
...
...
@@ -261,7 +265,7 @@ module Pod
it
'stores the targets created by the analyzer'
do
@installer
.
send
(
:analyze
)
@installer
.
aggregate_targets
.
map
(
&
:name
).
sort
.
should
==
[
'Pods'
]
@installer
.
pod_targets
.
map
(
&
:name
).
sort
.
should
==
[
'
Pods-
JSONKit'
]
@installer
.
pod_targets
.
map
(
&
:name
).
sort
.
should
==
[
'JSONKit'
]
end
it
'configures the analyzer to use update mode if appropriate'
do
...
...
@@ -269,7 +273,7 @@ module Pod
Installer
::
Analyzer
.
any_instance
.
expects
(
:update
=
).
with
(
true
)
@installer
.
send
(
:analyze
)
@installer
.
aggregate_targets
.
map
(
&
:name
).
sort
.
should
==
[
'Pods'
]
@installer
.
pod_targets
.
map
(
&
:name
).
sort
.
should
==
[
'
Pods-
JSONKit'
]
@installer
.
pod_targets
.
map
(
&
:name
).
sort
.
should
==
[
'JSONKit'
]
end
end
...
...
spec/unit/target/pod_target_spec.rb
View file @
fcdc97c7
...
...
@@ -9,17 +9,34 @@ module Pod
@pod_target
.
stubs
(
:platform
).
returns
(
:ios
)
end
describe
'Meta'
do
describe
'#scoped'
do
it
'returns a cloned target, which is scoped'
do
@pod_target
.
should
.
not
.
be
.
scoped
@pod_target
.
scoped
.
should
.
be
.
scoped
@pod_target
.
should
.
not
.
be
.
scoped
end
end
end
describe
'In general'
do
it
'returns the target_definition that generated it'
do
@pod_target
.
target_definition
.
should
==
@target_definition
end
it
'returns its name'
do
@pod_target
.
name
.
should
==
'Pods-BananaLib'
@pod_target
.
name
.
should
==
'BananaLib'
@pod_target
.
scoped
.
name
.
should
==
'Pods-BananaLib'
end
it
'returns its label'
do
@pod_target
.
label
.
should
==
'BananaLib'
@pod_target
.
scoped
.
label
.
should
==
'Pods-BananaLib'
end
it
'returns the name of its product'
do
@pod_target
.
product_name
.
should
==
'libPods-BananaLib.a'
@pod_target
.
product_name
.
should
==
'libBananaLib.a'
@pod_target
.
scoped
.
product_name
.
should
==
'libPods-BananaLib.a'
end
it
'returns the spec consumers for the pod targets'
do
...
...
@@ -35,7 +52,8 @@ module Pod
end
it
'returns the name of the resources bundle target'
do
@pod_target
.
resources_bundle_target_label
(
'Fruits'
).
should
==
'Pods-BananaLib-Fruits'
@pod_target
.
resources_bundle_target_label
(
'Fruits'
).
should
==
'BananaLib-Fruits'
@pod_target
.
scoped
.
resources_bundle_target_label
(
'Fruits'
).
should
==
'Pods-BananaLib-Fruits'
end
it
'returns the name of the Pods on which this target depends'
do
...
...
@@ -84,40 +102,61 @@ module Pod
describe
'Support files'
do
it
'returns the absolute path of the xcconfig file'
do
@pod_target
.
xcconfig_path
(
'Release'
).
to_s
.
should
.
include?
(
'Pods/Target Support Files/BananaLib/BananaLib.release.xcconfig'
,
)
@pod_target
.
scoped
.
xcconfig_path
(
'Release'
).
to_s
.
should
.
include?
(
'Pods/Target Support Files/Pods-BananaLib/Pods-BananaLib.release.xcconfig'
,
)
end
it
'escapes the file separators in variant build configuration name in the xcconfig file'
do
@pod_target
.
xcconfig_path
(
"Release
#{
File
::
SEPARATOR
}
1"
).
to_s
.
should
.
include?
(
'Pods/Target Support Files/BananaLib/BananaLib.release-1.xcconfig'
,
)
@pod_target
.
scoped
.
xcconfig_path
(
"Release
#{
File
::
SEPARATOR
}
1"
).
to_s
.
should
.
include?
(
'Pods/Target Support Files/Pods-BananaLib/Pods-BananaLib.release-1.xcconfig'
,
)
end
it
'returns the absolute path of the prefix header file'
do
@pod_target
.
prefix_header_path
.
to_s
.
should
.
include?
(
'Pods/Target Support Files/BananaLib/BananaLib-prefix.pch'
,
)
@pod_target
.
scoped
.
prefix_header_path
.
to_s
.
should
.
include?
(
'Pods/Target Support Files/Pods-BananaLib/Pods-BananaLib-prefix.pch'
,
)
end
it
'returns the absolute path of the bridge support file'
do
@pod_target
.
bridge_support_path
.
to_s
.
should
.
include?
(
'Pods/Target Support Files/
Pods-BananaLib/Pods-
BananaLib.bridgesupport'
,
'Pods/Target Support Files/
BananaLib/
BananaLib.bridgesupport'
,
)
end
it
'returns the absolute path of the info plist file'
do
@pod_target
.
info_plist_path
.
to_s
.
should
.
include?
(
'Pods/Target Support Files/BananaLib/Info.plist'
,
)
@pod_target
.
scoped
.
info_plist_path
.
to_s
.
should
.
include?
(
'Pods/Target Support Files/Pods-BananaLib/Info.plist'
,
)
end
it
'returns the absolute path of the dummy source file'
do
@pod_target
.
dummy_source_path
.
to_s
.
should
.
include?
(
'Pods/Target Support Files/BananaLib/BananaLib-dummy.m'
,
)
@pod_target
.
scoped
.
dummy_source_path
.
to_s
.
should
.
include?
(
'Pods/Target Support Files/Pods-BananaLib/Pods-BananaLib-dummy.m'
,
)
end
it
'returns the absolute path of the public and private xcconfig files'
do
@pod_target
.
xcconfig_path
.
to_s
.
should
.
include?
(
'Pods/Target Support Files/
Pods-BananaLib/Pods-
BananaLib.xcconfig'
,
'Pods/Target Support Files/
BananaLib/
BananaLib.xcconfig'
,
)
@pod_target
.
xcconfig_private_path
.
to_s
.
should
.
include
(
'Pods/Target Support Files/
Pods-BananaLib/Pods-
BananaLib-Private.xcconfig'
,
'Pods/Target Support Files/
BananaLib/
BananaLib-Private.xcconfig'
,
)
end
...
...
@@ -150,7 +189,8 @@ module Pod
end
it
'returns the library name'
do
@pod_target
.
static_library_name
.
should
==
'libPods-BananaLib.a'
@pod_target
.
static_library_name
.
should
==
'libBananaLib.a'
@pod_target
.
scoped
.
static_library_name
.
should
==
'libPods-BananaLib.a'
end
it
'returns :framework as product type'
do
...
...
@@ -164,7 +204,8 @@ module Pod
describe
'Host does not requires frameworks'
do
it
'returns the product name'
do
@pod_target
.
product_name
.
should
==
'libPods-BananaLib.a'
@pod_target
.
product_name
.
should
==
'libBananaLib.a'
@pod_target
.
scoped
.
product_name
.
should
==
'libPods-BananaLib.a'
end
it
'returns the framework name'
do
...
...
@@ -172,7 +213,8 @@ module Pod
end
it
'returns the library name'
do
@pod_target
.
static_library_name
.
should
==
'libPods-BananaLib.a'
@pod_target
.
static_library_name
.
should
==
'libBananaLib.a'
@pod_target
.
scoped
.
static_library_name
.
should
==
'libPods-BananaLib.a'
end
it
'returns :static_library as product type'
do
...
...
@@ -208,7 +250,8 @@ module Pod
end
it
'returns the library name'
do
@pod_target
.
static_library_name
.
should
==
'libPods-OrangeFramework.a'
@pod_target
.
static_library_name
.
should
==
'libOrangeFramework.a'
@pod_target
.
scoped
.
static_library_name
.
should
==
'libPods-OrangeFramework.a'
end
it
'returns :framework as product type'
do
...
...
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