Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/swift/17.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
是否可以在没有Xcode项目的情况下从命令行运行Swift测试用例?_Xcode_Swift_Command Line - Fatal编程技术网

是否可以在没有Xcode项目的情况下从命令行运行Swift测试用例?

是否可以在没有Xcode项目的情况下从命令行运行Swift测试用例?,xcode,swift,command-line,Xcode,Swift,Command Line,我对Array.swift和String.swift文件中的Array&String类做了一些扩展;我还分别在ArrayTest.swift和StringTest.swift中为它们添加了单元测试。现在我想从命令行运行这些单元测试,而不需要Xcode项目文件 在阅读之后,我想到了这样的想法: xcrun -sdk macosx swiftc -F/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Develop

我对Array.swift和String.swift文件中的Array&String类做了一些扩展;我还分别在ArrayTest.swift和StringTest.swift中为它们添加了单元测试。现在我想从命令行运行这些单元测试,而不需要Xcode项目文件

在阅读之后,我想到了这样的想法:

xcrun -sdk macosx swiftc -F/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/Library/Frameworks \
  -Xlinker -rpath \
  -Xlinker /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/Library/Frameworks \
  -lswiftCore Array.swift \
  -module-name array_extension

。。。这似乎是在将数组扩展编译成一个模块。但是,如何针对此模块编译/链接
ArrayTest.swift
文件?

检查此项-设置一个包,包括一个测试目标,然后您可以运行
swift测试