如何将cocos2d-x js打包部署到ios上 Mac M1系统

项目环境

cocos2d-x 3.13

xcode 12

mac m1 big sur

先找到你的项目

使用xcode软件打开上面这个文件

打开后应该是这个样子

执行编译运行就好了

可能会碰到的错误

在xcode11版本以上都会有这个错误,这是因为iOS11+废弃了system。

将上面代码修改为

cpp 复制代码
#if (CC_TARGET_PLATFORM != CC_PLATFORM_ANDROID)
#include <ftw.h>
#endif

namespace
{
#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;
    else
        return true;
#else
    std::string command = "rm -r ";
    // Path may include space.
    command += "\"" + path + "\"";
    if (system(command.c_str()) >= 0)
        return true;
    else
        return false;
#endif // (CC_TARGET_PLATFORM != CC_PLATFORM_ANDROID)

#else
    return 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值

再运行,终于运行成功

相关推荐
二流小码农1 小时前
鸿蒙开发:自定义一个圆形动画菜单
android·ios·harmonyos
淘气淘的宝宝1 小时前
MAC intel 迁移至M4后brew及iterm2配置
macos
不爱吃糖的程序媛2 小时前
解决鸿蒙PC命令行编译 macOS 上 cp 命令参数冲突问题
macos·harmonyos·策略模式
00后程序员张2 小时前
fastlane 结合 appuploader 命令行实现跨平台上传发布 iOS App
android·ios·小程序·https·uni-app·iphone·webview
Bruce_Liuxiaowei2 小时前
Mac_Linux 查询网站IP地址:4个核心命令详解
linux·tcp/ip·macos
2501_915106322 小时前
iOS 性能优化这件事,结合多工具分析运行期性能问题
android·ios·性能优化·小程序·uni-app·cocoa·iphone
游戏开发爱好者82 小时前
App Store 上架流程,结合多工具协作
android·ios·小程序·https·uni-app·iphone·webview
逐梦苍穹2 小时前
ClamAV在macOS上的离线查杀与定时扫描实战(含clamd加速)
人工智能·安全·macos·策略模式·杀毒
2501_915921434 小时前
uni-app 的 iOS 打包与上架流程,多工具协作
android·ios·小程序·uni-app·cocoa·iphone·webview
胖虎114 小时前
SwiftUI 页面作为一级页面数据被重置问题分析
ios·swiftui·swift·state·observedobject·stateobject·swiftui页面生命周期