Fix The deployment target used to find the right simulator to compile the binaries #73
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Context
cocoapods: 1.6.0cocoapods-binary: masterThe issue
Currently, when I try to use cocoapods-binary on a project which uses
platform :ios, '11.0'at the top of its Podfile,pod installfails during the prebuild of binary pods becauseFourflusherfinds the older simulator matchingiOS 8.0, and thenxcodebuild(Xcode 10.2 on our CircleCI) fails with:Where that id
85D2D947-6AFF-469A-9C95-FFBFFB069294corresponds to a simulator with theiOS 10.3runtime when I listxcrun simctlon said CI.The reason
This is due to the fact that the code uses the
PodTarget.platform.deployment_targetvalue to determine the minimum deployment target to pass toFourflusher::SimControl.new.destination(:oldest, platform, deployment_target)As a matter of fact,
target.platform.deployment_targetcorresponds to the Pod's minimum deployment target as defined in its.podspec(or more precisely, the max between '8.0' and the value in the podspec, as seen here in CocoaPods' source).But what is finally used as the
IPHONEOS_DEPLOYMENT_TARGETBuild Setting for the Pod targets generated by CocoaPods in thePods.xcodeprojin the end, is theplatform.deployment_targetof the Aggregate Targets – as seen here in CocoaPods source – and not thePodTarget(whoseplatformreflects the one in their spec, not the one for integration). So this is the minimum version we need to use to build the podsThe current behavior means that if we have any pod which have a
s.platforms.ios = '8.0'in theirpodspec,cocoapods-binarywill askFourFlusherfor a simulator with iOS 8.0 minimum, find for example a 10.3 simulator, but then will fail to compile the Pod target due to itsIPHONEOS_DEPLOYMENT_TARGET=11.0set on the Pod target – because we usedplatform :ios, '11.0'at the top of ourPodfileThe fix
We need to rely on the
platform.deployment_targetof the aggregate target (which will then be used by CocoaPods to set theIPHONEOS_DEPLOYMENT_TARGETbuild setting in each pod's.xcconfigfile) to determine the right simulator to use for compilation and especially the minimum iOS version that this simulator needs to support.My solution is to use the maximum value of all the aggregate targets that include the Pod being compiled. That way, if Pod
Ais integrated in ourPodfilein both in atargetspecifyingplatform :ios, '10.0'and anothertargetspecifyingplatform :ios, '11.0', then we'd need to compilepod Ausing an iOS 11 simulator.Alternative
We could also instead just use the latest iOS simulator available. After all, what's important for compilation is the SDK version. So if we're using Xcode 10.2 to compile, we should use the latest simulator, one running with iOS SDK 12, because what we care about is the iOS SDK used to compile.
Sadly, after a quick glance at Fourflusher, it seems there's no filter
:newestto get the most recent simulator, only:oldest.