What is the error you get ?
You have probably already read this ; otherwise, may it help ?
Here they show that in XCode 6, t-uple limit was 1948 (so it must have grown in later version)
They mention compilation error 254.
What is surprising is that a size of 8192 worked in XCode 10, no more in XCode 11.
The limit may not only come from Swift itself, but from the t-uple generator that converts array to t-uple ?
I posted a question on Swift.org to get more insight.
Got interesting information https://forums.swift.org/t/t-uple-max-size/30635/2
The Swift limit of t-uple size is 2**20. which is way larger than 4096 (2**12)
So the limit you get is not due to this, but more likely to the conversion code from C array to Swift t-uple.
Did you file a bug report for the change between XCode 10 and XCode 11 ?
A bug report was filed (not by me) to Swift.org
Its very easy to reproduce.
A simple Swift console project with a C header file containing
// file testc.h
In Build Setting specify as Objective-C Bridging Header
And test using the followng Swift code in main.swift
// file main.swift
let cStruct = TEST_FIXED_ARRAY()
let data = cStruct.data
This work without problem using Xcode 10 with size > 4096
But with Xcode 11.2 the following error:
Value of type 'TEST_FIXED_ARRAY' has no member 'data'
So the compiler simply don't see the 'data' member.
Changing the size to 4096 and its fine.
Changing the type to uint16_t and same result, So not related to the member type but the array size.
There is a many article related to Swift interop with C and fixed-array. C fixed are imported as Swift tuple. This is not the problem, I can process the tuple in Swift to get the data bytes. The problem is related to the C array size when imported with Xcode 11.
I understood your point and trust you on the 4096 limit.
My point was just trying to clarify if that came from some Swift limit in t-uple arity. Clearly not.
Did you file a bug report against compiler with this use case ?
Thanks Claude31, your right its not clear to me too if related to a tuple size limit in Xcode 11 / Swift 5 or if the bridging header engine now have a limit on array size when importing C fixed array. I will file a radar on this. Thanks again for sharing.
That will be great to report when you get the answer.
I'm guessing it is linked to the bridging header engine.
I discovered this mechanism to convert to t-uple for fixed size arrays. But also read that it is extremely resource hungry and that another way is to use unsafePointers. But that would probably cause too many changes in your libraries.
Sure, I will report.
Just to clarify, once I got the tuple in Swift I can iterate the tuple to read the data bytes using withUnsafeBytes, no problem here.
However with C array > 4096 the compiler error code say it simply can't access the data element:
"Value of type 'TEST_FIXED_ARRAY' has no member 'data'"
Simply comment the data line in the struct:
And you will see the same error. Of course because now effetively there is no longer a data member.
Uncomment, change the size to 4096 and voilà, the data member is well accessed and printed.
I will file a radar on this.
Thanks! Please post your bug number, just for the record.
Oh, also, as the importer is part of the Swift open source project, you can file a Swift bug about it. That’ll give you greater visibility into its state.
Share and Enjoy
Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware
let myEmail = "eskimo" + "1" + "@apple.com"
Bug filed on Apple Feedback # FB7438876
C array larger than 4096 failed to import in Swift with Xcode 11.2