What is build object file extension in iOS?
Asked Answered
S

3

2

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:

car.java  --> build --> car.class

what would be after build?

car.swift --> build --> ?
Seaborne answered 11/10, 2018 at 9:38 Comment(1)
I think you are interested in this article: bignerdranch.com/blog/…Lemmuela
S
4

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.

Schuck answered 11/10, 2018 at 9:56 Comment(0)
D
4

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

So in Java, we have this (source: W3schools). enter image description here

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

enter image description here

I hope this helps!

Decision answered 11/10, 2018 at 9:58 Comment(0)
K
2

Mach-O format

[LLVM]

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(.o) - ABI Mach-O[About] file which contains nexts grouped bytes with a meta-information

  • Mach-O header - general information like cpu type(CPU_TYPE)
  • Load Commands - table of contents
  • Raw segment data - code

This groups are repeated for every architecture(Universal library)[About]

`*.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.

To investigate Mach-O file you can use otool[About]

[Mach-O Type]

[Xcode build process]

Kizzee answered 6/12, 2019 at 13:54 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.