Commit 921492d5 authored by Samuel E. Giddins's avatar Samuel E. Giddins Committed by Samuel Giddins

Introduce new Podfile DSL

wip

get tests passing

[Gemfile] Point to git for Core
parent 71ce9d47
......@@ -17,7 +17,7 @@ gem 'json', :git => 'https://github.com/segiddins/json.git', :branch => 'seg-1.7
group :development do
cp_gem 'claide', 'CLAide'
cp_gem 'cocoapods-core', 'Core'
cp_gem 'cocoapods-core', 'Core', 'seg-podfile-refactor'
cp_gem 'cocoapods-deintegrate', 'cocoapods-deintegrate'
cp_gem 'cocoapods-downloader', 'cocoapods-downloader'
cp_gem 'cocoapods-plugins', 'cocoapods-plugins'
......
......@@ -7,8 +7,8 @@ GIT
GIT
remote: https://github.com/CocoaPods/Core.git
revision: 0851a1e712e1e1c206ed03f67a25ef28af52fa69
branch: master
revision: 3114804fac0ab28cd17ceb7d6fc29d0ca9c88e6e
branch: seg-podfile-refactor
specs:
cocoapods-core (0.39.0)
activesupport (>= 4.0.2)
......
......@@ -87,15 +87,9 @@ module Pod
#---------------------------------------------------------------------#
private
protected
# Add build settings, which ensure that the pod targets can be imported
# from the integrating target by all sort of imports, which are:
# - `#import <…>`
# - `#import "…"`
# - `@import …;` / `import …`
#
def generate_settings_to_import_pod_targets
def settings_to_import_pod_targets
if target.requires_frameworks?
framework_header_search_paths = pod_targets.select(&:should_build?).map do |target|
if target.scoped?
......@@ -118,17 +112,32 @@ module Pod
if pod_targets.any? { |t| t.should_build? && t.scoped? }
build_settings['FRAMEWORK_SEARCH_PATHS'] = '"$PODS_FRAMEWORK_BUILD_PATH"'
end
@xcconfig.merge!(build_settings)
build_settings
else
# Make headers discoverable from $PODS_ROOT/Headers directory
header_search_paths = target.sandbox.public_headers.search_paths(target.platform)
build_settings = {
{
# by `#import "…"`
'HEADER_SEARCH_PATHS' => '$(inherited) ' + XCConfigHelper.quote(header_search_paths),
# by `#import <…>`
'OTHER_CFLAGS' => '$(inherited) ' + XCConfigHelper.quote(header_search_paths, '-isystem'),
}
@xcconfig.merge!(build_settings)
end
end
private
# Add build settings, which ensure that the pod targets can be imported
# from the integrating target by all sort of imports, which are:
# - `#import <…>`
# - `#import "…"`
# - `@import …;` / `import …`
#
def generate_settings_to_import_pod_targets
@xcconfig.merge!(settings_to_import_pod_targets)
target.search_paths_aggregate_targets.each do |search_paths_target|
generator = AggregateXCConfig.new(search_paths_target, configuration_name)
@xcconfig.merge!(generator.settings_to_import_pod_targets)
end
end
......
......@@ -225,9 +225,14 @@ module Pod
#
def generate_targets
pod_targets = generate_pod_targets(result.specs_by_target)
result.specs_by_target.map do |target_definition, _|
aggregate_targets = result.specs_by_target.keys.reject(&:abstract?).map do |target_definition|
generate_target(target_definition, pod_targets)
end
aggregate_targets.each do |target|
target.search_paths_aggregate_targets = aggregate_targets.select do |aggregate_target|
target.target_definition.targets_to_inherit_search_paths.include?(aggregate_target.target_definition)
end
end
end
# Setup the aggregate target for a single user target
......@@ -246,6 +251,7 @@ module Pod
if config.integrate_targets?
target_inspection = result.target_inspections[target_definition]
raise "missing inspection: #{target_definition.name}" unless target_inspection
target.user_project = target_inspection.project
target.client_root = target.user_project_path.dirname.realpath
target.user_target_uuids = target_inspection.project_target_uuids
......@@ -665,8 +671,9 @@ module Pod
inspection_result = {}
UI.section 'Inspecting targets to integrate' do
inspectors = podfile.target_definition_list.map do |target_definition|
next if target_definition.abstract?
TargetInspector.new(target_definition, config.installation_root)
end
end.compact
inspectors.group_by(&:compute_project_path).each do |project_path, target_inspectors|
project = Xcodeproj::Project.open(project_path)
target_inspectors.each do |inspector|
......
......@@ -102,18 +102,9 @@ module Pod
#
def compute_targets(user_project)
native_targets = user_project.native_targets
if link_with = target_definition.link_with
targets = native_targets.select { |t| link_with.include?(t.name) }
raise Informative, "Unable to find the targets named #{link_with.map { |x| "`#{x}`" }.to_sentence}" \
"to link with target definition `#{target_definition.name}`" if targets.empty?
elsif target_definition.link_with_first_target?
targets = [native_targets.first].compact
raise Informative, 'Unable to find a target' if targets.empty?
else
target = native_targets.find { |t| t.name == target_definition.name.to_s }
targets = [target].compact
raise Informative, "Unable to find a target named `#{target_definition.name}`" if targets.empty?
end
targets
end
......
......@@ -27,6 +27,7 @@ module Pod
#
def validate
validate_pod_directives
validate_no_abstract_only_pods!
@validated = true
end
......@@ -38,7 +39,7 @@ module Pod
def valid?
validate unless @validated
@validated && errors.size == 0
@validated && errors.empty?
end
# A message describing any errors in the
......@@ -81,6 +82,22 @@ module Pod
' download strategies. This is not allowed'
end
end
def validate_no_abstract_only_pods!
abstract_pods = ->(target_definition) do
if !target_definition.abstract? || !target_definition.children.empty?
target_definition.children.flat_map do |td|
abstract_pods[td]
end
else
target_definition.dependencies
end
end
pods = podfile.root_target_definitions.flat_map(&abstract_pods).uniq
pods.each do |pod|
add_error "The dependency `#{pod}` is not used in any concrete target."
end
end
end
end
end
......@@ -17,6 +17,7 @@ module Pod
@target_definition = target_definition
@sandbox = sandbox
@pod_targets = []
@search_paths_aggregate_targets = []
@file_accessors = []
@xcconfigs = {}
end
......@@ -103,6 +104,8 @@ module Pod
#
attr_accessor :pod_targets
attr_accessor :search_paths_aggregate_targets
# @param [String] build_configuration The build configuration for which the
# the pod targets should be returned.
#
......
......@@ -665,6 +665,7 @@ module Pod
urls = source_urls
Pod::Podfile.new do
urls.each { |u| source(u) }
target 'App' do
use_frameworks!(use_frameworks)
platform(platform_name, deployment_target)
if local
......@@ -674,6 +675,7 @@ module Pod
end
end
end
end
# Parse the xcode build output to identify the lines which are relevant
# to the linter.
......
......@@ -34,6 +34,7 @@
A346497C14F9BE9A0080D870 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = A346497A14F9BE9A0080D870 /* InfoPlist.strings */; };
A346497E14F9BE9A0080D870 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = A346497D14F9BE9A0080D870 /* main.m */; };
A346498214F9BE9A0080D870 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = A346498114F9BE9A0080D870 /* AppDelegate.m */; };
C0C495361B9E5C47004F9854 /* SampleProjectTests.m in Sources */ = {isa = PBXBuildFile; fileRef = C0C495351B9E5C47004F9854 /* SampleProjectTests.m */; };
/* End PBXBuildFile section */
/* Begin PBXContainerItemProxy section */
......@@ -44,6 +45,13 @@
remoteGlobalIDString = 51E94E0F164472080035348C;
remoteInfo = "Sample Lib";
};
C0C495381B9E5C47004F9854 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = A346496414F9BE990080D870 /* Project object */;
proxyType = 1;
remoteGlobalIDString = A346496C14F9BE9A0080D870;
remoteInfo = SampleProject;
};
/* End PBXContainerItemProxy section */
/* Begin PBXCopyFilesBuildPhase section */
......@@ -79,6 +87,9 @@
A346497F14F9BE9A0080D870 /* SampleProject-Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "SampleProject-Prefix.pch"; sourceTree = "<group>"; };
A346498014F9BE9A0080D870 /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = "<group>"; };
A346498114F9BE9A0080D870 /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = "<group>"; };
C0C495331B9E5C47004F9854 /* SampleProjectTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = SampleProjectTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
C0C495351B9E5C47004F9854 /* SampleProjectTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SampleProjectTests.m; sourceTree = "<group>"; };
C0C495371B9E5C47004F9854 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
......@@ -110,6 +121,13 @@
);
runOnlyForDeploymentPostprocessing = 0;
};
C0C495301B9E5C47004F9854 /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXFrameworksBuildPhase section */
/* Begin PBXGroup section */
......@@ -157,6 +175,7 @@
A346497714F9BE9A0080D870 /* SampleProject */,
51075D4F1521D0C100E39B41 /* TestRunner */,
29FAC56B1B1F0502002187FA /* CLITool */,
C0C495341B9E5C47004F9854 /* SampleProjectTests */,
A346497014F9BE9A0080D870 /* Frameworks */,
A346496E14F9BE9A0080D870 /* Products */,
);
......@@ -168,6 +187,7 @@
A346496D14F9BE9A0080D870 /* SampleProject.app */,
51075D4A1521D0C100E39B41 /* TestRunner.app */,
29FAC56A1B1F0502002187FA /* CLITool */,
C0C495331B9E5C47004F9854 /* SampleProjectTests.xctest */,
);
name = Products;
sourceTree = "<group>";
......@@ -203,6 +223,15 @@
name = "Supporting Files";
sourceTree = "<group>";
};
C0C495341B9E5C47004F9854 /* SampleProjectTests */ = {
isa = PBXGroup;
children = (
C0C495351B9E5C47004F9854 /* SampleProjectTests.m */,
C0C495371B9E5C47004F9854 /* Info.plist */,
);
path = SampleProjectTests;
sourceTree = "<group>";
};
/* End PBXGroup section */
/* Begin PBXNativeTarget section */
......@@ -257,18 +286,41 @@
productReference = A346496D14F9BE9A0080D870 /* SampleProject.app */;
productType = "com.apple.product-type.application";
};
C0C495321B9E5C47004F9854 /* SampleProjectTests */ = {
isa = PBXNativeTarget;
buildConfigurationList = C0C4953A1B9E5C47004F9854 /* Build configuration list for PBXNativeTarget "SampleProjectTests" */;
buildPhases = (
C0C4952F1B9E5C47004F9854 /* Sources */,
C0C495301B9E5C47004F9854 /* Frameworks */,
C0C495311B9E5C47004F9854 /* Resources */,
);
buildRules = (
);
dependencies = (
C0C495391B9E5C47004F9854 /* PBXTargetDependency */,
);
name = SampleProjectTests;
productName = SampleProjectTests;
productReference = C0C495331B9E5C47004F9854 /* SampleProjectTests.xctest */;
productType = "com.apple.product-type.bundle.unit-test";
};
/* End PBXNativeTarget section */
/* Begin PBXProject section */
A346496414F9BE990080D870 /* Project object */ = {
isa = PBXProject;
attributes = {
LastSwiftUpdateCheck = 0700;
LastUpgradeCheck = 0630;
ORGANIZATIONNAME = "LJR Software Limited";
TargetAttributes = {
29FAC5691B1F0502002187FA = {
CreatedOnToolsVersion = 6.3.2;
};
C0C495321B9E5C47004F9854 = {
CreatedOnToolsVersion = 7.0;
TestTargetID = A346496C14F9BE9A0080D870;
};
};
};
buildConfigurationList = A346496714F9BE990080D870 /* Build configuration list for PBXProject "SampleProject" */;
......@@ -293,6 +345,7 @@
51075D491521D0C100E39B41 /* TestRunner */,
51D6A8AB16C445B800E174E1 /* AggregateTarget */,
29FAC5691B1F0502002187FA /* CLITool */,
C0C495321B9E5C47004F9854 /* SampleProjectTests */,
);
};
/* End PBXProject section */
......@@ -324,6 +377,13 @@
);
runOnlyForDeploymentPostprocessing = 0;
};
C0C495311B9E5C47004F9854 /* Resources */ = {
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXResourcesBuildPhase section */
/* Begin PBXSourcesBuildPhase section */
......@@ -353,8 +413,24 @@
);
runOnlyForDeploymentPostprocessing = 0;
};
C0C4952F1B9E5C47004F9854 /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
C0C495361B9E5C47004F9854 /* SampleProjectTests.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXSourcesBuildPhase section */
/* Begin PBXTargetDependency section */
C0C495391B9E5C47004F9854 /* PBXTargetDependency */ = {
isa = PBXTargetDependency;
target = A346496C14F9BE9A0080D870 /* SampleProject */;
targetProxy = C0C495381B9E5C47004F9854 /* PBXContainerItemProxy */;
};
/* End PBXTargetDependency section */
/* Begin PBXVariantGroup section */
51075D521521D0C100E39B41 /* InfoPlist.strings */ = {
isa = PBXVariantGroup;
......@@ -721,6 +797,101 @@
};
name = Release;
};
C0C4953B1B9E5C47004F9854 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
BUNDLE_LOADER = "$(TEST_HOST)";
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
DEBUG_INFORMATION_FORMAT = dwarf;
ENABLE_TESTABILITY = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
INFOPLIST_FILE = SampleProjectTests/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
MTL_ENABLE_DEBUG_INFO = YES;
PRODUCT_BUNDLE_IDENTIFIER = org.cocoapods.SampleProjectTests;
PRODUCT_NAME = "$(TARGET_NAME)";
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/SampleProject.app/SampleProject";
};
name = Debug;
};
C0C4953C1B9E5C47004F9854 /* Test */ = {
isa = XCBuildConfiguration;
buildSettings = {
BUNDLE_LOADER = "$(TEST_HOST)";
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
COPY_PHASE_STRIP = NO;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
ENABLE_NS_ASSERTIONS = NO;
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
INFOPLIST_FILE = SampleProjectTests/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
MTL_ENABLE_DEBUG_INFO = NO;
PRODUCT_BUNDLE_IDENTIFIER = org.cocoapods.SampleProjectTests;
PRODUCT_NAME = "$(TARGET_NAME)";
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/SampleProject.app/SampleProject";
};
name = Test;
};
C0C4953D1B9E5C47004F9854 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
BUNDLE_LOADER = "$(TEST_HOST)";
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
COPY_PHASE_STRIP = NO;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
ENABLE_NS_ASSERTIONS = NO;
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
INFOPLIST_FILE = SampleProjectTests/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
MTL_ENABLE_DEBUG_INFO = NO;
PRODUCT_BUNDLE_IDENTIFIER = org.cocoapods.SampleProjectTests;
PRODUCT_NAME = "$(TARGET_NAME)";
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/SampleProject.app/SampleProject";
};
name = Release;
};
C0C4953E1B9E5C47004F9854 /* App Store */ = {
isa = XCBuildConfiguration;
buildSettings = {
BUNDLE_LOADER = "$(TEST_HOST)";
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
COPY_PHASE_STRIP = NO;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
ENABLE_NS_ASSERTIONS = NO;
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
INFOPLIST_FILE = SampleProjectTests/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
MTL_ENABLE_DEBUG_INFO = NO;
PRODUCT_BUNDLE_IDENTIFIER = org.cocoapods.SampleProjectTests;
PRODUCT_NAME = "$(TARGET_NAME)";
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/SampleProject.app/SampleProject";
};
name = "App Store";
};
/* End XCBuildConfiguration section */
/* Begin XCConfigurationList section */
......@@ -733,6 +904,7 @@
29FAC5711B1F0502002187FA /* App Store */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
51075D5B1521D0C100E39B41 /* Build configuration list for PBXNativeTarget "TestRunner" */ = {
isa = XCConfigurationList;
......@@ -778,6 +950,16 @@
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
C0C4953A1B9E5C47004F9854 /* Build configuration list for PBXNativeTarget "SampleProjectTests" */ = {
isa = XCConfigurationList;
buildConfigurations = (
C0C4953B1B9E5C47004F9854 /* Debug */,
C0C4953C1B9E5C47004F9854 /* Test */,
C0C4953D1B9E5C47004F9854 /* Release */,
C0C4953E1B9E5C47004F9854 /* App Store */,
);
defaultConfigurationIsVisible = 0;
};
/* End XCConfigurationList section */
};
rootObject = A346496414F9BE990080D870 /* Project object */;
......
<?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>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>$(PRODUCT_NAME)</string>
<key>CFBundlePackageType</key>
<string>BNDL</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1</string>
</dict>
</plist>
//
// SampleProjectTests.m
// SampleProjectTests
//
// Created by Samuel Giddins on 9/7/15.
// Copyright © 2015 LJR Software Limited. All rights reserved.
//
#import <XCTest/XCTest.h>
@interface SampleProjectTests : XCTestCase
@end
@implementation SampleProjectTests
- (void)setUp {
[super setUp];
// Put setup code here. This method is called before the invocation of each test method in the class.
}
- (void)tearDown {
// Put teardown code here. This method is called after the invocation of each test method in the class.
[super tearDown];
}
- (void)testExample {
// This is an example of a functional test case.
// Use XCTAssert and related functions to verify your tests produce the correct results.
}
- (void)testPerformanceExample {
// This is an example of a performance test case.
[self measureBlock:^{
// Put the code you want to measure the time of here.
}];
}
@end
......@@ -58,8 +58,7 @@ module Pod
describe '#compute_targets' do
it 'returns the targets specified in the target definition' do
target_definition = Podfile::TargetDefinition.new(:default, nil)
target_definition.link_with = ['UserTarget']
target_definition = Podfile::TargetDefinition.new('UserTarget', nil)
user_project = Xcodeproj::Project.new('path')
user_project.new_target(:application, 'FirstTarget', :ios)
user_project.new_target(:application, 'UserTarget', :ios)
......@@ -70,13 +69,12 @@ module Pod
end
it 'raises if it is unable to find the targets specified by the target definition' do
target_definition = Podfile::TargetDefinition.new(:default, nil)
target_definition.link_with = %w(UserTarget AnotherUserTarget)
target_definition = Podfile::TargetDefinition.new('UserTarget', nil)
user_project = Xcodeproj::Project.new('path')
target_inspector = TargetInspector.new(target_definition, config.installation_root)
e = lambda { target_inspector.send(:compute_targets, user_project) }.should.raise Informative
e.message.should.match /Unable to find the targets named `UserTarget` and `AnotherUserTarget`/
e.message.should.match /Unable to find a target named `UserTarget`/
end
it 'returns the target with the same name of the target definition' do
......@@ -98,27 +96,6 @@ module Pod
e = lambda { target_inspector.send(:compute_targets, user_project) }.should.raise Informative
e.message.should.match /Unable to find a target named/
end
it 'returns the first target of the project if the target definition is named default' do
target_definition = Podfile::TargetDefinition.new('Pods', nil)
target_definition.link_with_first_target = true
user_project = Xcodeproj::Project.new('path')
user_project.new_target(:application, 'FirstTarget', :ios)
user_project.new_target(:application, 'UserTarget', :ios)
target_inspector = TargetInspector.new(target_definition, config.installation_root)
targets = target_inspector.send(:compute_targets, user_project)
targets.map(&:name).should == ['FirstTarget']
end
it 'raises if the default target definition cannot be linked because there are no user targets' do
target_definition = Podfile::TargetDefinition.new(:default, nil)
user_project = Xcodeproj::Project.new('path')
target_inspector = TargetInspector.new(target_definition, config.installation_root)
e = lambda { target_inspector.send(:compute_targets, user_project) }.should.raise Informative
e.message.should.match /Unable to find a target/
end
end
#--------------------------------------#
......
......@@ -7,16 +7,21 @@ module Pod
@podfile = Pod::Podfile.new do
platform :ios, '6.0'
xcodeproj 'SampleProject/SampleProject'
target 'SampleProject' do
pod 'JSONKit', '1.5pre'
pod 'AFNetworking', '1.0.1'
pod 'SVPullToRefresh', '0.4'
pod 'libextobjc/EXTKeyPathCoding', '0.2.3'
target 'TestRunner' do
inherit! :search_paths
pod 'libextobjc/EXTKeyPathCoding', '0.2.3'
pod 'libextobjc/EXTSynthesize', '0.2.3'
end
end
end
hash = {}
hash['PODS'] = ['JSONKit (1.5pre)', 'NUI (0.2.0)', 'SVPullToRefresh (0.4)']
......@@ -131,9 +136,9 @@ module Pod
'JSONKit',
'AFNetworking',
'SVPullToRefresh',
'Pods-libextobjc',
'Pods-SampleProject-libextobjc',
].sort
target.support_files_dir.should == config.sandbox.target_support_files_dir('Pods')
target.support_files_dir.should == config.sandbox.target_support_files_dir('Pods-SampleProject')
target.pod_targets.map(&:archs).uniq.should == [[]]
......@@ -187,6 +192,7 @@ module Pod
source SpecHelper.test_repo_url
platform :ios, '6.0'
xcodeproj 'SampleProject/SampleProject'
target 'SampleProject' do
pod 'BananaLib'
pod 'monkey'
......@@ -195,14 +201,15 @@ module Pod
pod 'monkey'
end
end
end
analyzer = Pod::Installer::Analyzer.new(config.sandbox, podfile)
analyzer.analyze
analyzer.analyze.targets.flat_map { |at| at.pod_targets.map { |pt| "#{at.name}/#{pt.name}" } }.sort.should == %w(
Pods/BananaLib
Pods/monkey
Pods-TestRunner/BananaLib
Pods-TestRunner/monkey
Pods-SampleProject-TestRunner/BananaLib
Pods-SampleProject-TestRunner/monkey
Pods-SampleProject/BananaLib
Pods-SampleProject/monkey
).sort
end
......@@ -214,10 +221,12 @@ module Pod
pod 'BananaLib'
pod 'monkey'
target 'SampleProject' do
target 'TestRunner' do
pod 'BananaLib'
pod 'monkey'
end
end
target 'CLITool' do
platform :osx, '10.10'
......@@ -228,11 +237,11 @@ module Pod
analyzer.analyze
analyzer.analyze.targets.flat_map { |at| at.pod_targets.map { |pt| "#{at.name}/#{pt.name}" } }.sort.should == %w(
Pods/Pods-BananaLib
Pods/Pods-monkey
Pods-TestRunner/Pods-TestRunner-BananaLib
Pods-TestRunner/Pods-TestRunner-monkey
Pods-CLITool/Pods-CLITool-monkey
Pods-SampleProject-TestRunner/Pods-SampleProject-TestRunner-BananaLib
Pods-SampleProject-TestRunner/Pods-SampleProject-TestRunner-monkey
Pods-SampleProject/Pods-SampleProject-BananaLib
Pods-SampleProject/Pods-SampleProject-monkey
).sort
end
end
......@@ -335,9 +344,11 @@ module Pod
podfile = Podfile.new do
platform :ios, '8.0'
xcodeproj 'SampleProject/SampleProject'
target 'SampleProject' do
pod 'AFNetworking'
pod 'AFNetworkActivityLogger'
end
end
hash = {}
hash['PODS'] = [
{ 'AFNetworkActivityLogger (2.0.3)' => ['AFNetworking/NSURLConnection (~> 2.0)', 'AFNetworking/NSURLSession (~> 2.0)'] },
......@@ -367,8 +378,10 @@ module Pod
podfile = Podfile.new do
platform :ios, '8.0'
xcodeproj 'SampleProject/SampleProject'
target 'SampleProject' do
pod 'ARAnalytics/Mixpanel'
end
end
hash = {}
hash['PODS'] = ['ARAnalytics/CoreIOS (2.8.0)', { 'ARAnalytics/Mixpanel (2.8.0)' => ['ARAnlytics/CoreIOS', 'Mixpanel'] }, 'Mixpanel (2.5.1)']
hash['DEPENDENCIES'] = %w(ARAnalytics/Mixpanel)
......@@ -454,9 +467,6 @@ module Pod
'libextobjc/EXTKeyPathCoding (0.2.3)',
]
@analyzer.analyze.targets[1].pod_targets.map(&:specs).flatten.map(&:to_s).should == [
'AFNetworking (1.0.1)',
'JSONKit (1.5pre)',
'SVPullToRefresh (0.4)',
'libextobjc/EXTKeyPathCoding (0.2.3)',
'libextobjc/EXTSynthesize (0.2.3)',
]
......@@ -469,9 +479,11 @@ module Pod
source 'https://github.com/CocoaPods/Specs.git'
xcodeproj 'SampleProject/SampleProject'
platform :ios, '8.0'
target 'SampleProject' do
pod 'RestKit', '~> 0.23.0'
pod 'RestKit', '<= 0.23.2'
end
end
analyzer = Pod::Installer::Analyzer.new(config.sandbox, podfile, nil)
analyzer.analyze
......@@ -542,9 +554,11 @@ module Pod
source 'https://github.com/CocoaPods/Specs.git'
xcodeproj 'SampleProject/SampleProject'
platform :ios
target 'SampleProject' do
pod 'SEGModules', :git => 'https://github.com/segiddins/SEGModules.git'
pod 'SEGModules', :git => 'https://github.com/segiddins/Modules.git'
end
end
analyzer = Pod::Installer::Analyzer.new(config.sandbox, podfile, nil)
e = should.raise(Informative) { analyzer.analyze }
......@@ -559,9 +573,11 @@ module Pod
source 'https://github.com/CocoaPods/Specs.git'
xcodeproj 'SampleProject/SampleProject'
platform :ios
target 'SampleProject' do
pod 'RestKit/Core', :git => 'https://github.com/RestKit/RestKit.git'
pod 'RestKit', :git => 'https://github.com/segiddins/RestKit.git'
end
end
analyzer = Pod::Installer::Analyzer.new(config.sandbox, podfile, nil)
e = should.raise(Informative) { analyzer.analyze }
......@@ -576,9 +592,11 @@ module Pod
source 'https://github.com/CocoaPods/Specs.git'
xcodeproj 'SampleProject/SampleProject'
platform :ios
target 'SampleProject' do
pod 'RestKit', :git => 'https://github.com/RestKit/RestKit.git'
pod 'RestKit', '~> 0.23.0'
end
end
analyzer = Pod::Installer::Analyzer.new(config.sandbox, podfile, nil)
e = should.raise(Informative) { analyzer.analyze }
......@@ -591,8 +609,10 @@ module Pod
describe 'using lockfile checkout options' do
before do
@podfile = Pod::Podfile.new do
target 'SampleProject' do
pod 'BananaLib', :git => 'example.com'
end
end
@dependency = @podfile.dependencies.first
@lockfile_checkout_options = { :git => 'example.com', :commit => 'commit' }
......
......@@ -5,6 +5,7 @@ module Pod
describe 'podspec/path in combination with other download strategies' do
it 'validates that podspec is not used in combination with other download strategies' do
podfile = Pod::Podfile.new do
abstract!(false)
pod 'JSONKit', :podspec => 'https://raw.githubusercontent.com/CocoaPods/Specs/master/Specs/JSONKit/1.5pre/JSONKit.podspec.json',
:git => 'git@github.com:johnezang/JSONKit.git'
end
......@@ -19,6 +20,7 @@ module Pod
it 'validates that path is not used in combination with other download strategies' do
podfile = Pod::Podfile.new do
abstract!(false)
pod 'JSONKit', :path => './JSONKit/1.5pre/JSONKit.podspec.json',
:git => 'git@github.com:johnezang/JSONKit.git'
end
......@@ -33,6 +35,7 @@ module Pod
it 'validates when calling `valid?` before calling `validate`' do
podfile = Pod::Podfile.new do
abstract!(false)
pod 'JSONKit', :path => './JSONKit/1.5pre/JSONKit.podspec.json',
:git => 'git@github.com:johnezang/JSONKit.git'
end
......@@ -47,6 +50,7 @@ module Pod
describe 'multiple download strategies' do
it 'validates that only one download strategy is specified' do
podfile = Pod::Podfile.new do
abstract!(false)
pod 'JSONKit', :svn => 'svn.example.com/JSONKit',
:git => 'git@github.com:johnezang/JSONKit.git'
end
......
......@@ -19,7 +19,12 @@ def generate_podfile(pods = ['JSONKit'])
Pod::Podfile.new do
platform :ios
xcodeproj SpecHelper.fixture('SampleProject/SampleProject'), 'Test' => :debug, 'App Store' => :release
target 'SampleProject' do
pods.each { |name| pod name }
target 'SampleProjectTests' do
inherit! :search_paths
end
end
end
end
......@@ -29,7 +34,12 @@ def generate_local_podfile
Pod::Podfile.new do
platform :ios
xcodeproj SpecHelper.fixture('SampleProject/SampleProject'), 'Test' => :debug, 'App Store' => :release
target 'SampleProject' do
pod 'Reachability', :path => SpecHelper.fixture('integration/Reachability')
target 'SampleProjectTests' do
inherit! :search_paths
end
end
end
end
......@@ -226,7 +236,9 @@ module Pod
pod 'OrangeFramework', :path => (fixture_path + 'orange-framework').to_s
pod 'monkey', :path => (fixture_path + 'monkey').to_s
target 'TestRunner', :exclusive => true do
target 'SampleProject'
target 'TestRunner' do
inherit! :search_paths
pod 'monkey', :path => (fixture_path + 'monkey').to_s
end
end
......@@ -262,6 +274,7 @@ module Pod
pod 'BananaLib', :path => (fixture_path + 'banana-lib').to_s
pod 'OrangeFramework', :path => (fixture_path + 'orange-framework').to_s
pod 'monkey', :path => (fixture_path + 'monkey').to_s
target 'SampleProject'
end
lockfile = generate_lockfile
config.integrate_targets = false
......@@ -304,6 +317,7 @@ module Pod
pod 'BananaLib', :path => (fixture_path + 'banana-lib').to_s
pod 'OrangeFramework', :path => (fixture_path + 'orange-framework').to_s
pod 'monkey', :path => (fixture_path + 'monkey').to_s
target 'SampleProject'
end
@lockfile = generate_lockfile
......@@ -345,6 +359,7 @@ module Pod
platform :ios, '8.0'
xcodeproj 'SampleProject/SampleProject'
pod 'OrangeFramework', :path => (fixture_path + 'orange-framework').to_s
target 'SampleProject'
end
lockfile = generate_lockfile
config.integrate_targets = false
......@@ -387,7 +402,7 @@ module Pod
it 'stores the targets created by the analyzer' do
@installer.send(:analyze)
@installer.aggregate_targets.map(&:name).sort.should == ['Pods']
@installer.aggregate_targets.map(&:name).sort.should == ["Pods-SampleProject", "Pods-SampleProjectTests"]
@installer.pod_targets.map(&:name).sort.should == ['JSONKit']
end
......@@ -395,7 +410,7 @@ module Pod
@installer.update = true
Installer::Analyzer.any_instance.expects(:update=).with(true)
@installer.send(:analyze)
@installer.aggregate_targets.map(&:name).sort.should == ['Pods']
@installer.aggregate_targets.map(&:name).sort.should == ["Pods-SampleProject", "Pods-SampleProjectTests"]
@installer.pod_targets.map(&:name).sort.should == ['JSONKit']
end
end
......@@ -458,6 +473,7 @@ module Pod
platform :osx, '10.10'
pod 'CargoBay', '2.1.0'
pod 'AFNetworking/NSURLSession', :head
abstract!(false)
end
@installer.stubs(:podfile).returns(podfile)
@installer.stubs(:lockfile).returns(nil)
......
......@@ -321,7 +321,7 @@ module Pod
validator.stubs(:validate_url)
validator.stubs(:validate_screenshots)
podfile = validator.send(:podfile_from_spec, :ios, '5.0')
dependency = podfile.target_definitions['Pods'].dependencies.first
dependency = podfile.target_definitions['App'].dependencies.first
dependency.external_source.key?(:podspec).should.be.true
end
......@@ -358,7 +358,7 @@ module Pod
it 'configures the deployment target' do
podfile = @validator.send(:podfile_from_spec, :ios, '5.0')
target_definition = podfile.target_definitions['Pods']
target_definition = podfile.target_definitions['App']
platform = target_definition.platform
platform.symbolic_name.should == :ios
platform.deployment_target.to_s.should == '5.0'
......@@ -366,13 +366,13 @@ module Pod
it 'includes the use_frameworks! directive' do
podfile = @validator.send(:podfile_from_spec, :ios, '5.0', true)
target_definition = podfile.target_definitions['Pods']
target_definition = podfile.target_definitions['App']
target_definition.uses_frameworks?.should == true
end
it 'includes the use_frameworks!(false) directive' do
podfile = @validator.send(:podfile_from_spec, :ios, '5.0', false)
target_definition = podfile.target_definitions['Pods']
target_definition = podfile.target_definitions['App']
# rubocop:disable Style/DoubleNegation
(!!target_definition.uses_frameworks?).should == false
# rubocop:enable Style/DoubleNegation
......
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