ruipacheco
ruipacheco

Reputation: 16422

C++ program works on command line but fails on Xcode

I have a C++ static lib that uses libxml2 extensively. I test it using Google Test, which means I build a command line executable where unit tests are called. The command line application works perfectly and all output is as expected.

I carry over the library to an iOS project in Xcode by copying the source files. I build it and call the C++ source files from a file with the .mm extension. I've set Xcode's C++ language dialect to c++11 and the C++ Standard Library to LLVM.

To build the command line I pass these switches: -Wno-attributes -g -Wall -std=c++11 -stdlib=libc++ -Wunused -D_GLIBCXX_USE_NANOSLEEP -m64

My problem is that once I call the iOS app, it crashes silently. Some caveman debugging with NSLog statements throughout the code shows that some variables could potentially be null. The problem is that the exact same input crashes the app on Xcode but not on the console.

What's the best way to debug this?

Upvotes: 0

Views: 205

Answers (1)

smaryus
smaryus

Reputation: 349

Try activate from xcode all the memory management checks. From Project > Scheme > Edit Scheme… Click the Run item in the list on the left. Then click the Diagnostics.

Upvotes: 1

Related Questions