Commit 193572d8 authored by Eloy Duran's avatar Eloy Duran

Generate a prefix header for each target and remove the files from disk and the project template.

parent 018cb7f4
...@@ -61,6 +61,19 @@ module Pod ...@@ -61,6 +61,19 @@ module Pod
"#{@definition.lib_name}.bridgesupport" "#{@definition.lib_name}.bridgesupport"
end end
# TODO move out
def save_prefix_header_as(pathname)
pathname.open('w') do |header|
header.puts "#ifdef __OBJC__"
header.puts "#import #{@podfile.platform == :ios ? '<UIKit/UIKit.h>' : '<Cocoa/Cocoa.h>'}"
header.puts "#endif"
end
end
def prefix_header_filename
"#{@definition.lib_name}-prefix.pch"
end
# TODO move xcconfig related code into the xcconfig method, like copy_resources_script and generate_bridge_support. # TODO move xcconfig related code into the xcconfig method, like copy_resources_script and generate_bridge_support.
def install! def install!
# First add the target to the project # First add the target to the project
...@@ -86,10 +99,12 @@ module Pod ...@@ -86,10 +99,12 @@ module Pod
end end
xcconfig.merge!('USER_HEADER_SEARCH_PATHS' => user_header_search_paths.sort.uniq.join(" ")) xcconfig.merge!('USER_HEADER_SEARCH_PATHS' => user_header_search_paths.sort.uniq.join(" "))
# Add the xcconfig file to the project and make it the base of the target's configurations. # Add the prefix header and xcconfig files to the project
@xcodeproj.files.new('path' => prefix_header_filename)
xcconfig_file = @xcodeproj.files.new("path" => xcconfig_filename) xcconfig_file = @xcodeproj.files.new("path" => xcconfig_filename)
@target.buildConfigurations.each do |config| @target.buildConfigurations.each do |config|
config.baseConfiguration = xcconfig_file config.baseConfiguration = xcconfig_file
config.buildSettings['GCC_PREFIX_HEADER'] = prefix_header_filename
end end
end end
...@@ -99,6 +114,7 @@ module Pod ...@@ -99,6 +114,7 @@ module Pod
bridge_support_generator.save_as(root + bridge_support_filename) bridge_support_generator.save_as(root + bridge_support_filename)
copy_resources_script.resources << bridge_support_filename copy_resources_script.resources << bridge_support_filename
end end
save_prefix_header_as(root + prefix_header_filename)
copy_resources_script.save_as(root + copy_resources_filename) copy_resources_script.save_as(root + copy_resources_filename)
end end
end end
...@@ -154,9 +170,12 @@ module Pod ...@@ -154,9 +170,12 @@ module Pod
puts " * Writing Xcode project file to `#{pbxproj}'" if config.verbose? puts " * Writing Xcode project file to `#{pbxproj}'" if config.verbose?
xcodeproj.save_as(pbxproj) xcodeproj.save_as(pbxproj)
build_specifications.each(&:post_install) # Post install hooks run last!
targets.each do |target|
target.build_specifications.each { |spec| spec.post_install(target) }
end
end end
def configure_project(projpath) def configure_project(projpath)
root = File.dirname(projpath) root = File.dirname(projpath)
xcworkspace = File.join(root, File.basename(projpath, '.xcodeproj') + '.xcworkspace') xcworkspace = File.join(root, File.basename(projpath, '.xcodeproj') + '.xcworkspace')
......
...@@ -325,17 +325,18 @@ module Pod ...@@ -325,17 +325,18 @@ module Pod
# This is a convenience method which gets called after all pods have been # This is a convenience method which gets called after all pods have been
# downloaded, installed, and the Xcode project and related files have been # downloaded, installed, and the Xcode project and related files have been
# generated. Override this to, for instance, add to the prefix header: # generated. (It receives the Pod::Installer::Target instance for the current
# target.) Override this to, for instance, add to the prefix header:
# #
# Pod::Spec.new do |s| # Pod::Spec.new do |s|
# def s.post_install # def s.post_install(target)
# prefix_header = config.project_pods_root + 'Pods-Prefix.pch' # prefix_header = config.project_pods_root + target.prefix_header_filename
# prefix_header.open('a') do |file| # prefix_header.open('a') do |file|
# file.puts(%{#ifdef __OBJC__\n#import "SSToolkitDefines.h"\n#endif}) # file.puts(%{#ifdef __OBJC__\n#import "SSToolkitDefines.h"\n#endif})
# end # end
# end # end
# end # end
def post_install def post_install(target)
end end
end end
......
...@@ -331,7 +331,6 @@ module Pod ...@@ -331,7 +331,6 @@ module Pod
self.buildSettings = { self.buildSettings = {
'DSTROOT' => '/tmp/Pods.dst', 'DSTROOT' => '/tmp/Pods.dst',
'GCC_PRECOMPILE_PREFIX_HEADER' => 'YES', 'GCC_PRECOMPILE_PREFIX_HEADER' => 'YES',
'GCC_PREFIX_HEADER' => 'Pods-Prefix.pch',
'GCC_VERSION' => 'com.apple.compilers.llvm.clang.1_0', 'GCC_VERSION' => 'com.apple.compilers.llvm.clang.1_0',
# The OTHER_LDFLAGS option *has* to be overriden so that it does not # The OTHER_LDFLAGS option *has* to be overriden so that it does not
# use those from the xcconfig (for CocoaPods specifically). # use those from the xcconfig (for CocoaPods specifically).
......
...@@ -174,6 +174,7 @@ else ...@@ -174,6 +174,7 @@ else
Dir.chdir(config.project_pods_root) do Dir.chdir(config.project_pods_root) do
puts "\n[!] Compiling static library `Pods'..." puts "\n[!] Compiling static library `Pods'..."
#system("xcodebuild -target Pods").should == true
system("xcodebuild -target Pods > /dev/null 2>&1").should == true system("xcodebuild -target Pods > /dev/null 2>&1").should == true
puts "\n[!] Compiling static library `Pods-debug'..." puts "\n[!] Compiling static library `Pods-debug'..."
system("xcodebuild -target Pods-debug > /dev/null 2>&1").should == true system("xcodebuild -target Pods-debug > /dev/null 2>&1").should == true
......
...@@ -183,7 +183,8 @@ describe "Pod::Xcode::Project" do ...@@ -183,7 +183,8 @@ describe "Pod::Xcode::Project" do
configuration.buildSettings.should == { configuration.buildSettings.should == {
'DSTROOT' => '/tmp/Pods.dst', 'DSTROOT' => '/tmp/Pods.dst',
'GCC_PRECOMPILE_PREFIX_HEADER' => 'YES', 'GCC_PRECOMPILE_PREFIX_HEADER' => 'YES',
'GCC_PREFIX_HEADER' => 'Pods-Prefix.pch', # TODO do we need a default?
#'GCC_PREFIX_HEADER' => 'Pods-Prefix.pch',
'OTHER_LDFLAGS' => '', 'OTHER_LDFLAGS' => '',
'GCC_VERSION' => 'com.apple.compilers.llvm.clang.1_0', 'GCC_VERSION' => 'com.apple.compilers.llvm.clang.1_0',
'PRODUCT_NAME' => '$(TARGET_NAME)', 'PRODUCT_NAME' => '$(TARGET_NAME)',
...@@ -322,8 +323,6 @@ describe "Pod::Xcode::Project" do ...@@ -322,8 +323,6 @@ describe "Pod::Xcode::Project" do
it "saves the template with the adjusted project" do it "saves the template with the adjusted project" do
@template.copy_to(temporary_directory) @template.copy_to(temporary_directory)
@project.save_as(temporary_directory + 'Pods.xcodeproj') @project.save_as(temporary_directory + 'Pods.xcodeproj')
(temporary_directory + 'Pods-Prefix.pch').should.exist
(temporary_directory + 'Pods.xcconfig').should.exist
project_file = (temporary_directory + 'Pods.xcodeproj/project.pbxproj') project_file = (temporary_directory + 'Pods.xcodeproj/project.pbxproj')
NSDictionary.dictionaryWithContentsOfFile(project_file.to_s).should == @project.to_hash NSDictionary.dictionaryWithContentsOfFile(project_file.to_s).should == @project.to_hash
end end
......
//
// Prefix header for all source files of the 'Pods' target in the 'Pods' project
//
#ifdef __OBJC__
#import <Cocoa/Cocoa.h>
#endif
...@@ -8,15 +8,12 @@ ...@@ -8,15 +8,12 @@
/* Begin PBXFileReference section */ /* Begin PBXFileReference section */
518ACD3E1446050200F6BE80 /* Cocoa.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Cocoa.framework; path = System/Library/Frameworks/Cocoa.framework; sourceTree = SDKROOT; }; 518ACD3E1446050200F6BE80 /* Cocoa.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Cocoa.framework; path = System/Library/Frameworks/Cocoa.framework; sourceTree = SDKROOT; };
518ACD461446050200F6BE80 /* Pods-Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "Pods-Prefix.pch"; sourceTree = "<group>"; };
518ACD53144605B400F6BE80 /* Pods.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = Pods.xcconfig; sourceTree = "<group>"; };
/* End PBXFileReference section */ /* End PBXFileReference section */
/* Begin PBXGroup section */ /* Begin PBXGroup section */
518ACD301446050100F6BE80 = { 518ACD301446050100F6BE80 = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
518ACD53144605B400F6BE80 /* Pods.xcconfig */,
518ACD5B1446449B00F6BE80 /* Pods */, 518ACD5B1446449B00F6BE80 /* Pods */,
518ACD3D1446050200F6BE80 /* Frameworks */, 518ACD3D1446050200F6BE80 /* Frameworks */,
518ACD3C1446050200F6BE80 /* Products */, 518ACD3C1446050200F6BE80 /* Products */,
...@@ -41,7 +38,6 @@ ...@@ -41,7 +38,6 @@
518ACD451446050200F6BE80 /* Supporting Files */ = { 518ACD451446050200F6BE80 /* Supporting Files */ = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
518ACD461446050200F6BE80 /* Pods-Prefix.pch */,
); );
name = "Supporting Files"; name = "Supporting Files";
path = Pods; path = Pods;
......
//
// Prefix header for all source files of the 'Pods' target in the 'Pods' project
//
#ifdef __OBJC__
#import <UIKit/UIKit.h>
#endif
...@@ -7,16 +7,13 @@ ...@@ -7,16 +7,13 @@
objects = { objects = {
/* Begin PBXFileReference section */ /* Begin PBXFileReference section */
515160D0141EC5D100EBB823 /* Pods.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = Pods.xcconfig; sourceTree = "<group>"; };
515B0FB8141D52E0001DC3E6 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; }; 515B0FB8141D52E0001DC3E6 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; };
515B0FBC141D52E0001DC3E6 /* Pods-Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "Pods-Prefix.pch"; sourceTree = SOURCE_ROOT; };
/* End PBXFileReference section */ /* End PBXFileReference section */
/* Begin PBXGroup section */ /* Begin PBXGroup section */
515B0FAA141D52E0001DC3E6 = { 515B0FAA141D52E0001DC3E6 = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
515160D0141EC5D100EBB823 /* Pods.xcconfig */,
515B0FC9141D5FBE001DC3E6 /* Pods */, 515B0FC9141D5FBE001DC3E6 /* Pods */,
515B0FB7141D52E0001DC3E6 /* Frameworks */, 515B0FB7141D52E0001DC3E6 /* Frameworks */,
515B0FB6141D52E0001DC3E6 /* Products */, 515B0FB6141D52E0001DC3E6 /* Products */,
...@@ -41,7 +38,6 @@ ...@@ -41,7 +38,6 @@
515B0FBB141D52E0001DC3E6 /* Supporting Files */ = { 515B0FBB141D52E0001DC3E6 /* Supporting Files */ = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
515B0FBC141D52E0001DC3E6 /* Pods-Prefix.pch */,
); );
name = "Supporting Files"; name = "Supporting Files";
path = Pods; path = Pods;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment