`swift package generate-xcodeproj` fails with “Swift does not support the SDK”

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-24 21:53:15

问题


I'm having trouble running swift package generate-xcodeproj. I created my package like this:

$ /Applications/Xcode9.4.1.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift package init --type executable

(as I have many Xcode versions installed I explicitly targeted a swift binary when running the command so that I don't need to xcode-select all the time)

This created a Package.swift with the version header // swift-tools-version:4.0.

Now, when I run swift package generate-xcodeproj I get a fatal error:

$ /Applications/Xcode9.4.1.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift package generate-xcodeproj
/Users/max.chuquimia/Desktop/xcode/MyPackage: error: manifest parse error(s):
<unknown>:0: error: Swift does not support the SDK 'MacOSX10.12.sdk'

No .xcodeproj is generated. Why is this occurring?


回答1:


It seems the problem is the $DEVELOPER_DIR environment variable is wrong - it should also be made to point to the Xcode version that the swift binary resides in.

$ DEVELOPER_DIR=/Applications/Xcode9.4.1.app/Contents/Developer /Applications/Xcode9.4.1.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift package generate-xcodeproj


来源:https://stackoverflow.com/questions/51094495/swift-package-generate-xcodeproj-fails-with-swift-does-not-support-the-sdk

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!