我有一个工作的swift脚本,我想编译为可执行文件。
执行时
swiftc create-event-in-calendar.swift -F /System/Library/Frameworks -o create-event-in-calendar
我得到所有种类或编译错误,如
<unknown>:0: error: could not build Objective-C module 'CoreFoundation'
<module-includes>:1:9: note: in file included from <module-includes>:1:
#import "/System/Library/Frameworks/CoreGraphics.framework/Headers/CoreGraphics.h"
^
/System/Library/Frameworks/CoreGraphics.framework/Headers/CoreGraphics.h:8:10: note: in file included from /System/Library/Frameworks/CoreGraphics.framework/Headers/CoreGraphics.h:8:
#include <CoreGraphics/CGBase.h>
编译swift脚本需要做什么?
答案 0 :(得分:2)
原来很简单。在命令行的开头添加xcrun -sdk macosx。
xcrun -sdk macosx swiftc create-event-in-calendar.swift -o create-event-in-calendar