"You create QApplication before calling UIApplicationMain" on iOS

When I create a QtWidgets app, select iphonesimulator-clang Qt5.3 and run the app in debug mode on the iOS simulator. I am getting below error. I am not adding any code; just by running the Qt Creator template code.

"Error: you are creating a QApplication before calling UIApplicationMain. If you are writing a native iOS application and want to use Qt for part of the application, a good place to create a QApplication is from within 'applicationDidFinishLaunching' inside your UIApplication delegate.

I have Qt5.3.1 (installed using the online installer) and Xcode 5.1.1.

Running the provided calculator example on the iOS simulator works fine without error.

+3


source to share


1 answer


Just in case, the solution decided to disappear elsewhere: the fix is ​​to change the signature of the main function.



#if defined(Q_OS_IOS)
extern "C" int qtmn(int argc, char **argv)
#else
int main(int argc, char **argv)
#endif
{
  ...
}

      

+4


source







All Articles