Scenario 1: The AppStore package exported by Achieve

DistributionSummary.plist
ExportOptions.plist
Packaging.log
xxx.ipa
Copy the code
  • DistributionSummaryContains ipA support architecture, bitcode, certificate, embeddedBinaries (non-system dynamic library related), Entitlements (APNS environment, Application-Identifier, etc.), profile, and other related information
  • ExportOptionsPp file etc.
  • Packaging.logPackaging log
  • xxx.ipaPackage content

xxx.ipa

Full name: iPhone Application

The IPA file is essentially a ZIP package

Ipa size: 377.8MB

Decompress the suffix xxx.zip to obtain the following information:

  • The size of xxx.app in the payload directory is 114.6MB
  • The BCSymbolMaps Symbol file, the mapping table generated by Xcode after Symbol Hiding on the BitCode Symbol table, will be one-to-one corresponding to the dSYM file.
  • SwiftSupport SwiftSupport. Before ios12.2, swift standard library was placed in app, resulting in package size increase

Analysis of XXX. The app

Display package contents: This table contains a lot of contents, sorted as follows:

  • CodeResources file signature, which is a plist file that holds the plaintext hashes of every file in the app except the executable of the app

This file is generated when the app is signed by the codesign command

  • Assets. Car Image resource 334K + 1.7MB

Assets. Car View method github.com/insidegui/A…

  • Embedded. Mobileprovision Production certificate
  • The Frameworks dynamic library (both native and system) is 373.5MB in size
  • Info.plist
  • PlugIns (today Extension, etc.) are 1.8MB in size
  • Other image resources and bundles
  • XXX Unix executable file size 280.7MB

Scenario 2: IPA exported from the AppStore

Phones: iPhone11Pro, 6Pro

OS: iOS14.2 and 12.2

Obtained through Apple Configure2

xxx.ipa

Full name: iPhone Application

The IPA file is essentially a ZIP package

Ipa size: 88.6MB

Decompress the suffix xxx.zip to obtain the following information:

  • ITunesArtwork, in essence, is a PNG image without a suffix
  • Itunesmetadata. plist, which records buyer information and price data.
  • Stores information describing data attributes and contains two subfiles:

Com. Apple. FixedZipMetadata. Bin, com. Apple. ZipMetadata. Plist

  • The size of xxx.app in the payload directory is 114.6MB

Analysis of XXX. The app

Display package contents: This table contains a lot of contents, sorted as follows:

  • CodeResources file signature, which is a plist file that holds the plaintext hashes of every file in the app except the executable of the app

This file is generated when the app is signed by the codesign command

  • Assets. Car Image resource 334K + 1.7MB

Assets. Car View method github.com/insidegui/A…

  • Embedded. Mobileprovision Production certificate
  • The Frameworks dynamic library (own and system) is 47.5MB in size
  • Info.plist
  • PlugIns (such as today Extension) are 0.54MB in size
  • Other image resources and bundles
  • The XXX Unix executable is 46.7MB in size
  • SC_Info
SC_Info content manifest.plist yourapp.sinf yourapp.supf myapp.supp myapp.supxCopy the code

Sinf is the metadata file. Supp is the key to decrypt the executable file

There are obvious differences between scenario 1 and Scenario 2 xxx.IPA

The name of the Size (MB)
Ipa in scenario 1 377.8 MB
Ipa in scenario 2 88.6 MB
Frameworks in Scenario 1 373.5 MB
Frameworks in Scenario 2 47.5 MB
The XXX Unix executable in scenario 1 280.7 MB
The XXX Unix executable in scenario 2 46.7 MB

App Slicing

Phone: iPhone11Pro, iphone6Pro are obtained through Apple Configure2, not jailbroken IPA

App Slicing doesn’t work for Assets in a package

I found App Slicing had no effect on Assets in the package. Assets. Car in the package still contains 2x diagrams.

Meanwhile, App Slicing in IPA I got through Ace’s assistant had the same result

