-
Notifications
You must be signed in to change notification settings - Fork 2.6k
/
target.rb
120 lines (96 loc) · 3.16 KB
/
target.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
module Pod
# Model class which describes a Pods target.
#
# The Target class stores and provides the information necessary for
# working with a target in the Podfile and it's dependent libraries.
# This class is used to represent both the targets and their libraries.
#
class Target
# @return [PBXNativeTarget] the target definition of the Podfile that
# generated this target.
#
attr_reader :target_definition
# @return [Sandbox] The sandbox where the Pods should be installed.
#
attr_reader :sandbox
# @return [String] the name of the library.
#
def name
label
end
# @return [String] the name of the library.
#
def product_name
"lib#{label}.a"
end
# @return [String] the XCConfig namespaced prefix.
#
def xcconfig_prefix
label.upcase.gsub(/[^A-Z]/, '_') + '_'
end
# @return [String] A string suitable for debugging.
#
def inspect
"<#{self.class} name=#{name} >"
end
#-------------------------------------------------------------------------#
# @!group Information storage
# @return [Hash{String=>Symbol}] A hash representing the user build
# configurations where each key corresponds to the name of a
# configuration and its value to its type (`:debug` or `:release`).
#
attr_accessor :user_build_configurations
# @return [PBXNativeTarget] the target generated in the Pods project for
# this library.
#
attr_accessor :target
# @return [Platform] the platform for this library.
#
def platform
@platform ||= target_definition.platform
end
# @return [String] The value for the ARCHS build setting.
#
attr_accessor :archs
#-------------------------------------------------------------------------#
# @!group Support files
# @return [Pathname] the folder where to store the support files of this
# library.
#
def support_files_root
@sandbox.library_support_files_dir(name)
end
# @return [Pathname] the absolute path of the xcconfig file.
#
def xcconfig_path
support_files_root + "#{label}.xcconfig"
end
# @return [Pathname] the absolute path of the private xcconfig file.
#
def xcconfig_private_path
support_files_root + "#{label}-Private.xcconfig"
end
# @return [Pathname] the absolute path of the header file which contains
# the information about the installed pods.
#
def target_environment_header_path
support_files_root + "#{target_definition.label.to_s}-environment.h"
end
# @return [Pathname] the absolute path of the prefix header file.
#
def prefix_header_path
support_files_root + "#{label}-prefix.pch"
end
# @return [Pathname] the absolute path of the bridge support file.
#
def bridge_support_path
support_files_root + "#{label}.bridgesupport"
end
# @return [Pathname] the path of the dummy source generated by CocoaPods
#
def dummy_source_path
support_files_root + "#{label}-dummy.m"
end
#-------------------------------------------------------------------------#
end
end