Skip to content
This repository
Browse code

Instead of copying headers to BUILT_PRODUCTS_DIR symlink them into a …

…defined dir structure in Pods/Headers.
  • Loading branch information...
commit fa69d832f9c372c0ad26de051985be9b466c459c 1 parent 9386904
Dieter Komendera authored
21  lib/cocoapods/installer.rb
@@ -29,7 +29,7 @@ def initialize(podfile, project, definition)
29 29
       def xcconfig
30 30
         @xcconfig ||= Xcodeproj::Config.new({
31 31
           # In a workspace this is where the static library headers should be found.
32  
-          'HEADER_SEARCH_PATHS' => '"$(BUILT_PRODUCTS_DIR)/Pods"',
  32
+          'HEADER_SEARCH_PATHS' => '"Pods/Headers"',
33 33
           # This makes categories from static libraries work, which many libraries
34 34
           # require, so we add these by default.
35 35
           'OTHER_LDFLAGS'            => '-ObjC -all_load',
@@ -75,11 +75,18 @@ def prefix_header_filename
75 75
         "#{@definition.lib_name}-prefix.pch"
76 76
       end
77 77
 
  78
+      def headers_symlink_path_name
  79
+        "Pods/Headers"
  80
+      end
  81
+
78 82
       # TODO move xcconfig related code into the xcconfig method, like copy_resources_script and generate_bridge_support.
79 83
       def install!
80 84
         # First add the target to the project
81 85
         @target = @project.targets.new_static_library(@definition.lib_name)
82 86
 
  87
+        # Clean old header symlinks
  88
+        FileUtils.rm_r(headers_symlink_path_name, :secure => true) if File.exists?(headers_symlink_path_name)
  89
+
83 90
         header_search_paths = []
84 91
         build_specifications.each do |spec|
85 92
           xcconfig.merge!(spec.xcconfig)
@@ -87,12 +94,14 @@ def install!
87 94
           spec.implementation_files.each do |file|
88 95
             @target.add_source_file(file, nil, spec.compiler_flags)
89 96
           end
90  
-          # Add header files to a `copy header build phase` for each destination
91  
-          # directory in the pod's header directory.
  97
+          # Symlink header files to Pods/Headers
92 98
           spec.copy_header_mappings.each do |header_dir, files|
93  
-            copy_phase = @target.copy_files_build_phases.new_pod_dir(spec.name, header_dir)
94  
-            files.each do |file|
95  
-              @target.add_source_file(file, copy_phase)
  99
+            target_dir = "#{headers_symlink_path_name}/#{header_dir}"
  100
+            FileUtils.mkdir_p(target_dir)
  101
+            Dir.chdir(target_dir) do
  102
+              files.each do |file|
  103
+                FileUtils.ln_s("../../#{file}", file.basename)
  104
+              end
96 105
             end
97 106
           end
98 107
           # Collect all header search paths
2  lib/cocoapods/specification.rb
@@ -296,7 +296,7 @@ def copy_header_mappings
296 296
     # methods.
297 297
     def header_search_paths
298 298
       dirs = [header_dir] + copy_header_mappings.keys
299  
-      dirs.map { |dir| %{"$(BUILT_PRODUCTS_DIR)/Pods/#{dir}"} }
  299
+      dirs.map { |dir| %{"Pods/Headers/#{dir}"} }
300 300
     end
301 301
 
302 302
     def to_s
2  spec/unit/installer_spec.rb
@@ -10,7 +10,7 @@
10 10
     end
11 11
 
12 12
     it "sets the header search paths where installed Pod headers can be found" do
13  
-      @xcconfig['HEADER_SEARCH_PATHS'].should == '"$(BUILT_PRODUCTS_DIR)/Pods"'
  13
+      @xcconfig['HEADER_SEARCH_PATHS'].should == '"Pods/Headers"'
14 14
       @xcconfig['ALWAYS_SEARCH_USER_PATHS'].should == 'YES'
15 15
     end
16 16
 
8  spec/unit/specification_spec.rb
@@ -209,8 +209,8 @@ def @spec.copy_header_mapping(from)
209 209
       Pathname.new('ns') + from.basename
210 210
     end
211 211
     @spec.header_search_paths.should == %w{
212  
-      "$(BUILT_PRODUCTS_DIR)/Pods/SSZipArchive"
213  
-      "$(BUILT_PRODUCTS_DIR)/Pods/SSZipArchive/ns"
  212
+      "Pods/Headers/SSZipArchive"
  213
+      "Pods/Headers/SSZipArchive/ns"
214 214
     }
215 215
   end
216 216
 
@@ -220,8 +220,8 @@ def @spec.copy_header_mapping(from)
220 220
       Pathname.new('ns') + from.basename
221 221
     end
222 222
     @spec.header_search_paths.should == %w{
223  
-      "$(BUILT_PRODUCTS_DIR)/Pods/AnotherRoot"
224  
-      "$(BUILT_PRODUCTS_DIR)/Pods/AnotherRoot/ns"
  223
+      "Pods/Headers/AnotherRoot"
  224
+      "Pods/Headers/AnotherRoot/ns"
225 225
     }
226 226
   end
227 227
 

0 notes on commit fa69d83

Please sign in to comment.
Something went wrong with that request. Please try again.