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

再运行,终于运行成功

相关推荐
往来凡尘9 小时前
Flutter运行iOS26真机的两个问题
flutter·ios
普通网友10 小时前
Objective-C 类的方法重载与重写:区别与正确使用场景
开发语言·ios·objective-c
denggun1234512 小时前
卡顿监测原理
macos·ios·xcode
@大迁世界15 小时前
iOS 26.2 引入三种全新 iPhone 自定义方式
ios·iphone
Sheffi6616 小时前
iOS 触摸事件完整传递链路:Hit-Test 全流程深度解析
macos·ios·cocoa
Swift社区17 小时前
用 Task Local Values 构建 Swift 里的依赖容器:一种更轻量的依赖注入思路
开发语言·ios·swift
2501_9159090617 小时前
苹果应用加密方案的一种方法,在没有源码的前提下,如何处理 IPA 的安全问题
android·安全·ios·小程序·uni-app·iphone·webview
TouchWorld17 小时前
iOS逆向-哔哩哔哩增加3倍速播放(4)- 竖屏视频·全屏播放场景
ios·swift
2501_9159090617 小时前
iOS 项目中常被忽略的 Bundle ID 管理问题
android·ios·小程序·https·uni-app·iphone·webview