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
aa36ea80
Commit
aa36ea80
authored
Dec 19, 2012
by
Fabio Pelosin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added Generator::TargetHeader
- Needs a new name :-) - Closes #695
parent
edb8860a
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
192 additions
and
81 deletions
+192
-81
CHANGELOG.md
CHANGELOG.md
+7
-6
cocoapods.rb
lib/cocoapods.rb
+4
-3
acknowledgements.rb
lib/cocoapods/generator/acknowledgements.rb
+0
-6
prefix_header.rb
lib/cocoapods/generator/prefix_header.rb
+12
-5
target_header.rb
lib/cocoapods/generator/target_header.rb
+57
-0
target_installer.rb
lib/cocoapods/installer/target_installer.rb
+16
-2
library.rb
lib/cocoapods/library.rb
+33
-38
prefix_header_spec.rb
spec/unit/generator/prefix_header_spec.rb
+12
-0
target_header_spec.rb
spec/unit/generator/target_header_spec.rb
+20
-0
target_installer_spec.rb
spec/unit/installer/target_installer_spec.rb
+17
-6
library_spec.rb
spec/unit/library_spec.rb
+14
-15
No files found.
CHANGELOG.md
View file @
aa36ea80
...
...
@@ -5,13 +5,14 @@
###### TODO
-
Add Rake FileList warning.
-
Rake FileList is not working.
-
Enable CocoaPods Core-warnings
-
LocalPod should return a has for the resources.
-
FileList is not working.
-
Bad bug with Specification default values being corroded exponentially in subsequent calls.
-
Dropped script for resources.
-
Added support for
`prefix_header_file`
in subspecs
-
Added support for
`prefix_header_contents`
in subspecs
-
Drop script for resources.?
-
Add support for
`prefix_header_file`
in subspecs
-
Add support for
`prefix_header_contents`
in subspecs
-
Add Rake FileList warning.
-
Release: Enable CocoaPods Core-warnings
###### Specification DSL
...
...
lib/cocoapods.rb
View file @
aa36ea80
...
...
@@ -35,14 +35,15 @@ module Pod
autoload
:Pathname
,
'pathname'
module
Generator
autoload
:Acknowledgements
,
'cocoapods/generator/acknowledgements'
autoload
:BridgeSupport
,
'cocoapods/generator/bridge_support'
autoload
:CopyResourcesScript
,
'cocoapods/generator/copy_resources_script'
autoload
:Documentation
,
'cocoapods/generator/documentation'
autoload
:Acknowledgements
,
'cocoapods/generator/acknowledgements'
autoload
:Plist
,
'cocoapods/generator/acknowledgements/plist'
autoload
:Markdown
,
'cocoapods/generator/acknowledgements/markdown'
autoload
:DummySource
,
'cocoapods/generator/dummy_source'
autoload
:Markdown
,
'cocoapods/generator/acknowledgements/markdown'
autoload
:Plist
,
'cocoapods/generator/acknowledgements/plist'
autoload
:PrefixHeader
,
'cocoapods/generator/prefix_header'
autoload
:TargetHeader
,
'cocoapods/generator/target_header'
autoload
:XCConfig
,
'cocoapods/generator/xcconfig'
end
...
...
lib/cocoapods/generator/acknowledgements.rb
View file @
aa36ea80
...
...
@@ -11,12 +11,6 @@ module Pod
@target_definition
,
@pods
=
target_definition
,
pods
end
def
save_as
(
path
)
Acknowledgements
.
generators
.
each
do
|
generator
|
generator
.
new
(
@target_definition
,
@pods
).
save_as
(
path
)
end
end
def
header_title
"Acknowledgements"
end
...
...
lib/cocoapods/generator/prefix_header.rb
View file @
aa36ea80
...
...
@@ -10,25 +10,28 @@ module Pod
class
PrefixHeader
# @return [Platform] the platform for which the prefix header will be
# generated.
#
generated.
#
attr_reader
:platform
# @return [Array<LocalPod>] the LocalPod for the target for which the
# prefix header needs to be generated.
#
prefix header needs to be generated.
#
attr_reader
:pods
# @return [Array<String>] any header to import (with quotes).
#
attr_reader
:imports
# @param [Platform] platform @see platform
# @param [Array<LocalPod>] pods @see pods
#
def
initialize
(
platform
,
pods
)
@platform
=
platform
@pods
=
pods
@pods
=
pods
@imports
=
[]
end
#--------------------------------------#
# Generates the contents of the prefix header according to the platform
# and the pods.
#
...
...
@@ -45,6 +48,10 @@ module Pod
result
<<
"#import
#{
platform
==
:ios
?
'<UIKit/UIKit.h>'
:
'<Cocoa/Cocoa.h>'
}
\n
"
result
<<
"#endif
\n
"
imports
.
each
do
|
import
|
result
<<
%|\n#import "#{import}"|
end
pods
.
each
do
|
pod
|
result
<<
"
\n
"
if
prefix_header_contents
=
pod
.
top_specification
.
prefix_header_contents
...
...
lib/cocoapods/generator/target_header.rb
0 → 100644
View file @
aa36ea80
module
Pod
module
Generator
# Generates a header which allows to inspect at compile time the installed
# pods and the installed specifications of a pod.
#
# Example output:
#
# #define __COCOA_PODS
#
# #define __POD_AFIncrementaStore
# #define __POD_AFNetworking
# #define __POD_libextobjc_EXTConcreteProtocol
# #define __POD_libextobjc_EXTKeyPathCoding
# #define __POD_libextobjc_EXTScope
#
# Example usage:
#
# #ifdef __COCOA_PODS
# #ifdef __POD__AFNetworking
# #import "MYLib+AFNetworking.h"
# #endif
# #else
# // Non CocoaPods code
# #endif
#
class
TargetHeader
# @return [Array<LocalPod>] the specifications installed for the target.
#
attr_reader
:specs
# @param [Array<LocalPod>] pods @see pods
#
def
initialize
(
specs
)
@specs
=
specs
end
# Generates and saves the file.
#
# @param [Pathname] pathname
# The path where to save the generated file.
#
# @return [void]
#
def
save_as
(
pathname
)
pathname
.
open
(
'w'
)
do
|
source
|
source
.
puts
"#define __COCOA_PODS"
source
.
puts
specs
.
each
do
|
specs
|
source
.
puts
"#define __POD_
#{
specs
.
name
.
gsub
(
/[^\w]/
,
'_'
)
}
"
end
end
end
end
end
end
lib/cocoapods/installer/target_installer.rb
View file @
aa36ea80
...
...
@@ -25,6 +25,7 @@ module Pod
create_suport_files_group
create_xcconfig_file
create_target_header
create_prefix_header
create_bridge_support_file
create_copy_resources_script
...
...
@@ -188,6 +189,18 @@ module Pod
end
end
# Generates a header which allows to inspect at compile time the installed
# pods and the installed specifications of a pod.
#
def
create_target_header
path
=
library
.
target_header_path
UI
.
message
"- Creating target header at
#{
UI
.
path
(
path
)
}
"
do
generator
=
Generator
::
TargetHeader
.
new
(
library
.
specs
)
generator
.
save_as
(
path
)
add_file_to_support_group
(
path
)
end
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.
...
...
@@ -197,8 +210,9 @@ module Pod
def
create_prefix_header
path
=
library
.
prefix_header_path
UI
.
message
"- Generating prefix header at
#{
UI
.
path
(
path
)
}
"
do
gen
=
Generator
::
PrefixHeader
.
new
(
target_definition
.
platform
,
pods
)
gen
.
save_as
(
path
)
generator
=
Generator
::
PrefixHeader
.
new
(
target_definition
.
platform
,
pods
)
generator
.
imports
<<
library
.
target_header_path
.
basename
generator
.
save_as
(
path
)
add_file_to_support_group
(
path
)
target
.
build_configurations
.
each
do
|
c
|
...
...
lib/cocoapods/library.rb
View file @
aa36ea80
...
...
@@ -96,50 +96,23 @@ module Pod
# @!group Support files
# @return [String] The xcconfig path of the root from the `$(SRCROOT)`
# variable of the user's project.
#
def
relative_pods_root
"${SRCROOT}/
#{
relative_to_srcroot
}
"
end
# @return [String] the name of the xcconfig file relative to this target.
#
def
xcconfig_name
"
#{
label
}
.xcconfig"
end
# @return [Pathname] the absolute path of the xcconfig file.
#
def
xcconfig_path
support_files_root
+
xcconfig_name
end
# @return [String] the path of the xcconfig file relative to the root of
# the user project.
#
def
xcconfig_relative_path
relative_to_srcroot
(
"
#{
xcconfig_name
}
"
).
to_s
end
# @return [String] the name of the copy resources script relative to this
# target.
#
def
copy_resources_script_name
"
#{
label
}
-resources.sh"
support_files_root
+
"
#{
label
}
.xcconfig"
end
# @return [Pathname] the absolute path of the copy resources script.
#
def
copy_resources_script_path
support_files_root
+
copy_resources_script_name
support_files_root
+
"
#{
label
}
-resources.sh"
end
# @return [
String] the path of the copy resources script relative to the
#
root of the user project
.
# @return [
Pathname] the absolute path of the header file which contains
#
the information about the installed pods
.
#
def
copy_resources_script_relative
_path
"${SRCROOT}/
#{
relative_to_srcroot
(
"
#{
copy_resources_script_name
}
"
)
}
"
def
target_header
_path
support_files_root
+
"
#{
label
}
-header.h
"
end
# @return [Pathname] the absolute path of the prefix header file.
...
...
@@ -160,13 +133,36 @@ module Pod
# the file type.
#
def
acknowledgements_basepath
support_files_root
+
"
#{
label
}
-
A
cknowledgements"
support_files_root
+
"
#{
label
}
-
a
cknowledgements"
end
# @return [Pathname] the path of the dummy source generated by CocoaPods
#
def
dummy_source_path
support_files_root
+
"
#{
label
}
-Dummy.m"
support_files_root
+
"
#{
label
}
-dummy.m"
end
#--------------------------------------#
# @return [String] The xcconfig path of the root from the `$(SRCROOT)`
# variable of the user's project.
#
def
relative_pods_root
"${SRCROOT}/
#{
support_files_root
.
relative_path_from
(
user_project_path
.
dirname
)
}
"
end
# @return [String] the path of the xcconfig file relative to the root of
# the user project.
#
def
xcconfig_relative_path
relative_to_srcroot
(
xcconfig_path
).
to_s
end
# @return [String] the path of the copy resources script relative to the
# root of the user project.
#
def
copy_resources_script_relative_path
"${SRCROOT}/
#{
relative_to_srcroot
(
copy_resources_script_path
)
}
"
end
#-------------------------------------------------------------------------#
...
...
@@ -183,9 +179,8 @@ module Pod
#
# @return [String] the computed path.
#
def
relative_to_srcroot
(
path
=
nil
)
base_path
=
path
?
support_files_root
+
path
:
support_files_root
base_path
.
relative_path_from
(
user_project_path
.
dirname
).
to_s
def
relative_to_srcroot
(
path
)
path
.
relative_path_from
(
user_project_path
.
dirname
).
to_s
end
end
end
spec/unit/generator/prefix_header_spec.rb
View file @
aa36ea80
...
...
@@ -34,6 +34,18 @@ describe PrefixHeader = Pod::Generator::PrefixHeader do
EOS
end
it
"includes the imports"
do
@gen
.
imports
<<
"header.h"
@gen
.
generate
.
should
==
<<-
EOS
.
strip_heredoc
#ifdef __OBJC__
#import <UIKit/UIKit.h>
#endif
#import "header.h"
#import <BananaTree/BananaTree.h>
EOS
end
it
"prefers the inline specification of the prefix header contents"
do
spec
=
@pod
.
top_specification
spec
.
prefix_header_contents
=
'#import "BlocksKit.h"'
...
...
spec/unit/generator/target_header_spec.rb
0 → 100644
View file @
aa36ea80
require
File
.
expand_path
(
'../../../spec_helper'
,
__FILE__
)
describe
Pod
::
Generator
::
TargetHeader
do
before
do
specification
=
fixture_spec
(
'banana-lib/BananaLib.podspec'
)
@gen
=
Pod
::
Generator
::
TargetHeader
.
new
([
specification
])
end
it
"generates a header files wihc include the CocoaPods definition"
do
file
=
temporary_directory
+
'PodsDummy.m'
@gen
.
save_as
(
file
)
file
.
read
.
should
==
<<-
EOS
.
strip_heredoc
#define __COCOA_PODS
#define __POD_BananaLib
EOS
end
end
spec/unit/installer/target_installer_spec.rb
View file @
aa36ea80
...
...
@@ -20,6 +20,7 @@ module Pod
@library
.
user_project_path
=
config
.
sandbox
.
root
+
'../user_project.xcodeproj'
@library
.
user_build_configurations
=
{
'Debug'
=>
:debug
,
'Release'
=>
:release
,
'AppStore'
=>
:release
,
'Test'
=>
:debug
}
specification
=
fixture_spec
(
'banana-lib/BananaLib.podspec'
)
@library
.
specs
=
[
specification
]
@pod
=
LocalPod
.
new
(
specification
,
config
.
sandbox
,
@library
.
platform
)
@library
.
local_pods
=
[
@pod
]
...
...
@@ -34,9 +35,10 @@ module Pod
@installer
.
install!
group
=
@project
.
support_files_group
[
'Pods'
]
group
.
children
.
map
(
&
:display_name
).
sort
.
should
==
[
"Pods-Acknowledgements.markdown"
,
"Pods-Acknowledgements.plist"
,
"Pods-Dummy.m"
,
"Pods-acknowledgements.markdown"
,
"Pods-acknowledgements.plist"
,
"Pods-dummy.m"
,
"Pods-header.h"
,
"Pods-prefix.pch"
,
"Pods-resources.sh"
,
"Pods.xcconfig"
...
...
@@ -147,6 +149,14 @@ module Pod
xcconfig
.
to_hash
[
'PODS_ROOT'
].
should
==
'${SRCROOT}/Pods'
end
it
"creates a header for the target which contains the information about the installed Pods"
do
@installer
.
install!
file
=
config
.
sandbox
.
root
+
'Pods-header.h'
contents
=
file
.
read
contents
.
should
.
include?
(
'#define __COCOA_PODS'
)
contents
.
should
.
include?
(
'#define __POD_BananaLib'
)
end
it
"creates a prefix header, including the contents of the specification's prefix header"
do
@pod
.
top_specification
.
prefix_header_contents
=
'#import "BlocksKit.h"'
@installer
.
install!
...
...
@@ -156,6 +166,7 @@ module Pod
#import <UIKit/UIKit.h>
#endif
#import "Pods-header.h"
#import "BlocksKit.h"
EOS
end
...
...
@@ -183,10 +194,10 @@ module Pod
it
"creates a dummy source to ensure the compilation of libraries with only categories"
do
@installer
.
install!
build_files
=
@installer
.
target
.
source_build_phase
.
files
build_file
=
build_files
.
find
{
|
bf
|
bf
.
file_ref
.
name
==
'Pods-
D
ummy.m'
}
build_file
=
build_files
.
find
{
|
bf
|
bf
.
file_ref
.
name
==
'Pods-
d
ummy.m'
}
build_file
.
should
.
be
.
not
.
nil
build_file
.
file_ref
.
path
.
should
==
'Pods-
D
ummy.m'
dummy
=
config
.
sandbox
.
root
+
'Pods-
D
ummy.m'
build_file
.
file_ref
.
path
.
should
==
'Pods-
d
ummy.m'
dummy
=
config
.
sandbox
.
root
+
'Pods-
d
ummy.m'
dummy
.
read
.
should
.
include?
(
'@interface PodsDummy_Pods'
)
end
end
...
...
spec/unit/library_spec.rb
View file @
aa36ea80
...
...
@@ -34,28 +34,16 @@ module Pod
@lib
.
user_project_path
=
config
.
sandbox
.
root
+
'../user_project.xcodeproj'
end
it
"returns the xcconfig name"
do
@lib
.
xcconfig_name
.
should
==
'Pods.xcconfig'
end
it
"returns the absolute path of the xcconfig file"
do
@lib
.
xcconfig_path
.
to_s
.
should
.
include?
(
'Pods/Pods.xcconfig'
)
end
it
"returns the path of the xcconfig file relative to the user project"
do
@lib
.
xcconfig_relative_path
.
should
==
'Pods/Pods.xcconfig'
end
it
"returns the resources script name"
do
@lib
.
copy_resources_script_name
.
should
==
'Pods-resources.sh'
end
it
"returns the absolute path of the resources script"
do
@lib
.
copy_resources_script_path
.
to_s
.
should
.
include?
(
'Pods/Pods-resources.sh'
)
end
it
"returns the
path of the resources script relative to the user project
"
do
@lib
.
copy_resources_script_relative_path
.
should
==
'${SRCROOT}/Pods/Pods-resources.sh'
it
"returns the
absolute path of the target header file
"
do
@lib
.
target_header_path
.
to_s
.
should
.
include?
(
'Pods/Pods-header.h'
)
end
it
"returns the absolute path of the prefix header file"
do
...
...
@@ -67,8 +55,19 @@ module Pod
end
it
"returns the absolute path of the acknowledgements files without extension"
do
@lib
.
acknowledgements_basepath
.
to_s
.
should
.
include?
(
'Pods/Pods-
A
cknowledgements'
)
@lib
.
acknowledgements_basepath
.
to_s
.
should
.
include?
(
'Pods/Pods-
a
cknowledgements'
)
end
#--------------------------------------#
it
"returns the path of the resources script relative to the user project"
do
@lib
.
copy_resources_script_relative_path
.
should
==
'${SRCROOT}/Pods/Pods-resources.sh'
end
it
"returns the path of the xcconfig file relative to the user project"
do
@lib
.
xcconfig_relative_path
.
should
==
'Pods/Pods.xcconfig'
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