getFileDataFromZip on iOS

getFileDataFromZip on iOS
0.0 0



I am attempting to use Cocos2Dx for an iPhone application, while also allowing development on windows. So far having one code base compile for both has caused very few problems, but one issue has come up which I do not know how to resolve.

While running on windows I recently started to use CCFileUtils::getFileDataFromZip which worked like a charm; however, when I go to use this function in my ios xcode project the project complains that there is no symbol defined for it for a given architecture (i386 on sim, armv6 or 7 otherwise). If I comment out that one line then it works fine. I am able to use other functions from CCFIleUitls without an issue such as for determining full paths.

I have tried for now to make a local to my application function which is IDENTICAL to the CCFileUtils one (literally copied and pasted) and the code runs and performs fine on my iOS builds. Does anyone have an idea why using the CCFileUtils::getFileDataFromZip function specifically would cause errors about having no symbols defined for a given architecture?

By the way I am using the latest (0.10) version of cocos2d-x

Thanks in advance!


Update: I went to try this in the HelloLua sample just to be sure it wasn’t my project.

Simply adding
unsigned long fileSize = 0;
unsigned char* fileData = CCFileUtils::getFileDataFromZip(“”, “file.xml”, &fileSize);

Results in the following error:

Undefined symbols for architecture i386:
“cocos2d::CCFileUtils::getFileDataFromZip(char const**, char const**, unsigned long*)”, referenced from:
AppDelegate::applicationDidFinishLaunching() in AppDelegate.o
ld: symbol(s) not found for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)

I am running Xcode 4.2 if that is of any help.


I think I found my problem… the contents of CCFileUtils.cpp are ignored for targets of IOS. I assume the is suposed to implement its functionality, but it does not implement this function (which is odd as the one in CCFileUtils.cpp will build fine for iOS if not removed due to the preprocessor macros).

Are there a lot of functions in cocos2dx which only have implementations on certain platforms? I was excited to use / learn this platform, but this discovery has me worried.


I have resolved my issue by moving the definition of this function so it is included exactly as in on iOS builds. Is there some way which I may log a bug for this? I went to the issues page but appear to only be able to view.


Thank you.
#917 is created for it.

Because all other platforms share some c++ codes and using include to have their own implementation.
But we can not do it on iOS, can not include .mm file in a .cpp file.

If you refer CCFileUtils.cpp, you will find the codes:

#include "win32/CCFileUtils_win32.cpp"

#include "wophone/CCFileUtils_wophone.cpp"

#include "android/CCFileUtils_android.cpp"

#include "marmalade/CCFileUtils_marmalade.cpp"

#include "bada/CCFileUtils_bada.cpp"

#include "qnx/CCFileUtils_qnx.cpp"


I had same problem on iOS.

I copied getFileDataFromZip function from CCFileUtils_android.cpp (also, include “support/zip_support/unzip.h” ) to It works!