简体   繁体   English

如何在没有 IDE 的情况下编写 macOS 应用程序?

[英]How do I write a macOS app without an IDE?

How do I write a macOS app that just gets a window up, without an IDE?如何在没有 IDE 的情况下编写一个只打开一个窗口的 macOS 应用程序?

PS.附注。 Rant:咆哮:

Programming is very simple, it's writing code invoking some libraries, typing a clang command and watching the CPU execute the program.编程很简单,就是编写代码调用一些库,输入clang命令并观察CPU执行程序。

Why is every page of Apple programmer documentation a thousand words about nothing and zero words about which library classes to use in the main method of your simple program to get a macOS window up.为什么 Apple 程序员文档的每一页都是一千字关于什么都没有,零字关于在简单程序的main方法中使用哪些库类来打开 macOS 窗口。

How do I get a macOS window up in my main function?如何在main函数中打开 macOS 窗口? It could have been like 5 lines in a hello.c file compiled with one clang command.它可能就像是用一个clang命令编译的hello.c文件中的 5 行。 Not opening massive Xcode and fiddling forever with random IDE features that I'm not interested in.不要打开大量的 Xcode 并永远摆弄我不感兴趣的随机 IDE 功能。

Figured it out, this is a swift file that when compiled and run will get a macOS window up:想通了,这是一个 swift 文件,编译和运行时会打开一个 macOS 窗口:

import Cocoa
let window = NSWindow(contentRect: NSRect(x: 0, y: 0, width: 200, height: 200), styleMask: .titled, backing: .buffered, defer: false)
window.makeKeyAndOrderFront(nil)
NSApp.run()

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

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