Skip to content

Commit 1722fd7

Browse files
olehermanseminggo
authored andcommitted
Use new version_minimum() func to compare XCode versions (#424)
Signed-off-by: Ole Herman Schumacher Elgesem <[email protected]>
1 parent 7bf96af commit 1722fd7

File tree

2 files changed

+27
-2
lines changed

2 files changed

+27
-2
lines changed

bin/cocos.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -717,6 +717,29 @@ def get_xcode_version():
717717

718718
return version
719719

720+
def version_minimum(a, b):
721+
'''Compares two version numbers to see if a >= b
722+
723+
expects two dot separated version numbers
724+
can be string, float or int
725+
'''
726+
if a == b or str(a).strip() == str(b).strip():
727+
return True
728+
729+
a = [int(x) for x in str(a).split(".")]
730+
b = [int(x) for x in str(b).split(".")]
731+
for i in range(max(len(a), len(b))):
732+
ai, bi = 0, 0
733+
if len(a) > i:
734+
ai = a[i]
735+
if len(b) > i:
736+
bi = b[i]
737+
if ai > bi:
738+
return True
739+
if ai < bi:
740+
return False
741+
742+
return True
720743

721744
def copy_files_in_dir(src, dst):
722745

plugins/plugin_compile/project_compile.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -804,10 +804,12 @@ def build_ios(self):
804804
"CONFIGURATION_BUILD_DIR=\"%s\"" % (output_dir),
805805
"%s" % "VALID_ARCHS=\"i386\"" if self.use_sdk == 'iphonesimulator' else ''
806806
])
807-
807+
808808
# PackageApplication is removed since xcode 8.3, should use new method to generate .ipa
809809
# should generate .xcarchive first, then generate .ipa
810-
use_new_ipa_method = float(cocos.get_xcode_version()) >= 8.3
810+
xcode_version = cocos.get_xcode_version()
811+
812+
use_new_ipa_method = cocos.version_minimum(xcode_version, 8.3)
811813

812814
if self._sign_id is not None:
813815
if use_new_ipa_method:

0 commit comments

Comments
 (0)