So I’m a little confused about whether App Slicing is effective only if downloaded from the App Store

App Slicing works well with binaries

Scenario 1: The Mach-O file is 280.7MB Scenario 2: the Mach-O file is 46.7MB

240MB smaller, 1/6 of the original size

IOS default instruction set armv7 | armv7s | arm64 | arm64e is ARM processor's instruction set simulator: i386: under the iphone 5 / iphone5c simulator x86_64: iPhone5s above simulator's machine: armv6: IPhone3Gs, iPhone4, iPhone4s, iPad, iPad 2 armV7s: iPhone 3GS, iPhone4, iPhone4s, iPad 2 armV7s: IPhone5, iPhone5c arm64: iPhone5s, iPhone6, iPhone6p, iPhone6s, iPhone6sp, iPhone7, iPhone7p, iPhone8, iPhone8p, iPhoneX arm64E: IPhone XS, iPhone XS Max, iPhone XR, iPhone 11, iPhone 11 Pro, iPhone 11 Pro Max Emulator 32-bit processor requires i386 architecture emulator 64-bit processor requires X86_64 architecture Real 32-bit processor requires ARMV7, or ARMV7S architecture real 64-bit processor requires ARM64 or ARM64E architecture Source: https://www.jianshu.com/p/5f1e87b82ecb Jane books copyright owned by the author. Commercial reprint please contact the author for authorization, non-commercial reprint please indicate the source.Copy the code

App Bitcode thin body

Bitcode is an intermediate code of the LLVM compiler. The App Store server can package different executable machine instruction data according to different CPU architectures, including undeveloped architectures, which seem to have no real effect on the size of the app downloaded by users.

After opening Bitcode, the package downloaded by real users is compiled by the Appstore server, so the local symbol table is invalid and you need to download it from the official website

The App Link – Time thin body

Modify link-time Optimization=Incremental in Build Settings

Analysis of the link map

If Write Link Map File is set to Yes, a Link Map File is generated in the default path after the Build is complete

/Users/a2020/Library/Developer/Xcode/DerivedData/myapp-hblkggblkurwjjacpdugtpzutctm/Build/Intermediates.noindex/myapp.bu ild/BetaDebug-iphoneos/myapp.build/myapp_Beta-LinkMap-normal-arm64.txtCopy the code

Executable file flow:

Preprocessing -> Compilation -> Assembly -> links

Generate.o files (object files, executable files) after assembly

Myapp_beta-linkmap-normal-arm64. TXT is used to record link information

It could be tens of trillions in size

What is a Link Map File used for?

  • View the code load order
  • Understand segmented memory partitioning
  • The mechanism of locating source code through Symbols in Crash
  • Analyze class or library volume in executable files and optimize package volume

Reference links! : www.jianshu.com/p/52e0dee35…

Its general contents are as follows:

