-
-
Notifications
You must be signed in to change notification settings - Fork 10
propose edits to readme #4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,31 +3,37 @@ | |
| Order files can reduce app startup time by co-locating symbols that are accessed during app launch, reducing the number of page faults from the app. This package generates an order | ||
| file by launching the app in an XCUITest. Read all about how order files work in [our blog post](https://www.emergetools.com/blog/posts/FasterAppStartupOrderFiles). | ||
|
|
||
| Setting up your app for order files requires 2 steps: | ||
| 1 - Use this library to generate an order file as part of your XCUITest. The library instruments app launch in the UI test and uses the results to generate an optimized order file | ||
| 2 - Re-build the app with the order file. Once the order file is generated you build the app again, this time passing the order file as an option to the linker. | ||
| ## Setup | ||
|
|
||
| ## Installation | ||
| Setting up your app to use order files requires 2 general steps: | ||
|
|
||
| Create a UI testing target using XCUITest. Add the package dependency to your Xcode project using the URL of this repository (https://github.com/getsentry/FaultOrdering). | ||
| Add `FaultOrderingTests` and `FaultOrdering` as a dependency of your new UI test target. | ||
| 1. Generate an order file from an XCUITest. `FaultOrdering` instruments app launch in the UI test and uses the results to generate an optimized order file. | ||
| 2. Once the order file is generated, build the app again, this time passing the order file as an option to the linker. | ||
|
|
||
| ### Package installation | ||
|
|
||
| - Create a UI testing target using XCUITest. | ||
| - Add https://github.com/getsentry/FaultOrdering to your project via Swift Package Manager. | ||
| - Add `FaultOrderingTests` and `FaultOrdering` as dependencies of your new UI test target. | ||
|
|
||
| ### Generating the linkmap | ||
|
|
||
| To use this package you'll need to tell Xcode to generate a linkmap for your main app binary. In your app's Xcode target, set the following build settings: | ||
| In your app's Xcode target, set the following build settings: | ||
|
|
||
| ``` | ||
| LD_GENERATE_MAP_FILE = YES | ||
| LD_MAP_FILE_PATH = $(PROJECT_DIR)/Linkmap.txt | ||
| ``` | ||
|
|
||
| We recommend using `$(PROJECT_DIR)` so that it generates within your project directory instead of derived data, but this can be changed to whatever makes sense for your setup. | ||
|
|
||
| After adding these settings, make sure to build your app and verify the file exists. | ||
|
|
||
| > [!NOTE] We recommend using `$(PROJECT_DIR)` so that it generates within your project directory instead of derived data, but this can be changed to whatever makes sense for your setup. | ||
|
|
||
| ### Including the linkmap | ||
|
|
||
| Once the `Linkmap.txt` file exists, it needs to be included as a resource in your UI test target. Add it in the build phases for your target under Copy Bundle Resources. | ||
| Add `Linkmap.txt` in the build phases for your UI test target under Copy Bundle Resources. | ||
|
|
||
| > [!IMPORTANT] Do **not** check the box to copy the file. | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Moved this "above the fold" as people might only see the step to add linkmap and skip over the screenshots if they think they already know how to do it, and this important bit was buried under the last one (i also still left it there) |
||
|
|
||
| <img src="images/copy.png" width="600" alt="Copy Bundle Resources"> | ||
|
|
||
|
|
@@ -37,34 +43,48 @@ Choose "Add Other" and browse to where you generated the file. You may need to c | |
| <img src="images/confirm.png" width="600" alt="Confirm"> | ||
| Confirm your selection and <strong>do not</strong> check the box to copy the file. | ||
|
|
||
| > [!IMPORTANT] | ||
| > The generated Linkmap.txt file must be included in your UI test target. You don't need to specificly use `"$(PROJECT_DIR)/Linkmap.txt"` as the path, only that whatever the `LD_MAP_FILE_PATH` is set is also the file that you include in Copy Bundle Resources. | ||
| > [!NOTE] | ||
| > You don't need to specifically use `"$(PROJECT_DIR)/Linkmap.txt"` as the path. Whatever value is set in `LD_MAP_FILE_PATH` is also the file that you include in Copy Bundle Resources. | ||
|
Comment on lines
-40
to
+47
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This didn't actually seem super important, and we already call out in a similar note in its section that this isn't actually a requirement. |
||
|
|
||
| ## Usage | ||
| ## Generating the order file | ||
|
|
||
| In a UI test, create an instance of `FaultOrderingTest` and optionally provide a closure to perform any necessary app setup. In most cases, this should include logging in to the app. Centering your UI test around a fully logged in session is strongly recommended, not only because it optimizes for the most common user experience, but also because it significantly improves the efficacy of this tool. By logging in, you allow much more of the app’s initial code to execute within the test context, allowing for a greater number of page fault reductions. The test case can then be executed. | ||
| In a UI test case, create an instance of `FaultOrderingTest` and optionally provide a closure to perform any necessary app setup. | ||
|
|
||
| > [!TIP] In most cases, this should include logging in to the app. Centering your UI test around a fully logged in session is strongly recommended, not only because it optimizes for the most common user experience, but also because it significantly improves the efficacy of this tool. By logging in, you allow much more of the app’s initial code to execute within the test context, allowing for a greater number of page fault reductions. | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. See discussion in slack about logging in. |
||
|
|
||
| Example: | ||
|
|
||
| ```swift | ||
| let app = XCUIApplication() | ||
| let test = FaultOrderingTest { app in | ||
| // Perform setup such as logging in | ||
| import FaultOrderingTests | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This didn't build until adding the import; i thought it'd be best to give a complete working snippet here. |
||
| import XCTest | ||
|
|
||
| final class FaultOrderingLaunchTest: XCTestCase { | ||
| @MainActor | ||
| func testLaunch() throws { | ||
| let app = XCUIApplication() | ||
| let test = FaultOrderingTest { app in | ||
| // Perform setup such as logging in | ||
| } | ||
| test.testApp(testCase: self, app: app) | ||
| } | ||
| } | ||
| test.testApp(testCase: self, app: app) | ||
| ``` | ||
|
|
||
| The test case can then be executed. | ||
|
|
||
| > [!IMPORTANT] | ||
| > This test should be run with a release build configuration, using the same compiler/linker optimizations that you would use on the App Store. | ||
| > This test should run with the same compiler/linker optimizations that you would use for your App Store deliverable. | ||
|
|
||
| ### Accessing results | ||
| ### Device support | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I moved this section above "accessing results" since it's really a subdetail of how to run the ui test. |
||
|
|
||
| Results are added as a XCTAttachment named `"order-file"`. | ||
| To run on a physical device, the app must link to the `FaultOrdering` product from this package. Update your main app target to include this framework in its embedded frameworks. If your app takes a different codepath on physical devices than simulators (such as using device only frameworks like Metal) it is best to generate an order file while running on the physical device. | ||
|
|
||
| ### Device support | ||
| ## Accessing results | ||
|
|
||
| To run on a physical device the app must link to the `FaultOrdering` product from this package. Update your main app target to have this framework in it's embedded frameworks. If your app takes a different codepath on physical devices than simulators (such as using device only frameworks like Metal) it is best to generate an order file while running on the physical device. | ||
| After running the UI test, the order file will will appear as an XCTAttachment named `"order-file"`. | ||
|
|
||
| ## Using the order file | ||
|
|
||
| Once you run the UI test to generate an order file you have to use this file as an input to a new build of the app. Technically you only need to re-link the app, not re-compile everything, but running a new build with xcode is the easiest way to do this. Set the xcode build setting "ORDER_FILE" to the path to your order file when you build the app. | ||
| In your app target's build settings, set "ORDER_FILE" to the path to your order file and rebuild the app. | ||
|
|
||
| > [!TIP] Technically, the app only needs to be relinked to include the order file, as it has no effect on compilation of source code, but it may be easier to simply rebuild the entire app target. | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is nice to know but i thought it better if it's separate. |
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Made this a note instead since it isn't technically required.