Swift File Format and ABI

##ABI

###Name Demangling:

####Simple Protocol:

Swift namespace:

_TtPSs(protocol name length)(protocol name)

Non-Swift namespace:

_TtP(namespace name length)(namespace name)(protocol name length)(protocol name)

####Simple Class:

Swift namespace:

_TtCSs(class name length)(class name)

Non-Swift namespace

_TtC(namespace name length)(namespace name)(class name length)(class name)

##File Format

###Offset: 0x0

####.swiftmodule + .swiftdoc

E2 9C A8

###Offset: 0x3

####.swiftmodule

0E

####.swiftdoc

07

###Offset: 0x4

####.swiftmodule + .swiftdoc

01 08 00 00

###Offset: 0x8

####.swiftmodule

9E 05 00 00

####.swiftdoc

22 00 00 00

...

####.swiftmodule regardless of platform the first 5768 bytes of the file is the same

####.swiftdoc regardless of platform the first 152 bytes of the file is the same

...

####.swiftdoc

name mangling:

[4 bytes] = full length of item string
[4 bytes] = unknown
s:*#_____#____#____
* = unknown
# = number of characters per segment of the described item
_____ = name of item

comment format:

[01 00 00 00] = prefix
[4 bytes] = length of described comment
[N bytes] = comment string (non-null terminated.)

...

####.swiftmodule + .swiftdoc

end in 12 bytes of zero

00 00 00 00     00 00 00 00     00 00 00 00


If this blog post was helpful to you, please consider donating to keep this blog alive, thank you!

donate to support this blog