Lazy module linking with swift

The question is about lazy module linking with swift. AFAIK swift does not support this feature out of the box.

Explanation:

If you have some module called Dynamic with a class DynamicClass and have another module called DynamicClient where you import Dynamic and use DynamicClass, then swift will force a linker to generate a load command to dynamically link against Dynamic.framework in runtime. This feature is called autolinking.

Attempts:

Autolinking can be disabled using private swift compiler flag disable-autolink-framework {name} as described in this stackoverflow question.

However, if you use this flag, the linker reports an undefined symbol error, which is pretty obvious, so this flag does not help.

Question:
It would be great to avoid swift's eager linking in favor of lazy one. Is this anyhow possible or planned for implementation?

4 Likes