我正在尝试使用 Github Actions 构建一个 macOS 应用程序。这已经很有效了,直到我将我的依赖项迁移到 Swift Package Manager。现在我在构建我的应用程序时收到以下错误:
xcodebuild: error: Could not resolve package dependencies:
The server SSH fingerprint failed to verify.
我有一个私有 GitHub 存储库作为我的应用程序中的依赖项,使用 ssh 位置添加为 Swift 包。因此,我需要在Set up ssh-agent步骤中为依赖项添加我的 ssh 密钥。在一个步骤中手动克隆存储库git clone工作正常,但我需要让它与 xcodebuild 一起使用才能成功构建我的应用程序。
name: Main
on:
push:
tags:
- 'v*.*.*'
jobs:
build:
name: Release
runs-on: macOS-latest
steps:
- name: Checkout
uses: actions/checkout@master
with:
fetch-depth: 1
- name: Set up ssh-agent
uses: yakuhzi/action-ssh-agent@v1
with:
public: ${{ secrets.SSH_PUBLIC_KEY }}
private: ${{ secrets.SSH_PRIVATE_KEY }} …Run Code Online (Sandbox Code Playgroud) 我想将应用程序中的文件(代表网络驱动器上的文件)拖到用户的桌面或 Finder 窗口。因此,只有在拖放操作结束后才应下载该文件。
使用 AppKit 我可以使用File Promises实现此行为。但对于 SwiftUI 来说,似乎没有等价的东西。唯一的选择是使用NSItemProvideror Transferable(或两者组合)(请参阅此问题)。但既不NSItemProvider也不Transferable支持这种异步行为。
主要问题是在拖动会话开始时调用itemProvider闭包FileRepresentation,从而也开始下载文件。这使得该功能无法使用,例如,如果您一次拖动一个大文件或多个文件。
struct Item: Identifiable, Transferable {
let id = UUID()
let name: String
let description: String
let url: URL
static var transferRepresentation: some TransferRepresentation {
FileRepresentation(contentType: .fileURL) { (item: DragItem) in
let urlSession = URLSession(configuration: .default)
// This download is already started when the drag & drop session starts
let (tempURL, response) = try! await …Run Code Online (Sandbox Code Playgroud) 当我将游戏鼠标移动到a中时javax.swing.JFrame,所有动画GIF(javax.swing.ImageIcon在a内javax.swing.JLabel)停止动画直到鼠标停止移动.
这只是一个游戏鼠标与司机发生的MacOS(与火箭通力XTD和两台计算机上的Razer游戏鼠标测试过).当我使用其他鼠标时,一切正常.
游戏鼠标也导致javax.swing.Timers停止调用他们的actionPerformed()方法.我在这里为这个问题打开了一个线程,但是这可以用来java.util.TimerTask代替.(编辑:实际上TimerTask也没有修复它,因为JFrame在鼠标停止移动之前不会重新绘制.)
但我找不到动画GIF的替代方案.我更感兴趣的是解决问题而不是使用替代方案,尽管我也会感谢一个有效的替代方案.
import java.lang.reflect.InvocationTargetException;
import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.SwingUtilities;
public class Mouse {
public static void main(String[] args) {
try {
SwingUtilities.invokeAndWait(new Runnable() {
public void run() {
new Mouse();
}
});
} catch (InvocationTargetException e) {
e.printStackTrace();
} catch (InterruptedException e) {
e.printStackTrace();
}
}
public Mouse() {
JFrame frame = …Run Code Online (Sandbox Code Playgroud) 在 WWDC 2022 上,Apple 推出了Transferable协议,以简单的方式支持拖放操作。如何对 SwiftUI表(而非列表)使用这项新技术(与新的draggable和dropDestination修饰符结合使用) ?
TableRowContent不支持和draggable修饰符dropDestination。此外,当将修改器直接应用于 s 中的视图时TableColumn,拖放操作将仅适用于该特定单元格,而不适用于整行。将修改器添加到所有单元格时,在例如行内的空白区域中拖动时,它仍然不起作用。
struct Item: Identifiable, Codable, Transferable {
let id = UUID()
let text: String
static var transferRepresentation: some TransferRepresentation {
CodableRepresentation(contentType: .text)
}
}
struct Test: View {
var body: some View {
Table {
TableColumn("Column 1") { item in
Text(item.text)
.draggable(item) // This does only work when dragging not in the space between two columns
} …Run Code Online (Sandbox Code Playgroud)