我有一个项目,其中包含一些基本功能,我可以重用,我正在尝试将其用作另一个项目中的框架。所以我的podspec包括字符串,swift,资产文件,所有这些都被添加到项目中,但字符串键没有从localizables.strings获取值。基本上它不是从捆绑路径获取的。这是我在框架中调用字符串文件的代码。"路径"正在变得为零。它在基础项目中工作正常
let bundle: Bundle = .main
if let currentLanguage = languageManager.getCurrentLanguage() {
if let path = bundle.path(forResource: currentLanguage.rawValue, ofType: "lproj"),
let bundle = Bundle(path: path) {
return bundle.localizedString(forKey: self, value: nil, table: nil)
}
}
我解决了这个问题。在 podspec 中,它是
spec.resource_bundle = { 'AppName' => ['AppName/**/*.{strings}'] }
我把它改成了
spec.resources = "AppName/**/*.{xcassets}", "AppName/**/*.{Strings}"