Skip to content

Commit 1a71fe7

Browse files
author
minggo
committed
Merge pull request cocos2d#164 from natural-law/develop
Solve the error when running app on iOS simulator in cocos2d-x 3.3
2 parents fed86b0 + cda7552 commit 1a71fe7

File tree

6 files changed

+36
-20
lines changed

6 files changed

+36
-20
lines changed

bin/cocos.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,27 @@ def check_environment_variable(var):
282282

283283
return value
284284

285+
def get_xcode_version():
286+
commands = [
287+
"xcodebuild",
288+
"-version"
289+
]
290+
child = subprocess.Popen(commands, stdout=subprocess.PIPE)
291+
292+
xcode = None
293+
version = None
294+
for line in child.stdout:
295+
if 'Xcode' in line:
296+
xcode, version = str.split(line, ' ')
297+
298+
child.wait()
299+
300+
if xcode is None:
301+
message = "Xcode wasn't installed"
302+
raise CCPluginError(message)
303+
304+
return version
305+
285306
def copy_files_in_dir(src, dst):
286307

287308
for item in os.listdir(src):

plugins/project_compile/project_compile.py

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -428,23 +428,7 @@ def build_android(self):
428428
cocos.Logging.info("build succeeded.")
429429

430430
def check_ios_mac_build_depends(self):
431-
commands = [
432-
"xcodebuild",
433-
"-version"
434-
]
435-
child = subprocess.Popen(commands, stdout=subprocess.PIPE)
436-
437-
xcode = None
438-
version = None
439-
for line in child.stdout:
440-
if 'Xcode' in line:
441-
xcode, version = str.split(line, ' ')
442-
443-
child.wait()
444-
445-
if xcode is None:
446-
message = "Xcode wasn't installed"
447-
raise cocos.CCPluginError(message)
431+
version = cocos.get_xcode_version()
448432

449433
if version <= '5':
450434
message = "Update xcode please"
@@ -600,7 +584,8 @@ def build_ios(self):
600584
"%s" % "-arch i386" if self.use_sdk == 'iphonesimulator' else '',
601585
"-sdk",
602586
"%s" % self.use_sdk,
603-
"CONFIGURATION_BUILD_DIR=%s" % (output_dir)
587+
"CONFIGURATION_BUILD_DIR=%s" % (output_dir),
588+
"%s" % "VALID_ARCHS=\"i386\"" if self.use_sdk == 'iphonesimulator' else ''
604589
])
605590

606591
if self._sign_id is not None:

plugins/project_run/bin/ios-sim

-94.9 KB
Binary file not shown.
100 KB
Binary file not shown.
70 KB
Binary file not shown.

plugins/project_run/project_run.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,17 @@ def _check_custom_options(self, args):
5353
self._mode = args.mode
5454
self._host = args.host
5555
self._browser = args.browser
56-
56+
57+
def get_ios_sim_name(self):
58+
# get the version of xcodebuild
59+
ver = cocos.get_xcode_version()
60+
61+
if ver.startswith("5"):
62+
ret = "ios-sim-xcode5"
63+
else:
64+
ret = "ios-sim-xcode6"
65+
66+
return ret
5767

5868
def run_ios_sim(self, dependencies):
5969
if not self._platforms.is_ios_active():
@@ -64,7 +74,7 @@ def run_ios_sim(self, dependencies):
6474
cocos.Logging.warning("The generated app is for device. Can't run it on simulator.")
6575
cocos.Logging.warning("The signed app & ipa are generated in path : %s" % os.path.dirname(deploy_dep._iosapp_path))
6676
else:
67-
iossim_exe_path = os.path.join(os.path.dirname(__file__), 'bin', 'ios-sim')
77+
iossim_exe_path = os.path.join(os.path.dirname(__file__), 'bin', self.get_ios_sim_name())
6878
launch_sim = "%s launch \"%s\" &" % (iossim_exe_path, deploy_dep._iosapp_path)
6979
self._run_cmd(launch_sim)
7080

0 commit comments

Comments
 (0)