Force SDK for make and xcrun version error - xcode

I am trying to compile with make using c++ on a 10.15 system under Xcode and Command Line Tools 12.2. It keeps wanting to use the 10.15 SDK which does not support arm64. I am thus getting architecture not supported errors.
My make file contains:
SDKROOT=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.0.sdk
and the build command contains:
-isystem /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.0.sdk
Curiously:
xcrun --show-sdk-path
/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk
xcrun --show-sdk-version
xcodebuild: error: SDK "/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk" cannot be located.
xcrun: error: unable to lookup item 'SDKVersion' in SDK '/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk'
Any ideas? There was a clean install on Xcode 11.7 previously and then I copied 12.2 (replacing 11.7). I have verified that the SDK (v15) exists at /Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk and the OSX11 SDK is also in the SDK folder.
A build for x86_64 works fine.

Related

Mac OS Catalina gfortran - "ld: library not found for -lgcrt1.o"

I'm compiling a fortran program on Mac (10.15.2) with cmake and gfortran, but I'm getting the following error:
ld: library not found for -lgcrt1.o
I found the file grcrt1.o in the folder
/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/usr/lib/gcrt1.o
But even if I add that to my PATH it still doesn't work.
The version of gfortran I'm using was installed with homebrew and is in
/usr/local/bin/gfortran
gfortran is version 9.2.0
This just happened to me as well. I have Xcode 11 and 10.1 installed. For me switching back to version 10.1 helped:
sudo xcode-select --switch /Applications/Xcode-10.1.app/

building for UIKitForMac, but linking in .tbd built for macOS

I'm trying to compile my iOS app to work on macOS and after checking the Mac checkbox, I'm getting this error on compile:
d: building for UIKitForMac, but linking in .tbd built for macOS, file '/Users/jan/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/System/Library/Frameworks//GLKit.framework/GLKit.tbd' for architecture x86_64
Any idea what it means and how to fix it?
Though I've not had this particular error I have had similar ones when trying to port from iPad to UIKitForMac. UIKitForMac appears to be the iOS SDK built for x86_64 when you're linking with frameworks. As a result it shouldn't be trying to pull the x86_64 files from the macOS SDK.
I'd be tempted to check over your 'architectures' and 'valid architectures' settings in Xcode to make sure that any settings you have are deleted and switched back to the standard ones.
Remove architectures

Clang error after using OpenFrameworks Project Generator

I'm trying to update an OpenFrameworks project using the Project Generator.
After updating the project, I'm now getting the following error in Xcode 8.2.1:
clang: error: unknown argument: '-mmacosx-version-min'
That flag is found in the Apple LLVM 8.0 - Custom Compiler Flags section of Build Settings in both my Project and Target:
Anyone have an idea on what the issue may be? I'm on macOS 10.12.1 Sierra.
You can remove the -mmacosx-version-min flag; Xcode uses MACOSX_DEPLOYMENT_TARGET.
MACOSX_DEPLOYMENT_TARGET specifies the minimum version of OS X for the build target.
↳ Configuring a Project for SDK-Based Development

How do you change the macOS SDK associated with the swift compiler

I have Xcode 7.3 installed, and the swiftc command line compiler declares that is is version 2.2, yet it is configured to target the macos10.9 sdk:
🍺> swiftc -v
Apple Swift version 2.2 (swiftlang-703.0.18.8 clang-703.0.31)
Target: x86_64-apple-macosx10.9
FWIW I am running OS X 10.11.6. Compiling Metal API code using this swiftc in this configuration results in errors such as:
src/Application.swift:76:29: error: 'MTLBuffer' is only available on OS X 10.11 or newer
var _mtlPositionBuffer : MTLBuffer?
And finally, to address this, I've compiled with the flag:
-sdk /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk
to no avail. How do you change the sdk/platform target for the swiftc command line compiler?
Looking at what Xcode does when compiling swift code, it uses the following CLI flag, which seems to address the problem here nicely:
-target x86_64-apple-macosx10.11

building for iOS Simulator, but linking against dylib built for MacOSX file

This is a strange problem. My XCode version is 6.3.2. After I installed the command line tools, I could not compile any more. Any compilation that need to link with a dylib will cause the error like:
ld: building for iOS Simulator, but linking against dylib built for MacOSX file '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/usr/lib/libm.dylib' for architecture x86_64
This happens when I use pip to install uwsgi and compile mongrel2 manually.
I have already export SDKROOT to /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk and xcrun --show-sdk-path is showing that. gcc --version shows:
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/usr/include/c++/4.2.1
Apple LLVM version 6.1.0 (clang-602.0.53) (based on LLVM 3.6.0svn)
Target: x86_64-apple-darwin14.3.0
Thread model: posix
I know that gcc is link to clang, and I have tried to add option -mmacosx-version-min=10.9 to the CFLAGS, but nothing fixed.
I want to change the SDK to MacOSX, not iOS Simulator, how can I do that? Or what can I do to fix this.

Resources