CocosCreater 3.8.6如何嵌入到iOS原生项目

CocosCreater 3.8.6如何嵌入到iOS原生项目

同求 有消息 分享下

在启动退出流程上,3.x 比 2.x 已经好太多了,没有太多需要自己处理的全局对象,大多都会随着占用的内存一起释放,不需要自己做太多修改。
有一点不好的是,默认 build 出来的工程里面全部都是绝对路径,对于多人协作/ci等极度不友好。官方的方案是要么就不要把这些东西用 git 管理,所有人本地都装上 cocos creator 从头 build,要么就把这些从根目录开始所有人放在一个统一的位置上以避免绝对路径产生问题,比如 /work/project/xxxxx。
如果你本来就有一个 iOS 项目,只是要把 cocos 集成进去作为一个子功能模块,这种就是最麻烦的情况了。我现在的做法是把整个 cocos 做成一个 pod,对外分发 xcframework,这样至少现有的 iOS 项目不怎么需要关心这些集成问题了。

大佬 能加个qq 请教下不,

大佬,能具体请教下吗,把cocos集成变成子模块,这个要怎么操作呢

比如,把 cocos 整个编译成一个 xcframework 在原生 app 中使用
这可能需要你在 cocos 引擎源码外围自己做对应的封装,尤其如果你不想在 app 中直接使用 cocos 的 C++ 代码的话。

https://minihost.tuanjie.cn/help/docs/welcome

因为是flutter要在app内启动游戏,不知道怎么把这个引擎整成一个插件,让他直接调用

参考 https://juejin.cn/post/7333066398174806053

