Swift 1.2 Upgradation - ios

I have updated my Swift project to version 1.2 and the build times have been improved after using Build Setting option Whole Module Optimization=Yes. But even if there is a small change in Swift file the entire Objective C files are getting compiled when I tried to build. Is there any other optimization option Available? I'm using Xcode 6.3.2

Why don't you only enable Whole Module Optimization in your Release build and leave it off for Debug. That way you won't have to wait long for compilation and testing builds but your users still get the benefit of the speeds of Whole Module Optimization.

Related

How to best modularize an Xcode project to speed up building

I work in a team on an iOS project that has grown to enormous size in terms of Swift code.
It takes about 10 minutes to build the project from the clean state and, most scrutinizing, 30 seconds to build and run the project after changing anything in the code, even if that code pertains to a single line in a private method in Swift file symbols from which are not used anywhere else.
We've tried lots of thing to improve build times, including techniques from this nice resource https://github.com/fastred/Optimizing-Swift-Build-Times
Nothing helped, you still need to wait the whole 30 seconds after changing every minor thing to see it in the app.
We use Xcode 10, the "New build system" with the compilation mode set to Incremental. If I build the project via Perform Action > Build With Timing Summary, the longest phase is "Swift code compilation" which is nothing new. We suspect that Xcode tries to follow conservative compilation decision making and rebuilds every Swift file that could potentially have any connection to the modified Swift code. And it seems that Xcode is wrong most of the time and does redundant work.
I kinda miss Objective-C days when the compiler would look at the all import/include statements and only rebuild explicitly declared dependencies, which meant blazing fast build times.
So I now think that maybe we could break our project into modules and ubiquitously use import in Swift to tell the compiler what Swift files depend on what other Swift files.
Is there a good and perhaps automated way to modularize a big project into many small components to speed up regular lets-try-how-it-works builds?
You can split your projects into Cocoa Touch Frameworks. -> https://www.raywenderlich.com/5109-creating-a-framework-for-ios
Add each framework to its own git repo. It may be private repo.
Create private cocoapods. -> https://guides.cocoapods.org/making/private-cocoapods.html
Add new dependencies to your project podfile. -> pod 'YourFramework', :git => 'FrameworkGitRepoPath'
I might be late to the party here, but we are using this tool: https://github.com/yonaskolb/XcodeGen/
Not only did it allow us to easily split the project into modules, it completely eliminated conflicts in the project file, because it doesn't need to be added to the repository any more.

Xcode 8.3 Indexing & Building Extremely Slow

I am posting this after reading many similar posts on here regarding this issue and none of the solutions that worked for other people not working...
Xcode Version 8.3.3 (8E3004b)
Swift 3.1
Things I tried
Deleting Derived Data folder
Deleting Workspace File
Cleaning Build Folder
Cleaning Build
Reinstalled Xcode (after complete removal)
I also looked for Swift Issues:
Removed all concatenating strings
Cleaned up Swift arrays and dictionaries
Added Whole module optimizations
This all started happening after last Xcode update of 8.3.3. My project was compiling within seconds and now I have to wait at least 15 mins for it to index, then 5 minutes to compile after everything I change even something small in code.
When Building, it get stuck in "Compiling Swift source files". Is there way for me to look in to where it is actually getting stuck?
BIG UPDATE
I tried pretty much everything. Read every article, post, ect. NOTHING worked. My project was created right after 10.0.
Solution
Creating a new project and copying each file worked! It used to take 8-9 minuted to build. Now less than 2 seconds!
Apple knows about this problem, and says that Xcode 9 beta will perform much better. Note that if you don't want to update to Swift 4, you can continue compiling in Swift 3 mode using Xcode 9. The big limitation is that you won't be able to submit your project to the App Store until Xcode 9 goes final.
Also, Xcode 9 contains a new build system. You don't get it by default: you have to turn it on for this project. Choose File > Project Settings and switch the pop-up menu to New Build System (Preview). This is experimental, but it will be the default build system eventually, so it would be interesting to know whether this makes an appreciable difference.
If you don't want to update to Xcode 9 beta, you will just have to do a binary search: comment out all your code and start adding it back, piece by piece, until you find that piece that's causing the trouble.
The best way to work this out is to find what out what the build is doing while compiling your code. This is a really useful tool to use: https://github.com/RobertGummesson/BuildTimeAnalyzer-for-Xcode
When you run this tool it will show you what methods are taking the longest to compile, and then you fix those. Once you have done that, you can also try the answer I gave here to decrease the build times: Extremely long compilation times with Swift in Xcode

