Objective-C - Fast Bridge Performance for Existing Codebase

A performance question for developers who have experience adding a high-speed Objective-C codebase.

My premise is this: ultimately Bridging-Header.h can become really big (ultimately it can contain all 1.5k of existing Objective-C classes (give or take classes that won't be accessible from Swift)) and vice versa for PRODUCT-Swift.h generated header.

I am afraid that compilation performance may decrease dramatically: every time when any of the included .h classes has changed, it will have to recompile all .swift files.

This is true? If so, is there a way to optimize performance?

Explanation : Imagine that you included all the project classes in a .pch file, now every change to the class causes a recompilation of the entire project. Bridging-Header.h this look like the way Bridging-Header.h works?

+7
objective-c swift objective-c-swift-bridge
source share
1 answer

If you expect a lot of glitches in header files, I would recommend modules. By dividing the Swift code into modules, each of which has its own header, you should significantly reduce the recovery time of Swift. You will probably also get improvements in Swift rebuild times if you don't need to consider every internal function in the whole system.

The modules seem to be where Swift wants to go about organizing the program. I am not saying that they are very strong; they still seem pretty dirty. But they are probably the best tool for this job. The good news is that you should be able to migrate in parts when you encounter problems. You do not have to rework your entire project at once. I would definitely not recommend working and creating 100 different modules on the first day. Look at just a few large ones that can segment your program well.

+1
source share

All Articles