cocoapods 0.22.3 → 0.23.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,6 +1,6 @@
1
1
  module Pod
2
2
  # The version of the cocoapods command line tool.
3
3
  #
4
- VERSION = '0.22.3' unless defined? Pod::VERSION
4
+ VERSION = '0.23.0.rc1' unless defined? Pod::VERSION
5
5
  end
6
6
 
@@ -70,7 +70,7 @@ module Pod
70
70
  def script
71
71
  script = install_resources_function
72
72
  resources.each do |resource|
73
- script += "install_resource '#{resource}'\n"
73
+ script += %Q[install_resource "#{resource}"\n]
74
74
  end
75
75
  script += RSYNC_CALL
76
76
  script
@@ -102,12 +102,16 @@ install_resource()
102
102
  cp -fpR "${PODS_ROOT}/$1" "${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}"
103
103
  ;;
104
104
  *.xcdatamodel)
105
- echo xcrun momc \"${PODS_ROOT}/$1\" ${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$1" .xcdatamodel`.mom
106
- xcrun momc \"${PODS_ROOT}/$1\" ${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$1" .xcdatamodel`.mom
105
+ echo "xcrun momc \\"${PODS_ROOT}/$1\\" \\"${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$1"`.mom\\""
106
+ xcrun momc "${PODS_ROOT}/$1" "${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$1" .xcdatamodel`.mom"
107
107
  ;;
108
108
  *.xcdatamodeld)
109
- echo xcrun momc \"${PODS_ROOT}/$1\" ${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$1" .xcdatamodeld`.momd
110
- xcrun momc \"${PODS_ROOT}/$1\" ${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$1" .xcdatamodeld`.momd
109
+ echo "xcrun momc \\"${PODS_ROOT}/$1\\" \\"${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$1" .xcdatamodeld`.momd\\""
110
+ xcrun momc "${PODS_ROOT}/$1" "${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$1" .xcdatamodeld`.momd"
111
+ ;;
112
+ /*)
113
+ echo "$1"
114
+ echo "$1" >> "$RESOURCES_TO_COPY"
111
115
  ;;
112
116
  *)
113
117
  echo "${PODS_ROOT}/$1"
@@ -5,124 +5,12 @@ module Pod
5
5
  # for each Pod and for each Pod target definition. The aggregates the
6
6
  # configurations of the Pods and define target specific settings.
7
7
  #
8
- class XCConfig
8
+ module XCConfig
9
9
 
10
- # @return [Target] the target represented by this xcconfig.
11
- #
12
- attr_reader :target
13
-
14
- # @param [Target] target @see target
15
- #
16
- def initialize(target)
17
- @target = target
18
- end
19
-
20
- # @return [Sandbox] the sandbox of this target.
21
- #
22
- def sandbox
23
- target.sandbox
24
- end
25
-
26
- # @return [Xcodeproj::Config] The generated xcconfig.
27
- #
28
- attr_reader :xcconfig
29
-
30
- # Generates and saves the xcconfig to the given path.
31
- #
32
- # @param [Pathname] path
33
- # the path where the prefix header should be stored.
34
- #
35
- # @return [void]
36
- #
37
- def save_as(path)
38
- generate.save_as(path)
39
- end
40
-
41
- #-----------------------------------------------------------------------#
42
-
43
- # @!group Private helpers.
44
-
45
- private
46
-
47
- # @return [String] the default linker flags. `-ObjC` is always included
48
- # while `-fobjc-arc` is included only if requested in the
49
- # Podfile.
50
- #
51
- def default_ld_flags
52
- ld_flags = '-ObjC'
53
- if target.target_definition.podfile.set_arc_compatibility_flag? and
54
- target.spec_consumers.any? { |consumer| consumer.requires_arc? }
55
- ld_flags << ' -fobjc-arc'
56
- end
57
- ld_flags
58
- end
59
-
60
- # Converts an array of strings to a single string where the each string
61
- # is surrounded by double quotes and separated by a space. Used to
62
- # represent strings in a xcconfig file.
63
- #
64
- # @param [Array<String>] strings
65
- # a list of strings.
66
- #
67
- # @return [String] the resulting string.
68
- #
69
- def quote(strings)
70
- strings.sort.map { |s| %W|"#{s}"| }.join(" ")
71
- end
72
-
73
- # Configures the given Xcconfig according to the build settings of the
74
- # given Specification.
75
- #
76
- # @param [Specification::Consumer] consumer
77
- # The consumer of the specification.
78
- #
79
- # @param [Xcodeproj::Config] xcconfig
80
- # The xcconfig to edit.
81
- #
82
- def add_spec_build_settings_to_xcconfig(consumer, xcconfig)
83
- xcconfig.merge!(consumer.xcconfig)
84
- xcconfig.libraries.merge(consumer.libraries)
85
- xcconfig.frameworks.merge(consumer.frameworks)
86
- xcconfig.weak_frameworks.merge(consumer.weak_frameworks)
87
- add_developers_frameworks_if_needed(consumer, xcconfig)
88
- end
89
-
90
- # @return [Array<String>] The search paths for the developer frameworks.
91
- #
92
- # @todo Inheritance should be properly handled in Xcconfigs.
93
- #
94
- DEVELOPER_FRAMEWORKS_SEARCH_PATHS = [
95
- '$(inherited)',
96
- '"$(SDKROOT)/Developer/Library/Frameworks"',
97
- '"$(DEVELOPER_LIBRARY_DIR)/Frameworks"'
98
- ]
99
-
100
- # Adds the search paths of the developer frameworks to the specification
101
- # if needed. This is done because the `SenTestingKit` requires them and
102
- # adding them to each specification which requires it is repetitive and
103
- # error prone.
104
- #
105
- # @param [Specification::Consumer] consumer
106
- # The consumer of the specification.
107
- #
108
- # @param [Xcodeproj::Config] xcconfig
109
- # The xcconfig to edit.
110
- #
111
- # @return [void]
112
- #
113
- def add_developers_frameworks_if_needed(consumer, xcconfig)
114
- if xcconfig.frameworks.include?('SenTestingKit')
115
- search_paths = xcconfig.attributes['FRAMEWORK_SEARCH_PATHS'] ||= ''
116
- DEVELOPER_FRAMEWORKS_SEARCH_PATHS.each do |search_path|
117
- unless search_paths.include?(search_path)
118
- search_paths << ' ' unless search_paths.empty?
119
- search_paths << search_path
120
- end
121
- end
122
- end
123
- end
124
-
125
- #-----------------------------------------------------------------------#
10
+ autoload :AggregateXCConfig, 'cocoapods/generator/xcconfig/aggregate_xcconfig'
11
+ autoload :PublicPodXCConfig, 'cocoapods/generator/xcconfig/public_pod_xcconfig'
12
+ autoload :PrivatePodXCConfig, 'cocoapods/generator/xcconfig/private_pod_xcconfig'
13
+ autoload :XCConfigHelper, 'cocoapods/generator/xcconfig/xcconfig_helper'
126
14
 
127
15
  end
128
16
  end
@@ -1,9 +1,35 @@
1
1
  module Pod
2
2
  module Generator
3
+ module XCConfig
3
4
 
4
5
  # Generates the xcconfigs for the aggregate targets.
5
6
  #
6
- class AggregateXCConfig < XCConfig
7
+ class AggregateXCConfig
8
+
9
+ # @return [Target] the target represented by this xcconfig.
10
+ #
11
+ attr_reader :target
12
+
13
+ # @param [Target] target @see target
14
+ #
15
+ def initialize(target)
16
+ @target = target
17
+ end
18
+
19
+ # @return [Xcodeproj::Config] The generated xcconfig.
20
+ #
21
+ attr_reader :xcconfig
22
+
23
+ # Generates and saves the xcconfig to the given path.
24
+ #
25
+ # @param [Pathname] path
26
+ # the path where the prefix header should be stored.
27
+ #
28
+ # @return [void]
29
+ #
30
+ def save_as(path)
31
+ generate.save_as(path)
32
+ end
7
33
 
8
34
  # Generates the xcconfig.
9
35
  #
@@ -12,19 +38,28 @@ module Pod
12
38
  # Each namespaced configuration value is merged into the Pod
13
39
  # xcconfig file.
14
40
  #
41
+ # @todo This doesn't include the specs xcconfigs anymore and now the
42
+ # logic is duplicated.
43
+ #
15
44
  # @return [Xcodeproj::Config]
16
45
  #
17
46
  def generate
18
47
  @xcconfig = Xcodeproj::Config.new({
19
- 'OTHER_LDFLAGS' => default_ld_flags,
20
- 'HEADER_SEARCH_PATHS' => quote(sandbox.public_headers.search_paths),
21
- 'PODS_ROOT' => target.relative_pods_root,
48
+ 'OTHER_LDFLAGS' => XCConfigHelper.default_ld_flags(target),
49
+ 'HEADER_SEARCH_PATHS' => XCConfigHelper.quote(target.sandbox.public_headers.search_paths),
50
+ 'PODS_ROOT' => target.relative_pods_root,
22
51
  'GCC_PREPROCESSOR_DEFINITIONS' => '$(inherited) COCOAPODS=1',
23
52
  })
24
53
 
25
54
  target.pod_targets.each do |pod_target|
26
- pod_target.spec_consumers.each do |consumer|
27
- add_spec_build_settings_to_xcconfig(consumer, @xcconfig)
55
+ pod_target.file_accessors.each do |file_accessor|
56
+ XCConfigHelper.add_spec_build_settings_to_xcconfig(file_accessor.spec_consumer, @xcconfig)
57
+ file_accessor.vendored_frameworks.each do |vendored_framework|
58
+ XCConfigHelper.add_framework_build_settings(vendored_framework, @xcconfig, target.sandbox.root)
59
+ end
60
+ file_accessor.vendored_libraries.each do |vendored_library|
61
+ XCConfigHelper.add_library_build_settings(vendored_library, @xcconfig, target.sandbox.root)
62
+ end
28
63
  end
29
64
  end
30
65
 
@@ -42,3 +77,4 @@ module Pod
42
77
  end
43
78
  end
44
79
  end
80
+ end
@@ -1,5 +1,6 @@
1
1
  module Pod
2
2
  module Generator
3
+ module XCConfig
3
4
 
4
5
  # Generates the private xcconfigs for the pod targets.
5
6
  #
@@ -7,7 +8,11 @@ module Pod
7
8
  # values of the public namespaced xcconfig with the default private
8
9
  # configuration values required by CocoaPods.
9
10
  #
10
- class PrivatePodXCConfig < XCConfig
11
+ class PrivatePodXCConfig
12
+
13
+ # @return [Target] the target represented by this xcconfig.
14
+ #
15
+ attr_reader :target
11
16
 
12
17
  # @return [Xcodeproj::Config] The public xcconfig which this one will
13
18
  # use.
@@ -18,21 +23,37 @@ module Pod
18
23
  # @param [Xcodeproj::Config] public_xcconfig @see public_xcconfig
19
24
  #
20
25
  def initialize(target, public_xcconfig)
21
- super(target)
26
+ @target = target
22
27
  @public_xcconfig = public_xcconfig
23
28
  end
24
29
 
30
+ # @return [Xcodeproj::Config] The generated xcconfig.
31
+ #
32
+ attr_reader :xcconfig
33
+
34
+ # Generates and saves the xcconfig to the given path.
35
+ #
36
+ # @param [Pathname] path
37
+ # the path where the prefix header should be stored.
38
+ #
39
+ # @return [void]
40
+ #
41
+ def save_as(path)
42
+ generate.save_as(path)
43
+ end
44
+
25
45
  # Generates the xcconfig.
26
46
  #
27
47
  # @return [Xcodeproj::Config]
28
48
  #
29
49
  def generate
50
+ search_pahts = target.build_headers.search_paths.concat(target.sandbox.public_headers.search_paths)
30
51
  config = {
31
- 'OTHER_LDFLAGS' => default_ld_flags,
32
- 'PODS_ROOT' => '${SRCROOT}',
33
- 'HEADER_SEARCH_PATHS' => quote(target.build_headers.search_paths) + ' ' + quote(sandbox.public_headers.search_paths),
52
+ 'OTHER_LDFLAGS' => XCConfigHelper.default_ld_flags(target),
53
+ 'PODS_ROOT' => '${SRCROOT}',
54
+ 'HEADER_SEARCH_PATHS' => XCConfigHelper.quote(search_pahts),
34
55
  'GCC_PREPROCESSOR_DEFINITIONS' => 'COCOAPODS=1',
35
- # 'USE_HEADERMAP' => 'NO'
56
+ # 'USE_HEADERMAP' => 'NO'
36
57
  }
37
58
 
38
59
  xcconfig_hash = add_xcconfig_namespaced_keys(public_xcconfig.to_hash, config, target.xcconfig_prefix)
@@ -93,3 +114,4 @@ module Pod
93
114
  end
94
115
  end
95
116
  end
117
+ end
@@ -1,5 +1,6 @@
1
1
  module Pod
2
2
  module Generator
3
+ module XCConfig
3
4
 
4
5
  # Generates the public xcconfigs for the pod targets.
5
6
  #
@@ -8,7 +9,21 @@ module Pod
8
9
  # xcconfig includes the standard podspec defined values including
9
10
  # libraries, frameworks, weak frameworks and xcconfig overrides.
10
11
  #
11
- class PublicPodXCConfig < XCConfig
12
+ class PublicPodXCConfig
13
+
14
+ # @return [Target] the target represented by this xcconfig.
15
+ #
16
+ attr_reader :target
17
+
18
+ # @param [Target] target @see target
19
+ #
20
+ def initialize(target)
21
+ @target = target
22
+ end
23
+
24
+ # @return [Xcodeproj::Config] The generated xcconfig.
25
+ #
26
+ attr_reader :xcconfig
12
27
 
13
28
  # Generates and saves the xcconfig to the given path.
14
29
  #
@@ -27,8 +42,14 @@ module Pod
27
42
  #
28
43
  def generate
29
44
  @xcconfig = Xcodeproj::Config.new
30
- target.spec_consumers.each do |consumer|
31
- add_spec_build_settings_to_xcconfig(consumer, @xcconfig)
45
+ target.file_accessors.each do |file_accessor|
46
+ XCConfigHelper.add_spec_build_settings_to_xcconfig(file_accessor.spec_consumer, @xcconfig)
47
+ file_accessor.vendored_frameworks.each do |vendored_framework|
48
+ XCConfigHelper.add_framework_build_settings(vendored_framework, @xcconfig, target.sandbox.root)
49
+ end
50
+ file_accessor.vendored_libraries.each do |vendored_library|
51
+ XCConfigHelper.add_library_build_settings(vendored_library, @xcconfig, target.sandbox.root)
52
+ end
32
53
  end
33
54
  @xcconfig
34
55
  end
@@ -38,3 +59,4 @@ module Pod
38
59
  end
39
60
  end
40
61
  end
62
+ end
@@ -0,0 +1,124 @@
1
+ module Pod
2
+ module Generator
3
+ module XCConfig
4
+
5
+ # Stores the shared logic of the classes of the XCConfig module.
6
+ #
7
+ module XCConfigHelper
8
+
9
+ # Converts an array of strings to a single string where the each string
10
+ # is surrounded by double quotes and separated by a space. Used to
11
+ # represent strings in a xcconfig file.
12
+ #
13
+ # @param [Array<String>] strings
14
+ # a list of strings.
15
+ #
16
+ # @return [String] the resulting string.
17
+ #
18
+ def self.quote(strings)
19
+ strings.sort.map { |s| %W|"#{s}"| }.join(" ")
20
+ end
21
+
22
+ # @return [String] the default linker flags. `-ObjC` is always included
23
+ # while `-fobjc-arc` is included only if requested in the
24
+ # Podfile.
25
+ #
26
+ def self.default_ld_flags(target)
27
+ ld_flags = '-ObjC'
28
+ if target.target_definition.podfile.set_arc_compatibility_flag? and
29
+ target.spec_consumers.any? { |consumer| consumer.requires_arc? }
30
+ ld_flags << ' -fobjc-arc'
31
+ end
32
+ ld_flags
33
+ end
34
+
35
+ # Configures the given Xcconfig according to the build settings of the
36
+ # given Specification.
37
+ #
38
+ # @param [Specification::Consumer] consumer
39
+ # The consumer of the specification.
40
+ #
41
+ # @param [Xcodeproj::Config] xcconfig
42
+ # The xcconfig to edit.
43
+ #
44
+ def self.add_spec_build_settings_to_xcconfig(consumer, xcconfig)
45
+ xcconfig.merge!(consumer.xcconfig)
46
+ xcconfig.libraries.merge(consumer.libraries)
47
+ xcconfig.frameworks.merge(consumer.frameworks)
48
+ xcconfig.weak_frameworks.merge(consumer.weak_frameworks)
49
+ add_developers_frameworks_if_needed(xcconfig)
50
+ end
51
+
52
+ # Configures the given Xcconfig with the the build settings for the given
53
+ # framework path.
54
+ #
55
+ # @param [Pathanme] framework_path
56
+ # The path of the framework.
57
+ #
58
+ # @param [Xcodeproj::Config] xcconfig
59
+ # The xcconfig to edit.
60
+ #
61
+ def self.add_framework_build_settings(framework_path, xcconfig, sandbox_root)
62
+ name = File.basename(framework_path, ".framework")
63
+ dirname = File.dirname(framework_path).sub(sandbox_root.to_s, '$(PODS_ROOT)')
64
+ build_settings = {
65
+ 'OTHER_LDFLAGS' => "-framework #{name}",
66
+ 'FRAMEWORK_SEARCH_PATHS' => quote([dirname])
67
+ }
68
+ xcconfig.merge!(build_settings)
69
+ end
70
+
71
+ # Configures the given Xcconfig with the the build settings for the given
72
+ # framework path.
73
+ #
74
+ # @param [Pathanme] framework_path
75
+ # The path of the framework.
76
+ #
77
+ # @param [Xcodeproj::Config] xcconfig
78
+ # The xcconfig to edit.
79
+ #
80
+ def self.add_library_build_settings(library_path, xcconfig, sandbox_root)
81
+ name = File.basename(library_path, ".a").sub(/\Alib/, '')
82
+ dirname = File.dirname(library_path).sub(sandbox_root.to_s, '$(PODS_ROOT)')
83
+ build_settings = {
84
+ 'OTHER_LDFLAGS' => "-l#{name}",
85
+ 'LIBRARY_SEARCH_PATHS' => quote([dirname])
86
+ }
87
+ xcconfig.merge!(build_settings)
88
+ end
89
+
90
+ # @return [Array<String>] The search paths for the developer frameworks.
91
+ #
92
+ DEVELOPER_FRAMEWORKS_SEARCH_PATHS = [
93
+ '$(inherited)',
94
+ '"$(SDKROOT)/Developer/Library/Frameworks"',
95
+ '"$(DEVELOPER_LIBRARY_DIR)/Frameworks"'
96
+ ]
97
+
98
+ # Adds the search paths of the developer frameworks to the specification
99
+ # if needed. This is done because the `SenTestingKit` requires them and
100
+ # adding them to each specification which requires it is repetitive and
101
+ # error prone.
102
+ #
103
+ # @param [Xcodeproj::Config] xcconfig
104
+ # The xcconfig to edit.
105
+ #
106
+ # @return [void]
107
+ #
108
+ def self.add_developers_frameworks_if_needed(xcconfig)
109
+ if xcconfig.frameworks.include?('SenTestingKit')
110
+ search_paths = xcconfig.attributes['FRAMEWORK_SEARCH_PATHS'] ||= ''
111
+ DEVELOPER_FRAMEWORKS_SEARCH_PATHS.each do |search_path|
112
+ unless search_paths.include?(search_path)
113
+ search_paths << ' ' unless search_paths.empty?
114
+ search_paths << search_path
115
+ end
116
+ end
117
+ end
118
+ end
119
+
120
+ #---------------------------------------------------------------------#
121
+ end
122
+ end
123
+ end
124
+ end