Skip to content

Commit 40c3218

Browse files
author
Bin Zhang
authored
Merge pull request #328 from xpol/add-cocoapods-xcworkspace-support
Support CocoaPods workspace.
2 parents 6063254 + 3cc6b22 commit 40c3218

File tree

2 files changed

+16
-6
lines changed

2 files changed

+16
-6
lines changed

bin/strings.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,7 @@
176176
"COMPILE_INFO_BUILDING" : "Building...",
177177
"COMPILE_INFO_FIND_IN_REG_FMT" : "Finding VS in registry : %s",
178178
"COMPILE_INFO_REQUIRED_VS_FMT" : "Required VS version : %s",
179+
"COMPILE_INFO_USE_COCOAPODS" : "CocoaPods detected: use xcworkspace for build",
179180
"COMPILE_ERROR_WRONG_MODE_FMT" : "Value of '-m' should be one of %s.",
180181
"COMPILE_ERROR_WRONG_NDK_MODE_FMT" : "Value of '--ndk-mode' should be one of %s.",
181182
"COMPILE_ERROR_WRONG_VS_VER_FMT" : "VS %d is not supported.",
@@ -517,6 +518,7 @@
517518
"COMPILE_INFO_BUILDING" : "正在编译...",
518519
"COMPILE_INFO_FIND_IN_REG_FMT" : "在 %s 注册表中查找 VS 安装路径。",
519520
"COMPILE_INFO_REQUIRED_VS_FMT" : "要求的 VS 版本:%s",
521+
"COMPILE_INFO_USE_COCOAPODS" : "检测到 CocoaPods:使用 xcworkspace 进行编译。",
520522
"COMPILE_ERROR_WRONG_MODE_FMT" : "'-m' 参数取值范围:%s。",
521523
"COMPILE_ERROR_WRONG_NDK_MODE_FMT" : "'--ndk-mode' 参数取值范围:%s。",
522524
"COMPILE_ERROR_WRONG_VS_VER_FMT" : "不支持 VS %d。",
@@ -857,6 +859,7 @@
857859
"COMPILE_INFO_BUILDING" : "正在編譯...",
858860
"COMPILE_INFO_FIND_IN_REG_FMT" : "在 %s 註冊表中查找 VS 安裝路徑。",
859861
"COMPILE_INFO_REQUIRED_VS_FMT" : "要求的 VS 版本:%s",
862+
"COMPILE_INFO_USE_COCOAPODS" : "檢測到 CocoaPods:使用 xcworkspace 进行编译。",
860863
"COMPILE_ERROR_WRONG_MODE_FMT" : "'-m' 參數取值範圍:%s。",
861864
"COMPILE_ERROR_WRONG_NDK_MODE_FMT" : "'--ndk-mode' 參數取值範圍:%s。",
862865
"COMPILE_ERROR_WRONG_VS_VER_FMT" : "不支持 VS %d。",

plugins/plugin_compile/project_compile.py

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -565,6 +565,13 @@ def check_ios_mac_build_depends(self):
565565

566566
self.project_name = name
567567
self.xcodeproj_name = xcodeproj_name
568+
project_dir = self._platforms.project_path()
569+
podfile = os.path.join(project_dir, 'Podfile')
570+
self.xcworkspace = os.path.join(project_dir, name+'.xcworkspace')
571+
self.cocoapods = os.path.exists(self.xcworkspace) and os.path.exists(podfile)
572+
if self.cocoapods:
573+
cocos.Logging.info(MultiLanguage.get_string('COMPILE_INFO_USE_COCOAPODS'))
574+
568575

569576
def _remove_res(self, target_path):
570577
build_cfg_dir = self._build_cfg_path()
@@ -739,11 +746,11 @@ def build_ios(self):
739746

740747
command = ' '.join([
741748
"xcodebuild",
742-
"-project",
743-
"\"%s\"" % projectPath,
749+
"-workspace" if self.cocoapods else "-project",
750+
"\"%s\"" % self.xcworkspace if self.cocoapods else projectPath,
744751
"-configuration",
745752
"%s" % 'Debug' if self._mode == 'debug' else 'Release',
746-
"-target",
753+
"-scheme" if self.cocoapods else "-target",
747754
"\"%s\"" % targetName,
748755
"%s" % "-arch i386" if self.use_sdk == 'iphonesimulator' else '',
749756
"-sdk",
@@ -877,11 +884,11 @@ def build_mac(self):
877884

878885
command = ' '.join([
879886
"xcodebuild",
880-
"-project",
881-
"\"%s\"" % projectPath,
887+
"-workspace" if self.cocoapods else "-project",
888+
"\"%s\"" % self.xcworkspace if self.cocoapods else projectPath,
882889
"-configuration",
883890
"%s" % 'Debug' if self._mode == 'debug' else 'Release',
884-
"-target",
891+
"-scheme" if self.cocoapods else "-target",
885892
"\"%s\"" % targetName,
886893
"CONFIGURATION_BUILD_DIR=\"%s\"" % (output_dir)
887894
])

0 commit comments

Comments
 (0)