Skip to content

Fix bug related to Podfile.lock-only changes #104

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 15 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion cocoapods-binary.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -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
14 changes: 5 additions & 9 deletions lib/cocoapods-binary/Prebuild.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
8 changes: 6 additions & 2 deletions lib/cocoapods-binary/rome/build_framework.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
Expand Down Expand Up @@ -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"
Expand All @@ -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

Expand Down
172 changes: 170 additions & 2 deletions test/change_podfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand All @@ -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
"""),
"""
Expand All @@ -70,7 +77,7 @@ def revertToSourceCode():
"""
keep_source_code_for_prebuilt_frameworks!

pod "RxCocoa", :binary => true
pod "RxCocoa", "~> 4.0", :binary => true
pod "Literal"
"""),
"""
Expand Down Expand Up @@ -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<Int, NSError>.empty)
static func b<U: BindingSource>(_ 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]
Expand Down
9 changes: 7 additions & 2 deletions test/test.sh
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,15 +1,20 @@
#!/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
}

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
Expand Down