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
21af2670
Commit
21af2670
authored
Nov 14, 2012
by
Fabio Pelosin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Core Extraction] Adapted Target Installer (with clean up).
parent
39f80935
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
133 additions
and
90 deletions
+133
-90
copy_resources_script.rb
lib/cocoapods/generator/copy_resources_script.rb
+1
-1
target_installer.rb
lib/cocoapods/installer/target_installer.rb
+0
-0
spec_helper.rb
spec/spec_helper.rb
+2
-1
target_installer_spec.rb
spec/unit/installer/target_installer_spec.rb
+130
-88
No files found.
lib/cocoapods/generator/copy_resources_script.rb
View file @
21af2670
...
@@ -26,7 +26,7 @@ EOS
...
@@ -26,7 +26,7 @@ EOS
attr_reader
:resources
attr_reader
:resources
# A list of files relative to the project pods root.
# A list of files relative to the project pods root.
def
initialize
(
resources
)
def
initialize
(
resources
=
[]
)
@resources
=
resources
@resources
=
resources
end
end
...
...
lib/cocoapods/installer/target_installer.rb
View file @
21af2670
This diff is collapsed.
Click to expand it.
spec/spec_helper.rb
View file @
21af2670
...
@@ -44,7 +44,7 @@ config = Pod::Config.instance
...
@@ -44,7 +44,7 @@ config = Pod::Config.instance
config
.
silent
=
true
config
.
silent
=
true
config
.
repos_dir
=
SpecHelper
.
tmp_repos_path
config
.
repos_dir
=
SpecHelper
.
tmp_repos_path
config
.
project_root
=
SpecHelper
.
temporary_directory
config
.
project_root
=
SpecHelper
.
temporary_directory
Pod
::
Specification
::
Statistics
.
instance
.
cache_file
=
nil
Pod
::
Specification
::
S
et
::
S
tatistics
.
instance
.
cache_file
=
nil
require
'tmpdir'
require
'tmpdir'
...
@@ -77,3 +77,4 @@ VCR.configure do |c|
...
@@ -77,3 +77,4 @@ VCR.configure do |c|
c
.
allow_http_connections_when_no_cassette
=
true
c
.
allow_http_connections_when_no_cassette
=
true
end
end
require
"active_support/core_ext/string/strip"
spec/unit/installer/target_installer_spec.rb
View file @
21af2670
require
File
.
expand_path
(
'../../../spec_helper'
,
__FILE__
)
require
File
.
expand_path
(
'../../../spec_helper'
,
__FILE__
)
TMP_POD_ROOT
=
ROOT
+
"tmp"
+
"podroot"
unless
defined?
TMP_POD_ROOT
describe
TargetInstaller
=
Pod
::
Installer
::
TargetInstaller
do
describe
"In general"
do
before
do
@podfile
=
Pod
::
Podfile
.
new
do
platform
:ios
end
@target_definition
=
@podfile
.
target_definitions
[
:default
]
@project
=
Pod
::
Project
.
new
(
config
.
sandbox
)
@specification
=
fixture_spec
(
'banana-lib/BananaLib.podspec'
)
@pods
=
[
Pod
::
LocalPod
.
new
(
@specification
,
config
.
sandbox
,
Pod
::
Platform
.
ios
)]
@installer
=
TargetInstaller
.
new
(
@project
,
@target_definition
,
@pods
,)
end
describe
Pod
::
Installer
::
TargetInstaller
do
it
"returns the project"
do
extend
SpecHelper
::
TemporaryDirectory
@installer
.
project
.
should
==
@project
end
before
do
it
"returns the target_definition"
do
@podfile
=
Pod
::
Podfile
.
new
do
@installer
.
target_definition
.
should
==
@target_definition
platform
:ios
xcodeproj
'dummy'
end
end
@target_definition
=
@podfile
.
target_definitions
[
:default
]
@project
=
Pod
::
Project
.
new
it
"returns the pods of the target definition"
do
@project
.
new_group
(
'Targets Support Files'
)
@installer
.
pods
.
should
==
@pods
end
end
@installer
=
Pod
::
Installer
::
TargetInstaller
.
new
(
@podfile
,
@project
,
@target_definition
)
describe
"Installation"
do
extend
SpecHelper
::
TemporaryDirectory
before
do
@podfile
=
Pod
::
Podfile
.
new
do
platform
:ios
xcodeproj
'dummy'
end
@target_definition
=
@podfile
.
target_definitions
[
:default
]
@project
=
Pod
::
Project
.
new
(
config
.
sandbox
)
specification
=
fixture_spec
(
'banana-lib/BananaLib.podspec'
)
@pod
=
Pod
::
LocalPod
.
new
(
specification
,
config
.
sandbox
,
@target_definition
.
platform
)
@installer
=
TargetInstaller
.
new
(
@project
,
@target_definition
,
[
@pod
])
specification
.
prefix_header_contents
=
'#import "BlocksKit.h"'
@pod
.
stubs
(
:root
).
returns
(
Pathname
.
new
(
fixture
(
'banana-lib'
)))
end
@sandbox
=
Pod
::
Sandbox
.
new
(
TMP_POD_ROOT
)
def
do_install!
FileUtils
.
cp_r
(
fixture
(
'banana-lib'
),
TMP_POD_ROOT
+
'BananaLib'
)
# Prevent raise for missing dummy project.
@specification
=
fixture_spec
(
'banana-lib/BananaLib.podspec'
)
Pathname
.
any_instance
.
stubs
(
:exist?
).
returns
(
true
)
@pods
=
[
Pod
::
LocalPod
.
new
(
@specification
,
@sandbox
,
Pod
::
Platform
.
ios
)]
@pod
.
add_file_references_to_project
(
@project
)
end
@installer
.
install
end
def
do_install!
it
'adds a new static library target to the project'
do
@pods
.
each
{
|
pod
|
pod
.
add_file_references_to_project
(
@project
)
}
do_install!
@installer
.
install!
(
@pods
,
@sandbox
)
@project
.
targets
.
count
.
should
==
1
end
@project
.
targets
.
first
.
name
.
should
==
@target_definition
.
label
end
it
'adds a new static library target to the project
'
do
it
'adds the source files of each pod to the target of the Pod library
'
do
do_install!
do_install!
@project
.
targets
.
count
.
should
==
1
names
=
@installer
.
target
.
source_build_phase
.
files
.
map
{
|
bf
|
bf
.
file_ref
.
name
}
@project
.
targets
.
first
.
name
.
should
==
@target_definition
.
label
names
.
should
==
[
"Banana.m"
]
end
end
it
"adds the user's build configurations to the target"
do
it
"adds file references for the support files of the target"
do
@project
.
user_build_configurations
=
{
'Debug'
=>
:debug
,
'Release'
=>
:release
,
'AppStore'
=>
:release
,
'Test'
=>
:debug
}
do_install!
do_install!
group
=
@project
.
support_files_group
[
'Pods'
]
@project
.
targets
.
first
.
build_configurations
.
map
(
&
:name
).
sort
.
should
==
%w{ AppStore Debug Release Test }
group
.
children
.
map
(
&
:display_name
).
sort
.
should
==
[
end
"Pods-prefix.pch"
,
"Pods-resources.sh"
,
"Pods.xcconfig"
]
end
it
'adds each pod to the static library target'
do
#--------------------------------------#
@pods
[
0
].
expects
(
:add_build_files_to_target
)
do_install!
it
"adds the user's build configurations to the target"
do
end
@project
.
user_build_configurations
=
{
'Debug'
=>
:debug
,
'Release'
=>
:release
,
'AppStore'
=>
:release
,
'Test'
=>
:debug
}
do_install!
@project
.
targets
.
first
.
build_configurations
.
map
(
&
:name
).
sort
.
should
==
%w{ AppStore Debug Release Test }
end
# TODO: move to project
it
'adds the sandbox header search paths to the xcconfig, with quotes'
do
# it 'tells each pod to link its headers' do
do_install!
# @pods[0].expects(:link_headers)
@installer
.
library
.
xcconfig
.
to_hash
[
'PODS_BUILD_HEADERS_SEARCH_PATHS'
].
should
.
include
(
"
\"
#{
config
.
sandbox
.
build_headers
.
search_paths
.
join
(
'" "'
)
}
\"
"
)
# do_install!
end
# end
it
'adds the sandbox header search paths to the xcconfig, with quotes
'
do
it
'does not add the -fobjc-arc to OTHER_LDFLAGS by default as Xcode 4.3.2 does not support it
'
do
do_install!
do_install!
@installer
.
xcconfig
.
to_hash
[
'PODS_BUILD_HEADERS_SEARCH_PATHS'
].
should
.
include
(
"
\"
#{
@sandbox
.
build_headers
.
search_paths
.
join
(
'" "'
)
}
\"
"
)
@installer
.
library
.
xcconfig
.
to_hash
[
'OTHER_LDFLAGS'
].
split
(
" "
).
should
.
not
.
include
(
"-fobjc-arc
"
)
end
end
it
'does not add the -fobjc-arc to OTHER_LDFLAGS by default as Xcode 4.3.2 does not support it'
do
it
'adds the -fobjc-arc to OTHER_LDFLAGS if any pods require arc (to support non-ARC projects on iOS 4.0)'
do
do_install!
Pod
::
Podfile
.
any_instance
.
stubs
(
:set_arc_compatibility_flag?
=>
true
)
@installer
.
xcconfig
.
to_hash
[
'OTHER_LDFLAGS'
].
split
(
" "
).
should
.
not
.
include
(
"-fobjc-arc"
)
@pod
.
top_specification
.
stubs
(
:requires_arc
).
returns
(
true
)
end
do_install!
@installer
.
library
.
xcconfig
.
to_hash
[
'OTHER_LDFLAGS'
].
split
(
" "
).
should
.
include
(
"-fobjc-arc"
)
end
it
'adds the -fobjc-arc to OTHER_LDFLAGS if any pods require arc (to support non-ARC projects on iOS 4.0)'
do
it
"does not enable the GCC_WARN_INHIBIT_ALL_WARNINGS flag by default"
do
@podfile
.
stubs
(
:set_arc_compatibility_flag?
=>
true
)
do_install!
@specification
.
stubs
(
:requires_arc
).
returns
(
true
)
@installer
.
target
.
build_configurations
.
each
do
|
config
|
do_install!
config
.
build_settings
[
'GCC_WARN_INHIBIT_ALL_WARNINGS'
].
should
==
'NO'
@installer
.
xcconfig
.
to_hash
[
'OTHER_LDFLAGS'
].
split
(
" "
).
should
.
include
(
"-fobjc-arc"
)
end
end
end
it
"does not enable the GCC_WARN_INHIBIT_ALL_WARNINGS flag by default"
do
it
"enables the GCC_WARN_INHIBIT_ALL_WARNINGS flag"
do
do_install!
@podfile
.
inhibit_all_warnings!
@installer
.
target
.
build_configurations
.
each
do
|
config
|
do_install!
config
.
build_settings
[
'GCC_WARN_INHIBIT_ALL_WARNINGS'
].
should
==
'NO'
@installer
.
target
.
build_configurations
.
each
do
|
config
|
config
.
build_settings
[
'GCC_WARN_INHIBIT_ALL_WARNINGS'
].
should
==
'YES'
end
end
end
end
it
"enables the GCC_WARN_INHIBIT_ALL_WARNINGS flag"
do
it
"creates and xcconfig file"
do
@podfile
.
inhibit_all_warnings!
do_install!
do_install!
xcconfig
=
config
.
sandbox
.
root
+
'Pods.xcconfig'
@installer
.
target
.
build_configurations
.
each
do
|
config
|
xcconfig
.
read
.
should
==
<<-
EOS
.
strip_heredoc
.
gsub
(
/\n$/
,
''
)
config
.
build_settings
[
'GCC_WARN_INHIBIT_ALL_WARNINGS'
].
should
==
'YES'
ALWAYS_SEARCH_USER_PATHS = YES
OTHER_LDFLAGS = -ObjC -framework SystemConfiguration
HEADER_SEARCH_PATHS = ${PODS_HEADERS_SEARCH_PATHS}
PODS_ROOT = ${SRCROOT}/Pods
PODS_BUILD_HEADERS_SEARCH_PATHS = "${PODS_ROOT}/BuildHeaders"
PODS_PUBLIC_HEADERS_SEARCH_PATHS = "${PODS_ROOT}/Headers"
PODS_HEADERS_SEARCH_PATHS = ${PODS_PUBLIC_HEADERS_SEARCH_PATHS}
EOS
end
end
end
it
"creates a prefix header, including the contents of the specification's prefix header file
"
do
it
"creates a prefix header, including the contents of the specification's prefix header
"
do
do_install!
@pod
.
top_specification
.
prefix_header_contents
=
'#import "BlocksKit.h"'
prefix_header
=
@sandbox
.
root
+
'Pods.pch'
do_install!
@installer
.
save_prefix_header_as
(
prefix_header
,
@pods
)
prefix_header
=
config
.
sandbox
.
root
+
'Pods-prefix.pch'
prefix_header
.
read
.
should
==
<<-
EOS
prefix_header
.
read
.
should
==
<<-
EOS
.
strip_heredoc
#ifdef __OBJC__
#ifdef __OBJC__
#import <UIKit/UIKit.h>
#import <UIKit/UIKit.h>
#endif
#endif
#import <BananaTree/BananaTree.h>
#import "BlocksKit.h"
EOS
EOS
end
end
it
"creates a prefix header, including the contents of the specification's prefix header"
do
it
"creates a bridge support file"
do
do_install!
Pod
::
Podfile
.
any_instance
.
stubs
(
:generate_bridge_support?
=>
true
)
prefix_header
=
@sandbox
.
root
+
'Pods.pch'
Pod
::
Generator
::
BridgeSupport
.
any_instance
.
expects
(
:save_as
).
once
@specification
.
prefix_header_contents
=
'#import "BlocksKit.h"'
do_install!
@installer
.
save_prefix_header_as
(
prefix_header
,
@pods
)
end
prefix_header
.
read
.
should
==
<<-
EOS
#ifdef __OBJC__
it
"creates a create copy resources script"
do
#import <UIKit/UIKit.h>
do_install!
#endif
script
=
config
.
sandbox
.
root
+
'Pods-resources.sh'
script
.
read
.
should
.
include?
(
'logo-sidebar.png'
)
#import "BlocksKit.h"
end
EOS
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