Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 928
Fooberman Avatar asked Jul 04 '16 16:07

Fooberman


People also ask

What is macOS SDK?

A software development kit (SDK) provides a set of files to build applications for a target platform, and defines the actual location of those files on the target platform or an intermediate platform that supports the target platform.

Can I delete SDK on Mac?

You can simply open the applications folder and move Android Studio to the trash. The same thing goes for the SDK.

Where are macOS SDK located?

The SDK is located at /Applications/Xcode. app/Contents/Developer/Platforms/MacOSX. platform/Developer/SDKs/MacOSX.

What is SDK in Swift?

SWIFT Software Development Kit (SDK) provides a simplified way for developers to consume the growing number of API-based services available on the SWIFT platform. The SDK delivers APIs that hide much of lower-level application plumbing, including authentication, authorization, signing and error handling.

Where is iOS SDK located?

SDKs (Software Development Kits) are bundles that contain headers, binaries, and other tools needed to build for a specific version of iOS. These can be found within Xcode at Xcode. app/Contents/Developer/Platforms/iPhoneOS. platform/Developer/SDKs .


1 Answers

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
like image 74
Fooberman Avatar answered Oct 10 '22 00:10

Fooberman