我使用服務器端的斯威夫特,做後做我的Xcode開發:服務器端斯威夫特:測試代碼,使用捆綁
swift package generate-xcodeproj
我有一個使用Bundle
(以前NSBundle
)一類加載.plist文件中的服務器中的一些設置。它在服務器本身運行時工作正常,但是當我爲這個類創建一些單元測試時,我無法訪問.plist文件所在的目錄。代碼的相關片段是:
let bundlePath = Bundle.main.bundlePath as NSString
let plistPath = bundlePath.appendingPathComponent("Test.plist")
plistDict = NSDictionary(contentsOfFile: plistPath)
當我在單位XCTests運行此,plistPath是:
/Applications/Xcode-8.2.app/Contents/Developer/Platforms/MacOSX.platform/ Developer/Library/Xcode/Agents/Test.plist
這不是很有用。
我注意到的一件事是沒有「常規」選項卡下的「主機應用程序:」的選項。
想法?