項目環境
cocos2d-x 3.13
xcode 12
mac m1 big sur
先找到你的項目
使用xcode軟件打開上面這個文件
打開后應該是這個樣子
執行編譯運行就好了
可能會碰到的錯誤
在xcode11版本以上都會有這個錯誤,這是因為iOS11+廢棄了system。
將上面代碼修改為
#if (CC_TARGET_PLATFORM != CC_PLATFORM_ANDROID)
#include <ftw.h>
#endifnamespace
{
#if (CC_TARGET_PLATFORM != CC_PLATFORM_ANDROID)int unlink_cb(const char *fpath, const struct stat *sb, int typeflag, struct FTW *ftwbuf){int rv = remove(fpath);if (rv)perror(fpath);return rv;}
#endif
}bool FileUtils::removeDirectory(const std::string& path)
{
#if !defined(CC_TARGET_OS_TVOS)#if (CC_TARGET_PLATFORM != CC_PLATFORM_ANDROID)if (nftw(path.c_str(), unlink_cb, 64, FTW_DEPTH | FTW_PHYS) == -1)return false;elsereturn true;
#elsestd::string command = "rm -r ";// Path may include space.command += "\"" + path + "\"";if (system(command.c_str()) >= 0)return true;elsereturn false;
#endif // (CC_TARGET_PLATFORM != CC_PLATFORM_ANDROID)#elsereturn false;
#endif // !defined(CC_TARGET_OS_TVOS)
}
解決方案地址
remove "system" usage by minggo · Pull Request #17921 · cocos2d/cocos2d-x · GitHub
繼續運行碰到錯誤
building for iOS Simulator, but linking in object file built for iOS,
找到配置項的這一行添加arm64
再繼續運行 又出現錯誤
解決方法 刪除全部VALID_ARCHS 配置項 全局搜索?VALID_ARCHS 然后整行刪除。
繼續運行? 報錯
解決方法
找到42行代碼
改成下面
再運行 報錯
?
解決方法
找到ios info.list 添加version值
?
再運行,終于運行成功