如何将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值

再运行,终于运行成功

相关推荐
谈吐大方的鹏sir1 小时前
SwiftUI-TextField组件学习
ios
谈吐大方的鹏sir4 小时前
SwiftUI-Button组件学习
ios
Misnice6 小时前
Mac查看本机ip地址
网络协议·tcp/ip·macos
谈吐大方的鹏sir6 小时前
SwiftUI-Image组件学习
ios
鹏多多.7 小时前
flutter-完美解决键盘弹出遮挡输入框的问题
android·flutter·ios·前端框架
杂雾无尘9 小时前
SwiftUI 动画新技能,让你的应用「活」起来!
ios·swiftui·swift
林大鹏天地10 小时前
iOS18系统 [YYKVStorage _dbClose] 偶现崩溃
ios
林大鹏天地10 小时前
使用Xcode16打包后,App在暗夜模式下,iOS18 切换Tabbar的item,会有一根白色线条闪过。
ios
2501_9159090610 小时前
iOS 加固工具实战解析,主流平台审核机制与工具应对策略
android·ios·小程序·https·uni-app·iphone·webview
2501_9151063212 小时前
iOS WebView 调试实战,第三方脚本加载失败与内容安全策略冲突问题排查指南
android·ios·小程序·https·uni-app·iphone·webview