Extremely long compilation times with Swift in Xcode

I have three iOS projects:
First one - 35k Swift LOC, Swift 2.1 (or 2.0?), compiled using Xcode 7.2.3
Second one - 15k Swift LOC, Swift 2.3, compiled using Xcode 8.2.1
Third one - 15k Swift LOC, Swift 3.0, compiled using Xcode 8.2.1
The compile times for all of these are abysmal (10+ minutes for a clean build), and the development on each one of these is slowing to a crawl.
I have already tried:
Using Whole Module Optimization
Changing C Dialect to compiler default
Analyzing build times for the project and optimizing bottlenecks (a few methods that took 6-10s to compile with array concatenation, nil coalescing operators and such), which shaved like 15 seconds - completely unnoticeable difference
HEADERMAP_USES_VFS = YES
A few other I don't remember now
I'm working on a Mac mini Late 2014 with an SSD, 8GB RAM & 2.6ghz i5, if that matters.
Anyone knows what might cause that, what to do with that or even any workarounds for now? From what I've read on SO and other places, it seems like an unresolved compiler issue.
EDIT: Yes, I'm using Cocoapods for dependencies. I'll try moving to Carthage and see what happens.
Try set the following in Build Settings as a workaround. I am assuming you have just one Target.
Set the Build Active Architecture Only to Yes.
Set Optimization Level to None [-Onone]
Add User-Defined setting called "SWIFT_WHOLE_MODULE_OPTIMIZATION" with the value "YES"
Empty your derived data and build.
You can also then use this tool to analyze any slow compiling Swift files: https://github.com/RobertGummesson/BuildTimeAnalyzer-for-Xcode
I was experiencing build times that were taking 6-7 minutes. I moved away from Cocoapods and started using Carthage which helped for clean builds. Even then builds were still taking 3 minutes. The biggest improvement came with the steps I mentioned above.
Update
Instead of adding the User-Defined setting, on your Debug build set the Optimization Level to 'Fast, Whole Module Optimization'. Then in Other Swift Flags for your debug build add '-Onone'.
It's an open issue on swift's site: https://bugs.swift.org/browse/SR-6037
Hopefully they'll fix it soon.

Xcode always recompiles everything every time I build

I'm working on a Swift 2.3 project using Xcode Version 8.0 (8A218a), I use Cocoapods 1.0.1 for dependency management.
I don't know what happens but every time I hit build or build & run, wether there is a modification in a file or not, the compiler will take 2-3 minutes to recompile what seems to be all the sources files of my project.
I found this thread on Apple's forum (https://forums.developer.apple.com/thread/44406) that doesn't solve my issue (I applied Compiler Default settings to both my project and the Pods sub-project).
I have no idea what's happening and it's driving me crazy. Any lead welcome :)
Thanks!
Cyril

Xcode 6.3 always does full rebuild of Swift project

One of the long anticipated features of Swift 1.2/Xcode 6.3 is incremental builds. They worked fine for me until recently, but now almost every time I change even a single line of code it does full rebuild.
I tried restarting Xcode, computer, cleaning derived data, but to no avail. Googling doesn't seem to reveal anything.
Does anyone else have this problem? How do I fix it?
I think that this is what you searching for
I am not this is a source of the problem. According to https://developer.apple.com
Swift Performance
A new compilation mode has been introduced for Swift called Whole Module Optimization. This option optimizes all of the files in a target together and enables better performance (at the cost of increased compile time). The new flag can be enabled in Xcode using the “Whole Module Optimization” build setting or by using the swiftc command line tool with the flag -whole-module-optimization. (18603795)

Resources