# Path: /Users/a2020/Library/Developer/Xcode/DerivedData/myapp-hblkggblkurwjjacpdugtpzutctm/Build/Products/BetaDebug-iphoneos/myapp_Beta.app/myapp_Beta
# Arch: arm64
# Object files:
[  0] linker synthesized
[  1] dtrace
[  2] /Users/a2020/Library/Developer/Xcode/DerivedData/myapp-hblkggblkurwjjacpdugtpzutctm/Build/Intermediates.noindex/myapp.build/BetaDebug-iphoneos/myapp.build/Objects-normal/arm64/AppDelegate+Net.o
[  3] /Users/a2020/Library/Developer/Xcode/DerivedData/myapp-hblkggblkurwjjacpdugtpzutctm/Build/Intermediates.noindex/myapp.build/BetaDebug-iphoneos/myapp.build/Objects-normal/arm64/AppDelegate+Login.o
[  4] /Users/a2020/Library/Developer/Xcode/DerivedData/myapp-hblkggblkurwjjacpdugtpzutctm/Build/Intermediates.noindex/myapp.build/BetaDebug-iphoneos/myapp.build/Objects-normal/arm64/AppDelegate+IM.o
[  5] /Users/a2020/Library/Developer/Xcode/DerivedData/myapp-hblkggblkurwjjacpdugtpzutctm/Build/Intermediates.noindex/myapp.build/BetaDebug-iphoneos/myapp.build/Objects-normal/arm64/AppDelegate+Firebase.o
[  6] /Users/a2020/Library/Developer/Xcode/DerivedData/myapp-hblkggblkurwjjacpdugtpzutctm/Build/Intermediates.noindex/myapp.build/BetaDebug-iphoneos/myapp.build/Objects-normal/arm64/Target_TabBar.o
[  7] /Users/a2020/Library/Developer/Xcode/DerivedData/myapp-hblkggblkurwjjacpdugtpzutctm/Build/Intermediates.noindex/myapp.build/BetaDebug-iphoneos/myapp.build/Objects-normal/arm64/AppDelegate+BackgroundTask.o
[  8] /Users/a2020/Library/Developer/Xcode/DerivedData/myapp-hblkggblkurwjjacpdugtpzutctm/Build/Intermediates.noindex/myapp.build/BetaDebug-iphoneos/myapp.build/Objects-normal/arm64/AppDelegate+Token.o
[  9] /Users/a2020/Library/Developer/Xcode/DerivedData/myapp-hblkggblkurwjjacpdugtpzutctm/Build/Intermediates.noindex/myapp.build/BetaDebug-iphoneos/myapp.build/Objects-normal/arm64/AppDelegate+TPNS.o
[ 10] /Users/a2020/Library/Developer/Xcode/DerivedData/myapp-hblkggblkurwjjacpdugtpzutctm/Build/Intermediates.noindex/myapp.build/BetaDebug-iphoneos/myapp.build/Objects-normal/arm64/AppDelegate+Custom.o
[ 11] /Users/a2020/Library/Developer/Xcode/DerivedData/myapp-hblkggblkurwjjacpdugtpzutctm/Build/Intermediates.noindex/myapp.build/BetaDebug-iphoneos/myapp.build/Objects-normal/arm64/AppDelegate.o
[ 12] /Users/a2020/Library/Developer/Xcode/DerivedData/myapp-hblkggblkurwjjacpdugtpzutctm/Build/Intermediates.noindex/myapp.build/BetaDebug-iphoneos/myapp.build/Objects-normal/arm64/AppTabBarController.o
路路路
路路路
[2729] /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS14.3.sdk/usr/lib/swift/libswiftDarwin.tbd
[2730] /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS14.3.sdk/usr/lib/swift/libswiftCoreGraphics.tbd
# Sections:
# Address	Size    	Segment	Section
0x100007940	0x00E95C20	__TEXT	__text
0x100E9D560	0x000071B8	__TEXT	__stubs
0x100EA4718	0x00006018	__TEXT	__stub_helper
0x100EAA730	0x000136D6	__TEXT	__swift5_typeref
0x100EBDE08	0x0000E578	__TEXT	__swift5_capture
0x100ECC380	0x000B772B	__TEXT	__cstring
0x100F83AAB	0x00068FF9	__TEXT	__objc_methname
0x100FECAB0	0x00084720	__TEXT	__const
0x1010711D0	0x00000A14	__TEXT	__swift5_builtin
路路路
# Symbols:
# Address	Size    	File  Name
0x100007940	0x00000970	[  2] _$s14myapp_Beta11AppDelegateC8setupNetyyF
0x1000082B0	0x00000040	[  2] l_objectdestroy
0x1000082F0	0x0000015C	[  2] _$s14myapp_Beta11AppDelegateC8setupNetyyFySi_SDySSypGSgtcfU_
0x10000844C	0x00000008	[  2] _$s14myapp_Beta11AppDelegateC8setupNetyyFySi_SDySSypGSgtcfU_TA
0x100008454	0x00000078	[  2] ___swift_instantiateConcreteTypeFromMangledName
0x1000084CC	0x0000002C	[  2] _$sSSWOh
0x1000084F8	0x00000058	[  2] ___swift_project_boxed_opaque_existential_1
0x100008550	0x00000070	[  2] ___swift_destroy_boxed_opaque_existential_1
0x1000085C0	0x00000058	[  2] ___swift_project_boxed_opaque_existential_0
0x100008618	0x00000070	[  2] ___swift_destroy_boxed_opaque_existential_0
0x100008688	0x000005AC	[  2] _$s14myapp_Beta11AppDelegateC21ct_listeningErrorCode4code4dataySi_SDySSypGSgtF
0x100008C34	0x0000002C	[  2] _$ss26DefaultStringInterpolationVWOh
0x100008C60	0x0000002C	[  2] _$ss10debugPrint_9separator10terminatoryypd_S2StFfA0_
0x100008C8C	0x0000002C	[  2] _$ss10debugPrint_9separator10terminatoryypd_S2StFfA1_
0x100008CB8	0x00000030	[  2] _$sypSgWOh
0x100008CE8	0x00000074	[  2] _$sSNySiGSNyxGSXsWl
0x100008D5C	0x000000A0	[  2] _$sSNySiGMa
0x100008DFC	0x00000044	[  2] _$sSSSgWOc
0x100008E40	0x000000D8	[  2] _$s14myapp_Beta11AppDelegateC21ct_listeningErrorCode4code4dataySi_SDySSypGSgtFTo
0x100008F18	0x00000308	[  3] _$s14myapp_Beta11AppDelegateC21toLoginViewController6reasonySS_tF
0x100009220	0x0000002C	[  3] _$sSo8UIWindowCSgWOh
0x10000924C	0x00000250	[  3] _$s14myapp_Beta11AppDelegateC22toTabbarViewControlleryyF
0x10000949C	0x00000264	[  3] _$s14myapp_Beta11AppDelegateC31toPerfectUserInfoViewControlleryyF
0x100009700	0x000001E0	[  4] _$s14myapp_Beta11AppDelegateC7setupIMyyF
0x1000098E0	0x0000056C	[  4] _$s14myapp_Beta11AppDelegateC7imLoginyyF
0x100009E4C	0x00000120	[  4] _$s14myapp_Beta11AppDelegateC9imReLogin33_17381B2BC94020957961CA3A3A401E51LLyyF
0x100009F6C	0x00000088	[  4] _$s14myapp_Beta11AppDelegateC9imReLogin33_17381B2BC94020957961CA3A3A401E51LLyyFySDySSypGSg_s5Error_pSgtcfU
路路路
0x1007E9BB0	0x0000003C	[1354] ___68-[HWPanModalPresentableHandler setScrollableContentOffset:animated:]_block_invoke
0x1007E9BEC	0x000001A8	[1354] -[HWPanModalPresentableHandler configureViewLayout]
0x1007E9D94	0x000000B8	[1354] -[HWPanModalPresentableHandler gestureRecognizer:shouldRecognizeSimultaneouslyWithGestureRecognizer:]
0x1007E9E4C	0x000000C8	[1354] -[HWPanModalPresentableHandler gestureRecognizer:shouldBeRequiredToFailByGestureRecognizer:]
0x1007E9F14	0x0000022C	[1354] -[HWPanModalPresentableHandler gestureRecognizerShouldBegin:]
0x1007EA140	0x0000010C	[1354] -[HWPanModalPresentableHandler addKeyboardObserver]
0x1007EA24C	0x00000050	[1354] -[HWPanModalPresentableHandler removeKeyboardObserver]
0x1007EA29C	0x000000CC	[1354] -[HWPanModalPresentableHandler keyboardWillShow:]
0x1007EA368	0x000001E0	[1354] -[HWPanModalPresentableHandler keyboardWillHide:]
0x1007EA548	0x0000048C	[1354] -[HWPanModalPresentableHandler updatePanContainerFrameForKeyboard]
0x1007EA9D4	0x000001F4	[1354] -[HWPanModalPresentableHandler findCurrentTextInputInView:]
0x1007EABC8	0x0000006C	[1354] -[HWPanModalPresentableHandler transitionToState:]
0x1007EAC34	0x0000005C	[1354] -[HWPanModalPresentableHandler cancelInteractiveTransition]
0x1007EAC90	0x0000005C	[1354] -[HWPanModalPresentableHandler finishInteractiveTransition]
0x1007EACEC	0x00000074	[1354] -[HWPanModalPresentableHandler dismissPresentable:mode:]
0x1007EAD60	0x000000CC	[1354] -[HWPanModalPresentableHandler isPresentedViewAnchored]
0x1007EAE2C	0x000000CC	[1354] -[HWPanModalPresentableHandler isBeingDismissed]
0x1007EAEF8	0x000000CC	[1354] -[HWPanModalPresentableHandler isBeingPresented]
0x1007EAFC4	0x000000CC	[1354] -[HWPanModalPresentableHandler isPresentedViewControllerIn
路路路
0x1016C9480	0x00000008	[2681] _gXGPushExtendClass
0x1016C9488	0x0000001C	[2707] _tpns_cipher_supported

# Dead Stripped Symbols:
#        	Size    	File  Name
<<dead>> 	0x00000004	[  2] literal string: iOS
<<dead>> 	0x00000001	[  2] literal string: 
<<dead>> 	0x00000001	[  2] literal string: 
<<dead>> 	0x00000001	[  2] literal string: 
<<dead>> 	0x00000001	[  2] literal string: 
<<dead>> 	0x00000001	[  2] literal string: 
<<dead>> 	0x00000001	[  2] literal string: 
<<dead>> 	0x00000001	[  2] literal string: 
<<dead>> 	0x00000001	[  2] literal string: 
<<dead>> 	0x00000001	[  2] literal string: 
<<dead>> 	0x00000001	[  2] literal string: 
<<dead>> 	0x00000001	[  2] literal string: 
<<dead>> 	0x00000001	[  2] literal string: 
<<dead>> 	0x00000001	[  2] literal string: 
<<dead>> 	0x00000001	[  2] literal string: 
路路路
路路路
Copy the code

Analysis tools:

Github.com/huanxsd/Lin…

Dynamic and static libraries

In theory: dynamically compiling into an executable. O, only “copying” some relocation and symbol table information, the actual linking is done while the program is running

It is also obvious that “static library linked executables” are much larger than “dynamic library linked executables”

However, it should not be ignored that for APP, the size of static library link executable < dynamic library size + dynamic library link executable size

The specific formula is as follows:

Dynamic library size + dynamic library linked executable size – relocation and symbol table information = static library linked executable size

Why is ADHoc smaller than an appstore package?

The size of the adhoc package is 57MB. The size of the appstore package is 88MB

Adhoc ipa decompressed directory:

AppThinning.plist
Payload
Copy the code

Store IPA decompressed directory:

META-INF
Payload
iTunesArtwork
iTunesMetadata.plist
Copy the code

The adhoc ipa lacks all the documentation in the catalog compared to the appstore ipa.

However, iTunesArtwork and Itunesmetadata. plist are relatively small, and together they are only 500K

The real difference is in Payload

The size of xxx.app in the Payload of the adhoc package is 136.6MB. The size of xxx.app in the Payload of the appstore package is 114.6MB

Is it because of the high compression ratio of xxx.app in adhoc packet Payload?
The Payload in the App Store package has a lower compression of xxx.app.

practice

The size of the xxx.app zip in the adhoc packet Payload is 54MB

The size of the xxx.app zip in the Payload of the appstore package is 89MB

So why are the compression rates so different? In doubt…