Hi, I am a novice in cocos2d-x, so I faced a problem during Facebook integration for iOS version of app.
The problem is app crashes when Facebook registration dialog appears and app goes to background.
Using the debugger I found out that method applicationDidEnterBackground() is executed without errors.
// This function will be called when the app is inactive. When comes a phone call,it's be invoked too
void AppDelegate::applicationDidEnterBackground()
{
CCDirector::sharedDirector()->stopAnimation();
CCDirector::sharedDirector()->pause();
}
Objective-C applicationDidEnterBackground: method is executed without errors too.
Then throws to the window with assembly code. After several steps app crashes with message in Target Output:
Cocos2d: cocos2d: deallocing 0x315bf8
Hi,
I used materials from http://www.plungeinteractive.com/blog/ .
All work with native facebook sdk was done in AppController.
Facebook SDK was added to the project by adding it’s source files.
I added your code but there is lot of errors when i run my app…
: warning: directory not found for option ‘-L/Applications/cocos2d-2.0-x-2.0.2/samples/TestCpp/proj.ios/MoSync/bin/freetype219/lib’
ld: warning: directory not found for option ‘-L/Applications/cocos2d-2.0-x-2.0.2/samples/TestCpp/proj.ios/MoSync/bin’
ld: warning: directory not found for option ‘-L/Applications/cocos2d-2.0-x-2.0.2/samples/TestCpp/proj.ios/MoSync/bin/ImageMagick/ImageMagick/lib’
ld: warning: directory not found for option ‘-L/Applications/cocos2d-2.0-x-2.0.2/samples/TestCpp/proj.ios/MoSync/bin/ImageMagick/lib’
ld: warning: directory not found for option ‘-L/Applications/cocos2d-2.0-x-2.0.2/samples/TestCpp/proj.ios/MoSync/profiles/runtimes/iphoneos/1/template/libs/Debug-iphoneos’
ld: warning: directory not found for option ‘-L/Applications/cocos2d-2.0-x-2.0.2/samples/TestCpp/proj.ios/MoSync/profiles/runtimes/iphoneos/1/template/libs/Debug-iphonesimulator’
ld: warning: directory not found for option ‘-L/Applications/cocos2d-2.0-x-2.0.2/samples/TestCpp/proj.ios/MoSync/profiles/runtimes/iphoneos/1/template/libs/Release-iphoneos’
ld: warning: directory not found for option ‘-L/Applications/cocos2d-2.0-x-2.0.2/samples/TestCpp/proj.ios/MoSync/profiles/runtimes/iphoneos/1/template/libs/Release-iphonesimulator’
ld: warning: directory not found for option ‘-L/Applications/cocos2d-2.0-x-2.0.2/samples/TestCpp/proj.ios/Versions/A’
ld: warning: directory not found for option ‘-L/Applications/cocos2d-2.0-x-2.0.2/samples/TestCpp/proj.ios/Versions/Current’
ld: warning: directory not found for option ‘-L/Applications/cocos2d-2.0-x-2.0.2/samples/TestCpp/proj.ios/FacebookSDK/Versions/A’
ld: warning: directory not found for option ‘-L/Applications/cocos2d-2.0-x-2.0.2/samples/TestCpp/proj.ios/FacebookSDK/Versions/Current’
ld: warning: directory not found for option ‘-L/Applications/cocos2d-2.0-x-2.0.2/samples/TestCpp/proj.ios/FacebookSDK.framework/Versions/A’
ld: warning: directory not found for option ‘-L/Applications/cocos2d-2.0-x-2.0.2/samples/TestCpp/proj.ios/FacebookSDK.framework/Versions/Current’
ld: warning: directory not found for option ‘-F/Applications/cocos2d-2.0-x-2.0.2/samples/TestCpp/proj.ios/FacebookSDK’
Undefined symbols for architecture armv7:
“_sqlite3_reset”, referenced from:
_initializeStatement in FacebookSDK(FBCacheIndex.o)
“_sqlite3_prepare_v2”, referenced from:
_initializeStatement in FacebookSDK(FBCacheIndex.o)
“_sqlite3_open_v2”, referenced from:
___36-[FBCacheIndex initWithCacheFolder:]_block_invoke_0 in FacebookSDK(FBCacheIndex.o)
“_sqlite3_bind_text”, referenced from:
-[FBCacheIndex _updateEntryInDatabaseForKey:entry:] in FacebookSDK(FBCacheIndex.o)
-[FBCacheIndex _writeEntryInDatabase:] in FacebookSDK(FBCacheIndex.o)
-[FBCacheIndex _readEntryFromDatabase:] in FacebookSDK(FBCacheIndex.o)
-[FBCacheIndex _readEntriesFromDatabase:excludingFragment:] in FacebookSDK(FBCacheIndex.o)
-[FBCacheIndex _removeEntryFromDatabaseForKey:] in FacebookSDK(FBCacheIndex.o)
“_sqlite3_step”, referenced from:
-[FBCacheIndex _updateEntryInDatabaseForKey:entry:] in FacebookSDK(FBCacheIndex.o)
-[FBCacheIndex _writeEntryInDatabase:] in FacebookSDK(FBCacheIndex.o)
-[FBCacheIndex _createCacheEntityInfo:] in FacebookSDK(FBCacheIndex.o)
-[FBCacheIndex _fetchCurrentDiskUsage] in FacebookSDK(FBCacheIndex.o)
-[FBCacheIndex _removeEntryFromDatabaseForKey:] in FacebookSDK(FBCacheIndex.o)
-[FBCacheIndex _dropTrimmingTable] in FacebookSDK(FBCacheIndex.o)
-[FBCacheIndex _trimDatabase] in FacebookSDK(FBCacheIndex.o)
…
“_sqlite3_bind_double”, referenced from:
-[FBCacheIndex _updateEntryInDatabaseForKey:entry:] in FacebookSDK(FBCacheIndex.o)
-[FBCacheIndex _writeEntryInDatabase:] in FacebookSDK(FBCacheIndex.o)
“_sqlite3_bind_int”, referenced from:
-[FBCacheIndex _updateEntryInDatabaseForKey:entry:] in FacebookSDK(FBCacheIndex.o)
-[FBCacheIndex _writeEntryInDatabase:] in FacebookSDK(FBCacheIndex.o)
-[FBCacheIndex _trimDatabase] in FacebookSDK(FBCacheIndex.o)
“_sqlite3_finalize”, referenced from:
_releaseStatement in FacebookSDK(FBCacheIndex.o)
“_sqlite3_column_text”, referenced from:
-[FBCacheIndex _createCacheEntityInfo:] in FacebookSDK(FBCacheIndex.o)
-[FBCacheIndex _trimDatabase] in FacebookSDK(FBCacheIndex.o)
“_sqlite3_exec”, referenced from:
___36-[FBCacheIndex initWithCacheFolder:]_block_invoke_0 in FacebookSDK(FBCacheIndex.o)
“_sqlite3_errmsg”, referenced from:
_releaseStatement in FacebookSDK(FBCacheIndex.o)
-[FBCacheIndex _updateEntryInDatabaseForKey:entry:] in FacebookSDK(FBCacheIndex.o)
_initializeStatement in FacebookSDK(FBCacheIndex.o)
-[FBCacheIndex _writeEntryInDatabase:] in FacebookSDK(FBCacheIndex.o)
-[FBCacheIndex _readEntryFromDatabase:] in FacebookSDK(FBCacheIndex.o)
-[FBCacheIndex _readEntriesFromDatabase:excludingFragment:] in FacebookSDK(FBCacheIndex.o)
-[FBCacheIndex _fetchCurrentDiskUsage] in FacebookSDK(FBCacheIndex.o)
…
“_sqlite3_column_int”, referenced from:
-[FBCacheIndex _createCacheEntityInfo:] in FacebookSDK(FBCacheIndex.o)
-[FBCacheIndex _fetchCurrentDiskUsage] in FacebookSDK(FBCacheIndex.o)
-[FBCacheIndex _trimDatabase] in FacebookSDK(FBCacheIndex.o)
“_sqlite3_close”, referenced from:
___23-[FBCacheIndex dealloc]_block_invoke_0 in FacebookSDK(FBCacheIndex.o)
“_sqlite3_column_double”, referenced from:
-[FBCacheIndex _createCacheEntityInfo:] in FacebookSDK(FBCacheIndex.o)
ld: symbol(s) not found for architecture armv7
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Or try this: Select the Build Phases tab. The Link Binary with Libraries section lists the libraries and frameworks already included in the project. To add another library or framework click on the ‘+’ button to display the full list. From this list, select the required item (in this case libsqlite3.dylib) and click Add.
I added sqllite and there is no error now… but when i added your facebookManager class i have many errors…The reason i think is i created it as c*+ class but you are saying it is objective-c*+ class…how can i create objective c++ file?
Hi,
to make your .cpp file an objective-c*+ file you need to click the .cpp file and in the “Identity and type” window on Xcode , choose Objective C*+ source as the type.
i am sorry i m taking your more time…I was already doing same what u did for login…but it causing crash at this line " int retVal = UIApplicationMain(argc, argv, nil, @“AppController”);".