This is the 11th day of my participation in the Gwen Challenge in November. Check out the details: The last Gwen Challenge in 2021.

Code Generation Options

Options for code generation conventions:

  1. None[-00]Not optimization:
In this setting, the compiler's goal is to reduce compilation costs and ensure that the desired results are produced during debugging. The program statements are independent: if the program stops at a breakpoint on a line, we can assign a new value to any variable or point the program counter to any statement in the method, and get a run result that is exactly the same as the source code.Copy the code
  1. Fast[-01]Large functions require slightly more compile time and memory consumption:
In this setting, the compiler tries to reduce the size of the code file and the execution time, but does not perform optimizations that require a lot of compile time. In Apple's compiler, strict aliases, block rearrangements, and scheduling between blocks are disabled by default during optimization. This optimization level provides a good debugging experience, improved stack utilization, and better code quality than None[-o0].Copy the code
  1. Faster[-02]The compiler performs all supported optimizations that do not involve time-space swapping:
Is higher performance optimization Fast[-O1]. In this setting, the compiler does not loop unwrap, function inlining, or register renaming. Compared with Fast[-o1], this setting increases compilation time, reduces debugging experience, and may increase the code size, but improves the performance of the generated code.Copy the code
  1. Fastest[-03]In the openFast[-01]Enable function inlining and register renaming options while supporting all optimizations:
Faster[-O2] is the higher performance optimization that instructs the compiler to optimize the performance of the generated code, ignoring the size of the generated code, potentially resulting in larger binaries. It also reduces the debugging experience.Copy the code
  1. Fastest, Smallest[-Os]Maximize performance without significantly increasing code size:
This setting enables all optimizations in Fast[-o1] that do not increase the code size, and further optimizations that reduce the code size are performed. The code size increased is smaller than the Fastest[-O3]. It also reduces the debugging experience compared to Fast[-O1].Copy the code
  1. Fastest, Aggressive, Optimizations[-Ofast]withFastest, Smallest[-Os]There are other more aggressive optimizations performed at this level:
This setting enabled all of the optimizations in the Fastest[-O3] option, as well as active optimizations that might break the strict compilation standards, but did not affect the code that worked well. This level degrades the debugging experience and can lead to increased code size.Copy the code
  1. Smallest, Aggressive Size Optimizations [-Oz]Do not useLTOTo reduce the code size:
Similar to -OS, instructs the compiler to optimize only for code size, ignoring performance tuning, which can cause code to slow down.Copy the code

Conclusion:

strip

Strip: Removes the specified symbol. By default in Xcode strip will only be archived, remove the corresponding symbol. Strip -s: Remove debug symbols (used by static libraries) Strip: Remove all symbols except those used in the indirect symbol table (used by the shelf App)

  • Deployment PostprocessingThe English original meaning is:
If enabled, indicates that binaries should be stripped and file mode, owner, and group information should be set to standard values.
Copy the code

When opened, the strip is run at compile time.

  • Strip Debug Symbols During CopyThe English original meaning is:
Specifies whether binary files that are copied during the build, such as in a Copy Bundle Resources or Copy Files build phase, It does not cause the linked product of a target to be stripped.Copy the code

In plain English, when your application copies a binary file at compile time, this option removes the debug symbol for that binary. But it does not strip out the symbolic information of the end product of the link (executable file \ dynamic library). To remove symbolic information from the product of the link (the executable file of the App).

  • Strip Linked ProductThe English original meaning is:
If enabled, the linked product of the build will be stripped of symbols when performing deployment postprocessing.
Copy the code

If Deployment Postprocessing is not turned on, symbolic information for the end product (executable) of the link is processed at the Archive. Otherwise, symbolic information is processed after the link is complete.

View the App Size report

  • Method 1: Provide accurate App size through App Store Connect;
  • Method 2: Use Xcode built-in reporting tool to create App size report
    1. Archive App
    2. throughAd Hoc,DevelopmentorEnterpriseExport the distribution modeArchive App;
    3. In the list of set development distribution options, selectAll compatible device variantsFor application streamlining, and then enableRebuild from Bitcode;
    4. Sign and export.

This process creates a folder containing the App, which contains: 1. A Universal IPA containing resource files and binaries for multiple platforms; 2. 2. A Thinned IPA, specifying resource files and binaries for the platform. There is also a App Hillclimbing Size report.txt, which lists the framework in full range:

App Thinning Size Report for All Variants of ExampleApp Variant: ExampleApp.ipa Supported variant descriptors: [device: IPhone11,4, OS-version: 12.0], [Device: iPhone9,4, OS-version: 12.0], [Device: iPhone10,3, OS-version: 12.0], [Device: iPhone10,3, OS-version: 12.0], [Device: IPhone11,6, OS-version: 12.0], [Device: iPhone10,6, OS-version: 12.0], [Device: iPhone9,2, OS-version: 12.0], [Device: iPhone9,2, OS-version: 12.0], [Device: IPhone10,5, OS-version: 12.0], [Device: iPhone11,2, OS-version: 12.0], and [Device: iPhone10,2, OS-version: 12.0], and [Device: iPhone10,2, OS-version: 12.0] 12.03] App + On Demand Resources size: 1.6mb compressed, 1.6mb uncompressed App size: 1.6mb 1.6mb compressed, 1.6MB uncompressed On Demand Resources size: Zero KB compressed, Zero KB uncompressed // Other Variants of Your App.Copy the code
  • Mode 3: Output App Size report by script:
xcodebuild -exportArchive -archivePath iOSApp.xcarchive -exportPath Release/MyApp -exportOptionsPlist OptionsPlist.plist
Copy the code