简体   繁体   English

Xcode 10自动完成功能在其他Swift文件中不起作用

[英]Xcode 10 autocomplete not working in other swift file

Xcode Version 10.0 (10A255) Xcode版本10.0(10A255)

I have a struct in MyStruct.swift 我在MyStruct.swift中有一个结构

struct MyStruct {
  var aa = ""
  var bb = ""
}

In MyStruct.swift autocomplete it's working. 在MyStruct.swift自动完成功能中。

在此处输入图片说明

In other file it's not working. 在其他文件中,它不起作用。

在此处输入图片说明

I try deleting derivedData, it's not working too :( 我尝试删除导出数据,它也不起作用:(

It seems like there is some issue with the auto-suggestion in Xcode-10. 似乎Xcode-10中的自动建议存在一些问题。 I just tried with the below example and found that suggestion were not appearing for default initialisation. 我只是尝试使用下面的示例,发现默认初始化没有出现建议。 However if you write and compile, it will work. 但是,如果您编写和编译,它将起作用。

let newObj = MyStruct(aa: "1", bb: "2")

Even if you want to debug it more, use init method, it will show auto-suggestion as well: 即使您想对其进行更多调试,请使用init方法,它也会显示自动建议:

let newObj1 = MyStruct.init(aa: "A", bb: "B")

MyStruct.swift

import Foundation

struct MyStruct {
    var aa = ""
    var bb = ""
}

func test() {
    let myStruct = MyStruct(aa: "", bb: "")
    print(myStruct)
}

ViewController.swift

import UIKit

override func viewDidLoad() {
    super.viewDidLoad()
    let newObj = MyStruct(aa: "1", bb: "2")
    print(newObj)

    let newObj1 = MyStruct.init(aa: "A", bb: "B")
    print(newObj1)
}

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

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