简体   繁体   English

在 Swift 中以编程方式打开 Xcode 项目

[英]Open Xcode project programmatically in Swift

How would you go about opening an Xcode project programmatically from within a macOSX app.您将如何从 macOSX 应用程序中以编程方式打开 Xcode 项目。

I have a URL object with the path to the xcodeProj file.我有一个带有 xcodeProj 文件路径的 URL 对象。

Would you execute a script within the app or use an API?您会在应用程序中执行脚本还是使用 API?

What API could be used for this?什么 API 可以用于此目的?

I don't want to use NSOpenPanel because I don't want the user to have to go chose the file to open.我不想使用 NSOpenPanel,因为我不想让用户不得不去选择要打开的文件。

Turns out you can use NSWorkspace to do this instead of writing a shell script.事实证明,您可以使用 NSWorkspace 来执行此操作,而无需编写 shell 脚本。

https://developer.apple.com/documentation/appkit/nsworkspacehttps://developer.apple.com/documentation/appkit/nsworkspace

NSWorkspace.shared.openFile(url.path, withApplication: "Xcode")

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM