After the IOS app compiles, in addition to some resource files, the rest is an executable file, sometimes the project is large, the introduction of more libraries, executable file is very large, want to know the composition of this executable file, what the content is what, which library occupies a high space, can be surveyed in the following ways:
1.XCode turn on compile option write Link Map File
Set the Write Link map file option to Yes and specify the storage location for the Linkmap, Settings, Build, XCode, Project,
2. After compiling, find the TXT file in the compilation directory, the file name and path are the above path to Link Map file
Located in ~/library/developer/xcode/deriveddata/xxx-eumsvrzbvgfofvbfsoqokmjprvuh/build/intermediates/xxx.build/ debug-iphoneos/xxx.build/
This linkmap shows a complete picture of the entire executable, listing each of the compiled. O Target file information (including the static link library. A), and the code snippet for each target file, and the data segment to store the details.
a
In the case of the Iraq Book project, the list of target files is listed first in Linkmap:
# Object files:[0] linker synthesized
[1]/applications/xcode.app/contents/developer/platforms/iphonesimulator.platform/developer/sdks/ iphonesimulator7.0.sdk/usr/lib/crt1.o
...
[280]/USERS/BANG/DOWNLOADS/YISHU/YISHU/CLASSES/LIB/UMENG/MOBCLICK/LIBMOBCLICKLIBRARY.A (UMANJOB.O)
[281]/users/bang/downloads/yishu/yishu/classes/lib/umeng/mobclick/libmobclicklibrary.a (UMANWORKER.O)
...
In the preceding brackets is the number of this file, which will be used later, like the project reference to the static link library libmobclicklibrary.a in the target file will be listed here.
two
Next is a segment table that describes the offset position and size of each segment in the final compiled executable, including the code snippet (__text, the machine code that saved the program snippet) and the data segment (__data, saving the variable value)
# sections:# Address Size Segment section0x00002740 0x00273890 __text __text0x00275fd0 0x00000ada __text __symbol_ Stub ...
0x003375e0 0x000018e8 __data __BSS
The first column is where the data is at the offset of the file, the second column occupies the size, the third column is the segment type, the code snippet and the data segment, and the fourth column is the segment name.
Each row of data is immediately following the previous line, such as the address of the second row of __symbol_stub 0x00275fd0 is the first row __text address 0x00002740 plus the size 0x00273890, the entire executable file approximate data distribution is this.
Here you can see clearly the proportions of the various types of data in the final executable, for example, __text represents the compiled program execution statement, __data represents the initialized global variables and local static variables, __BSS represents uninitialized global variables and local static variables, __ CString represents string constants in the code, and so on.
Three
Then, in the table order, list the specific location and footprint of each corresponding field by each file:
# Address Size File name0x00002740 0x0000003e [1] start0x00002780 0x00000400 [2] +[tkpfileinfo parsewithdictionary:]0x00 002b80 0x00000030 [2]-[tkpfileinfo FileID] ...
The same first column is the data in the file offset address, the second column is occupied size, the third column belongs to the file ordinal, corresponding to the above object files list, and finally the name.
For example, the second line represents a file sequence number of 2 (the reverse check is TKPFILEINFO.O) The Parsewithdictionary method occupies 1000byte size.
Use
This file can let you know the whole app after compiling the situation, perhaps you can find some exceptions, you can also use this file to calculate the static link library in the project accounted for the size, sometimes we chain a lot of third-party libraries in the project, resulting in the app volume is much larger, we want to know exactly how much space each library occupies, can give us a direction to optimize. Linkmap has each target file each method each data occupies the size data, so just write a script, you can count each. o The last size, belongs to a. A static link library of. O adds up, which is the amount of space the library occupies in the app.
The composition of the IOS app executable file