Search code examples
objective-cxcode7xcode8objective-c++

.mm file works if built on Xcode 7 but not on Xcode 8


I'm calling a function from a compiled C library from a 3rd party developer which i cannot divulge. The problem is that function returns an error when the app is built using Xcode 8, but works ok when using Xcode 7. I'm calling the library function from a .mm file in my application. I know there's a possibility that this is caused by the 3rd party library, but what are the changes in the Xcode versions which might be affecting this? I have no idea where to start, and cannot paste code here.


Solution

  • I figured a workaround for this but still don't know why it behaves like that. I found the cause of the error was the Optimization Level. When in XCode 8, I need to set optimization level for it to work, or else it fails.

    The specific source code that fails is this:

    char subject[256];
    memset(&subject, 0x00, sizeof(subject));
    strcpy(subject, "Test");
    mail.emailSubject = subject
    

    I replaced above code with this:

    mail.emailSubject = (char*)"Test";
    

    If anyone can explain, please feel free. thanks!