首页 > 解决方案 > Xcode 完成不能跨多个源文件工作

问题描述

我简化了这个问题。
我有 2 个快速文件。

第一个包含结构定义。第二个包含结构声明。

// swift file 1
// definition of struct

import Foundation

struct river {
    var color = ""
    var depth = 0
}

当我在 swift 文件 2 中使用这个结构来声明一个常量(tiber)时,我确实看到了 Xcode 的完成功能建议的结构,但是当我键入after时S river,完成并没有显示变量(color和) 。 depth(river

基本上,我必须手动输入结构声明的变量。

// swift file 2
// declaration of struct

import Foundation

let tiber = river(color: "blue", depth: 15) // "color: "blue", depth: 15" manually typed

现在,当我river第二次使用时,变量的完成效果很好。

// swift file 2
// declaration of struct

import Foundation

let tiber = river(color: "blue", depth: 15) // "color:, depth: " manually typed
let nile = river(color: "green", depth: 11) // "color:, depth: " was suggested properly by completition

这里出了什么问题?

此外,当结构定义和声明位于同一个文件中时,完成工作正常!

我有一些相当广泛的结构,我肯定希望完成工作正常。

我阅读了一些帖子,删除该文件夹DerivedData可能会有所帮助。但是我不想深入到文件系统中。macOS 和 Xcode 是全新安装。

标签: swiftxcodeautocomplete

解决方案


推荐阅读