警告XCODELGKIT不考虑迁移到金属,而苹果电子邮件不推荐API使用,使用WKWebVIEW代替UIWebVIEW

警告XCODELGKIT不考虑迁移到金属,而苹果电子邮件不推荐API使用,使用WKWebVIEW代替UIWebVIEW,xcode,opengl,metal,glkit,buildbox,Xcode,Opengl,Metal,Glkit,Buildbox,我已经使用Buildbox2.3.3完成了我的游戏,并在Xcode上清除了尽可能多的警告。然而,我已经在这个星期,我从OpenGL迁移到金属,我认为这是我在XCODE中有错误的原因,表示GLITK被弃用,考虑迁移到金属。 我试图在未解决此错误的情况下将游戏上载到App store connect,但随后我立即收到一封电子邮件,其中说 ITMS-90809:不推荐使用API,新应用不再使用UIWebView, 改用WKWebView 我不知道如何去转换我的代码,以满足这一点,我真的很感激一些指导,

我已经使用Buildbox2.3.3完成了我的游戏,并在Xcode上清除了尽可能多的警告。然而,我已经在这个星期,我从OpenGL迁移到金属,我认为这是我在XCODE中有错误的原因,表示GLITK被弃用,考虑迁移到金属。 我试图在未解决此错误的情况下将游戏上载到App store connect,但随后我立即收到一封电子邮件,其中说

ITMS-90809:不推荐使用API,新应用不再使用UIWebView, 改用WKWebView

我不知道如何去转换我的代码,以满足这一点,我真的很感激一些指导,或者如果有人可以重写我的代码为我转换OpenGL到金属

我将在下面附上我正在使用的代码,如果有人能帮助我,我将不胜感激。我已经被困在这个最后阶段好几个星期了,这非常令人沮丧

AppDelegate.h

#import <UIKit/UIKit.h>

@interface AppDelegate : UIResponder <UIApplicationDelegate>{
}

@property (strong, nonatomic) UIWindow *window;


@end
AppDelegate.mm

#import "AppDelegate.h"
#import <GLKit/GLKit.h>
#include "PTPSettingsController.h"
#include "libs/cocos2dx/include/audio/include/SimpleAudioEngine.h"

@interface AppDelegate ()

@end

@implementation AppDelegate

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

    return YES;
}


- (void)applicationWillResignActive:(UIApplication *)application {
    cocos2d::CCDirector::sharedDirector()->pause();
}

- (void)applicationDidEnterBackground:(UIApplication *)application {
    cocos2d::CCApplication::sharedApplication()->applicationDidEnterBackground();
}

- (void)applicationWillEnterForeground:(UIApplication *)application {
    cocos2d::CCApplication::sharedApplication()->applicationWillEnterForeground();
}

- (void)applicationDidBecomeActive:(UIApplication *)application {
    cocos2d::CCDirector::sharedDirector()->resume();
}

- (void)applicationWillTerminate:(UIApplication *)application {
}

- (void)loadingDidComplete{
}

-(void)showCustomFullscreenAd{
}

- (void)screenOnEnter:(const char*) name{
}

- (void)screenOnExit:(const char*) name{
}

@end
GameViewController.h

#import <UIKit/UIKit.h>
#import <GLKit/GLKit.h>

@interface GameViewController : GLKViewController

@end
GameViewController.mm

#import "GameViewController.h"
#import <OpenGLES/ES2/glext.h>
#import "PTModelController.h"
#import "PTModelGeneralSettings.h"
#import "PTPAppDelegate.h"
#import "cocos2d.h"
#import "PTPConfig.h"
#include "PTPSettingsController.h"


#define IOS_MAX_TOUCHES_COUNT     10

static PTPAppDelegate s_sharedApplication;

@interface GameViewController () {
    NSString* shareMessage;
    bool sheduledForShareWidget;
}
@property (strong, nonatomic) EAGLContext *context;

@end

@implementation GameViewController

