2

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

Community
  • 1
  • 1
Lounès KSOURI
  • 89
  • 1
  • 10
  • Do you have your framework under the `Embed Frameworks` area? check this https://stackoverflow.com/a/52787285/1040347 – Aleksey Potapov Dec 09 '19 at 17:42
  • @AlekseyPotapov I had seen this post, and I think the "Frameworks, Libraries, and Embedded Content" under General tab is quite the same thing (as in my Xcode version, there's not "Embed Framework" area in the Builder Phases tab), so yes all my frameworks are listed in this section... – Lounès KSOURI Dec 09 '19 at 17:57
  • To make sure, do you have under `Targets/Build Phases/Embedded Frameworks` your sfml frameworks? – Aleksey Potapov Dec 09 '19 at 18:01
  • Did you try to delete Derived Data under `~/Library/Developer/Xcode/DerivedData/` ? (xcode should be closed) via terminal command `rm -rf ~/Library/Developer/Xcode/DerivedData/*` – Aleksey Potapov Dec 09 '19 at 18:04
  • @AlekseyPotapov yes, I did try a lot of times to delete Derived Data. And I don't have the `Targets/Build Phases/Embedded Frameworks` section – Lounès KSOURI Dec 09 '19 at 18:34
  • I suppose it is a framework's issue, as [another user](https://stackoverflow.com/questions/58738867/how-to-fix-bundle-format-unrecognized-invalid-or-unsuitable) is experiencing the same issue. So it is better to contact them [directly](https://www.sfml-dev.org/community.php) they even have a Discord channel – Aleksey Potapov Dec 09 '19 at 19:00
  • @AlekseyPotapov Thanks for your help, I finally got a solution (see my answer) ! – Lounès KSOURI Dec 09 '19 at 19:55
  • Glad, you solved it – Aleksey Potapov Dec 09 '19 at 20:23

3 Answers3

3

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.

Lounès KSOURI
  • 89
  • 1
  • 10
  • This part helped me a lot, for the code signing I just resigned the SFML libs with my identity. (see my answer below) – MoVod Dec 19 '20 at 08:50
  • Thank you. There is one more thing that you may need to change if still have the problem. Under the **Build Settings->Other Code Signing Flags** put `--deep` for **Any SDK** variant for the version selected (Debug or Release) – PVD Nov 23 '21 at 18:44
0

I faced this problem with the new update of Xcode. I was reading your discussion, and did some accidental modifications. I am definetely not an expert but what I did fixed the problem so I did not receive tgis error anymore. So I added the sfml libraries (5 libraries), whose paths are written in build settings -> framework swarch paths. And this adding automatically added them in Embedded Frameworks under the Build phases section. What I did is unchecking the checkboxes of all 5 libraries "Code sign On copy". Thank you guys for giving me the path for "solving" the problem :))))

0

For the Code-signing issue:

  1. Open a Terminal,
  2. Go to the Framework folder (cd /Library/Frameworks) and sing them.
  3. choose your identity
security find-identity -vp codesigning
  1. sign them Frameworks!
codesign -s AD90FAFAFAFAFAFAFAF-YOURHASH-9D6 ogg.framework
codesign ... all the others
  1. run and enjoy!
MoVod
  • 1,083
  • 10
  • 10