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 a good linkmap storage location, Settings, Build, XCode-
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.
1
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[2]/Users/bang/Library/Developer/ xcode/deriveddata/yishu-eyzgphknrrzpevagadjtwpzzeqag/build/intermediates/yishu.build/debug-iphonesimulator/ YISHU.BUILD/OBJECTS-NORMAL/I386/TKPFILEINFO.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) [282]/Users/bang/ DOWNLOADS/YISHU/YISHU/CLASSES/LIB/UMENG/MOBCLICK/LIBMOBCLICKLIBRARY.A (MOBCLICK.O) [283]/Users/bang/Downloads/ YISHU/YISHU/CLASSES/LIB/UMENG/MOBCLICK/LIBMOBCLICKLIBRARY.A (UMANLAUNCH.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.
2
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_ STUB0X00276AAC 0x00001222 __text __stub_helper0x00277cce 0x00019d9e __text __objc_methname0x00291a70 0x00012847 __TEXT __cstring0x002a42b7 0x00001fc1 __text __objc_classname0x002a6278 0x000046a7 __text __objc_methtype0x002AA920 0x000061ce __text __ustring0x002b0af0 0x00000764 __text __const0x002b1254 0x000028b8 __TEXT __gcc_except_tab0x002B3B0C 0x00004ebc __text __unwind_info0x002b89c8 0x0003662c __text __eh_frame0x002ef000 0x00000014 __DATA __PROGRAM_ vars0x002ef014 0x00000284 __data __nl_symbol_ptr0x002ef298 0x0000073c __data __la_symbol_ptr0x002ef9e0 0x000030A4 __ DATA __const0x002f2a84 0x00000590 __data __objc_classlist0x002f3014 0x0000000c __data __objc_nlclslist0x002F3020 0x0000006c __data __objc_catlist0x002f308c 0x000000d8 __data __objc_protolist0x002f3164 0x00000008 __DATA __objc_ imageinfo0x002f3170 0x0002bc80 __data __objc_const0x0031edf0 0x00003a30 __data __objc_selrefs0x00322820 0x00000014 __data __objc_protorefs0x00322834 0x000006b8 __DATA __objc_classrefs0x00322EEC 0x00000394 __data __objc_superrefs0x00323280 0x000037c8 __data __objc_data0x00326a48 0x000096D0 __DATA __ cfstring0x00330118 0x00001424 __data __objc_ivar0x00331540 0x00006080 __data __data0x003375c0 0x0000001C __DATA __ Common0x003375e0 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.
3
Then, in the table order, list the specific location and footprint of each corresponding field per 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