Search code examples
xcodemacossfmlcode-signing

Xcode 11.2.1 - Command CodeSign failed with a nonzero exit code


I'm working on a SFML app for macOS with the latest Xcode version.

I got a "Command CodeSign failed with a nonzero exit code" error when it tries to sign the SFML frameworks. I added these under "Link Binary with Libraries" and "Copy Files" in Target, under Build Phases. Before, I was working with my local frameworks under /Library/Frameworks, and it was working very well.

Now I need to create an archive .app. I've tried a lot of things seen on other posts here (like lock and unlock my keychains), but nothing worked. Still got that error.

My SFML Frameworks in "Link Binary with Libraries" "Link Binary with Libraries"

/Users/lounesksouri/Library/Developer/Xcode/DerivedData/Squadro-gqwjbvsooypqaifxxyzhdrahkdpo/Build/Intermediates.noindex/ArchiveIntermediates/Squadro/InstallationBuildProductsLocation/Applications/Squadro.app/Contents/Frameworks/sfml-system.framework/Versions/A: bundle format unrecognized, invalid, or unsuitable

Command CodeSign failed with a nonzero exit code


Solution

  • Ok, I solved my problem, after long hours.

    It's a lot more simple to use the script already present in Build Phases tab, generated if you use the SFML App Xcode template (see here the original script). I had tried it at first, but it didn't work so I let it down.

    But, in this script, the first three lines are not the good ones, for a normal SFML installation on macOS. We need to modify these lines with the good paths to the Frameworks and lib folders, as follows :

    SFML_DEPENDENCIES_INSTALL_PREFIX="/Library/Frameworks"
    CMAKE_INSTALL_FRAMEWORK_PREFIX="/Library/Frameworks"
    CMAKE_INSTALL_LIB_PREFIX="/usr/local/lib"
    FRAMEWORKS_FULL_PATH="$BUILT_PRODUCTS_DIR/$FRAMEWORKS_FOLDER_PATH/"
    

    Secondly, there is still the code signing problem : the archive will created but we will get an error if we start the .app. The solution to this problem is to check Disable Library Validation under Target/Signing & Capabilities to allow the application to load plug-ins or frameworks signed by other developers.

    Finally, if we create the archive and launch the application, everything goes normally, as planned.