同样获取权限代码一个项目
本地打包

云打包

这样就会造成我无法使用红框里面的文件

关注让【道友老李】来帮你解答,本回答参考gpt编写,并整理提供,如果还有疑问可以点击头像关注私信或评论。
如果答案让您满意,请采纳、关注,非常感谢!问题:在项目中需要获取权限,但由于本地打包和云打包的差异,导致无法使用特定文件。如何解决这个问题? 回答:针对这个问题,我们可以通过以下几种方法来解决:
#if RELEASE
let filePath = Bundle.main.path(forResource: "fileForRelease", ofType: "json")
#else
let filePath = Bundle.main.path(forResource: "fileForDebug", ofType: "json")
#endif
let currentBuildSetting = ConfigManager.shared.getCurrentBuildSetting()
if currentBuildSetting == "local" {
let filePath = Bundle.main.path(forResource: "fileForLocal", ofType: "json")
} else if currentBuildSetting == "cloud" {
let filePath = Bundle.main.path(forResource: "fileForCloud", ofType: "json")
}