本文介绍了检测您的可可快速应用程序正在运行的位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试但无法找出是否有一种方法可以使用swift检测正在运行的.app文件的路径和名称
I'm trying but unable to find out if there is a way using swift to detect the path and name of the .app file that is running
ie if我的应用程序是selfupdater.app,它存储在〜username / applications中
ie if my app is selfupdater.app and its stored in ~username/applications
当selfupdater.app作为swift中的字符串变量启动时,如何获取此信息
how can i get this information when selfupdater.app is launched as a string variable in swift
推荐答案这称为您的主捆绑包文件夹。
This is called your main bundle folder.
迅速3或更高版本
extension URL { var parentDirectory: URL? { return (try? resourceValues(forKeys: [.parentDirectoryURLKey]))?.parentDirectory } }
let bundleURL = Bundle.main.bundleURL if let path = bundleURL.parentDirectory?.path { print(path) }
更多推荐
检测您的可可快速应用程序正在运行的位置
发布评论