- (void)viewDidLoad{
    [super viewDidLoad];

    sheduledForShareWidget = false;
    self.context = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES2];

    if (!self.context) {
        NSLog(@"Failed to create ES context");
    }

    GLKView *view = (GLKView *)self.view;
    view.context = self.context;
    view.drawableDepthFormat = GLKViewDrawableDepthFormat24;
    [view setMultipleTouchEnabled: YES];

    [self setPreferredFramesPerSecond:60];
    [EAGLContext setCurrentContext:self.context];

    PTModelController *mc = PTModelController::shared();
    mc->clean();

    unsigned long size = 0;
    char* pBuffer = (char*)CCFileUtils::sharedFileUtils()->getFileData("data/data.pkg", "rb", &size);
    if (pBuffer != NULL && size > 0){
        mc->setUsingDataEncryption( true );
    }

    mc->loadDataForSplashScreen("data/data.pkg", processor().c_str());

    s_sharedApplication.setDataArchiveProcessor(processor());


    cocos2d::CCApplication::sharedApplication()->run();
}

- (void)dealloc{
    if ([EAGLContext currentContext] == self.context) {
        [EAGLContext setCurrentContext:nil];
    }
}

- (void)didReceiveMemoryWarning{
    [super didReceiveMemoryWarning];

    if ([self isViewLoaded] && ([[self view] window] == nil)) {
        self.view = nil;

        if ([EAGLContext currentContext] == self.context) {
            [EAGLContext setCurrentContext:nil];
        }
        self.context = nil;
    }

    // Dispose of any resources that can be recreated.
}

- (BOOL)prefersStatusBarHidden {
    return YES;
}

- (void)glkView:(GLKView *)view drawInRect:(CGRect)rect{
    glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

    cocos2d::CCDirector::sharedDirector()->setViewport();
    cocos2d::CCDirector::sharedDirector()->mainLoop();
}


- (void)update{
    if(sheduledForShareWidget == true){
        sheduledForShareWidget = false;

        GLKView *view  = (GLKView *)self.view;
        UIImage* screenshot = view.snapshot;

        PTLog("Opens Share Widget: screenshot was taken");

        UIActivityViewController *activityVC = [[UIActivityViewController alloc] initWithActivityItems:@[shareMessage, screenshot] applicationActivities:nil];

        NSArray *excludeActivities = @[UIActivityTypeSaveToCameraRoll,
                                       UIActivityTypeAssignToContact];
        activityVC.excludedActivityTypes = excludeActivities;


        float iOSVersion = [[UIDevice currentDevice].systemVersion floatValue];
        if(iOSVersion > 8.0){
            activityVC.popoverPresentationController.sourceView = self.view;
        }

        [self presentViewController:activityVC animated:YES completion:nil];
        PTLog("opens Share Widget: view controller presented");
    }
}

- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(nullable UIEvent *)event{
    int ids[IOS_MAX_TOUCHES_COUNT] = {0};
    float xs[IOS_MAX_TOUCHES_COUNT] = {0.0f};
    float ys[IOS_MAX_TOUCHES_COUNT] = {0.0f};

    int i = 0;
    for (UITouch *touch in touches) {
        ids[i] = (intptr_t)touch;
        xs[i] = [touch locationInView: [touch view]].x * self.view.contentScaleFactor;
        ys[i] = [touch locationInView: [touch view]].y * self.view.contentScaleFactor;
        ++i;
    }
    cocos2d::CCEGLView::sharedOpenGLView()->handleTouchesBegin(i, ids, xs, ys);
}

- (void)touchesMoved:(NSSet<UITouch *> *)touches withEvent:(nullable UIEvent *)event{
    int ids[IOS_MAX_TOUCHES_COUNT] = {0};
    float xs[IOS_MAX_TOUCHES_COUNT] = {0.0f};
    float ys[IOS_MAX_TOUCHES_COUNT] = {0.0f};

    int i = 0;
    for (UITouch *touch in touches) {
        ids[i] = (intptr_t)touch;
        xs[i] = [touch locationInView: [touch view]].x * self.view.contentScaleFactor;;
        ys[i] = [touch locationInView: [touch view]].y * self.view.contentScaleFactor;;
        ++i;
    }
    cocos2d::CCEGLView::sharedOpenGLView()->handleTouchesMove(i, ids, xs, ys);
}

