简体   繁体   中英

Xcode 10 autocomplete not working in other swift file

Xcode Version 10.0 (10A255)

I have a struct in MyStruct.swift

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

In MyStruct.swift autocomplete it's working.

在此处输入图片说明

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. 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:

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)
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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