为什么“CCTextureCache + CCBigImageExtensions”在我的Kobold2D项目中没有链接? [英] Why "CCTextureCache+CCBigImageExtensions" isn't linked in my Kobold2D project?

查看:195
本文介绍了为什么“CCTextureCache + CCBigImageExtensions”在我的Kobold2D项目中没有链接?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在iOS / Kobold2d项目中使用CCBigImage,因为sprite太大了,无法立刻加载。不幸的是,当执行应用程序时,它停止

 错误:未捕获异常 -  [CCTextureCache 
addImageFromAnotherThreadWithName:target:selector:] :当将plist文件加载到CCBigImage时,无法识别的
选择器发送到实例0xa17d010



<我将其固定到了

  CCBigImage * bg = [CCBigImage nodeWithTilesFile:@bg1dot5.plisttilesExtension:@ pvr.ccztilesZ:0] 

调用CCBigImage load此方法调用

  [CCTextureCache sharedTextureCache] addImageFromAnotherThreadWithName:_imageName 
target:self
selector:@selector loadedTexture :)

最终导致指定的异常。我导入CCTextureCache + CCBigImageExtensions.h到加载CCBigImage的源文件,所以我预计给定的选择器将被添加到CCTextureCache,但显然不是。



我使用Kobold2d 1.1.0和XCode 4.3.3(所有最新版本)。是否需要做其他事情才能包含该选择器?



我也叫

  [[CCTextureCache sharedTextureCache] addImageFromAnotherThreadWithName:@target:nil selector:nil];直接

,项目编译正常,因为我包括扩展头文件,但同样的异常发生时,加载CCBigImage。

解决方案

包含Objective-C类别的静态库必须与iOS应用程序强制链接有这个问题)否则类方法不能解决,你得到你描述的错误。 更多信息



不建议使用-all_load标志,特别是在Kobold2D中。这将盲目地链接所有可用的代码到应用程序,甚至是你没有在你的应用程序中使用的代码。它基本上使链接器盲目和愚蠢,应用程序的大小可能增加几兆字节。



我将添加cocos2d扩展的力链接在未来的Kobold2D版本。现在修复是在BuildSettings组中的Kobold2D-Libraries项目的Xcode中编辑 FrameworksAndLibraries.xcconfig 文件。



找到强制加载框架/库的部分:

  LINK_WITH_ADMOB = $(KKLIBROOT)/ GoogleAdMobAdsSDK / libGoogleAdMobAds .a 
FORCE_LOAD_COCOS2D = -force_load$(BUILT_PRODUCTS_DIR)/libcocos2d-ios.a
FORCE_LOAD_KOBOLD2D = -force_load$(BUILT_PRODUCTS_DIR)/libkobold2d-ios.a
FORCE_LOAD_KOBOLDSCRIPT = -force_load $(BUILT_PRODUCTS_DIR)/libkoboldscript-ios.a
FORCE_LOAD_KOBOLDSCRIPTWRAPPER = -force_load$(BUILT_PRODUCTS_DIR)/libkoboldscriptwrapper-ios.a
FORCE_LOAD_ISIMULATE = -force_load$(KKLIBROOT)/ iSimulateSDK / libisimulate- 4.x-opengl.a
FORCE_LOAD_COCOS3D = -force_load$(BUILT_PRODUCTS_DIR)/libcocos3d-ios.a

KKFW_IOS = $(KKFW_SYSConfig)$(KKFW_AVFoundation)$(KKFW_CoreGraphics) $(KKFW_CoreLocation)$(KKFW_MOOPENGLES)$(LINK_WITH_ADMOB)$(FORCE_LOAD_KOBOLD2D)$(FORCE_LOAD_KOBOLDSCRIPT)$(FORCE_LOAD_KOBOLDSCRIPTWRAPPER)$(FORCE_LOAD_COCOS2D)

现在在KKFW_IOS = ...行之前添加另一个FORCE_LOAD_ ...条目到-force_load cocos2d-extensions库(这一切都在一行,我只是添加了换行符以增加可读性) :

  FORCE_LOAD_COCOS2D_EXTENSIONS = 
-force_load$(BUILT_PRODUCTS_DIR)/libcocos2d-extensions-ios.a

然后将此新的FORCE_LOAD_COCOS2D_EXTENSIONS条目附加到KKFW_IOS = ...行末尾(为了便于阅读) / p>

  KKFW_IOS = $(KKFW_SysConfig)... $(FORCE_LOAD_COCOS2D_EXTENSIONS)

