I'm trying to use @inline(never) to solve a problem with leaky dependencies.
For context, I have a large, multi-module codebase. I have a “DataDefinition” module that defines all the public/shared type across the codebase and a “ServiceAPI” module that is responsible for translating REST call responses into domain models defined in the DataDefinition module.
I’m currently facing a build break in my iOS AppStore build (where inline-call optimization is enabled). The ServiceAPI module is referencing a function from the DataDefinition module, but the function implementation references an external dependency that only DataDefinition uses and which ServiceAPI doesn't import. The function gets inlined in ServiceAPI and causes a build break when optimizations are turned on.
DataDefinition Module
import DesignLanguageEngine
public enum TextBlockStyle {
public func backgroundColor() -> UIColor {
return DesignLanguageEngine.defaults.backgroundColor
}
}
ServiceAPI Module
// Build Break Here: "Undefined symbol: DesignLanguageEngine.Properties"
textBlock.backgroundColor = source.style.backgroundColor()
I thought I could annotate the function with @inline(never) , but that doesn’t seem to solve the problem.
import DesignLanguageEngine
public enum TextBlockStyle {
// suppress inline-expansion to avoid leaking the DesignLanguageEngine dependency
// sadly, this doesn't work
@inline(never)
public func backgroundColor() -> UIColor {
return DesignLanguageEngine.defaults.backgroundColor
}
}
Question:
What is the right way to define public interfaces on modules that avoid this kind of dependency leakage?