diff --git a/.travis.yml b/.travis.yml index 9327854..59e818b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,10 +1,14 @@ -osx_image: xcode9.3 +osx_image: xcode10.2 language: objective-c cache: - cocoapods - bundler +gemfile: test/Gemfile before_install: -- gem install cocoapods +- unset CPATH +install: +- bundle install --jobs=3 --retry=3 --path=${BUNDLE_PATH:-vendor/bundle} +- bundle exec pod setup script: - rake install - cd test diff --git a/cocoapods-binary.gemspec b/cocoapods-binary.gemspec index 697aeb2..de525fb 100644 --- a/cocoapods-binary.gemspec +++ b/cocoapods-binary.gemspec @@ -22,6 +22,6 @@ Gem::Specification.new do |spec| spec.add_dependency "fourflusher", "~> 2.0" spec.add_dependency "xcpretty", "~> 0.3.0" - spec.add_development_dependency 'bundler', '~> 1.3' + spec.add_development_dependency 'bundler', '> 1.3' spec.add_development_dependency 'rake' end diff --git a/lib/cocoapods-binary/Prebuild.rb b/lib/cocoapods-binary/Prebuild.rb index 77bc834..5ad44d4 100644 --- a/lib/cocoapods-binary/Prebuild.rb +++ b/lib/cocoapods-binary/Prebuild.rb @@ -11,20 +11,14 @@ class Installer private def local_manifest - if not @local_manifest_inited - @local_manifest_inited = true - raise "This method should be call before generate project" unless self.analysis_result == nil - @local_manifest = self.sandbox.manifest - end - @local_manifest + self.sandbox.manifest end # @return [Analyzer::SpecsState] def prebuild_pods_changes return nil if local_manifest.nil? - if @prebuild_pods_changes.nil? - changes = local_manifest.detect_changes_with_podfile(podfile) - @prebuild_pods_changes = Analyzer::SpecsState.new(changes) + if @prebuild_pods_changes.nil? && !self.analysis_result.nil? + @prebuild_pods_changes = self.analysis_result.sandbox_state # save the chagnes info for later stage Pod::Prebuild::Passer.prebuild_pods_changes = @prebuild_pods_changes end @@ -40,6 +34,8 @@ def have_exact_prebuild_cache? return false if local_manifest == nil changes = prebuild_pods_changes + return false if changes.nil? + added = changes.added changed = changes.changed unchanged = changes.unchanged diff --git a/lib/cocoapods-binary/rome/build_framework.rb b/lib/cocoapods-binary/rome/build_framework.rb index 10c8571..0f87c84 100644 --- a/lib/cocoapods-binary/rome/build_framework.rb +++ b/lib/cocoapods-binary/rome/build_framework.rb @@ -42,6 +42,7 @@ def build_for_iosish_platform(sandbox, module_name = target.product_module_name device_framework_path = "#{build_dir}/#{CONFIGURATION}-#{device}/#{target_name}/#{module_name}.framework" simulator_framework_path = "#{build_dir}/#{CONFIGURATION}-#{simulator}/#{target_name}/#{module_name}.framework" + output_framework_path = "#{output_path}/#{module_name}.framework" device_binary = device_framework_path + "/#{module_name}" simulator_binary = simulator_framework_path + "/#{module_name}" @@ -86,6 +87,7 @@ def build_for_iosish_platform(sandbox, # handle the dSYM files device_dsym = "#{device_framework_path}.dSYM" + device_dsym_output_path = "#{output_framework_path}.dSYM" if File.exist? device_dsym # lipo the simulator dsym simulator_dsym = "#{simulator_framework_path}.dSYM" @@ -96,12 +98,14 @@ def build_for_iosish_platform(sandbox, FileUtils.mv tmp_lipoed_binary_path, "#{device_framework_path}.dSYM/Contents/Resources/DWARF/#{module_name}", :force => true end # move - FileUtils.mv device_dsym, output_path, :force => true + FileUtils.rm_r device_dsym_output_path if Dir.exist? device_dsym_output_path + File.rename device_dsym, device_dsym_output_path end # output output_path.mkpath unless output_path.exist? - FileUtils.mv device_framework_path, output_path, :force => true + FileUtils.rm_r output_framework_path if Dir.exist? output_framework_path + File.rename device_framework_path, output_framework_path end diff --git a/test/change_podfile.py b/test/change_podfile.py index 5f31510..f7ba592 100644 --- a/test/change_podfile.py +++ b/test/change_podfile.py @@ -32,6 +32,13 @@ def save_to_podfile(text): file.write( "" if len(text) <= 2 else text[2]) file.close() + if len(text) > 3: + path = os.path.dirname(os.path.abspath(__file__)) + path += "/Podfile.lock" + file = open(path, "w+") + file.write(text[3]) + file.close() + def initial(): @@ -53,7 +60,7 @@ def addSwiftPod(): """ keep_source_code_for_prebuilt_frameworks! -pod "RxCocoa", :binary => true +pod "RxCocoa", "~> 4.0", :binary => true pod "Literal", :binary => true """), """ @@ -70,7 +77,7 @@ def revertToSourceCode(): """ keep_source_code_for_prebuilt_frameworks! -pod "RxCocoa", :binary => true +pod "RxCocoa", "~> 4.0", :binary => true pod "Literal" """), """ @@ -233,6 +240,167 @@ class A { """ ) +def oldPodVersion(): + return (wrapper( +""" +pod "ReactiveSwift", "= 3.0.0", :binary => true +""") , +""" +import ReactiveSwift +class A { + // Works on 3.x but not 4.x + let a = A.b(SignalProducer.empty) + static func b(_ b: U) -> Bool { + return true + } +} +""" +) + +def upgradePodVersion(): + return (wrapper( +""" +pod "ReactiveSwift", "= 4.0.0", :binary => true +""") , +""" +import ReactiveSwift +class A { + func b() { + // Works on 4.x but not 3.x + Lifetime.make().token.dispose() + } +} +""" +) + + +def originalPodfileAndLockfileVersion(): + return (wrapper( +""" +pod "Result", "= 3.2.2", :binary => true +""") , +""" +import Result +class A { + // Works on 3.x but not 4.x + var err: ErrorProtocolConvertible? +} +""", "", +""" +PODS: + - Result (3.2.2) + +DEPENDENCIES: + - Result (= 3.2.2) + +SPEC REPOS: + https://github.com/cocoapods/specs.git: + - Result + +SPEC CHECKSUMS: + Result: 4edd39003fdccf281d418ee1b006571f70123250 + +PODFILE CHECKSUM: 578d759c1f6329e159731bc0a232fb9051977130 + +COCOAPODS: 1.6.1 +""" +) + +def upgradePodfileAndLockfileVersion(): + return (wrapper( +""" +pod "Result", "= 4.0.0", :binary => true +""") , +""" +import Result +class A { + // Works on 4.x but not 3.x + var err: ErrorConvertible? +} +""", "", +""" +PODS: + - Result (4.0.0) + +DEPENDENCIES: + - Result (= 4.0.0) + +SPEC REPOS: + https://github.com/cocoapods/specs.git: + - Result + +SPEC CHECKSUMS: + Result: 7645bb3f50c2ce726dd0ff2fa7b6f42bbe6c3713 + +PODFILE CHECKSUM: ee7fa7b9f6dade6905c2b00142c54f164bdc2ceb + +COCOAPODS: 1.6.1 +""" +) + +def originalLockfileVersion(): + return (wrapper( +""" +pod "Result", :binary => true +""") , +""" +import Result +class A { + // Works on 3.x but not 4.x + var err: ErrorProtocolConvertible? +} +""", "", +""" +PODS: + - Result (3.2.2) + +DEPENDENCIES: + - Result + +SPEC REPOS: + https://github.com/cocoapods/specs.git: + - Result + +SPEC CHECKSUMS: + Result: 4edd39003fdccf281d418ee1b006571f70123250 + +PODFILE CHECKSUM: 8705dea54636097dca87d2a49ac6963c842b6eb4 + +COCOAPODS: 1.6.1 +""" +) + +def upgradeLockfileVersion(): + return (wrapper( +""" +pod "Result", :binary => true +""") , +""" +import Result +class A { + // Works on 4.x but not 3.x + var err: ErrorConvertible? +} +""", "", +""" +PODS: + - Result (4.0.0) + +DEPENDENCIES: + - Result + +SPEC REPOS: + https://github.com/cocoapods/specs.git: + - Result + +SPEC CHECKSUMS: + Result: 7645bb3f50c2ce726dd0ff2fa7b6f42bbe6c3713 + +PODFILE CHECKSUM: 8705dea54636097dca87d2a49ac6963c842b6eb4 + +COCOAPODS: 1.6.1 +""" +) if __name__ == "__main__": arg = sys.argv[1] diff --git a/test/test.sh b/test/test.sh old mode 100644 new mode 100755 index 4aa46dc..5b957a5 --- a/test/test.sh +++ b/test/test.sh @@ -1,5 +1,9 @@ #!/bin/sh -set -e +set -ex + +clean() { + rm -rf ~/Library/Developer/Xcode/DerivedData/*/ +} build() { xcodebuild -workspace Binary.xcworkspace -scheme Binary ONLY_ACTIVE_ARCH=YES CODE_SIGN_IDENTITY="" CODE_SIGNING_REQUIRED=NO CODE_SIGNING_ALLOWED=NO -quiet || exit 1 @@ -7,9 +11,10 @@ build() { rm -rf Pods -cases=("initial" "addSwiftPod" "revertToSourceCode" "addDifferentNamePod" "addSubPod" "deleteAPod" "addVendoredLibPod" "universalFlag" "multiplePlatforms" "multiplePlatformsWithALLFlag") +cases=("initial" "addSwiftPod" "revertToSourceCode" "addDifferentNamePod" "addSubPod" "deleteAPod" "addVendoredLibPod" "universalFlag" "multiplePlatforms" "multiplePlatformsWithALLFlag" "oldPodVersion" "upgradePodVersion" "originalPodfileAndLockfileVersion" "upgradePodfileAndLockfileVersion" "originalLockfileVersion" "upgradeLockfileVersion") for action in ${cases[@]}; do python change_podfile.py ${action} + clean bundle exec pod install build done