Skip to content

Commit 3cc6b22

Browse files
committed
Support CocoaPods workspace.
1. Needs `Podfile` exists in proj.ios_mac. 2. Needs the CocoaPods workspace has the same base name with `xcodeproj`. 3. If 1 and 2 are both satisfied, the `cocos compile -p [ios|mac]` will use CocoaPods workspace for build.
1 parent 6cc7a09 commit 3cc6b22

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
@@ -160,6 +160,7 @@
160160
"COMPILE_INFO_BUILDING" : "Building...",
161161
"COMPILE_INFO_FIND_IN_REG_FMT" : "Finding VS in registry : %s",
162162
"COMPILE_INFO_REQUIRED_VS_FMT" : "Required VS version : %s",
163+
"COMPILE_INFO_USE_COCOAPODS" : "CocoaPods detected: use xcworkspace for build",
163164
"COMPILE_ERROR_WRONG_MODE_FMT" : "Value of '-m' should be one of %s.",
164165
"COMPILE_ERROR_WRONG_NDK_MODE_FMT" : "Value of '--ndk-mode' should be one of %s.",
165166
"COMPILE_ERROR_WRONG_VS_VER_FMT" : "VS %d is not supported.",
@@ -498,6 +499,7 @@
498499
"COMPILE_INFO_BUILDING" : "正在编译...",
499500
"COMPILE_INFO_FIND_IN_REG_FMT" : "在 %s 注册表中查找 VS 安装路径。",
500501
"COMPILE_INFO_REQUIRED_VS_FMT" : "要求的 VS 版本:%s",
502+
"COMPILE_INFO_USE_COCOAPODS" : "检测到 CocoaPods:使用 xcworkspace 进行编译。",
501503
"COMPILE_ERROR_WRONG_MODE_FMT" : "'-m' 参数取值范围:%s。",
502504
"COMPILE_ERROR_WRONG_NDK_MODE_FMT" : "'--ndk-mode' 参数取值范围:%s。",
503505
"COMPILE_ERROR_WRONG_VS_VER_FMT" : "不支持 VS %d。",
@@ -835,6 +837,7 @@
835837
"COMPILE_INFO_BUILDING" : "正在編譯...",
836838
"COMPILE_INFO_FIND_IN_REG_FMT" : "在 %s 註冊表中查找 VS 安裝路徑。",
837839
"COMPILE_INFO_REQUIRED_VS_FMT" : "要求的 VS 版本:%s",
840+
"COMPILE_INFO_USE_COCOAPODS" : "檢測到 CocoaPods:使用 xcworkspace 进行编译。",
838841
"COMPILE_ERROR_WRONG_MODE_FMT" : "'-m' 參數取值範圍:%s。",
839842
"COMPILE_ERROR_WRONG_NDK_MODE_FMT" : "'--ndk-mode' 參數取值範圍:%s。",
840843
"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
@@ -548,6 +548,13 @@ def check_ios_mac_build_depends(self):
548548

549549
self.project_name = name
550550
self.xcodeproj_name = xcodeproj_name
551+
project_dir = self._platforms.project_path()
552+
podfile = os.path.join(project_dir, 'Podfile')
553+
self.xcworkspace = os.path.join(project_dir, name+'.xcworkspace')
554+
self.cocoapods = os.path.exists(self.xcworkspace) and os.path.exists(podfile)
555+
if self.cocoapods:
556+
cocos.Logging.info(MultiLanguage.get_string('COMPILE_INFO_USE_COCOAPODS'))
557+
551558

552559
def _remove_res(self, target_path):
553560
build_cfg_dir = self._build_cfg_path()
@@ -719,11 +726,11 @@ def build_ios(self):
719726

720727
command = ' '.join([
721728
"xcodebuild",
722-
"-project",
723-
"\"%s\"" % projectPath,
729+
"-workspace" if self.cocoapods else "-project",
730+
"\"%s\"" % self.xcworkspace if self.cocoapods else projectPath,
724731
"-configuration",
725732
"%s" % 'Debug' if self._mode == 'debug' else 'Release',
726-
"-target",
733+
"-scheme" if self.cocoapods else "-target",
727734
"\"%s\"" % targetName,
728735
"%s" % "-arch i386" if self.use_sdk == 'iphonesimulator' else '',
729736
"-sdk",
@@ -856,11 +863,11 @@ def build_mac(self):
856863

857864
command = ' '.join([
858865
"xcodebuild",
859-
"-project",
860-
"\"%s\"" % projectPath,
866+
"-workspace" if self.cocoapods else "-project",
867+
"\"%s\"" % self.xcworkspace if self.cocoapods else projectPath,
861868
"-configuration",
862869
"%s" % 'Debug' if self._mode == 'debug' else 'Release',
863-
"-target",
870+
"-scheme" if self.cocoapods else "-target",
864871
"\"%s\"" % targetName,
865872
"CONFIGURATION_BUILD_DIR=\"%s\"" % (output_dir)
866873
])

0 commit comments

Comments
 (0)