我一直在Xcode中使用一个简单的命令行应用程序(不是直接通过swiftc)来测试代码,否则会给Playground配合。几个月后,编译器更新,我无法链接似乎链接一个扩展Swift数组的琐碎和设计的片段。我在iOS应用程序中有这样的代码,它编译得很好。我一定错过了备忘录,但我不确定那是什么。
这是一个简单的片段(在main.swift文件中):
protocol MyProtocol : SequenceType {
func fubar()
}
extension Array : MyProtocol {
func fubar() {}
}
println("Hello, World!")
这导致了许多链接错误,例如:
Ld /Users/Redacted/Library/Developer/Xcode/DerivedData/Hacks-Redacted/Build/Products/Debug/Hacks normal x86_64
cd /Users/Redacted/development/tests/Hacks
export MACOSX_DEPLOYMENT_TARGET=10.10
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -arch x86_64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk -L/Users/Redacted/Library/Developer/Xcode/DerivedData/Hacks-Redacted/Build/Products/Debug -F/Users/Redacted/Library/Developer/Xcode/DerivedData/Hacks-Redacted/Build/Products/Debug -filelist /Users/Redacted/Library/Developer/Xcode/DerivedData/Hacks-Redacted/Build/Intermediates/Hacks.build/Debug/Hacks.build/Objects-normal/x86_64/Hacks.LinkFileList -mmacosx-version-min=10.10 -L/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift_static/macosx -Xlinker -force_load_swift_libs -lswiftRuntime -lc++ -framework Foundation -lcurses -Xlinker -add_ast_path -Xlinker /Users/Redacted/Library/Developer/Xcode/DerivedData/Hacks-Redacted/Build/Intermediates/Hacks.build/Debug/Hacks.build/Objects-normal/x86_64/Hacks.swiftmodule -Xlinker -dependency_info -Xlinker /Users/Redacted/Library/Developer/Xcode/DerivedData/Hacks-Redacted/Build/Intermediates/Hacks.build/Debug/Hacks.build/Objects-normal/x86_64/Hacks_dependency_info.dat -o /Users/Redacted/Library/Developer/Xcode/DerivedData/Hacks-Redacted/Build/Products/Debug/Hacks
duplicate symbol __TTWSaSs12SequenceTypeFS_8generateUS__USs13GeneratorType___fRQPS_FT_QS1_9Generator in:
/Users/Redacted/Library/Developer/Xcode/DerivedData/Hacks-Redacted/Build/Intermediates/Hacks.build/Debug/Hacks.build/Objects-normal/x86_64/main.o
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift_static/macosx/libswiftCore.a(Swift.o)
duplicate symbol __TTWSaSs12SequenceTypeFS_oi2tgUS__USs13GeneratorType___fMQPS_FTS1_TVSs19_UnderestimateCountT___Si in:
/Users/Redacted/Library/Developer/Xcode/DerivedData/Hacks-Redacted/Build/Intermediates/Hacks.build/Debug/Hacks.build/Objects-normal/x86_64/main.o
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift_static/macosx/libswiftCore.a(Swift.o)
... <>
我错过了一些新的链接要求吗?似乎它必须是简单的东西,但它正在逃避我。尽管如此,我已经在一台单独的机器上复制了这个并使用了Xcode 6.1.1(6A2008a) - 截至发布时的最新信息。
编辑澄清我正在尝试使用Xcode构建它,而不是从命令行构建。