这应该可以解决这个问题,你现在应该可以使用CCBigImage类别方法。


I am using CCBigImage in an iOS/Kobold2d project as the sprite would be too big to be loaded at once. Unfortunately when executing the application it stops with

ERROR: Uncaught exception -[CCTextureCache
addImageFromAnotherThreadWithName:target:selector:]: unrecognized
selector sent to instance 0xa17d010

when loading the plist file into CCBigImage. I nailed it down to the point that

CCBigImage* bg = [CCBigImage nodeWithTilesFile:@"bg1dot5.plist" tilesExtension: @"pvr.ccz" tilesZ: 0]

calls CCBigImage load(). This method calls

[CCTextureCache sharedTextureCache] addImageFromAnotherThreadWithName: _imageName
                                                               target: self
                                                             selector: @selector(loadedTexture:)

that finally leads to the specified exception. I imported "CCTextureCache+CCBigImageExtensions.h" into the source file that loads the CCBigImage so I expected the given selector to be added to CCTextureCache but obviously it is not.

I am using Kobold2d 1.1.0 and XCode 4.3.3 (so all latest versions). Is there something else I need to do in order to have that selector being included?

I also called

[[CCTextureCache sharedTextureCache] addImageFromAnotherThreadWithName:@"" target:nil selector:nil];

directly, the project compiles fine as I included the extension header file but the same exception occures as when I load a CCBigImage.

解决方案

Static libraries containing Objective-C categories must be force-linked with iOS apps (Mac apps don't have this problem) otherwise the category methods can not be resolved and you get the error you described. More info here.

It is not recommended to use the -all_load flag, particularly in Kobold2D. This would blindly link all available code to the app, even the code you're not using in your app. It basically makes the linker blind and stupid and the app size grows possibly by several megabytes.

I will add the force-link of the cocos2d extensions in future Kobold2D versions. For now the fix is to edit the FrameworksAndLibraries.xcconfig file, in Xcode in the Kobold2D-Libraries project in the BuildSettings group.

Locate the section where frameworks/libraries are force-loaded:

LINK_WITH_ADMOB = $(KKLIBROOT)/GoogleAdMobAdsSDK/libGoogleAdMobAds.a
FORCE_LOAD_COCOS2D = -force_load "$(BUILT_PRODUCTS_DIR)/libcocos2d-ios.a"
FORCE_LOAD_KOBOLD2D = -force_load "$(BUILT_PRODUCTS_DIR)/libkobold2d-ios.a"
FORCE_LOAD_KOBOLDSCRIPT = -force_load "$(BUILT_PRODUCTS_DIR)/libkoboldscript-ios.a"
FORCE_LOAD_KOBOLDSCRIPTWRAPPER = -force_load "$(BUILT_PRODUCTS_DIR)/libkoboldscriptwrapper-ios.a"
FORCE_LOAD_ISIMULATE = -force_load "$(KKLIBROOT)/iSimulateSDK/libisimulate-4.x-opengl.a"
FORCE_LOAD_COCOS3D = -force_load "$(BUILT_PRODUCTS_DIR)/libcocos3d-ios.a"

KKFW_IOS = $(KKFW_SysConfig) $(KKFW_AVFoundation) $(KKFW_CoreGraphics) $(KKFW_CoreLocation) $(KKFW_MediaPlayer) $(KKFW_OpenGLES) $(LINK_WITH_ADMOB) $(FORCE_LOAD_KOBOLD2D) $(FORCE_LOAD_KOBOLDSCRIPT) $(FORCE_LOAD_KOBOLDSCRIPTWRAPPER) $(FORCE_LOAD_COCOS2D) 

Now add another FORCE_LOAD_… entry before the "KKFW_IOS = …" line to -force_load the cocos2d-extensions library (this is all in one line, I just added the line break for readability):

FORCE_LOAD_COCOS2D_EXTENSIONS = 
           -force_load "$(BUILT_PRODUCTS_DIR)/libcocos2d-extensions-ios.a"

Then append this new FORCE_LOAD_COCOS2D_EXTENSIONS entry at the end of the "KKFW_IOS = …" line (abbreviated for readability):

KKFW_IOS = $(KKFW_SysConfig) … $(FORCE_LOAD_COCOS2D_EXTENSIONS)

This should resolve the issue and you should now be able to use the CCBigImage category methods.

这篇关于为什么“CCTextureCache + CCBigImageExtensions”在我的Kobold2D项目中没有链接?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