我按照这个文档生成了引擎.a,但是创建中间桥接框架时报错了。
In file included from /Users/shangdong/Downloads/xx_cocos_engine-master/build/CocosBridge/CocosBridge.mm:9:
In file included from …/cocos/platform/ios/IOSPlatform.h:27:
In file included from /Users/shangdong/Downloads/xx_cocos_engine-master/cocos/platform/UniversalPlatform.h:27:
In file included from /Users/shangdong/Downloads/xx_cocos_engine-master/cocos/platform/BasePlatform.h:27:
/Users/shangdong/Downloads/xx_cocos_engine-master/cocos/base/Log.h:47:7: error: variable has incomplete type ‘class __declspec’
47 | class CC_DLL Log {
| ^
In file included from /Users/shangdong/Downloads/xx_cocos_engine-master/build/CocosBridge/CocosBridge.mm:9:
In file included from …/cocos/platform/ios/IOSPlatform.h:27:
In file included from /Users/shangdong/Downloads/xx_cocos_engine-master/cocos/platform/UniversalPlatform.h:27:
In file included from /Users/shangdong/Downloads/xx_cocos_engine-master/cocos/platform/BasePlatform.h:27:
In file included from /Users/shangdong/Downloads/xx_cocos_engine-master/cocos/base/Log.h:27:
/Users/shangdong/Downloads/xx_cocos_engine-master/cocos/base/Macros.h:42:39: note: expanded from macro ‘CC_DLL’
42 | #define CC_DLL __declspec(dllimport)
| ^
In file included from /Users/shangdong/Downloads/xx_cocos_engine-master/build/CocosBridge/CocosBridge.mm:9:
In file included from …/cocos/platform/ios/IOSPlatform.h:27:
In file included from /Users/shangdong/Downloads/xx_cocos_engine-master/cocos/platform/UniversalPlatform.h:27:
In file included from /Users/shangdong/Downloads/xx_cocos_engine-master/cocos/platform/BasePlatform.h:27:
/Users/shangdong/Downloads/xx_cocos_engine-master/cocos/base/Log.h:47:7: note: forward declaration of ‘cc::__declspec’
In file included from /Users/shangdong/Downloads/xx_cocos_engine-master/build/CocosBridge/CocosBridge.mm:9:
In file included from …/cocos/platform/ios/IOSPlatform.h:27:
In file included from /Users/shangdong/Downloads/xx_cocos_engine-master/cocos/platform/UniversalPlatform.h:27:
In file included from /Users/shangdong/Downloads/xx_cocos_engine-master/cocos/platform/BasePlatform.h:27:
In file included from /Users/shangdong/Downloads/xx_cocos_engine-master/cocos/base/Log.h:27:
/Users/shangdong/Downloads/xx_cocos_engine-master/cocos/base/Macros.h:42:28: note: expanded from macro ‘CC_DLL’
42 | #define CC_DLL __declspec(dllimport)
| ^
In file included from /Users/shangdong/Downloads/xx_cocos_engine-master/build/CocosBridge/CocosBridge.mm:9:
In file included from …/cocos/platform/ios/IOSPlatform.h:27:
In file included from /Users/shangdong/Downloads/xx_cocos_engine-master/cocos/platform/UniversalPlatform.h:27:
In file included from /Users/shangdong/Downloads/xx_cocos_engine-master/cocos/platform/BasePlatform.h:27:
/Users/shangdong/Downloads/xx_cocos_engine-master/cocos/base/Log.h:47:13: error: expected ‘;’ after top level declarator
47 | class CC_DLL Log {
| ^
| ;
In file included from /Users/shangdong/Downloads/xx_cocos_engine-master/build/CocosBridge/CocosBridge.mm:9:
In file included from …/cocos/platform/ios/IOSPlatform.h:27:
In file included from /Users/shangdong/Downloads/xx_cocos_engine-master/cocos/platform/UniversalPlatform.h:27:
In file included from /Users/shangdong/Downloads/xx_cocos_engine-master/cocos/platform/BasePlatform.h:30:
In file included from /Users/shangdong/Downloads/xx_cocos_engine-master/cocos/engine/EngineEvents.h:30:
/Users/shangdong/Downloads/xx_cocos_engine-master/cocos/core/event/EventBus.h:166:13: error: no member named ‘Log’ in namespace ‘cc’
166 | CC_LOG_DEBUG(“EventBus[%s] has no listener found!”, BUS_NAME);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /Users/shangdong/Downloads/xx_cocos_engine-master/build/CocosBridge/CocosBridge.mm:9:
In file included from …/cocos/platform/ios/IOSPlatform.h:27:
In file included from /Users/shangdong/Downloads/xx_cocos_engine-master/cocos/platform/UniversalPlatform.h:27:
In file included from /Users/shangdong/Downloads/xx_cocos_engine-master/cocos/platform/BasePlatform.h:27:
/Users/shangdong/Downloads/xx_cocos_engine-master/cocos/base/Log.h:65:13: note: expanded from macro ‘CC_LOG_DEBUG’
65 | if (cc::Log::slogLevel >= cc::LogLevel::LEVEL_DEBUG) cc::Log::logMessage(cc::LogType::KERNEL, cc::LogLevel::LEVEL_DEBUG, formats, ##VA_ARGS)
| ^
In file included from /Users/shangdong/Downloads/xx_cocos_engine-master/build/CocosBridge/CocosBridge.mm:9:
In file included from …/cocos/platform/ios/IOSPlatform.h:27:
In file included from /Users/shangdong/Downloads/xx_cocos_engine-master/cocos/platform/UniversalPlatform.h:27:
In file included from /Users/shangdong/Downloads/xx_cocos_engine-master/cocos/platform/BasePlatform.h:30:
In file included from /Users/shangdong/Downloads/xx_cocos_engine-master/cocos/engine/EngineEvents.h:30:
/Users/shangdong/Downloads/xx_cocos_engine-master/cocos/core/event/EventBus.h:166:13: error: no member named ‘Log’ in namespace ‘cc’
166 | CC_LOG_DEBUG(“EventBus[%s] has no listener found!”, BUS_NAME);
| ^
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /Users/shangdong/Downloads/xx_cocos_engine-master/build/CocosBridge/CocosBridge.mm:9:
In file included from …/cocos/platform/ios/IOSPlatform.h:27:
In file included from /Users/shangdong/Downloads/xx_cocos_engine-master/cocos/platform/UniversalPlatform.h:27:
In file included from /Users/shangdong/Downloads/xx_cocos_engine-master/cocos/platform/BasePlatform.h:27:
/Users/shangdong/Downloads/xx_cocos_engine-master/cocos/base/Log.h:65:62: note: expanded from macro ‘CC_LOG_DEBUG’
65 | if (cc::Log::slogLevel >= cc::LogLevel::LEVEL_DEBUG) cc::Log::logMessage(cc::LogType::KERNEL, cc::LogLevel::LEVEL_DEBUG, formats, ##VA_ARGS)
| ^
In file included from /Users/shangdong/Downloads/xx_cocos_engine-master/build/CocosBridge/CocosBridge.mm:9:
In file included from …/cocos/platform/ios/IOSPlatform.h:27:
In file included from /Users/shangdong/Downloads/xx_cocos_engine-master/cocos/platform/UniversalPlatform.h:27:
In file included from /Users/shangdong/Downloads/xx_cocos_engine-master/cocos/platform/BasePlatform.h:31:
In file included from /Users/shangdong/Downloads/xx_cocos_engine-master/cocos/platform/interfaces/modules/ISystem.h:27:
/Users/shangdong/Downloads/xx_cocos_engine-master/cocos/platform/interfaces/OSInterface.h:33:7: error: redefinition of ‘dllimport’
33 | class CC_DLL OSInterface {
| ^
In file included from /Users/shangdong/Downloads/xx_cocos_engine-master/build/CocosBridge/CocosBridge.mm:9:
In file included from …/cocos/platform/ios/IOSPlatform.h:27:
In file included from /Users/shangdong/Downloads/xx_cocos_engine-master/cocos/platform/UniversalPlatform.h:27:
In file included from /Users/shangdong/Downloads/xx_cocos_engine-master/cocos/platform/BasePlatform.h:27:
In file included from /Users/shangdong/Downloads/xx_cocos_engine-master/cocos/base/Log.h:27:
/Users/shangdong/Downloads/xx_cocos_engine-master/cocos/base/Macros.h:42:39: note: expanded from macro ‘CC_DLL’
42 | #define CC_DLL __declspec(dllimport)
| ^
In file included from /Users/shangdong/Downloads/xx_cocos_engine-master/build/CocosBridge/CocosBridge.mm:9:
In file included from …/cocos/platform/ios/IOSPlatform.h:27:
In file included from /Users/shangdong/Downloads/xx_cocos_engine-master/cocos/platform/UniversalPlatform.h:27:
In file included from /Users/shangdong/Downloads/xx_cocos_engine-master/cocos/platform/BasePlatform.h:27:
/Users/shangdong/Downloads/xx_cocos_engine-master/cocos/base/Log.h:47:7: note: previous definition is here
47 | class CC_DLL Log {
| ^
In file included from /Users/shangdong/Downloads/xx_cocos_engine-master/build/CocosBridge/CocosBridge.mm:9:
In file included from …/cocos/platform/ios/IOSPlatform.h:27:
In file included from /Users/shangdong/Downloads/xx_cocos_engine-master/cocos/platform/UniversalPlatform.h:27:
In file included from /Users/shangdong/Downloads/xx_cocos_engine-master/cocos/platform/BasePlatform.h:27:
In file included from /Users/shangdong/Downloads/xx_cocos_engine-master/cocos/base/Log.h:27:
/Users/shangdong/Downloads/xx_cocos_engine-master/cocos/base/Macros.h:42:39: note: expanded from macro ‘CC_DLL’
42 | #define CC_DLL __declspec(dllimport)
| ^
In file included from /Users/shangdong/Downloads/xx_cocos_engine-master/build/CocosBridge/CocosBridge.mm:9:
In file included from …/cocos/platform/ios/IOSPlatform.h:27:
In file included from /Users/shangdong/Downloads/xx_cocos_engine-master/cocos/platform/UniversalPlatform.h:27:
In file included from /Users/shangdong/Downloads/xx_cocos_engine-master/cocos/platform/BasePlatform.h:31:
In file included from /Users/shangdong/Downloads/xx_cocos_engine-master/cocos/platform/interfaces/modules/ISystem.h:27:
/Users/shangdong/Downloads/xx_cocos_engine-master/cocos/platform/interfaces/OSInterface.h:33:13: error: expected ‘;’ after top level declarator
33 | class CC_DLL OSInterface {
| ^
| ;
In file included from /Users/shangdong/Downloads/xx_cocos_engine-master/build/CocosBridge/CocosBridge.mm:9:
In file included from …/cocos/platform/ios/IOSPlatform.h:27:
In file included from /Users/shangdong/Downloads/xx_cocos_engine-master/cocos/platform/UniversalPlatform.h:27:
In file included from /Users/shangdong/Downloads/xx_cocos_engine-master/cocos/platform/BasePlatform.h:31:
/Users/shangdong/Downloads/xx_cocos_engine-master/cocos/platform/interfaces/modules/ISystem.h:33:7: error: redefinition of ‘dllimport’
33 | class CC_DLL ISystem : public OSInterface {
| ^
In file included from /Users/shangdong/Downloads/xx_cocos_engine-master/build/CocosBridge/CocosBridge.mm:9:
In file included from …/cocos/platform/ios/IOSPlatform.h:27:
In file included from /Users/shangdong/Downloads/xx_cocos_engine-master/cocos/platform/UniversalPlatform.h:27:
In file included from /Users/shangdong/Downloads/xx_cocos_engine-master/cocos/platform/BasePlatform.h:27:
In file included from /Users/shangdong/Downloads/xx_cocos_engine-master/cocos/base/Log.h:27:
/Users/shangdong/Downloads/xx_cocos_engine-master/cocos/base/Macros.h:42:39: note: expanded from macro ‘CC_DLL’
42 | #define CC_DLL __declspec(dllimport)
| ^
In file included from /Users/shangdong/Downloads/xx_cocos_engine-master/build/CocosBridge/CocosBridge.mm:9:
In file included from …/cocos/platform/ios/IOSPlatform.h:27:
In file included from /Users/shangdong/Downloads/xx_cocos_engine-master/cocos/platform/UniversalPlatform.h:27:
In file included from /Users/shangdong/Downloads/xx_cocos_engine-master/cocos/platform/BasePlatform.h:31:
In file included from /Users/shangdong/Downloads/xx_cocos_engine-master/cocos/platform/interfaces/modules/ISystem.h:27:
/Users/shangdong/Downloads/xx_cocos_engine-master/cocos/platform/interfaces/OSInterface.h:33:7: note: previous definition is here
33 | class CC_DLL OSInterface {
| ^
In file included from /Users/shangdong/Downloads/xx_cocos_engine-master/build/CocosBridge/CocosBridge.mm:9:
In file included from …/cocos/platform/ios/IOSPlatform.h:27:
In file included from /Users/shangdong/Downloads/xx_cocos_engine-master/cocos/platform/UniversalPlatform.h:27:
In file included from /Users/shangdong/Downloads/xx_cocos_engine-master/cocos/platform/BasePlatform.h:27:
In file included from /Users/shangdong/Downloads/xx_cocos_engine-master/cocos/base/Log.h:27:
/Users/shangdong/Downloads/xx_cocos_engine-master/cocos/base/Macros.h:42:39: note: expanded from macro ‘CC_DLL’
42 | #define CC_DLL __declspec(dllimport)
| ^
In file included from /Users/shangdong/Downloads/xx_cocos_engine-master/build/CocosBridge/CocosBridge.mm:9:
In file included from …/cocos/platform/ios/IOSPlatform.h:27:
In file included from /Users/shangdong/Downloads/xx_cocos_engine-master/cocos/platform/UniversalPlatform.h:27:
In file included from /Users/shangdong/Downloads/xx_cocos_engine-master/cocos/platform/BasePlatform.h:31:
/Users/shangdong/Downloads/xx_cocos_engine-master/cocos/platform/interfaces/modules/ISystem.h:33:13: error: expected ‘;’ after top level declarator
33 | class CC_DLL ISystem : public OSInterface {
| ^
| ;
In file included from /Users/shangdong/Downloads/xx_cocos_engine-master/build/CocosBridge/CocosBridge.mm:9:
In file included from …/cocos/platform/ios/IOSPlatform.h:27:
In file included from /Users/shangdong/Downloads/xx_cocos_engine-master/cocos/platform/UniversalPlatform.h:27:
/Users/shangdong/Downloads/xx_cocos_engine-master/cocos/platform/BasePlatform.h:42:7: error: redefinition of ‘dllimport’
42 | class CC_DLL BasePlatform {
| ^
In file included from /Users/shangdong/Downloads/xx_cocos_engine-master/build/CocosBridge/CocosBridge.mm:9:
In file included from …/cocos/platform/ios/IOSPlatform.h:27:
In file included from /Users/shangdong/Downloads/xx_cocos_engine-master/cocos/platform/UniversalPlatform.h:27:
In file included from /Users/shangdong/Downloads/xx_cocos_engine-master/cocos/platform/BasePlatform.h:27:
In file included from /Users/shangdong/Downloads/xx_cocos_engine-master/cocos/base/Log.h:27:
/Users/shangdong/Downloads/xx_cocos_engine-master/cocos/base/Macros.h:42:39: note: expanded from macro ‘CC_DLL’
42 | #define CC_DLL __declspec(dllimport)
| ^
In file included from /Users/shangdong/Downloads/xx_cocos_engine-master/build/CocosBridge/CocosBridge.mm:9:
In file included from …/cocos/platform/ios/IOSPlatform.h:27:
In file included from /Users/shangdong/Downloads/xx_cocos_engine-master/cocos/platform/UniversalPlatform.h:27:
In file included from /Users/shangdong/Downloads/xx_cocos_engine-master/cocos/platform/BasePlatform.h:31:
In file included from /Users/shangdong/Downloads/xx_cocos_engine-master/cocos/platform/interfaces/modules/ISystem.h:27:
/Users/shangdong/Downloads/xx_cocos_engine-master/cocos/platform/interfaces/OSInterface.h:33:7: note: previous definition is here
33 | class CC_DLL OSInterface {
| ^
In file included from /Users/shangdong/Downloads/xx_cocos_engine-master/build/CocosBridge/CocosBridge.mm:9:
In file included from …/cocos/platform/ios/IOSPlatform.h:27:
In file included from /Users/shangdong/Downloads/xx_cocos_engine-master/cocos/platform/UniversalPlatform.h:27:
In file included from /Users/shangdong/Downloads/xx_cocos_engine-master/cocos/platform/BasePlatform.h:27:
In file included from /Users/shangdong/Downloads/xx_cocos_engine-master/cocos/base/Log.h:27:
/Users/shangdong/Downloads/xx_cocos_engine-master/cocos/base/Macros.h:42:39: note: expanded from macro ‘CC_DLL’
42 | #define CC_DLL __declspec(dllimport)
| ^
In file included from /Users/shangdong/Downloads/xx_cocos_engine-master/build/CocosBridge/CocosBridge.mm:9:
In file included from …/cocos/platform/ios/IOSPlatform.h:27:
In file included from /Users/shangdong/Downloads/xx_cocos_engine-master/cocos/platform/UniversalPlatform.h:27:
/Users/shangdong/Downloads/xx_cocos_engine-master/cocos/platform/BasePlatform.h:42:13: error: expected ‘;’ after top level declarator
42 | class CC_DLL BasePlatform {
| ^
| ;
In file included from /Users/shangdong/Downloads/xx_cocos_engine-master/build/CocosBridge/CocosBridge.mm:9:
In file included from …/cocos/platform/ios/IOSPlatform.h:27:
/Users/shangdong/Downloads/xx_cocos_engine-master/cocos/platform/UniversalPlatform.h:30:7: error: redefinition of ‘dllimport’
30 | class CC_DLL UniversalPlatform : public BasePlatform {
| ^
In file included from /Users/shangdong/Downloads/xx_cocos_engine-master/build/CocosBridge/CocosBridge.mm:9:
In file included from …/cocos/platform/ios/IOSPlatform.h:27:
In file included from /Users/shangdong/Downloads/xx_cocos_engine-master/cocos/platform/UniversalPlatform.h:27:
In file included from /Users/shangdong/Downloads/xx_cocos_engine-master/cocos/platform/BasePlatform.h:27:
In file included from /Users/shangdong/Downloads/xx_cocos_engine-master/cocos/base/Log.h:27:
/Users/shangdong/Downloads/xx_cocos_engine-master/cocos/base/Macros.h:42:39: note: expanded from macro ‘CC_DLL’
42 | #define CC_DLL __declspec(dllimport)
| ^
In file included from /Users/shangdong/Downloads/xx_cocos_engine-master/build/CocosBridge/CocosBridge.mm:9:
In file included from …/cocos/platform/ios/IOSPlatform.h:27:
In file included from /Users/shangdong/Downloads/xx_cocos_engine-master/cocos/platform/UniversalPlatform.h:27:
In file included from /Users/shangdong/Downloads/xx_cocos_engine-master/cocos/platform/BasePlatform.h:31:
In file included from /Users/shangdong/Downloads/xx_cocos_engine-master/cocos/platform/interfaces/modules/ISystem.h:27:
/Users/shangdong/Downloads/xx_cocos_engine-master/cocos/platform/interfaces/OSInterface.h:33:7: note: previous definition is here
33 | class CC_DLL OSInterface {
| ^
In file included from /Users/shangdong/Downloads/xx_cocos_engine-master/build/CocosBridge/CocosBridge.mm:9:
In file included from …/cocos/platform/ios/IOSPlatform.h:27:
In file included from /Users/shangdong/Downloads/xx_cocos_engine-master/cocos/platform/UniversalPlatform.h:27:
In file included from /Users/shangdong/Downloads/xx_cocos_engine-master/cocos/platform/BasePlatform.h:27:
In file included from /Users/shangdong/Downloads/xx_cocos_engine-master/cocos/base/Log.h:27:
/Users/shangdong/Downloads/xx_cocos_engine-master/cocos/base/Macros.h:42:39: note: expanded from macro ‘CC_DLL’
42 | #define CC_DLL __declspec(dllimport)
| ^
In file included from /Users/shangdong/Downloads/xx_cocos_engine-master/build/CocosBridge/CocosBridge.mm:9:
In file included from …/cocos/platform/ios/IOSPlatform.h:27:
/Users/shangdong/Downloads/xx_cocos_engine-master/cocos/platform/UniversalPlatform.h:30:13: error: expected ‘;’ after top level declarator
30 | class CC_DLL UniversalPlatform : public BasePlatform {
| ^
| ;
In file included from /Users/shangdong/Downloads/xx_cocos_engine-master/build/CocosBridge/CocosBridge.mm:9:
…/cocos/platform/ios/IOSPlatform.h:31:28: error: expected class name
31 | class IOSPlatform : public UniversalPlatform {
| ^
…/cocos/platform/ios/IOSPlatform.h:37:20: error: only virtual member functions can be marked ‘override’
37 | ~IOSPlatform() override;
| ^
~~~
…/cocos/platform/ios/IOSPlatform.h:41:20: error: only virtual member functions can be marked ‘override’
41 | int32_t init() override;
| ^~~~~~~~
…/cocos/platform/ios/IOSPlatform.h:46:46: error: only virtual member functions can be marked ‘override’
46 | int32_t run(int argc, const char **argv) override;
| ^~~~~~~~
…/cocos/platform/ios/IOSPlatform.h:50:20: error: only virtual member functions can be marked ‘override’
50 | int32_t loop() override;
| ^~~~~~~~
…/cocos/platform/ios/IOSPlatform.h:51:30: error: only virtual member functions can be marked ‘override’
51 | void setFps(int32_t fps) override;
| ^~~~~~~~
…/cocos/platform/ios/IOSPlatform.h:53:28: error: only virtual member functions can be marked ‘override’
53 | int32_t getFps() const override;
| ^~~~~~~~
fatal error: too many errors emitted, stopping now [-ferror-limit=]
20 errors generated.

下面是bridge文件
#import “CocosBridge.h”
#include “cocos/platform/ios/IOSPlatform.h”
#import “cocos/platform/ios/AppDelegateBridge.h”
#include “cocos/platform/ios/View.h”
#import “SDKWrapper.h”

@interface CocosBridge()

@property(nonatomic, readonly) AppDelegateBridge *appDelegateBridge;

@end
@implementation CocosBridge
@synthesize appDelegateBridge;
+(CocosBridge *)shared{
static id sharedInstance = nil;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
sharedInstance = [[self alloc] init];
});
return sharedInstance;
}

  • (void)initPlatform{
    cc::BasePlatform* platform = cc::BasePlatform::getPlatform();
    if (platform->init()) {
    return;
    }
    }

  • (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions{

}

  • (void)viewWillTransitionToSize:(CGSize)size withTransitionCoordinator:(id)coordinator{
    AppDelegate* delegate = [[UIApplication sharedApplication] delegate];
    [appDelegateBridge viewWillTransitionToSize:size withTransitionCoordinator:coordinator];
    float pixelRatio = [delegate.appDelegateBridge getPixelRatio];

    //CAMetalLayer is available on ios8.0, ios-simulator13.0.
    CAMetalLayer *layer = (CAMetalLayer *)self.view.layer;
    CGSize tsize = CGSizeMake(static_cast(size.width * pixelRatio),
    static_cast(size.height * pixelRatio));
    layer.drawableSize = tsize;
    }

  • (void)applicationWillResignActive:(UIApplication *)application {
    [[SDKWrapper shared] applicationWillResignActive:application];
    [appDelegateBridge applicationWillResignActive:application];
    }

  • (void)applicationDidBecomeActive:(UIApplication *)application {
    [[SDKWrapper shared] applicationDidBecomeActive:application];
    [appDelegateBridge applicationDidBecomeActive:application];
    }

  • (void)applicationDidEnterBackground:(UIApplication *)application {
    [[SDKWrapper shared] applicationDidEnterBackground:application];
    }

  • (void)applicationWillEnterForeground:(UIApplication *)application {
    [[SDKWrapper shared] applicationWillEnterForeground:application];
    }

  • (void)applicationWillTerminate:(UIApplication *)application {
    [[SDKWrapper shared] applicationWillTerminate:application];
    [appDelegateBridge applicationWillTerminate:application];
    }

#pragma mark -
#pragma mark Memory management

  • (void)applicationDidReceiveMemoryWarning:(UIApplication *)application {
    [[SDKWrapper shared] applicationDidReceiveMemoryWarning:application];
    }

  • (View *)getCocosView{
    CGRect bounds = [[UIScreen mainScreen] bounds];
    return [[View alloc] initWithFrame:bounds];
    }

  • (void)startGame{
    if(!appDelegateBridge){
    appDelegateBridge = [[AppDelegateBridge alloc] init];
    }
    [[SDKWrapper shared] application:[UIApplication sharedApplication] didFinishLaunchingWithOptions:nil];
    [appDelegateBridge application:[UIApplication sharedApplication] didFinishLaunchingWithOptions:nil];
    cc::IOSPlatform *platform = dynamic_cast<cc::IOSPlatform *>(cc::BasePlatform::getPlatform());
    platform->onResume();
    }

  • (void)stopGame{
    cc::IOSPlatform *platform = dynamic_cast<cc::IOSPlatform *>(cc::BasePlatform::getPlatform());
    platform->onPause();
    }

@end

如果你遇到这个问题而不知道为什么和怎么解决的话,那么你在集成的过程中会遇到非常多困难
你应该去问ai和google而不是我,同时在这个过程中去学习和理解这些问题的原因,然后它才能帮你解决遇到的这许多问题