英文:
Go - How to link Go macOS binary in an Xcode project?
问题
我完全不了解 macOS 开发,这可能听起来很基础。
我需要为 macOS 分发一个 Golang 应用程序。
我已经为 macOS 构建了 Go 可执行文件,该可执行文件在 macOS 上运行正常。
我按照这个教程创建了它的 .app 结构。
但在分发之前,我需要做一些事情,比如代码签名和集成 Sparkle(用于更新)。
为此,我需要将这个 .app 打开为一个 Xcode 项目。我该如何做?
Xcode 可以识别 .xcodeproj 扩展名。
我创建了一个示例的 Xcode Objective-C 项目,但是如何让这个项目运行我的可执行文件/.app?
英文:
I'm completely new to macOS development, this might sound quite basic.
I need to distribute a Golang app for macOS.
I built the Go executable for macOS, the executable works fine on macOS.
I made its .app structure following this tutorial
But before distributing it, I need to do a few things like code signing & integrating Sparkle (for updates).
For that, I need to open this .app as a Xcode project. How do I do that ?
Xcode recognizes .xcodeproj extension
I created a sample Xcode Objective-C project but how do I get this project to run my executable/.app ?
答案1
得分: 2
你不需要将应用程序作为Xcode项目打开,因为这没有意义,也无法实现,因为该应用程序不是Xcode项目。
我建议你使用gon
工具进行代码签名,你可以在这里找到它。
通常最简单的安装方法是通过HomeBrew运行以下命令:
brew tap mitchellh/gon
brew install mitchellh/gon/gon
上述操作需要事先安装HomeBrew。
安装完成后,你需要按照gon
GitHub页面上的说明创建一个config.json
文件,然后运行以下命令:
gon config.json
这将为你签名、压缩、进行公证并为你的应用程序添加标签,同时创建一个用于分发的.dmg
文件。
至于使用Sparkle来轻松更新你的程序,你需要将其集成到你的Go程序中。你可以在这里找到如何实现的示例。
示例中包含一个简单的Objective-C函数sparkle_checkUpdates()
,它使用Sparkle框架来调用更新机制。它还包含一个Go函数sparkle_checkUpdates()
,它使用C导入来调用之前描述的C函数。
在你现有的Go程序中,当用户想要检查更新时,你只需要从某个地方调用sparkle_checkUpdates
函数即可。
英文:
You do not need to open the app as an Xcode project - that doesn't make sense as such and cannot be done, as the app is not an Xcode project.
I would suggest instead using the gon
tool you can find here for code signing.
The easiest way to install it is usually through HomeBrew by running:
brew tap mitchellh/gon
brew install mitchellh/gon/gon
The above requires you to have HomeBrew installed in advance.
After installing, you create a config.json
file as described on the gon
GitHub page, and then run:
gon config.json
That will sign, zip, notarize and staple your application for you - creating a .dmg
file for distribution.
In regards to Sparkle for easily updating your program, this is something you have to integrate into your Go program. You can find an example of how to do that here.
The example contains a simply Objective-C function sparkle_checkUpdates()
that uses the Sparkle framework to invoke the updating mechanism. It also contains a Go function sparkle_checkUpdates()
that use C imports to call that C function described before.
In your existing Go program, you just need to call that sparke_checkUpdates
from somewhere when the user wants to check for updates.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论