小编Zor*_*ayr的帖子

Xcode 12 代码审查编辑器无法打开,因为它无法在源代码管理中找到文件

我有一个主“app”文件夹,它是 git 存储库的根目录。在这里,我有“ios-app”文件夹,其中我的 Xcode xcworkspace 位于“android-app”、“backend”等其他文件夹中。令人惊讶的是,Xcode 确实显示了文件的状态(即 M 表示已修改),而我能够使用 Fetch Changes 菜单选项,但我无法使用 Xcode 提交或在代码审查编辑器中查看文件。

打开代码预览时出错:

The source control operation failed because the file “...” could not be found.
Make sure a valid file exists in the repository and try again.
Run Code Online (Sandbox Code Playgroud)

在此处输入图片说明

提交时出错:

The working copy “...” failed to commit files.
error: pathspec 'app/ios-app/DataModel/EventMutations.swift' did not match any file(s) known to git
Run Code Online (Sandbox Code Playgroud)

在此处输入图片说明

控制台应用程序中没有什么有趣的,但以下细节可能是相关的:

[MT] DVTAssertions: Warning in /Library/Caches/com.apple.xbs/Sources/IDEFrameworks/IDEFrameworks-17220/IDEKit/CommandsAndSelection/IDEMenuBuilder.m:203
Details:  Unknown submenu: "Xcode.IDEPegasusSourceEditor.MenuDefinition.SourceCodeAuxiliaryEditorMenuItem3" in menu: "Xcode.IDEPegasusSourceEditor.MenuDefinition.Editor"!
Object:   <IDEMenuBuilder>
Method:   +_menuItemForMenuItemElement:inMenuWithIdentifierUsedForDebugging:forViewController:fillingExtensionIdToMenuMap:
Thread:   <NSThread: 0x7fb3aa517540>{number …
Run Code Online (Sandbox Code Playgroud)

git xcode ios swift

6
推荐指数
1
解决办法
830
查看次数

如何将文件和文件夹树复制到远程计算机?

我有两台服务器A和服务器B,我想使用PowerShell将所有文件和文件夹树从服务器A复制到服务器B.

我已经尝试了下面给出的命令,但它只复制文件夹中的文件而不创建文件夹树:

Copy-Item E:\TestSource\* //TestDestination/ -recurse -force
Run Code Online (Sandbox Code Playgroud)

directory powershell copy file copy-item

5
推荐指数
2
解决办法
1万
查看次数

HTML5 WebSocket:客户端的消息在Google Chrome 22中缓存

我正在编写一个基于HTML5 WebSocket技术的非常简单的聊天应用程序,其中服务器(使用node.js WS实现)跟踪所有连接的用户并广播每个接收的消息.另一方面,客户端连接到服务器,并根据用户的操作,将消息发送到服务器.

我观察到的问题是,除非服务器在打开连接后向客户端发送消息,否则从Google Chrome上运行的客户端发送的所有消息都会被缓冲,直到发送了几条消息.缓冲区已满后,将立即发送所有消息.这为最终用户创建了非常无响应的聊天体验.

我发现的修复是ws.send("Hello Client:" + clientId);在服务器端打开连接后添加单个,但我不确定为什么这是必要的?您可以在下面找到我的客户端和服务器组件的代码段,但ChatMate git项目中提供了完整的源代码.

服务器代码:

wsServer.on('connection', function (ws) {
    var clientId = nextClientId += 1;
    clients[clientId] = ws;
    log("Accepted connection from client " + clientId + ".");

    //The fix: If you emit this initial message from the server, then
    //all of client's messages will be cached. 
    ws.send("Hello Client: " + clientId);

    ws.on('message', function (message) {
        log("Received message: " + message);
        var id;
        for (id …
Run Code Online (Sandbox Code Playgroud)

javascript html5 google-chrome websocket

5
推荐指数
0
解决办法
2479
查看次数

SwiftUI - NavigationLink 内容加载过早

我的第一个视图中有一个基本列表,如下所示:

func buildList(sections: [Client]) -> some View {
    let list = List {
        ForEach(sections) { client in
            Section(header: Text(client.name)) {
                ForEach(client.projects) { project in
                    NavigationLink(destination: BuildsRouter.build(forProject: project)) {
                        HStack {
                            Text("Test \(project.id)").fontWeight(.ultraLight)
                        }
                    }
                }
            }
        }
    }
    return  list
}
Run Code Online (Sandbox Code Playgroud)

我正在NavigationLink为我的Project对象提供详细信息视图。

事情是,当我做一个内存分析图,我可以看到BuildsView(从创建BuildsRouter.build(forProject: project)之前,我确实点击导航链接创建

问题: 有没有办法在点击链接后创建详细信息视图?

ios swift swiftui swiftui-list

5
推荐指数
1
解决办法
1110
查看次数

Why does setting minWidth to .infinity crash SwiftUI app with EXC_BAD_INSTRUCTION?

Here is the exact code that I am running on iOS 13.4/Xcode 11.4:

import SwiftUI

struct TestView: View {

    var body: some View {
        VStack() {
            Text("Hello")
        }
        .frame(minWidth: .infinity)
    }
}

struct LoginView_Previews: PreviewProvider {
    static var previews: some View {
        TestView()
    }
}
Run Code Online (Sandbox Code Playgroud)

The crash happens in iOS, so it's hard to get much useful information other than the following:

Thread 1: EXC_BAD_INSTRUCTION (code=EXC_I386_INVOP, subcode=0x0)
#0  0x00007fff2c7cd371 in NSAttributedString.MetricsCache.findMetrics(requestedSize:) ()
Run Code Online (Sandbox Code Playgroud)

Setting minWidth to something other than .infinity fixes …

xcode swift swiftui xcode11.4 ios13.4

5
推荐指数
1
解决办法
1487
查看次数

我在哪里可以找到 firebase-debug.log 以了解为什么模拟器没有完全关闭?

我正在使用firebase emulators:start启动 firebase 模拟器。当通过 Ctrl+C 关闭它时,它告诉我它没有正确关闭,我需要咨询firebase-debug.log无处可寻。我怀疑它应该在与云功能相关的所有其他内容所在的函数/文件夹中,但它不在那里。

i  emulators: Shutting down emulators.
i  hub: Stopping emulator hub
i  ui: Stopping Emulator UI
?  Emulator UI has exited upon receiving signal: SIGINT
i  logging: Stopping Logging Emulator
i  functions: Stopping Functions Emulator
i  firestore: Stopping Firestore Emulator
i  database: Stopping Database Emulator
?  emulators: emulators failed to shut down cleanly, see firebase-debug.log for details.
Run Code Online (Sandbox Code Playgroud)

问题是firebase-debug.log找不到。我在哪里可以找到这个调试文件?请参阅以下functions文件夹内容:

在此处输入图片说明

node.js firebase google-cloud-functions google-cloud-firestore

5
推荐指数
1
解决办法
2191
查看次数

SwiftUI NavigationLink push in onAppear 使用@ObservableObject 时立即弹出视图

我想以编程方式能够浏览到内的一个链接ListNavigationLinks时候出现视(深深的建设从推送通知链接)。我有一个字符串 -> Bool 字典,它绑定到Binding<Bool>我的视图中的自定义。当视图出现时,我设置了 bool 属性,导航发生,但是,它立即弹出。我按照SwiftUI NavigationLink 中的答案立即导航回并确保中的每个项目List都有唯一的标识符,但问题仍然存在。

两个问题:

  1. 我这里的绑定逻辑是否正确?
  2. 为什么视图会立即弹出?
import SwiftUI

class ContentViewModel: ObservableObject {
    @Published var isLinkActive:[String: Bool] = [:]
}

struct ContentViewTwo: View {
    @ObservedObject var contentViewModel = ContentViewModel()
    @State var data = ["1", "2", "3"]
    @State var shouldPushPage3: Bool = true

    var page3: some View {
        Text("Page 3")
            .onAppear() {
                print("Page 3 Appeared!")
        }
    }

    func binding(chatId: String) -> Binding<Bool> {
        return .init(get: …
Run Code Online (Sandbox Code Playgroud)

ios swift swiftui swiftui-navigationlink

5
推荐指数
1
解决办法
2550
查看次数

有没有办法从 SwiftUI 中的 ButtonStyle 获取 isDisabled 状态?

我正在制作自己的自定义按钮样式,以简化按钮的外观和感觉。根据按钮是否被禁用,我想改变外观。我发现能够做到这一点的唯一方法是通过isDisabled从顶部传递属性。有没有办法直接从 获取这个ButtonStyle

struct CellButtonStyle: ButtonStyle {

    // Passed from the top... can I get this directly from configuration? 
    let isDisabled: Bool

    func makeBody(configuration: Self.Configuration) -> some View {
        let backgroundColor = isDisabled ? Color.white : Color.black
        return configuration.label
            .padding(7)
            .background(isDisabled || configuration.isPressed ? backgroundColor.opacity(disabledButtonOpacity) : backgroundColor)

    }
}
Run Code Online (Sandbox Code Playgroud)

isDisabled实际的问题是,它会导致创建按钮时处理标志的重复代码:

Button {
    invitedContacts.insert(contact.identifier)
} label: {
    Text(invitedContacts.contains(contact.identifier) ? "Invited" : "Invite")
}
// Passing down isDisabled twice! Would be awesome for the configuration to figure it …
Run Code Online (Sandbox Code Playgroud)

ios swift swiftui

5
推荐指数
1
解决办法
728
查看次数

如何在 Swift Joint Sink 收到至少一个值后停止存储 AnyCancellable?

我有一个接收器,需要在收到第一个值后立即取消。我不关心未来的值,只关心第一个发布的值。因为如果不存储AnyCancelable由接收器创建的,垃圾收集器将删除该接收器,所以我必须存储它。同时,我也必须在sink完成后清理它,否则,我会出现内存泄漏。

\n

我使用 UUID \xe2\x86\x92 AnyCancelable 映射构建了一个,但我担心这比应有的更复杂;还有另一种方法可以做到这一点吗?联合有什么推荐的?

\n
@Published var locationState: (location: CLLocation?, error: Error?)?\nvar requestLocationSinks: [String: AnyCancellable] = [:]\n\n// 1. Generate ID to uniquely identify the current sink.\nlet sinkID = UUID().uuidString\n\n// 2. Start the sink and store it in our ID \xe2\x86\x92 AnyCancellable dictionary.\nrequestLocationSinks[sinkID] = $locationState.sink { locationState in\n    if let locationState = locationState {\n        invokeCallbackWithLocationState(locationState)\n    }\n    // 3. Remove the stored AnyCancellable as soon as we received our first value!\n    self.requestLocationSinks.removeValue(forKey: sinkID)\n}\n
Run Code Online (Sandbox Code Playgroud)\n

ios swift combine

5
推荐指数
1
解决办法
7952
查看次数

如何在 SwiftUI 中为单行文本设置行高?

目前,我一直在使用.lineSpacing(...),但这仅适用于多行文本

/// Sets the amount of space between lines of text in this view.
///
/// - Parameter lineSpacing: The amount of space between the bottom of one
///   line and the top of the next line.
@inlinable public func lineSpacing(_ lineSpacing: CGFloat) -> some View
Run Code Online (Sandbox Code Playgroud)

这意味着我很难准确地从草图/figma 翻译字体,我需要调整填充以使其正确。这是一个示例,说明了这一点:

VStack {
    // Line spacing is ignored.
    Text("Hello, World!")
        .background(Color.green)
        .lineSpacing(50)

    Spacer()

    // Line spacing is correct.
    Text("Lorem ipsum is placeholder text commonly used in the graphic, print, …
Run Code Online (Sandbox Code Playgroud)

iphone xcode ios swift swiftui

4
推荐指数
3
解决办法
7384
查看次数