What is build object file extension in iOS?

后端 未结 3 554
故里飘歌
故里飘歌 2020-12-07 06:22

When I build java object class in a project, build file will be created with .class extension and human unreadable; What about swift build files?

example:

相关标签:
3条回答
  • 2020-12-07 06:33

    The compilation process is a bit different with Swift to Java, so there isn't necessarily a direct equivalent.

    As the build proceeds though each Swift file will get compiled in to an 'Object' file, ending in a .o extension. Then once they're all built they get linked together to form the binary. If you unpick an iOS app's IPA file, you won't see the individual .o files like how you can see the .class files inside a Java jar file.

    0 讨论(0)
  • 2020-12-07 06:37

    In iOS world every sources file - .m, .h, .swift are compiled into executable byte code that is understandable by CPU. These files are also called Mach object - ABI Mach-O (.o)[About] file with a meta-information.

    `*.swift` -> `*.o` (Mach-O object file).
    

    For example if you created a static library - myLibrary.a. You can use nm[About] command to display name list (symbol table).

    nm path/myLibrary.a
    

    As a result you will see a list of *.o files with methods, variables names etc.

    [Xcode build process]

    0 讨论(0)
  • 2020-12-07 06:44

    One thing I know is that Swift uses LLVM just like Objective-C.

    So in Java, we have this (source: W3schools).

    And here, for Swift (source: Swift.org)

    I hope this helps!

    0 讨论(0)
提交回复
热议问题