I’ve just run into an issue with a binary distributable XCFramework and stored properties with property wrappers.
We distribute a closed source iOS XCFramework written in Swift and have been chugging along just peachy. During the build we build both the simulator and device variants and use xcodebuild -create-xcframework
to package it up all nice, including the .swiftinterface
files.
Recently I came across a compatibility issue on our server side with how we were JSON encoding Int64
s... The server is expecting a string and serving these values as strings (based on Protobuf). By default the JSON encoder/decoder deals with numbers. This exact scenario was discussed on the Swift Forums and the proposed solution was to use a property wrapper to handle that.
So I went down that route and all was good in the world locally. I went to cut a release and was surprised when my builds that consumed the framework via SPM began to fail.
Digging into it, I am getting the following error: Invalid redeclaration of synthesized property '_theValue'
. Following that error through takes me to the .swiftinterface
file were I ended up seeing something I was not expecting...
@frozen public struct TestStruct : Swift.Codable, Swift.Equatable {
@PropertyWrapperTinkerSDK.StringRepresentedFixedWidthInt public var theValue: Swift.Int64 {
get
}
private var _theValue: PropertyWrapperTinkerSDK.StringRepresentedFixedWidthInt<Swift.Int64>
public init(theValue: Swift.Int64)
public static func == (a: PropertyWrapperTinkerSDK.TestStruct, b: PropertyWrapperTinkerSDK.TestStruct) -> Swift.Bool
public func encode(to encoder: Swift.Encoder) throws
public init(from decoder: Swift.Decoder) throws
}
Specifically, the private var _*
declaration for the backing value.
It would seem to me that this being a private implementation detail shouldn’t even be in the .swiftinterface
file. Manually removing these private var _*
entries allows the consuming applications to compile and... seem to work... But it seems a bit scary going in here and manually modifying this file.
I was wondering if anybody else has seen this and has a recommendation of how to proceed?
Note: This is cross posted on the Swift Forums as well as I am desperately trying to find a proper workaround/solution.