From 57ec4645da65d1b0d6e74f371093dca6b448b793 Mon Sep 17 00:00:00 2001 From: Fabio Pelosin Date: Thu, 28 Feb 2013 21:57:10 +0100 Subject: [PATCH] [Installer] Call per install hooks before cleaning --- CHANGELOG.md | 1 + .../hooks/installer_representation.rb | 2 ++ lib/cocoapods/hooks/library_representation.rb | 6 +++++ lib/cocoapods/installer.rb | 12 +++++++++- .../installer/pod_source_installer.rb | 10 ++++++++ .../after/Pods/Pods.xcodeproj.yaml | 8 +++++-- .../after/execution_output.txt | 2 +- .../after/Pods/Pods.xcodeproj.yaml | 8 +++++-- .../after/execution_output.txt | 2 +- .../after/Pods/Pods.xcodeproj.yaml | 8 +++++-- .../after/execution_output.txt | 2 +- .../after/Pods/Pods.xcodeproj.yaml | 24 ++++++++++++++----- .../after/execution_output.txt | 2 +- .../after/Pods/Pods.xcodeproj.yaml | 8 +++++-- .../install_new/after/execution_output.txt | 2 +- .../after/Pods/Pods.xcodeproj.yaml | 8 +++++-- .../after/execution_output.txt | 4 ++-- .../after/Pods/Pods.xcodeproj.yaml | 8 +++++-- .../after/execution_output.txt | 2 +- .../after/Pods/Pods.xcodeproj.yaml | 8 +++++-- .../after/execution_output.txt | 2 +- .../install_spec_callbacks/after/Podfile.lock | 2 +- .../{Reachability => }/DependenciesList.txt | 0 .../Pods/Local Podspecs/Reachability.podspec | 10 +++----- .../after/Pods/Manifest.lock | 2 +- .../after/Pods/Pods.xcodeproj.yaml | 8 +++++-- .../after/execution_output.txt | 4 ++-- .../before/Reachability.podspec | 10 +++----- .../after/Pods/Pods.xcodeproj.yaml | 16 +++++++++---- .../after/execution_output.txt | 2 +- .../update/after/Pods/Pods.xcodeproj.yaml | 8 +++++-- .../update/after/execution_output.txt | 2 +- spec/integration_spec.rb | 4 ++-- .../unit/hooks/library_representation_spec.rb | 4 ++++ .../installer/pod_source_installer_spec.rb | 3 +++ spec/unit/installer_spec.rb | 13 ++++------ 36 files changed, 149 insertions(+), 68 deletions(-) rename spec/integration/install_spec_callbacks/after/Pods/{Reachability => }/DependenciesList.txt (100%) diff --git a/CHANGELOG.md b/CHANGELOG.md index 19c243424c..ce50aed927 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ ###### Bug fixes +- Pre install hooks are called before the Pods are cleaned. - Fixed and issue which prevent the inclusion of OTHER_CFLAGS and OTHER_CPLUSPLUSFLAGS in the release builds of the Pods project. diff --git a/lib/cocoapods/hooks/installer_representation.rb b/lib/cocoapods/hooks/installer_representation.rb index 45788bde24..240c6fd936 100644 --- a/lib/cocoapods/hooks/installer_representation.rb +++ b/lib/cocoapods/hooks/installer_representation.rb @@ -26,6 +26,8 @@ def sandbox_root # @return [Pod::Project] the `Pods/Pods.xcodeproj` project. # + # @note This value is not yet set in the pre install callbacks. + # def project installer.pods_project end diff --git a/lib/cocoapods/hooks/library_representation.rb b/lib/cocoapods/hooks/library_representation.rb index d7004af53b..524586b0be 100644 --- a/lib/cocoapods/hooks/library_representation.rb +++ b/lib/cocoapods/hooks/library_representation.rb @@ -18,6 +18,12 @@ def dependencies target_definition.dependencies end + # @return [Pathname] The path of the Pods dir. + # + def sandbox_dir + sandbox.root + end + # @return [Pathname] The path of the prefix_header # def prefix_header_filename diff --git a/lib/cocoapods/installer.rb b/lib/cocoapods/installer.rb index 191ed71209..da0937990b 100644 --- a/lib/cocoapods/installer.rb +++ b/lib/cocoapods/installer.rb @@ -99,13 +99,14 @@ def download_dependencies UI.section "Downloading dependencies" do create_file_accessors install_pod_sources + run_pre_install_hooks + clean_pod_sources end end def generate_pods_project UI.section "Generating Pods project" do prepare_pods_project - run_pre_install_hooks install_file_references install_targets run_post_install_hooks @@ -240,15 +241,24 @@ def install_source_of_pod(pod_name) end end + @pod_installers ||= [] pod_installer = PodSourceInstaller.new(sandbox, specs_by_platform) pod_installer.clean = config.clean? pod_installer.aggressive_cache = config.aggressive_cache? pod_installer.generate_docs = config.generate_docs? pod_installer.install_docs = config.install_docs? pod_installer.install! + @pod_installers << pod_installer @installed_specs.concat(specs_by_platform.values.flatten) end + def clean_pod_sources + return unless @pod_installers + @pod_installers.each do |pod_installer| + pod_installer.clean! + end + end + # Creates the Pods project from scratch if it doesn't exists. # # @return [void] diff --git a/lib/cocoapods/installer/pod_source_installer.rb b/lib/cocoapods/installer/pod_source_installer.rb index 16665e6e01..d41b0eb0c9 100644 --- a/lib/cocoapods/installer/pod_source_installer.rb +++ b/lib/cocoapods/installer/pod_source_installer.rb @@ -82,6 +82,16 @@ def inspect def install! download_source unless predownloaded? || local? generate_docs if generate_docs? + end + + # Cleans the installations if appropriate. + # + # @todo As the pre install hooks need to run before cleaning this + # method should be refactored. + # + # @return [void] + # + def clean! clean_installation if clean? && !local? end diff --git a/spec/integration/install_add_pod/after/Pods/Pods.xcodeproj.yaml b/spec/integration/install_add_pod/after/Pods/Pods.xcodeproj.yaml index 766ac3c799..4a5ddc6ea2 100644 --- a/spec/integration/install_add_pod/after/Pods/Pods.xcodeproj.yaml +++ b/spec/integration/install_add_pod/after/Pods/Pods.xcodeproj.yaml @@ -49,7 +49,9 @@ Targets: PODS_HEADERS_SEARCH_PATHS: ${PODS_BUILD_HEADERS_SEARCH_PATHS} GCC_C_LANGUAGE_STANDARD: gnu99 OTHER_LDFLAGS: '' - OTHER_CFLAGS: -DNS_BLOCK_ASSERTIONS=1 + OTHER_CFLAGS: + - -DNS_BLOCK_ASSERTIONS=1 + - $(inherited) GCC_VERSION: com.apple.compilers.llvm.clang.1_0 ALWAYS_SEARCH_USER_PATHS: 'NO' SDKROOT: iphoneos @@ -60,7 +62,9 @@ Targets: INSTALL_PATH: $(BUILT_PRODUCTS_DIR) SKIP_INSTALL: 'YES' PODS_ROOT: ${SRCROOT} - OTHER_CPLUSPLUSFLAGS: -DNS_BLOCK_ASSERTIONS=1 + OTHER_CPLUSPLUSFLAGS: + - -DNS_BLOCK_ASSERTIONS=1 + - $(inherited) ARCHS: $(ARCHS_STANDARD_32_BIT) Base Configuration: Pods.xcconfig - Debug: diff --git a/spec/integration/install_add_pod/after/execution_output.txt b/spec/integration/install_add_pod/after/execution_output.txt index cb10472296..e12fd90f3f 100644 --- a/spec/integration/install_add_pod/after/execution_output.txt +++ b/spec/integration/install_add_pod/after/execution_output.txt @@ -32,10 +32,10 @@ Downloading dependencies Switched to a new branch 'activated-pod-commit' -> Using Reachability (3.1.0) + - Running pre install hooks Generating Pods project - Creating Pods project - - Running pre install hooks - Adding source files to Pods project - Adding resources to Pods project - Linking headers diff --git a/spec/integration/install_external_source/after/Pods/Pods.xcodeproj.yaml b/spec/integration/install_external_source/after/Pods/Pods.xcodeproj.yaml index 1dd5c6df50..b93cea39c6 100644 --- a/spec/integration/install_external_source/after/Pods/Pods.xcodeproj.yaml +++ b/spec/integration/install_external_source/after/Pods/Pods.xcodeproj.yaml @@ -47,7 +47,9 @@ Targets: PODS_HEADERS_SEARCH_PATHS: ${PODS_BUILD_HEADERS_SEARCH_PATHS} GCC_C_LANGUAGE_STANDARD: gnu99 OTHER_LDFLAGS: '' - OTHER_CFLAGS: -DNS_BLOCK_ASSERTIONS=1 + OTHER_CFLAGS: + - -DNS_BLOCK_ASSERTIONS=1 + - $(inherited) GCC_VERSION: com.apple.compilers.llvm.clang.1_0 ALWAYS_SEARCH_USER_PATHS: 'NO' SDKROOT: iphoneos @@ -58,7 +60,9 @@ Targets: INSTALL_PATH: $(BUILT_PRODUCTS_DIR) SKIP_INSTALL: 'YES' PODS_ROOT: ${SRCROOT} - OTHER_CPLUSPLUSFLAGS: -DNS_BLOCK_ASSERTIONS=1 + OTHER_CPLUSPLUSFLAGS: + - -DNS_BLOCK_ASSERTIONS=1 + - $(inherited) ARCHS: $(ARCHS_STANDARD_32_BIT) Base Configuration: Pods.xcconfig - Debug: diff --git a/spec/integration/install_external_source/after/execution_output.txt b/spec/integration/install_external_source/after/execution_output.txt index 4886bc3598..dc38ed5394 100644 --- a/spec/integration/install_external_source/after/execution_output.txt +++ b/spec/integration/install_external_source/after/execution_output.txt @@ -20,10 +20,10 @@ Comparing resolved specification to the sandbox manifest Downloading dependencies -> Installing PodTest (1.0) + - Running pre install hooks Generating Pods project - Creating Pods project - - Running pre install hooks - Adding source files to Pods project - Adding resources to Pods project - Linking headers diff --git a/spec/integration/install_local_source/after/Pods/Pods.xcodeproj.yaml b/spec/integration/install_local_source/after/Pods/Pods.xcodeproj.yaml index 8d21d012bb..2f41d6d81c 100644 --- a/spec/integration/install_local_source/after/Pods/Pods.xcodeproj.yaml +++ b/spec/integration/install_local_source/after/Pods/Pods.xcodeproj.yaml @@ -42,7 +42,9 @@ Targets: PODS_HEADERS_SEARCH_PATHS: ${PODS_BUILD_HEADERS_SEARCH_PATHS} GCC_C_LANGUAGE_STANDARD: gnu99 OTHER_LDFLAGS: '' - OTHER_CFLAGS: -DNS_BLOCK_ASSERTIONS=1 + OTHER_CFLAGS: + - -DNS_BLOCK_ASSERTIONS=1 + - $(inherited) GCC_VERSION: com.apple.compilers.llvm.clang.1_0 ALWAYS_SEARCH_USER_PATHS: 'NO' SDKROOT: iphoneos @@ -53,7 +55,9 @@ Targets: INSTALL_PATH: $(BUILT_PRODUCTS_DIR) SKIP_INSTALL: 'YES' PODS_ROOT: ${SRCROOT} - OTHER_CPLUSPLUSFLAGS: -DNS_BLOCK_ASSERTIONS=1 + OTHER_CPLUSPLUSFLAGS: + - -DNS_BLOCK_ASSERTIONS=1 + - $(inherited) ARCHS: $(ARCHS_STANDARD_32_BIT) Base Configuration: Pods.xcconfig - Debug: diff --git a/spec/integration/install_local_source/after/execution_output.txt b/spec/integration/install_local_source/after/execution_output.txt index 46ba795e3a..667decdccf 100644 --- a/spec/integration/install_local_source/after/execution_output.txt +++ b/spec/integration/install_local_source/after/execution_output.txt @@ -14,10 +14,10 @@ Comparing resolved specification to the sandbox manifest Downloading dependencies -> Installing Reachability (3.1.0) + - Running pre install hooks Generating Pods project - Creating Pods project - - Running pre install hooks - Adding source files to Pods project - Adding resources to Pods project - Linking headers diff --git a/spec/integration/install_multiple_targets/after/Pods/Pods.xcodeproj.yaml b/spec/integration/install_multiple_targets/after/Pods/Pods.xcodeproj.yaml index eae76544aa..8be9b3f2b8 100644 --- a/spec/integration/install_multiple_targets/after/Pods/Pods.xcodeproj.yaml +++ b/spec/integration/install_multiple_targets/after/Pods/Pods.xcodeproj.yaml @@ -64,7 +64,9 @@ Targets: PODS_HEADERS_SEARCH_PATHS: ${PODS_BUILD_HEADERS_SEARCH_PATHS} GCC_C_LANGUAGE_STANDARD: gnu99 OTHER_LDFLAGS: '' - OTHER_CFLAGS: -DNS_BLOCK_ASSERTIONS=1 + OTHER_CFLAGS: + - -DNS_BLOCK_ASSERTIONS=1 + - $(inherited) GCC_VERSION: com.apple.compilers.llvm.clang.1_0 ALWAYS_SEARCH_USER_PATHS: 'NO' SDKROOT: iphoneos @@ -75,7 +77,9 @@ Targets: INSTALL_PATH: $(BUILT_PRODUCTS_DIR) SKIP_INSTALL: 'YES' PODS_ROOT: ${SRCROOT} - OTHER_CPLUSPLUSFLAGS: -DNS_BLOCK_ASSERTIONS=1 + OTHER_CPLUSPLUSFLAGS: + - -DNS_BLOCK_ASSERTIONS=1 + - $(inherited) ARCHS: $(ARCHS_STANDARD_32_BIT) Base Configuration: Pods.xcconfig - Debug: @@ -127,7 +131,9 @@ Targets: PODS_HEADERS_SEARCH_PATHS: ${PODS_BUILD_HEADERS_SEARCH_PATHS} GCC_C_LANGUAGE_STANDARD: gnu99 OTHER_LDFLAGS: '' - OTHER_CFLAGS: -DNS_BLOCK_ASSERTIONS=1 + OTHER_CFLAGS: + - -DNS_BLOCK_ASSERTIONS=1 + - $(inherited) GCC_VERSION: com.apple.compilers.llvm.clang.1_0 ALWAYS_SEARCH_USER_PATHS: 'NO' SDKROOT: iphoneos @@ -138,7 +144,9 @@ Targets: INSTALL_PATH: $(BUILT_PRODUCTS_DIR) SKIP_INSTALL: 'YES' PODS_ROOT: ${SRCROOT} - OTHER_CPLUSPLUSFLAGS: -DNS_BLOCK_ASSERTIONS=1 + OTHER_CPLUSPLUSFLAGS: + - -DNS_BLOCK_ASSERTIONS=1 + - $(inherited) ARCHS: $(ARCHS_STANDARD_32_BIT) Base Configuration: Pods-SampleApp_2.xcconfig - Debug: @@ -187,7 +195,9 @@ Targets: PODS_HEADERS_SEARCH_PATHS: ${PODS_BUILD_HEADERS_SEARCH_PATHS} GCC_C_LANGUAGE_STANDARD: gnu99 OTHER_LDFLAGS: '' - OTHER_CFLAGS: -DNS_BLOCK_ASSERTIONS=1 + OTHER_CFLAGS: + - -DNS_BLOCK_ASSERTIONS=1 + - $(inherited) GCC_VERSION: com.apple.compilers.llvm.clang.1_0 ALWAYS_SEARCH_USER_PATHS: 'NO' SDKROOT: iphoneos @@ -198,7 +208,9 @@ Targets: INSTALL_PATH: $(BUILT_PRODUCTS_DIR) SKIP_INSTALL: 'YES' PODS_ROOT: ${SRCROOT} - OTHER_CPLUSPLUSFLAGS: -DNS_BLOCK_ASSERTIONS=1 + OTHER_CPLUSPLUSFLAGS: + - -DNS_BLOCK_ASSERTIONS=1 + - $(inherited) ARCHS: $(ARCHS_STANDARD_32_BIT) Base Configuration: Pods-test.xcconfig - Debug: diff --git a/spec/integration/install_multiple_targets/after/execution_output.txt b/spec/integration/install_multiple_targets/after/execution_output.txt index 123d797992..dbd91f2216 100644 --- a/spec/integration/install_multiple_targets/after/execution_output.txt +++ b/spec/integration/install_multiple_targets/after/execution_output.txt @@ -50,10 +50,10 @@ Downloading dependencies HEAD is now at f7176f4 updated podspec $ /usr/bin/git checkout -b activated-pod-commit 2>&1 Switched to a new branch 'activated-pod-commit' + - Running pre install hooks Generating Pods project - Creating Pods project - - Running pre install hooks - Adding source files to Pods project - Adding resources to Pods project - Linking headers diff --git a/spec/integration/install_new/after/Pods/Pods.xcodeproj.yaml b/spec/integration/install_new/after/Pods/Pods.xcodeproj.yaml index 8ec3f65aad..4b322b6e31 100644 --- a/spec/integration/install_new/after/Pods/Pods.xcodeproj.yaml +++ b/spec/integration/install_new/after/Pods/Pods.xcodeproj.yaml @@ -43,7 +43,9 @@ Targets: PODS_HEADERS_SEARCH_PATHS: ${PODS_BUILD_HEADERS_SEARCH_PATHS} GCC_C_LANGUAGE_STANDARD: gnu99 OTHER_LDFLAGS: '' - OTHER_CFLAGS: -DNS_BLOCK_ASSERTIONS=1 + OTHER_CFLAGS: + - -DNS_BLOCK_ASSERTIONS=1 + - $(inherited) GCC_VERSION: com.apple.compilers.llvm.clang.1_0 ALWAYS_SEARCH_USER_PATHS: 'NO' SDKROOT: iphoneos @@ -54,7 +56,9 @@ Targets: INSTALL_PATH: $(BUILT_PRODUCTS_DIR) SKIP_INSTALL: 'YES' PODS_ROOT: ${SRCROOT} - OTHER_CPLUSPLUSFLAGS: -DNS_BLOCK_ASSERTIONS=1 + OTHER_CPLUSPLUSFLAGS: + - -DNS_BLOCK_ASSERTIONS=1 + - $(inherited) ARCHS: $(ARCHS_STANDARD_32_BIT) Base Configuration: Pods.xcconfig - Debug: diff --git a/spec/integration/install_new/after/execution_output.txt b/spec/integration/install_new/after/execution_output.txt index a293476403..27681808ca 100644 --- a/spec/integration/install_new/after/execution_output.txt +++ b/spec/integration/install_new/after/execution_output.txt @@ -29,10 +29,10 @@ Downloading dependencies HEAD is now at f7176f4 updated podspec $ /usr/bin/git checkout -b activated-pod-commit 2>&1 Switched to a new branch 'activated-pod-commit' + - Running pre install hooks Generating Pods project - Creating Pods project - - Running pre install hooks - Adding source files to Pods project - Adding resources to Pods project - Linking headers diff --git a/spec/integration/install_podfile_callbacks/after/Pods/Pods.xcodeproj.yaml b/spec/integration/install_podfile_callbacks/after/Pods/Pods.xcodeproj.yaml index ca23691739..ca8118d7fe 100644 --- a/spec/integration/install_podfile_callbacks/after/Pods/Pods.xcodeproj.yaml +++ b/spec/integration/install_podfile_callbacks/after/Pods/Pods.xcodeproj.yaml @@ -44,7 +44,9 @@ Targets: PODS_HEADERS_SEARCH_PATHS: ${PODS_BUILD_HEADERS_SEARCH_PATHS} GCC_C_LANGUAGE_STANDARD: gnu99 OTHER_LDFLAGS: '' - OTHER_CFLAGS: -DNS_BLOCK_ASSERTIONS=1 + OTHER_CFLAGS: + - -DNS_BLOCK_ASSERTIONS=1 + - $(inherited) GCC_VERSION: com.apple.compilers.llvm.clang.1_0 ALWAYS_SEARCH_USER_PATHS: 'NO' SDKROOT: iphoneos @@ -53,7 +55,9 @@ Targets: PRODUCT_NAME: $(TARGET_NAME) IPHONEOS_DEPLOYMENT_TARGET: '6.0' INSTALL_PATH: $(BUILT_PRODUCTS_DIR) - OTHER_CPLUSPLUSFLAGS: -DNS_BLOCK_ASSERTIONS=1 + OTHER_CPLUSPLUSFLAGS: + - -DNS_BLOCK_ASSERTIONS=1 + - $(inherited) PODS_ROOT: ${SRCROOT} ARCHS: $(ARCHS_STANDARD_32_BIT) SKIP_INSTALL: 'YES' diff --git a/spec/integration/install_podfile_callbacks/after/execution_output.txt b/spec/integration/install_podfile_callbacks/after/execution_output.txt index 080fe3ea07..e3b0628ff4 100644 --- a/spec/integration/install_podfile_callbacks/after/execution_output.txt +++ b/spec/integration/install_podfile_callbacks/after/execution_output.txt @@ -29,11 +29,11 @@ Downloading dependencies HEAD is now at f7176f4 updated podspec $ /usr/bin/git checkout -b activated-pod-commit 2>&1 Switched to a new branch 'activated-pod-commit' + - Running pre install hooks + - Podfile Generating Pods project - Creating Pods project - - Running pre install hooks - - Podfile - Adding source files to Pods project - Adding resources to Pods project - Linking headers diff --git a/spec/integration/install_podspec/after/Pods/Pods.xcodeproj.yaml b/spec/integration/install_podspec/after/Pods/Pods.xcodeproj.yaml index 072892e2e8..debc33ea8d 100644 --- a/spec/integration/install_podspec/after/Pods/Pods.xcodeproj.yaml +++ b/spec/integration/install_podspec/after/Pods/Pods.xcodeproj.yaml @@ -42,7 +42,9 @@ Targets: PODS_HEADERS_SEARCH_PATHS: ${PODS_BUILD_HEADERS_SEARCH_PATHS} GCC_C_LANGUAGE_STANDARD: gnu99 OTHER_LDFLAGS: '' - OTHER_CFLAGS: -DNS_BLOCK_ASSERTIONS=1 + OTHER_CFLAGS: + - -DNS_BLOCK_ASSERTIONS=1 + - $(inherited) GCC_VERSION: com.apple.compilers.llvm.clang.1_0 ALWAYS_SEARCH_USER_PATHS: 'NO' SDKROOT: iphoneos @@ -53,7 +55,9 @@ Targets: INSTALL_PATH: $(BUILT_PRODUCTS_DIR) SKIP_INSTALL: 'YES' PODS_ROOT: ${SRCROOT} - OTHER_CPLUSPLUSFLAGS: -DNS_BLOCK_ASSERTIONS=1 + OTHER_CPLUSPLUSFLAGS: + - -DNS_BLOCK_ASSERTIONS=1 + - $(inherited) ARCHS: $(ARCHS_STANDARD_32_BIT) Base Configuration: Pods.xcconfig - Debug: diff --git a/spec/integration/install_podspec/after/execution_output.txt b/spec/integration/install_podspec/after/execution_output.txt index f6aa9fd7b1..77ef1ec949 100644 --- a/spec/integration/install_podspec/after/execution_output.txt +++ b/spec/integration/install_podspec/after/execution_output.txt @@ -32,10 +32,10 @@ Downloading dependencies HEAD is now at f7176f4 updated podspec $ /usr/bin/git checkout -b activated-pod-commit 2>&1 Switched to a new branch 'activated-pod-commit' + - Running pre install hooks Generating Pods project - Creating Pods project - - Running pre install hooks - Adding source files to Pods project - Adding resources to Pods project - Linking headers diff --git a/spec/integration/install_remove_pod/after/Pods/Pods.xcodeproj.yaml b/spec/integration/install_remove_pod/after/Pods/Pods.xcodeproj.yaml index 8ec3f65aad..4b322b6e31 100644 --- a/spec/integration/install_remove_pod/after/Pods/Pods.xcodeproj.yaml +++ b/spec/integration/install_remove_pod/after/Pods/Pods.xcodeproj.yaml @@ -43,7 +43,9 @@ Targets: PODS_HEADERS_SEARCH_PATHS: ${PODS_BUILD_HEADERS_SEARCH_PATHS} GCC_C_LANGUAGE_STANDARD: gnu99 OTHER_LDFLAGS: '' - OTHER_CFLAGS: -DNS_BLOCK_ASSERTIONS=1 + OTHER_CFLAGS: + - -DNS_BLOCK_ASSERTIONS=1 + - $(inherited) GCC_VERSION: com.apple.compilers.llvm.clang.1_0 ALWAYS_SEARCH_USER_PATHS: 'NO' SDKROOT: iphoneos @@ -54,7 +56,9 @@ Targets: INSTALL_PATH: $(BUILT_PRODUCTS_DIR) SKIP_INSTALL: 'YES' PODS_ROOT: ${SRCROOT} - OTHER_CPLUSPLUSFLAGS: -DNS_BLOCK_ASSERTIONS=1 + OTHER_CPLUSPLUSFLAGS: + - -DNS_BLOCK_ASSERTIONS=1 + - $(inherited) ARCHS: $(ARCHS_STANDARD_32_BIT) Base Configuration: Pods.xcconfig - Debug: diff --git a/spec/integration/install_remove_pod/after/execution_output.txt b/spec/integration/install_remove_pod/after/execution_output.txt index 9c0e0c278e..092520e653 100644 --- a/spec/integration/install_remove_pod/after/execution_output.txt +++ b/spec/integration/install_remove_pod/after/execution_output.txt @@ -18,10 +18,10 @@ Comparing resolved specification to the sandbox manifest Downloading dependencies -> Using Reachability (3.1.0) + - Running pre install hooks Generating Pods project - Creating Pods project - - Running pre install hooks - Adding source files to Pods project - Adding resources to Pods project - Linking headers diff --git a/spec/integration/install_spec_callbacks/after/Podfile.lock b/spec/integration/install_spec_callbacks/after/Podfile.lock index 0519a3fffd..021d32b730 100644 --- a/spec/integration/install_spec_callbacks/after/Podfile.lock +++ b/spec/integration/install_spec_callbacks/after/Podfile.lock @@ -9,6 +9,6 @@ EXTERNAL SOURCES: :podspec: Reachability.podspec SPEC CHECKSUMS: - Reachability: fc385e96bfc6d73ff55de863145498352d1c12ea + Reachability: c1e48cc25f8e7cba878c83ad1981d334ef325522 COCOAPODS: 0.17.0.rc2 diff --git a/spec/integration/install_spec_callbacks/after/Pods/Reachability/DependenciesList.txt b/spec/integration/install_spec_callbacks/after/Pods/DependenciesList.txt similarity index 100% rename from spec/integration/install_spec_callbacks/after/Pods/Reachability/DependenciesList.txt rename to spec/integration/install_spec_callbacks/after/Pods/DependenciesList.txt diff --git a/spec/integration/install_spec_callbacks/after/Pods/Local Podspecs/Reachability.podspec b/spec/integration/install_spec_callbacks/after/Pods/Local Podspecs/Reachability.podspec index 7880a4b389..ef95547e2c 100644 --- a/spec/integration/install_spec_callbacks/after/Pods/Local Podspecs/Reachability.podspec +++ b/spec/integration/install_spec_callbacks/after/Pods/Local Podspecs/Reachability.podspec @@ -11,7 +11,6 @@ Pod::Spec.new do |s| s.requires_arc = false def s.pre_install(pod, target_definition) - # Replace strings in existing files pod.source_files.each do |file| replaced = file.read.gsub("kReachabilityChangedNotification", "kTEST") @@ -21,13 +20,10 @@ Pod::Spec.new do |s| # Add new files File.open(pod.root + "TestClass.h", 'w') { |file| file.write("// TEST") } File.open(pod.root + "TestClass.m", 'w') { |file| file.write("// TEST") } - - dependencies = target_definition.dependencies.map(&:to_s) * ", " - File.open(pod.root + "DependenciesList.txt", 'w') { |file| file.write(dependencies) } - end - def s.post_install(target) - + def s.post_install(library) + dependencies = library.dependencies.map(&:to_s) * ", " + File.open(library.sandbox_dir + "DependenciesList.txt", 'w') { |file| file.write(dependencies) } end end diff --git a/spec/integration/install_spec_callbacks/after/Pods/Manifest.lock b/spec/integration/install_spec_callbacks/after/Pods/Manifest.lock index 0519a3fffd..021d32b730 100644 --- a/spec/integration/install_spec_callbacks/after/Pods/Manifest.lock +++ b/spec/integration/install_spec_callbacks/after/Pods/Manifest.lock @@ -9,6 +9,6 @@ EXTERNAL SOURCES: :podspec: Reachability.podspec SPEC CHECKSUMS: - Reachability: fc385e96bfc6d73ff55de863145498352d1c12ea + Reachability: c1e48cc25f8e7cba878c83ad1981d334ef325522 COCOAPODS: 0.17.0.rc2 diff --git a/spec/integration/install_spec_callbacks/after/Pods/Pods.xcodeproj.yaml b/spec/integration/install_spec_callbacks/after/Pods/Pods.xcodeproj.yaml index 4ae6eecb97..3babe5990d 100644 --- a/spec/integration/install_spec_callbacks/after/Pods/Pods.xcodeproj.yaml +++ b/spec/integration/install_spec_callbacks/after/Pods/Pods.xcodeproj.yaml @@ -46,7 +46,9 @@ Targets: PODS_HEADERS_SEARCH_PATHS: ${PODS_BUILD_HEADERS_SEARCH_PATHS} GCC_C_LANGUAGE_STANDARD: gnu99 OTHER_LDFLAGS: '' - OTHER_CFLAGS: -DNS_BLOCK_ASSERTIONS=1 + OTHER_CFLAGS: + - -DNS_BLOCK_ASSERTIONS=1 + - $(inherited) GCC_VERSION: com.apple.compilers.llvm.clang.1_0 ALWAYS_SEARCH_USER_PATHS: 'NO' SDKROOT: iphoneos @@ -57,7 +59,9 @@ Targets: INSTALL_PATH: $(BUILT_PRODUCTS_DIR) SKIP_INSTALL: 'YES' PODS_ROOT: ${SRCROOT} - OTHER_CPLUSPLUSFLAGS: -DNS_BLOCK_ASSERTIONS=1 + OTHER_CPLUSPLUSFLAGS: + - -DNS_BLOCK_ASSERTIONS=1 + - $(inherited) ARCHS: $(ARCHS_STANDARD_32_BIT) Base Configuration: Pods.xcconfig - Debug: diff --git a/spec/integration/install_spec_callbacks/after/execution_output.txt b/spec/integration/install_spec_callbacks/after/execution_output.txt index a4db1fc61d..8e55a0aad5 100644 --- a/spec/integration/install_spec_callbacks/after/execution_output.txt +++ b/spec/integration/install_spec_callbacks/after/execution_output.txt @@ -32,11 +32,11 @@ Downloading dependencies HEAD is now at f7176f4 updated podspec $ /usr/bin/git checkout -b activated-pod-commit 2>&1 Switched to a new branch 'activated-pod-commit' + - Running pre install hooks + - Reachability Generating Pods project - Creating Pods project - - Running pre install hooks - - Reachability - Adding source files to Pods project - Adding resources to Pods project - Linking headers diff --git a/spec/integration/install_spec_callbacks/before/Reachability.podspec b/spec/integration/install_spec_callbacks/before/Reachability.podspec index 7880a4b389..ef95547e2c 100644 --- a/spec/integration/install_spec_callbacks/before/Reachability.podspec +++ b/spec/integration/install_spec_callbacks/before/Reachability.podspec @@ -11,7 +11,6 @@ Pod::Spec.new do |s| s.requires_arc = false def s.pre_install(pod, target_definition) - # Replace strings in existing files pod.source_files.each do |file| replaced = file.read.gsub("kReachabilityChangedNotification", "kTEST") @@ -21,13 +20,10 @@ Pod::Spec.new do |s| # Add new files File.open(pod.root + "TestClass.h", 'w') { |file| file.write("// TEST") } File.open(pod.root + "TestClass.m", 'w') { |file| file.write("// TEST") } - - dependencies = target_definition.dependencies.map(&:to_s) * ", " - File.open(pod.root + "DependenciesList.txt", 'w') { |file| file.write(dependencies) } - end - def s.post_install(target) - + def s.post_install(library) + dependencies = library.dependencies.map(&:to_s) * ", " + File.open(library.sandbox_dir + "DependenciesList.txt", 'w') { |file| file.write(dependencies) } end end diff --git a/spec/integration/install_subspecs/after/Pods/Pods.xcodeproj.yaml b/spec/integration/install_subspecs/after/Pods/Pods.xcodeproj.yaml index 904841928d..8cb28e6511 100644 --- a/spec/integration/install_subspecs/after/Pods/Pods.xcodeproj.yaml +++ b/spec/integration/install_subspecs/after/Pods/Pods.xcodeproj.yaml @@ -55,7 +55,9 @@ Targets: DEBUG_INFORMATION_FORMAT: dwarf-with-dsym GCC_C_LANGUAGE_STANDARD: gnu99 OTHER_LDFLAGS: '' - OTHER_CFLAGS: -DNS_BLOCK_ASSERTIONS=1 + OTHER_CFLAGS: + - -DNS_BLOCK_ASSERTIONS=1 + - $(inherited) GCC_VERSION: com.apple.compilers.llvm.clang.1_0 ALWAYS_SEARCH_USER_PATHS: 'NO' COPY_PHASE_STRIP: 'YES' @@ -63,7 +65,9 @@ Targets: SDKROOT: macosx PRODUCT_NAME: $(TARGET_NAME) INSTALL_PATH: $(BUILT_PRODUCTS_DIR) - OTHER_CPLUSPLUSFLAGS: -DNS_BLOCK_ASSERTIONS=1 + OTHER_CPLUSPLUSFLAGS: + - -DNS_BLOCK_ASSERTIONS=1 + - $(inherited) PODS_ROOT: ${SRCROOT} ARCHS: $(ARCHS_STANDARD_64_BIT) GCC_ENABLE_OBJC_EXCEPTIONS: 'YES' @@ -117,7 +121,9 @@ Targets: PODS_HEADERS_SEARCH_PATHS: ${PODS_BUILD_HEADERS_SEARCH_PATHS} GCC_C_LANGUAGE_STANDARD: gnu99 OTHER_LDFLAGS: '' - OTHER_CFLAGS: -DNS_BLOCK_ASSERTIONS=1 + OTHER_CFLAGS: + - -DNS_BLOCK_ASSERTIONS=1 + - $(inherited) GCC_VERSION: com.apple.compilers.llvm.clang.1_0 ALWAYS_SEARCH_USER_PATHS: 'NO' SDKROOT: iphoneos @@ -128,7 +134,9 @@ Targets: INSTALL_PATH: $(BUILT_PRODUCTS_DIR) SKIP_INSTALL: 'YES' PODS_ROOT: ${SRCROOT} - OTHER_CPLUSPLUSFLAGS: -DNS_BLOCK_ASSERTIONS=1 + OTHER_CPLUSPLUSFLAGS: + - -DNS_BLOCK_ASSERTIONS=1 + - $(inherited) ARCHS: $(ARCHS_STANDARD_32_BIT) Base Configuration: Pods-iOS App.xcconfig - Debug: diff --git a/spec/integration/install_subspecs/after/execution_output.txt b/spec/integration/install_subspecs/after/execution_output.txt index 3402d5e6aa..320c0e4760 100644 --- a/spec/integration/install_subspecs/after/execution_output.txt +++ b/spec/integration/install_subspecs/after/execution_output.txt @@ -26,10 +26,10 @@ Comparing resolved specification to the sandbox manifest Downloading dependencies -> Installing PodTest (1.0) + - Running pre install hooks Generating Pods project - Creating Pods project - - Running pre install hooks - Adding source files to Pods project - Adding resources to Pods project - Linking headers diff --git a/spec/integration/update/after/Pods/Pods.xcodeproj.yaml b/spec/integration/update/after/Pods/Pods.xcodeproj.yaml index 8ec3f65aad..4b322b6e31 100644 --- a/spec/integration/update/after/Pods/Pods.xcodeproj.yaml +++ b/spec/integration/update/after/Pods/Pods.xcodeproj.yaml @@ -43,7 +43,9 @@ Targets: PODS_HEADERS_SEARCH_PATHS: ${PODS_BUILD_HEADERS_SEARCH_PATHS} GCC_C_LANGUAGE_STANDARD: gnu99 OTHER_LDFLAGS: '' - OTHER_CFLAGS: -DNS_BLOCK_ASSERTIONS=1 + OTHER_CFLAGS: + - -DNS_BLOCK_ASSERTIONS=1 + - $(inherited) GCC_VERSION: com.apple.compilers.llvm.clang.1_0 ALWAYS_SEARCH_USER_PATHS: 'NO' SDKROOT: iphoneos @@ -54,7 +56,9 @@ Targets: INSTALL_PATH: $(BUILT_PRODUCTS_DIR) SKIP_INSTALL: 'YES' PODS_ROOT: ${SRCROOT} - OTHER_CPLUSPLUSFLAGS: -DNS_BLOCK_ASSERTIONS=1 + OTHER_CPLUSPLUSFLAGS: + - -DNS_BLOCK_ASSERTIONS=1 + - $(inherited) ARCHS: $(ARCHS_STANDARD_32_BIT) Base Configuration: Pods.xcconfig - Debug: diff --git a/spec/integration/update/after/execution_output.txt b/spec/integration/update/after/execution_output.txt index 5e6a8c4b4a..867eabce1b 100644 --- a/spec/integration/update/after/execution_output.txt +++ b/spec/integration/update/after/execution_output.txt @@ -32,10 +32,10 @@ Downloading dependencies HEAD is now at f7176f4 updated podspec $ /usr/bin/git checkout -b activated-pod-commit 2>&1 Switched to a new branch 'activated-pod-commit' + - Running pre install hooks Generating Pods project - Creating Pods project - - Running pre install hooks - Adding source files to Pods project - Adding resources to Pods project - Linking headers diff --git a/spec/integration_spec.rb b/spec/integration_spec.rb index d27dd9d0a8..e13bf01948 100644 --- a/spec/integration_spec.rb +++ b/spec/integration_spec.rb @@ -135,13 +135,13 @@ module Pod pod 'SSZipArchive', '0.1.0' pre_install do |installer| - memo = "PODS:#{installer.pods * ', '} TARGETS:#{installer.project.targets * ', '}" + memo = "PODS:#{installer.pods * ', '} LIBRARIES:#{installer.libraries.map(&:name) * ', '}" File.open(installer.config.sandbox_root + 'memo.txt', 'w') {|f| f.puts memo} end end Installer.new(config.sandbox, podfile).install! - File.open(config.sandbox_root + 'memo.txt','rb').read.should == "PODS:SSZipArchive (0.1.0) TARGETS:\n" + File.open(config.sandbox_root + 'memo.txt','rb').read.should == "PODS:SSZipArchive (0.1.0) LIBRARIES:Pods\n" end #--------------------------------------# diff --git a/spec/unit/hooks/library_representation_spec.rb b/spec/unit/hooks/library_representation_spec.rb index 524a59b289..768e2f2bf2 100644 --- a/spec/unit/hooks/library_representation_spec.rb +++ b/spec/unit/hooks/library_representation_spec.rb @@ -22,6 +22,10 @@ module Pod @rep.dependencies.should == [Dependency.new('AFNetworking')] end + it "returns the sandbox dir" do + @rep.sandbox_dir.should == temporary_directory + 'Pods' + end + it "returns the path of the prefix header" do @lib.support_files_root = temporary_directory @rep.prefix_header_filename.should == temporary_directory + 'Pods-MyApp-prefix.pch' diff --git a/spec/unit/installer/pod_source_installer_spec.rb b/spec/unit/installer/pod_source_installer_spec.rb index a326dc1ddf..4d5bba949f 100644 --- a/spec/unit/installer/pod_source_installer_spec.rb +++ b/spec/unit/installer/pod_source_installer_spec.rb @@ -107,6 +107,7 @@ module Pod it "cleans the paths non used by the installation" do @installer.clean = true @installer.install! + @installer.clean! unused_file = config.sandbox.root + 'BananaLib/sub-dir/sub-dir-2/somefile.txt' unused_file.should.not.exist end @@ -114,6 +115,7 @@ module Pod it "preserves important files like the LICENSE and the README" do @installer.clean = true @installer.install! + @installer.clean! readme_file = config.sandbox.root + 'BananaLib/README' readme_file.should.exist end @@ -121,6 +123,7 @@ module Pod it "doesn't performs any cleaning if instructed to do so" do @installer.clean = false @installer.install! + @installer.clean! unused_file = config.sandbox.root + 'BananaLib/sub-dir/sub-dir-2/somefile.txt' unused_file.should.exist end diff --git a/spec/unit/installer_spec.rb b/spec/unit/installer_spec.rb index 8f7100b129..adb35d8761 100644 --- a/spec/unit/installer_spec.rb +++ b/spec/unit/installer_spec.rb @@ -44,17 +44,14 @@ module Pod @installer.stubs(:integrate_user_project) end - it "in runs the pre-install hooks before adding the file references" do - @installer.unstub(:generate_pods_project) - @installer.stubs(:prepare_pods_project) - @installer.stubs(:install_targets) - @installer.stubs(:run_post_install_hooks) - @installer.stubs(:write_pod_project) - @installer.stubs(:write_lockfiles) + it "in runs the pre-install hooks before cleaning the Pod sources" do + @installer.unstub(:download_dependencies) + @installer.stubs(:create_file_accessors) + @installer.stubs(:install_pod_sources) def @installer.run_pre_install_hooks @hook_called = true end - def @installer.install_file_references + def @installer.clean_pod_sources @hook_called.should.be.true end @installer.install!