Weird, random, slow compile time

Hello, I'm working on a Swift project which uses a C (static) library (packed in xcframework), and encounter this weird slow compile time, currently temporarily solved by slightly modifying the code.

For example, the code below takes forever to compile on my laptop, CPU 100%, fan goes crazy, battery drains quickly, etc., don't even bother waiting for it to finish

var bigCStruct1 = big_c_struct_1()

var bigCStruct2 = big_c_struct_2()

But after simply rearranging the code, the code compiles fine, although still a bit slow

var bigCStruct2 = big_c_struct_2()

var bigCStruct1 = big_c_struct_1()

Another example, code below won't finish compiling

func setUpBigCStruct() -> big_c_struct {
    var bigCStruct = big_c_struct()

    // ...more code here...

    return bigCStruct

// this is global
let bigCStruct = setUpBigCStruct()

But changing it into below will somehow make it work

// this is global
var bigCStruct = big_c_struct()

func setUpBigCStruct() {
    // ...access, modify bigCStruct here...


Why??? Help, what am I doing wrong? Never encountered this problem before. This is really frustrating :frowning:

Could you please file a bug report on with any information you can provide to reproduce the issue? For example, what kinds of fields do the big structs have (does one contain the other?)? What Xcode version are you using? Is there anything else in the xcframework? And so on.

Struct 2 in the first example and struct in the second example contain only basic, primitive data types, arrays of basic types, and some other structs, so big but simple, straightforward, no circular reference, etc. Struct 1 in the first example contains basic types, arrays of basic types, and arrays of many other structs (probably >50 other struct types), but those structs are also simple, straightforward, contain only basic types, arrays of basic types, no circular reference, etc.

This is on Xcode 11.7 (waiting for Big Sur to release, before upgrading)

The xcframework contains different binaries of the library for other platforms, architectures.

I'll file a bug report.

I said this in the bug as well, but please attach something to the bug that we can use to actually reproduce the problem.

Link to the bug report

Terms of Service

Privacy Policy

Cookie Policy