Swift4 未声明类型NSLinguisticTagScheme的使用
我让代码在操场上运行,Xcode没有显示任何bug,但是当我在命令行上编译文件时,它返回错误Swift4 未声明类型NSLinguisticTagScheme的使用,swift4,macos-high-sierra,nslinguistictagger,Swift4,Macos High Sierra,Nslinguistictagger,我让代码在操场上运行,Xcode没有显示任何bug,但是当我在命令行上编译文件时,它返回错误 use of undeclared type NSLinguisticTagScheme and String has no member 'tokenType' 这是问题代码 let tagSchemes : [NSLinguisticTagScheme] = [ .tokenType] let tagger : NSLinguisticTagger = NSLinguisticTagger(tag
use of undeclared type NSLinguisticTagScheme
and String has no member 'tokenType'
这是问题代码
let tagSchemes : [NSLinguisticTagScheme] = [ .tokenType]
let tagger : NSLinguisticTagger = NSLinguisticTagger(tagSchemes: tagSchemes, options: 0)
let options : NSLinguisticTagger.Options = [ .omitPunctuation, .omitWhitespace]
tagger.string = text
let range = NSRange(location: 0, length: text.utf16.count)
tagger.enumerateTags( in: range, unit: .sentence, scheme: .tokenType, options: options, using:
{ tag, tokenRange, stop in
let token = (text as NSString).substring(with: tokenRange)
sentences.append(token)
})
有什么想法吗?更新Xcode解决了问题
n语言标记方案
从iOS 11开始可用。您是否检查了部署目标?是的,当前正在使用swift 4部署到macOS 10.13,无法在macOS 10.13上复制您的问题您是否能够使用命令行编译该文件?