- (void)touchesEnded:(NSSet<UITouch *> *)touches withEvent:(nullable UIEvent *)event{
    int ids[IOS_MAX_TOUCHES_COUNT] = {0};
    float xs[IOS_MAX_TOUCHES_COUNT] = {0.0f};
    float ys[IOS_MAX_TOUCHES_COUNT] = {0.0f};

    int i = 0;
    for (UITouch *touch in touches) {
        ids[i] = (intptr_t)touch;
        xs[i] = [touch locationInView: [touch view]].x * self.view.contentScaleFactor;;
        ys[i] = [touch locationInView: [touch view]].y * self.view.contentScaleFactor;;
        ++i;
    }
    cocos2d::CCEGLView::sharedOpenGLView()->handleTouchesEnd(i, ids, xs, ys);
}

- (void)touchesCancelled:(NSSet<UITouch *> *)touches withEvent:(nullable UIEvent *)event{
    int ids[IOS_MAX_TOUCHES_COUNT] = {0};
    float xs[IOS_MAX_TOUCHES_COUNT] = {0.0f};
    float ys[IOS_MAX_TOUCHES_COUNT] = {0.0f};

    int i = 0;
    for (UITouch *touch in touches) {
        ids[i] = (intptr_t)touch;
        xs[i] = [touch locationInView: [touch view]].x * self.view.contentScaleFactor;;
        ys[i] = [touch locationInView: [touch view]].y * self.view.contentScaleFactor;;
        ++i;
    }
    cocos2d::CCEGLView::sharedOpenGLView()->handleTouchesCancel(i, ids, xs, ys);
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    PTModelGeneralSettingsPtr generalSettings = PTModelGeneralSettings::shared();
    if(generalSettings->orientation() == PTModelGeneralSettings::LandscapeOrientation){
        return UIInterfaceOrientationIsLandscape( interfaceOrientation );
    }
    else if(generalSettings->orientation() == PTModelGeneralSettings::PortraitOrientation){
        return UIInterfaceOrientationIsPortrait( interfaceOrientation );
    }

    return NO;
}

- (NSUInteger) supportedInterfaceOrientations{
    PTModelGeneralSettingsPtr generalSettings = PTModelGeneralSettings::shared();
    if(generalSettings->orientation() == PTModelGeneralSettings::LandscapeOrientation){
        return UIInterfaceOrientationMaskLandscape;

    }
    else if(generalSettings->orientation() == PTModelGeneralSettings::PortraitOrientation){
        return UIInterfaceOrientationMaskPortrait;
    }

    return NO;
}

- (BOOL) shouldAutorotate {
    return NO;
}

-(void) scheduleOpenShareWidget:(const char*) message{
    shareMessage = [NSString stringWithUTF8String:message];
    sheduledForShareWidget = true;
}

@end

正如已经告诉您的,您的问题有点不适合堆栈溢出。您可以开始将您的项目从OpenGL重写为Metal,并在出现任何问题时提出问题

Apple文档是一个很好的起点:


您还可以观看并学习一种逐步将基于OpenGL的应用程序转换为Metal API的方法。

OpenGL是可移植的,并且受到广泛支持,因此不能使用它很遗憾。幸运的是,该框架几乎是GLKit的完美替代品。我已经开始在地图渲染库的开发分支中使用它,它工作正常:与GLKit相比,我看不出图形有什么不同,我只需对代码进行一个小的更改就可以使其正常工作,而这个更改可能是由于GLKit的使用不正确造成的


因此,我的建议是:继续使用OpenGL并使用MetalANGLE。

很抱歉,这超出了StackOverflow的范围。通过更改几行代码,将游戏从OpenGL移植到Metal是不可能的。然而,OpenGL只是被弃用了——您仍然可以使用它。您得到的错误与此无关。它似乎在代码库中的某个地方,甚至在使用UIWebView的依赖项中。这需要用WKWebView替换,然后你应该能够提交应用程序。好的,我很感谢你的回复,我认为我必须完全转换为金属才能提交给苹果,这是我的第一款游戏,所以我还是新手。所以我只需要找到UIWebView并替换它,谢谢。我上下搜索了我的代码库,但我没有UIWebView。我仍然收到苹果的电子邮件,我正在尝试从我的故事板中的GLKView迁移到WKWebView。你认为这能解决问题吗?我已经尝试过了,但是当我将视图更改为WKWebviewNo时,我的游戏似乎正在加载超过主页。不,你不能将用于将OpenGL内容呈现到WKWebview Safari的GLKView替换为GLKView。您是否检查了您的依赖项(包括cocos2d)是否包含UIWebView?是的,我检查了依赖项中没有UIWebView