Question

I recently upgraded from Xcode 12.1 to 12.2, on macOS Catalina 10.15.7. My C++ project (which uses OpenCV) compiled without problem with Xcode 12.1. After the upgrade I get a lot of these:

ld: warning: ignoring file /usr/local/Cellar/opencv/4.5.0_5/lib/libopencv_gapi.dylib, building for macOS-arm64 but attempting to link with file built for macOS-x86_64

(I would have been unable to work but luckily I noticed that changing the “My Mac” Scheme to use Debug instead of Release for Build Configuration allows it to build without issue. Just runs much slower.)

My web searching suggests this might be related to “universal binary” compilation? Apparently the Apple approved solution is to wait for OpenCV to release a “universal binary” version of the .dylib? Until then:

  • is there a way to say that, for now, I only care about the x86_64 machine I am developing on?
  • is it possible to roll back to Xcode 12.1?
Was it helpful?

Solution

I did not intend to do a question-and-answer format. But after posting my question above, I tried searching harder in the main stackoverflow. I found a question by Oscar with an answer to my question by Yi Hu. To restate Yi Hu’s answer:

  • go to Project Settings
  • select the executable (“texsyn” in my case)
  • select Build Settings tab
  • search for Architectures
  • change Build Active Architecture Only to be Yes for BOTH Debug and Release

This totally solved my problem. Now builds without error and runs about twice as fast.

Before:

enter image description here

After:

enter image description here

Licensed under: CC-BY-SA with attribution
Not affiliated with apple.stackexchange
scroll top