Commit 69de5e8d authored by Eloy Duran's avatar Eloy Duran

Integrate multiple Pods libraries with multiple user targets.

parent 59eec5a9
......@@ -5,6 +5,8 @@ Kicker::Recipes::Ruby.runner_bin = 'bacon'
process do |files|
specs = files.take_and_map do |file|
case file
when %r{lib/cocoapods/installer.+\.rb$}
'spec/unit/installer_spec.rb'
when %r{lib/cocoapods/(.+?)\.rb$}
s = Dir.glob("spec/**/#{$1}_spec.rb")
s unless s.empty?
......
......@@ -21,18 +21,10 @@ module Pod
})
end
def xcconfig_filename
"#{@target_definition.lib_name}.xcconfig"
end
def copy_resources_script_for(pods)
@copy_resources_script ||= Generator::CopyResourcesScript.new(pods.map { |p| p.resources }.flatten)
end
def copy_resources_filename
"#{@target_definition.lib_name}-resources.sh"
end
def bridge_support_generator_for(pods, sandbox)
Generator::BridgeSupport.new(pods.map do |pod|
pod.header_files.map { |header| sandbox.root + header }
......@@ -40,7 +32,7 @@ module Pod
end
def bridge_support_filename
"#{@target_definition.lib_name}.bridgesupport"
"#{@target_definition.label}.bridgesupport"
end
# TODO move out to Generator::PrefixHeader
......@@ -52,12 +44,8 @@ module Pod
end
end
def prefix_header_filename
"#{@target_definition.lib_name}-prefix.pch"
end
def target_support_files
[copy_resources_filename, prefix_header_filename, xcconfig_filename]
[:copy_resources_script_name, :prefix_header_name, :xcconfig_name].map { |file| @target_definition.send(file) }
end
# TODO move xcconfig related code into the xcconfig method, like copy_resources_script and generate_bridge_support.
......@@ -65,7 +53,7 @@ module Pod
self.requires_arc = pods.any? { |pod| pod.requires_arc? }
# First add the target to the project
@target = @project.targets.new_static_library(@target_definition.lib_name)
@target = @project.targets.new_static_library(@target_definition.label)
pods.each do |pod|
xcconfig.merge!(pod.specification.xcconfig)
......@@ -77,10 +65,10 @@ module Pod
xcconfig.merge!('HEADER_SEARCH_PATHS' => quoted(sandbox.header_search_paths).join(" "))
support_files_group = @project.group("Targets Support Files").create_group(@target_definition.lib_name)
support_files_group = @project.group("Targets Support Files").create_group(@target_definition.label)
support_files_group.create_files(target_support_files)
xcconfig_file = support_files_group.files.where(:path => xcconfig_filename)
xcconfig_file = support_files_group.files.where(:path => @target_definition.xcconfig_name)
configure_build_configurations(xcconfig_file)
create_files(pods, sandbox)
......@@ -90,7 +78,7 @@ module Pod
@target.build_configurations.each do |config|
config.base_configuration = xcconfig_file
config.build_settings['OTHER_LDFLAGS'] = ''
config.build_settings['GCC_PREFIX_HEADER'] = prefix_header_filename
config.build_settings['GCC_PREFIX_HEADER'] = @target_definition.prefix_header_name
config.build_settings['PODS_ROOT'] = '$(SRCROOT)'
end
end
......@@ -102,12 +90,12 @@ module Pod
bridge_support_generator_for(pods, sandbox).save_as(bridge_support_metadata_path)
copy_resources_script_for(pods).resources << bridge_support_filename
end
puts "* Generating xcconfig file at `#{sandbox.root + xcconfig_filename}'" if config.verbose?
xcconfig.save_as(sandbox.root + xcconfig_filename)
puts "* Generating prefix header at `#{sandbox.root + prefix_header_filename}'" if config.verbose?
save_prefix_header_as(sandbox.root + prefix_header_filename)
puts "* Generating copy resources script at `#{sandbox.root + copy_resources_filename}'" if config.verbose?
copy_resources_script_for(pods).save_as(sandbox.root + copy_resources_filename)
puts "* Generating xcconfig file at `#{sandbox.root + @target_definition.xcconfig_name}'" if config.verbose?
xcconfig.save_as(sandbox.root + @target_definition.xcconfig_name)
puts "* Generating prefix header at `#{sandbox.root + @target_definition.prefix_header_name}'" if config.verbose?
save_prefix_header_as(sandbox.root + @target_definition.prefix_header_name)
puts "* Generating copy resources script at `#{sandbox.root + @target_definition.copy_resources_script_name}'" if config.verbose?
copy_resources_script_for(pods).save_as(sandbox.root + @target_definition.copy_resources_script_name)
end
private
......
......@@ -14,16 +14,32 @@ module Pod
@link_with = targets.is_a?(Array) ? targets : [targets]
end
def lib_name
def label
if name == :default
"Pods"
elsif @parent
"#{@parent.lib_name}-#{name}"
"#{@parent.label}-#{name}"
else
"Pods-#{name}"
end
end
def lib_name
"lib#{label}.a"
end
def xcconfig_name
"#{label}.xcconfig"
end
def copy_resources_script_name
"#{label}-resources.sh"
end
def prefix_header_name
"#{label}-prefix.pch"
end
# Returns *all* dependencies of this target, not only the target specific
# ones in `target_dependencies`.
def dependencies
......
......@@ -19,9 +19,7 @@ module Pod
create_workspace!
return if project_already_integrated?
base_user_project_configurations_on_xcconfig
add_pods_library_to_each_target
add_copy_resources_script_phase_to_each_target
targets.each(&:integrate!)
@user_project.save_as(user_project_path)
unless config.silent?
......@@ -38,6 +36,10 @@ module Pod
config.project_root + "Pods/Pods.xcodeproj"
end
def targets
@podfile.target_definitions.values.map { |definition| Target.new(self, definition) }
end
def create_workspace!
workspace = Xcodeproj::Workspace.new_from_xcworkspace(workspace_path)
[user_project_path, pods_project_path].each do |project_path|
......@@ -51,31 +53,54 @@ module Pod
@user_project.files.find { |file| file.path =~ /libPods\.a$/ }
end
def base_user_project_configurations_on_xcconfig
xcconfig = @user_project.files.new('path' => 'Pods/Pods.xcconfig')
user_project.targets.each do |target|
target.build_configurations.each do |config|
config.base_configuration = xcconfig
class Target
attr_reader :integrator, :target_definition
def initialize(integrator, target_definition)
@integrator, @target_definition = integrator, target_definition
end
def integrate!
add_xcconfig_base_configuration
add_pods_library
add_copy_resources_script_phase
end
# @return [Array<PBXNativeTarget>] Returns the list of targets that
# the Pods lib should be linked with.
def targets
@integrator.user_project.targets.select do |target|
@target_definition.link_with.include? target.name
end
end
end
def add_pods_library_to_each_target
pods_library = @user_project.group("Frameworks").files.new_static_library('Pods')
@user_project.targets.each do |target|
target.frameworks_build_phases.each do |build_phase|
build_phase.files << pods_library.build_files.new
def add_xcconfig_base_configuration
xcconfig = @integrator.user_project.files.new('path' => "Pods/#{@target_definition.xcconfig_name}") # TODO use Sandbox?
targets.each do |target|
target.build_configurations.each do |config|
config.base_configuration = xcconfig
end
end
end
end
def add_copy_resources_script_phase_to_each_target
@user_project.targets.each do |target|
phase = target.shell_script_build_phases.new
phase.name = 'Copy Pods Resources'
phase.shell_script = %{"${SRCROOT}/Pods/Pods-resources.sh"\n}
def add_pods_library
pods_library = @integrator.user_project.group("Frameworks").files.new_static_library(@target_definition.label)
targets.each do |target|
target.frameworks_build_phases.each do |build_phase|
build_phase.files << pods_library.build_files.new
end
end
end
def add_copy_resources_script_phase
targets.each do |target|
phase = target.shell_script_build_phases.new
phase.name = 'Copy Pods Resources'
phase.shell_script = %{"${SRCROOT}/Pods/#{@target_definition.copy_resources_script_name}"\n}
end
end
end
end
end
......
......@@ -7,6 +7,12 @@
objects = {
/* Begin PBXBuildFile section */
51075D4C1521D0C100E39B41 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A346497114F9BE9A0080D870 /* UIKit.framework */; };
51075D4D1521D0C100E39B41 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A346497314F9BE9A0080D870 /* Foundation.framework */; };
51075D4E1521D0C100E39B41 /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A346497514F9BE9A0080D870 /* CoreGraphics.framework */; };
51075D541521D0C100E39B41 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 51075D521521D0C100E39B41 /* InfoPlist.strings */; };
51075D561521D0C100E39B41 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 51075D551521D0C100E39B41 /* main.m */; };
51075D5A1521D0C100E39B41 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 51075D591521D0C100E39B41 /* AppDelegate.m */; };
A346497214F9BE9A0080D870 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A346497114F9BE9A0080D870 /* UIKit.framework */; };
A346497414F9BE9A0080D870 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A346497314F9BE9A0080D870 /* Foundation.framework */; };
A346497614F9BE9A0080D870 /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A346497514F9BE9A0080D870 /* CoreGraphics.framework */; };
......@@ -16,6 +22,13 @@
/* End PBXBuildFile section */
/* Begin PBXFileReference section */
51075D4A1521D0C100E39B41 /* TestRunner.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = TestRunner.app; sourceTree = BUILT_PRODUCTS_DIR; };
51075D511521D0C100E39B41 /* TestRunner-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "TestRunner-Info.plist"; sourceTree = "<group>"; };
51075D531521D0C100E39B41 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = "<group>"; };
51075D551521D0C100E39B41 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = "<group>"; };
51075D571521D0C100E39B41 /* TestRunner-Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "TestRunner-Prefix.pch"; sourceTree = "<group>"; };
51075D581521D0C100E39B41 /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = "<group>"; };
51075D591521D0C100E39B41 /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = "<group>"; };
A346496D14F9BE9A0080D870 /* SampleProject.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = SampleProject.app; sourceTree = BUILT_PRODUCTS_DIR; };
A346497114F9BE9A0080D870 /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; };
A346497314F9BE9A0080D870 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; };
......@@ -29,6 +42,16 @@
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
51075D471521D0C100E39B41 /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
51075D4C1521D0C100E39B41 /* UIKit.framework in Frameworks */,
51075D4D1521D0C100E39B41 /* Foundation.framework in Frameworks */,
51075D4E1521D0C100E39B41 /* CoreGraphics.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
A346496A14F9BE9A0080D870 /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
......@@ -42,10 +65,32 @@
/* End PBXFrameworksBuildPhase section */
/* Begin PBXGroup section */
51075D4F1521D0C100E39B41 /* TestRunner */ = {
isa = PBXGroup;
children = (
51075D581521D0C100E39B41 /* AppDelegate.h */,
51075D591521D0C100E39B41 /* AppDelegate.m */,
51075D501521D0C100E39B41 /* Supporting Files */,
);
path = TestRunner;
sourceTree = "<group>";
};
51075D501521D0C100E39B41 /* Supporting Files */ = {
isa = PBXGroup;
children = (
51075D511521D0C100E39B41 /* TestRunner-Info.plist */,
51075D521521D0C100E39B41 /* InfoPlist.strings */,
51075D551521D0C100E39B41 /* main.m */,
51075D571521D0C100E39B41 /* TestRunner-Prefix.pch */,
);
name = "Supporting Files";
sourceTree = "<group>";
};
A346496214F9BE990080D870 = {
isa = PBXGroup;
children = (
A346497714F9BE9A0080D870 /* SampleProject */,
51075D4F1521D0C100E39B41 /* TestRunner */,
A346497014F9BE9A0080D870 /* Frameworks */,
A346496E14F9BE9A0080D870 /* Products */,
);
......@@ -55,6 +100,7 @@
isa = PBXGroup;
children = (
A346496D14F9BE9A0080D870 /* SampleProject.app */,
51075D4A1521D0C100E39B41 /* TestRunner.app */,
);
name = Products;
sourceTree = "<group>";
......@@ -93,6 +139,23 @@
/* End PBXGroup section */
/* Begin PBXNativeTarget section */
51075D491521D0C100E39B41 /* TestRunner */ = {
isa = PBXNativeTarget;
buildConfigurationList = 51075D5B1521D0C100E39B41 /* Build configuration list for PBXNativeTarget "TestRunner" */;
buildPhases = (
51075D461521D0C100E39B41 /* Sources */,
51075D471521D0C100E39B41 /* Frameworks */,
51075D481521D0C100E39B41 /* Resources */,
);
buildRules = (
);
dependencies = (
);
name = TestRunner;
productName = TestRunner;
productReference = 51075D4A1521D0C100E39B41 /* TestRunner.app */;
productType = "com.apple.product-type.application";
};
A346496C14F9BE9A0080D870 /* SampleProject */ = {
isa = PBXNativeTarget;
buildConfigurationList = A346498514F9BE9A0080D870 /* Build configuration list for PBXNativeTarget "SampleProject" */;
......@@ -132,11 +195,20 @@
projectRoot = "";
targets = (
A346496C14F9BE9A0080D870 /* SampleProject */,
51075D491521D0C100E39B41 /* TestRunner */,
);
};
/* End PBXProject section */
/* Begin PBXResourcesBuildPhase section */
51075D481521D0C100E39B41 /* Resources */ = {
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
51075D541521D0C100E39B41 /* InfoPlist.strings in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
A346496B14F9BE9A0080D870 /* Resources */ = {
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
......@@ -148,6 +220,15 @@
/* End PBXResourcesBuildPhase section */
/* Begin PBXSourcesBuildPhase section */
51075D461521D0C100E39B41 /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
51075D561521D0C100E39B41 /* main.m in Sources */,
51075D5A1521D0C100E39B41 /* AppDelegate.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
A346496914F9BE9A0080D870 /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
......@@ -160,6 +241,14 @@
/* End PBXSourcesBuildPhase section */
/* Begin PBXVariantGroup section */
51075D521521D0C100E39B41 /* InfoPlist.strings */ = {
isa = PBXVariantGroup;
children = (
51075D531521D0C100E39B41 /* en */,
);
name = InfoPlist.strings;
sourceTree = "<group>";
};
A346497A14F9BE9A0080D870 /* InfoPlist.strings */ = {
isa = PBXVariantGroup;
children = (
......@@ -171,6 +260,34 @@
/* End PBXVariantGroup section */
/* Begin XCBuildConfiguration section */
51075D5C1521D0C100E39B41 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = "TestRunner/TestRunner-Prefix.pch";
INFOPLIST_FILE = "TestRunner/TestRunner-Info.plist";
IPHONEOS_DEPLOYMENT_TARGET = 5.1;
PRODUCT_NAME = "$(TARGET_NAME)";
TARGETED_DEVICE_FAMILY = "1,2";
WRAPPER_EXTENSION = app;
};
name = Debug;
};
51075D5D1521D0C100E39B41 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = "TestRunner/TestRunner-Prefix.pch";
INFOPLIST_FILE = "TestRunner/TestRunner-Info.plist";
IPHONEOS_DEPLOYMENT_TARGET = 5.1;
PRODUCT_NAME = "$(TARGET_NAME)";
TARGETED_DEVICE_FAMILY = "1,2";
WRAPPER_EXTENSION = app;
};
name = Release;
};
A346498314F9BE9A0080D870 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
......@@ -241,6 +358,14 @@
/* End XCBuildConfiguration section */
/* Begin XCConfigurationList section */
51075D5B1521D0C100E39B41 /* Build configuration list for PBXNativeTarget "TestRunner" */ = {
isa = XCConfigurationList;
buildConfigurations = (
51075D5C1521D0C100E39B41 /* Debug */,
51075D5D1521D0C100E39B41 /* Release */,
);
defaultConfigurationIsVisible = 0;
};
A346496714F9BE990080D870 /* Build configuration list for PBXProject "SampleProject" */ = {
isa = XCConfigurationList;
buildConfigurations = (
......@@ -257,6 +382,7 @@
A346498714F9BE9A0080D870 /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
/* End XCConfigurationList section */
};
......
......@@ -9,7 +9,7 @@
<key>CFBundleExecutable</key>
<string>${EXECUTABLE_NAME}</string>
<key>CFBundleIdentifier</key>
<string>co.uk.lukeredpath.${PRODUCT_NAME:rfc1034identifier}</string>
<string>org.cocoapods.${PRODUCT_NAME:rfc1034identifier}</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
......
//
// AppDelegate.h
// TestRunner
//
// Created by Eloy Durán on 3/27/12.
// Copyright (c) 2012 __MyCompanyName__. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface AppDelegate : UIResponder <UIApplicationDelegate>
@property (strong, nonatomic) UIWindow *window;
@end
//
// AppDelegate.m
// TestRunner
//
// Created by Eloy Durán on 3/27/12.
// Copyright (c) 2012 __MyCompanyName__. All rights reserved.
//
#import "AppDelegate.h"
@implementation AppDelegate
@synthesize window = _window;
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
// Override point for customization after application launch.
self.window.backgroundColor = [UIColor whiteColor];
[self.window makeKeyAndVisible];
return YES;
}
- (void)applicationWillResignActive:(UIApplication *)application
{
// Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
// Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
}
- (void)applicationDidEnterBackground:(UIApplication *)application
{
// Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
// If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
}
- (void)applicationWillEnterForeground:(UIApplication *)application
{
// Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
}
- (void)applicationDidBecomeActive:(UIApplication *)application
{
// Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
}
- (void)applicationWillTerminate:(UIApplication *)application
{
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
}
@end
<?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>CFBundleDisplayName</key>
<string>${PRODUCT_NAME}</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>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1.0</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>UIRequiredDeviceCapabilities</key>
<array>
<string>armv7</string>
</array>
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
<key>UISupportedInterfaceOrientations~ipad</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationPortraitUpsideDown</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
</dict>
</plist>
//
// Prefix header for all source files of the 'TestRunner' target in the 'TestRunner' project
//
#import <Availability.h>
#ifndef __IPHONE_3_0
#warning "This project uses features only available in iOS SDK 3.0 and later."
#endif
#ifdef __OBJC__
#import <UIKit/UIKit.h>
#import <Foundation/Foundation.h>
#endif
//
// main.m
// TestRunner
//
// Created by Eloy Durán on 3/27/12.
// Copyright (c) 2012 __MyCompanyName__. All rights reserved.
//
#import <UIKit/UIKit.h>
#import "AppDelegate.h"
int main(int argc, char *argv[])
{
@autoreleasepool {
return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
}
}
......@@ -4,10 +4,18 @@ describe Pod::Project::Integrator, 'TODO UNIT SPECS!' do
extend SpecHelper::TemporaryDirectory
before do
@podfile = Pod::Podfile.new do
platform :ios
dependency 'JSONKit'
target :test_runner, :exclusive => true, :link_with => 'TestRunner' do
dependency 'Kiwi'
end
end
@sample_project_path = SpecHelper.create_sample_app_copy_from_fixture('SampleProject')
config.project_root = @sample_project_path.dirname
@integrator = Pod::Project::Integrator.new(@sample_project_path)
@sample_project = Xcodeproj::Project.new(@sample_project_path)
@integrator = Pod::Project::Integrator.new(@sample_project_path, @podfile)
end
after do
......@@ -21,15 +29,31 @@ describe Pod::Project::Integrator, 'TODO UNIT SPECS!' do
it "returns the path to the Pods.xcodeproj document" do
@integrator.pods_project_path.should == config.project_root + 'Pods/Pods.xcodeproj'
end
it "returns a Pod::Project::Integrator::Target for each target definition in the Podfile" do
@integrator.targets.map(&:target_definition).should == @podfile.target_definitions.values
end
end
describe Pod::Project::Integrator do
extend SpecHelper::TemporaryDirectory
before do
@podfile = Pod::Podfile.new do
platform :ios
link_with 'SampleProject' # this is an app target!
dependency 'JSONKit'
target :test_runner, :exclusive => true, :link_with => 'TestRunner' do
dependency 'Kiwi'
end
end
@sample_project_path = SpecHelper.create_sample_app_copy_from_fixture('SampleProject')
config.project_root = @sample_project_path.dirname
@integrator = Pod::Project::Integrator.new(@sample_project_path)
@integrator = Pod::Project::Integrator.new(@sample_project_path, @podfile)
@integrator.integrate!
@sample_project = Xcodeproj::Project.new(@sample_project_path)
end
......@@ -58,31 +82,33 @@ describe Pod::Project::Integrator do
end
it 'sets the Pods xcconfig as the base config for each build configuration' do
xcconfig_file = @sample_project.files.where(:path => "Pods/Pods.xcconfig")
@sample_project.targets.each do |target|
@podfile.target_definitions.each do |_, definition|
target = @sample_project.targets.where(:name => definition.link_with.first)
xcconfig_file = @sample_project.files.where(:path => "Pods/#{definition.xcconfig_name}")
target.build_configurations.each do |config|
config.base_configuration.should == xcconfig_file
end
end
end
it 'adds a reference to the libPods static library' do
static_lib = @sample_project.files.where(:name => "libPods.a")
static_lib.should.not.be.nil
it 'adds references to the Pods static libraries' do
@sample_project.files.where(:name => "libPods.a").should.not == nil
@sample_project.files.where(:name => "libPods-test_runner.a").should.not == nil
end
it 'adds the libPods static library to the "Link binary with libraries" build phase of each target' do
@sample_project.targets.each do |target|
@podfile.target_definitions.each do |_, definition|
target = @sample_project.targets.where(:name => definition.link_with.first)
framework_build_phase = target.frameworks_build_phases.first
framework_build_phase.files.where(:file => {:name => 'libPods.a'}).should.not.be.nil
framework_build_phase.files.where(:file => { :name => definition.lib_name }).should.not == nil
end
end
it 'adds a Copy Pods Resources build phase to each target' do
@sample_project.targets.each do |target|
@podfile.target_definitions.each do |_, definition|
target = @sample_project.targets.where(:name => definition.link_with.first)
expected_phase = target.shell_script_build_phases.where(:name => "Copy Pods Resources")
expected_phase.shell_script.strip.should == "\"${SRCROOT}/Pods/Pods-resources.sh\"".strip
expected_phase.shell_script.strip.should == "\"${SRCROOT}/Pods/#{definition.copy_resources_script_name}\"".strip
end
end
end
......
......@@ -91,13 +91,13 @@ describe "Pod::Podfile" do
it "adds dependencies outside of any explicit target block to the default target" do
target = @podfile.target_definitions[:default]
target.lib_name.should == 'Pods'
target.label.should == 'Pods'
target.dependencies.should == [Pod::Dependency.new('ASIHTTPRequest')]
end
it "adds dependencies of the outer target to non-exclusive targets" do
target = @podfile.target_definitions[:debug]
target.lib_name.should == 'Pods-debug'
target.label.should == 'Pods-debug'
target.dependencies.sort_by(&:name).should == [
Pod::Dependency.new('ASIHTTPRequest'),
Pod::Dependency.new('SSZipArchive')
......@@ -106,13 +106,13 @@ describe "Pod::Podfile" do
it "does not add dependencies of the outer target to exclusive targets" do
target = @podfile.target_definitions[:test]
target.lib_name.should == 'Pods-test'
target.label.should == 'Pods-test'
target.dependencies.should == [Pod::Dependency.new('JSONKit')]
end
it "adds dependencies of the outer target to nested targets" do
target = @podfile.target_definitions[:subtarget]
target.lib_name.should == 'Pods-test-subtarget'
target.label.should == 'Pods-test-subtarget'
target.dependencies.should == [Pod::Dependency.new('Reachability'), Pod::Dependency.new('JSONKit')]
end
......@@ -121,10 +121,30 @@ describe "Pod::Podfile" do
target.link_with.should == nil
end
it "returns the name of the explicit target to link with" do
it "returns the names of the explicit targets to link with" do
target = @podfile.target_definitions[:test]
target.link_with.should == ['TestRunner']
end
it "returns the name of the Pods static library" do
@podfile.target_definitions[:default].lib_name.should == 'libPods.a'
@podfile.target_definitions[:test].lib_name.should == 'libPods-test.a'
end
it "returns the name of the xcconfig file for the target" do
@podfile.target_definitions[:default].xcconfig_name.should == 'Pods.xcconfig'
@podfile.target_definitions[:test].xcconfig_name.should == 'Pods-test.xcconfig'
end
it "returns the name of the 'copy resources script' file for the target" do
@podfile.target_definitions[:default].copy_resources_script_name.should == 'Pods-resources.sh'
@podfile.target_definitions[:test].copy_resources_script_name.should == 'Pods-test-resources.sh'
end
it "returns the name of the 'prefix header' file for the target" do
@podfile.target_definitions[:default].prefix_header_name.should == 'Pods-prefix.pch'
@podfile.target_definitions[:test].prefix_header_name.should == 'Pods-test-prefix.pch'
end
end
describe "concerning validations" do
......
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