DragonFireSDK Forum
Programming Discussions => Build Center => Topic started by: matthewsjc1 on May 03, 2012, 12:47:00 am
-
I've installed one test app before and I'm trying to install another to my iPhone, but when trying to sync, I get an error message that says it failed to install. I replaced the mobileprovision file first. Not sure what's going on..,
-
Have you checked if there are any errors? In your return zip file from the build center...
-
I don't see any error log files or anything. The only thing I could think of is that I included stdlib, but the help file says standard libraries are usable. Everything works fine I the simulator.
-
All includes should work without a problem. I think it's either the mobileprovision or something wrong in your code. There are somethings that I have experienced is working fine in the simulator, but is not allowed on the actual device.
-
It's a very simple app. I'm just playing around with the sdk. Here's my source code:
#include "DragonFireSDK.h"
#include "stdlib.h"
using namespace std;
int AddToScore(int touchId);
const int CUR_SCORE_TEXT_MAX_LENGTH = 200;
const int CUR_SCORE_FONT_SIZE = 20;
int fontId = 0;
int curScore = 0;
char curScoreText[10] = "\0";
int scoreLabelId = 0;
int scoreButtonId = 0;
const int BUTTON_TOUCH_ID = 1;
void AppMain()
{
fontId = FontAdd("Arial", "Regular", CUR_SCORE_FONT_SIZE, 0xff0000);
scoreButtonId = ButtonAdd("Images/button", 100, 100, AddToScore, BUTTON_TOUCH_ID);
scoreLabelId = TextAdd(10, 10, curScoreText, fontId);
}
void AppExit()
{
}
void OnTimer()
{
itoa(curScore, curScoreText, 10);
TextSetText(scoreLabelId, curScoreText);
}
int AddToScore(int touchId)
{
curScore++;
return 0;
}
-
Hmmm... just noticed I used "stdlib.h" instead of <stdlib>. i wouldn't think that would make a difference, but...
-
Maybe something to do with itoa be deprecated?
-
I wouldn't think so, remove using namespace std, that I am sure you can't use. That did at least give me a problem once.
-
I uploaded without it and will try it out. Thanks a bunch :) So, iTunes won't let the app install if it detects an internal problem within the app?
-
K. I got it back with errors this time, because itoa was found in the namespace. Guess I'll try it and manually declaring the namespace with each call.
-
K. I got it back with errors this time, because itoa was found in the namespace. Guess I'll try it and manually declaring the namespace with each call.
Nope, doesn't seem that way. :-) Try not to use too many "c++ shortcuts" in forms of using std namespaces and stuff like that. I am guessing the converter that tries to build it over to objective-c is strugging a bit with those lines, maybe not causing errors, just don't get anything.
-
Well, got it to install, but I had to remove anything to do with std and the text functions. Is there possibly a configuration I have to set in VC++ 2010 that is causing a problem?? Without use of the standard libraries, functionality is gonna be pretty limited.
-
I figured it out. DragonFire doesn't convert itoa to a compatible form in iOS. I found a source online that talks about it:
« on: March 16, 2012, 10:31:55 pm »
If you're trying to use the non-standard itoa() function on your device, here is a one that I wrote so that code that uses this function will compile for iOS.
Add the following to your App.cpp file:
Code: [Select]
#ifdef __APPLE__
char *itoa(int value,char *str,int radix)
{
switch (radix)
{
case 8: // Octal
sprintf(str,"%o",value);
break;
case 10: // Decimal
sprintf(str,"%d",value);
break;
case 16: // Hex
sprintf(str,"%x",value);
break;
default: // Other - assume decimal
sprintf(str,"%d",value);
break;
}
return(str);
}
#endif
This will let you continue to use itoa() on iOS. Alternatively, you could also just use sprintf(), but that's another story!
Enjoy!
Logged
I'll just use sprintf isntead. Thanks for the help man!
,Jared
-
Works
-
If you need to access overloaded methods in the classes attached as header files, you can't use the "using namespace std". You can however declare std::"property type/method", e.g. std::string varname.
-
Maybe something to do with itoa be deprecated?
The itoa() function isn't deprecated. It's non-standard C, and as such isn't supported on every platform (including Mac/iOS).
-
Just a head's up as well, if you get in to comparing strings and case sensitivity, avoid the use of strcasecmp() for those using VC++, as it's also Non-Standard C , use the toupper or tolower functions. You'll run into the same issue as using itoa() as well as a few other functions.
-
Just a head's up as well, if you get in to comparing strings and case sensitivity, avoid the use of strcasecmp() for those using VC++, as it's also Non-Standard C , use the toupper or tolower functions. You'll run into the same issue as using itoa() as well as a few other functions.
The abs() function comes to mind. If you're trying to get the absolute value of a double or a float, you need to use fabs() instead of abs() on iOS. The Visual C++ library overloads abs() to handle any numeric type, but that's non-standard...
If you have any questions about what's standard C/C++ and what isn't, http://www.cplusplus.com/reference/ is an excellent resource...
-
The itoa() function isn't deprecated. It's non-standard C, and as such isn't supported on every platform (including Mac/iOS).
Microsoft docs plus the compiler both warn that it's deprecated and you should use a safer alternative.
-
The itoa() function isn't deprecated. It's non-standard C, and as such isn't supported on every platform (including Mac/iOS).
Microsoft docs plus the compiler both warn that it's deprecated and you should use a safer alternative.
Fair enough. If it's deprecated in Visual C++, so much the better. It causes problems in DragonFireSDK. :)
-
http://www.cplusplus.com/reference/
So if it's there, it's supported by dragonfire?
-
What about c++ classes? Are all parts of classes supported? (constructors, destructors, inheritance, etc?)
-
http://www.cplusplus.com/reference/
So if it's there, it's supported by dragonfire?
Yep.
What about c++ classes? Are all parts of classes supported? (constructors, destructors, inheritance, etc?)
Yep.
Any standard C or C++ is supported. What you cannot use is anything non-standard or Microsoft-specific. You cannot use Windows DLL's or LIBs.