DragonFireSDK Forum

Programming Discussions => Build Center => Topic started by: matthewsjc1 on May 03, 2012, 12:47:00 am

Title: Failed To Install
Post 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..,
Title: Re: Failed To Install
Post by: martol1ni on May 03, 2012, 12:55:32 am
Have you checked if there are any errors? In your return zip file from the build center...
Title: Re: Failed To Install
Post by: matthewsjc1 on May 03, 2012, 01:00:16 am
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.
Title: Re: Failed To Install
Post by: martol1ni on May 03, 2012, 01:03:05 am
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.
Title: Re: Failed To Install
Post by: matthewsjc1 on May 03, 2012, 01:06:54 am
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;
}
Title: Re: Failed To Install
Post by: matthewsjc1 on May 03, 2012, 01:07:59 am
Hmmm... just noticed I used "stdlib.h" instead of <stdlib>. i wouldn't think that would make a difference, but...
Title: Re: Failed To Install
Post by: matthewsjc1 on May 03, 2012, 01:10:41 am
Maybe something to do with itoa be deprecated?
Title: Re: Failed To Install
Post by: martol1ni on May 03, 2012, 01:11:40 am
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.
Title: Re: Failed To Install
Post by: matthewsjc1 on May 03, 2012, 01:16:40 am
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?
Title: Re: Failed To Install
Post by: matthewsjc1 on May 03, 2012, 01:18:13 am
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.
Title: Re: Failed To Install
Post by: martol1ni on May 03, 2012, 01:27:34 am
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.
Title: Re: Failed To Install
Post by: matthewsjc1 on May 03, 2012, 01:36:49 am
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.
Title: Re: Failed To Install
Post by: matthewsjc1 on May 03, 2012, 01:51:30 am
I figured it out. DragonFire doesn't convert itoa to a compatible form in iOS. I found a source online that talks about it:

Quote
« 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
Title: Re: Failed To Install
Post by: matthewsjc1 on May 03, 2012, 01:58:37 am
Works
Title: Re: Failed To Install
Post by: nednones on May 03, 2012, 02:12:42 am
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.
Title: Re: Failed To Install
Post by: tim on May 03, 2012, 07:00:56 am
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).
Title: Re: Failed To Install
Post by: rjanes on May 03, 2012, 10:50:36 am
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.

Title: Re: Failed To Install
Post by: tim on May 03, 2012, 12:20:57 pm
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...
Title: Re: Failed To Install
Post by: matthewsjc1 on May 03, 2012, 07:25:19 pm
Quote
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.
Title: Re: Failed To Install
Post by: tim on May 03, 2012, 07:56:59 pm
Quote
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. :)
Title: Re: Failed To Install
Post by: matthewsjc1 on May 05, 2012, 05:48:37 am
Quote
http://www.cplusplus.com/reference/

So if it's there, it's supported by dragonfire?
Title: Re: Failed To Install
Post by: matthewsjc1 on May 05, 2012, 05:52:49 am
What about c++ classes? Are all parts of classes supported? (constructors, destructors, inheritance, etc?)
Title: Re: Failed To Install
Post by: tim on May 05, 2012, 08:18:15 am
Quote
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.