![]() You may have created a run script to invoke Carthage’s copy-frameworks script. Declaring script inputs and outputsĪ run script phase allows you to execute custom code during the compilation of the target. This means that the next target to be built will start a little bit early compared to Xcode 9, since linking and other operations can now be done in parallel. Xcode starts the compilation of a target as soon as the build and the run script phases of its dependencies are complete. One last improvement in the Xcode 10 build process worth mentioning is the parallelization of some parts of the build process. If your Xcode project is a few years old and survived some refactorings, make sure you are not specifying unnecessary target dependencies that may slow down your build. In the “Link Binary with Libraries”, implicit target dependencies are specified which are also used to figure out the dependency order.Īn example of build phases that specify dependencies between modules. The main app target Tweetometer specifies TweetometerKit as an explicit target dependency, in order to tell Xcode that it requires the framework to be ready before it can compile itself. TweetometerKit is a framework that contains the business logic of the app, such as network requests and models. Let’s take one of my side projects that I have been working on lately, Tweetometer. You can view the dependencies of a target directly in the “Build Phases” section. One example is creating a separate testing target for each framework, instead of testing all the libraries in a single unit testing bundle. There’s one thing that you can do to help Xcode in parallelizing the work: split up your targets into smaller units. ![]() A cool algorithm that is usually used to solve dependencies and figure out the order of compilation is topological sorting.įun fact: this is a common topic in technical interviews at Big N companies, so definitely learn more about it if you’re interested in computer science problems. Your project will most likely have some dependencies between the targets. Of course, Xcode can’t build all your targets at once. To check or change this option, open your scheme editor, select “Build” in the sidebar and make sure “Parallelize Build” is checked at the top. When opening your project in Xcode 10, build parallelization should already be enabled. Thus, the timeline could look like something like this.īy reducing the size of your targets, you will obtain a better parallelization. Xcode 10 tries to make better utilization of the available hardware by distributing on multiple cores the targets to build. This is why using Carthage usually decreases your build times, since the dependencies are compiled once and only linked at runtime with your app target. If you have 10 dependencies in your Podfile, Xcode needs to build all the Pods before building your target. One real example of where you may have noticed this behavior is when using CocoaPods. In Xcode 9 every target is built after the other.Īll the targets are built one after the other, starting from the ones that are dependencies of other targets. Let’s take the example shown in the session to see how the timeline would look in order to build 5 targets in Xcode 9. Xcode 10 is now much faster in building since it distributes tasks across multiple cores to build targets in parallel whenever possible. ![]() Previously to Xcode 10, all the targets were built serially, which means that only one target can be built at any given time. Most of the content in this post is taken from WWDC 2018 Session 408 - Building Faster in Xcode. I finally had time to watch some of the WWDC talks related to Xcode 10 today, and I wanted to share some very interesting and useful new tips to improve the build times of Swift and Objective-C projects in Xcode 10.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |