How do I import a swift function declared in a compiled .swiftmodule into another swift file?

前端 未结 3 729
死守一世寂寞
死守一世寂寞 2020-12-15 20:40

Is there a way to declare a function in a .swift file (that is compiled into a .swiftmodule), like so:

hello.swift

func hello_world() {
    println(\         


        
3条回答
  •  借酒劲吻你
    2020-12-15 20:52

    You don't actually have to import files in swift at the moment. Because all files are public to your program, you can call methods with a simple let helloSwift = hello You are defining a constant named helloSwift which is used as global hello. Of course, you cant just declare this without a class or a struct, but that is a whole other lesson. Just know that instead of importing, you use let.

提交回复
热议问题