Commit 816970fc authored by Marius Rackwitz's avatar Marius Rackwitz

Generate an Info.plist for frameworks

parent 4875a76e
...@@ -57,6 +57,7 @@ module Pod ...@@ -57,6 +57,7 @@ module Pod
autoload :CopyResourcesScript, 'cocoapods/generator/copy_resources_script' autoload :CopyResourcesScript, 'cocoapods/generator/copy_resources_script'
autoload :DummySource, 'cocoapods/generator/dummy_source' autoload :DummySource, 'cocoapods/generator/dummy_source'
autoload :Header, 'cocoapods/generator/header' autoload :Header, 'cocoapods/generator/header'
autoload :InfoPlistFile, 'cocoapods/generator/info_plist_file'
autoload :PrefixHeader, 'cocoapods/generator/prefix_header' autoload :PrefixHeader, 'cocoapods/generator/prefix_header'
autoload :TargetEnvironmentHeader, 'cocoapods/generator/target_environment_header' autoload :TargetEnvironmentHeader, 'cocoapods/generator/target_environment_header'
autoload :XCConfig, 'cocoapods/generator/xcconfig' autoload :XCConfig, 'cocoapods/generator/xcconfig'
......
module Pod
module Generator
# Generates Info.plist files. A Info.plist file is generated for each
# Pod and for each Pod target definition, that requires to be built as
# framework. It states public attributes.
#
class InfoPlistFile
# @return [Target] the target represented by this Info.plist.
#
attr_reader :target
# @param [Target] target @see target
#
def initialize(target)
@target = target
end
# Generates and saves the Info.plist to the given path.
#
# @param [Pathname] path
# the path where the prefix header should be stored.
#
# @return [void]
#
def save_as(path)
contents = generate
File.open(path, 'w') do |f|
f.write(contents)
end
end
# Generates the contents of the Info.plist
#
# @return [String]
#
def generate
FILE_CONTENTS
end
FILE_CONTENTS = <<-EOS
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleExecutable</key>
<string>${EXECUTABLE_NAME}</string>
<key>CFBundleIdentifier</key>
<string>org.cocoapods.${PRODUCT_NAME:rfc1034identifier}</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>${PRODUCT_NAME}</string>
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>${CURRENT_PROJECT_VERSION}</string>
<key>NSPrincipalClass</key>
<string></string>
</dict>
</plist>
EOS
end
end
end
...@@ -64,6 +64,24 @@ module Pod ...@@ -64,6 +64,24 @@ module Pod
target.support_files_dir.mkdir target.support_files_dir.mkdir
end end
# Creates the Info.plist file which sets public framework attributes
#
# @return [void]
#
def create_info_plist_file
path = target.info_plist_path
UI.message "- Generating Info.plist file at #{UI.path(path)}" do
generator = Generator::InfoPlistFile.new(target)
generator.save_as(path)
add_file_to_support_group(path)
native_target.build_configurations.each do |c|
relative_path = path.relative_path_from(sandbox.root)
c.build_settings['INFOPLIST_FILE'] = relative_path.to_s
end
end
end
# Generates a dummy source file for each target so libraries that contain # Generates a dummy source file for each target so libraries that contain
# only categories build. # only categories build.
# #
......
...@@ -14,6 +14,7 @@ module Pod ...@@ -14,6 +14,7 @@ module Pod
create_support_files_dir create_support_files_dir
create_suport_files_group create_suport_files_group
create_xcconfig_file create_xcconfig_file
create_info_plist_file if target.requires_framework?
create_target_environment_header create_target_environment_header
create_bridge_support_file create_bridge_support_file
create_copy_resources_script create_copy_resources_script
......
...@@ -20,6 +20,7 @@ module Pod ...@@ -20,6 +20,7 @@ module Pod
add_files_to_build_phases add_files_to_build_phases
add_resources_bundle_targets add_resources_bundle_targets
create_xcconfig_file create_xcconfig_file
create_info_plist_file if target.requires_framework?
create_prefix_header create_prefix_header
create_dummy_source create_dummy_source
end end
......
...@@ -158,6 +158,12 @@ module Pod ...@@ -158,6 +158,12 @@ module Pod
support_files_dir + "#{label}.bridgesupport" support_files_dir + "#{label}.bridgesupport"
end end
# @return [Pathname] the absolute path of the Info.plist file.
#
def info_plist_path
support_files_dir + "Info.plist"
end
# @return [Pathname] the path of the dummy source generated by CocoaPods # @return [Pathname] the path of the dummy source generated by CocoaPods
# #
def dummy_source_path def dummy_source_path
......
require File.expand_path('../../../spec_helper', __FILE__)
describe Pod::Generator::InfoPlistFile do
it 'generates a valid Info.plist file' do
generator = Pod::Generator::InfoPlistFile.new(mock('Target'))
file = temporary_directory + 'Info.plist'
generator.save_as(file)
`plutil -lint #{file}`
$?.should.be.success
end
end
...@@ -92,6 +92,12 @@ module Pod ...@@ -92,6 +92,12 @@ module Pod
) )
end end
it 'returns the absolute path of the info plist file' do
@pod_target.info_plist_path.to_s.should.include?(
'Pods/Target Support Files/Pods-BananaLib/Info.plist'
)
end
it 'returns the absolute path of the public and private xcconfig files' do it 'returns the absolute path of the public and private xcconfig files' do
@pod_target.xcconfig_path.to_s.should.include?( @pod_target.xcconfig_path.to_s.should.include?(
'Pods/Target Support Files/Pods-BananaLib/Pods-BananaLib.xcconfig' 'Pods/Target Support Files/Pods-BananaLib/Pods-BananaLib.xcconfig'
......
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