Post

Replies

Boosts

Views

Activity

Running unit tests on iOS 11 device from Xcode 14 fails
There appears to be an interoperability issue between Xcode 14 and iOS 11 devices. Specifically with libswiftCoreGraphics.dylib. I build a Swift based framework that has a deployment target of iOS 11. When I build the SDK with Xcode 13.4.1 and run the unit tests on iOS 11, everything works as expected. When I switched to Xcode 14, it continually fails when attempting to run the unit tests on an iOS 11 device. I began digging into this and was trying to determine if it was an issue with some dependency or something in my project. I created a test project with Xcode 13.4.1, Xcode14-iOS11_Bug, which consists of a simple Swift application and one unit test file. When I run the unit from Xcode 13.4.1 targeting an iPhone 7 running iOS 11.4.1, it runs as expected. I then opened the same project with Xcode 14 and attempted to run the unit test I am greeted with the same error about libswiftCoreGraphics.dylib not being loaded. 2022-09-14 15:19:00.871686-0400 Xcode14-iOS11_Bug[616:100103] Failed to load test bundle from file:///var/containers/Bundle/Application/5E87802C-9C84-48FD-9D2D-8441983B61E8/Xcode14-iOS11_Bug.app/PlugIns/Xcode14-iOS11_BugTests.xctest/: Error Domain=NSCocoaErrorDomain Code=3587 "dlopen_preflight(/var/containers/Bundle/Application/5E87802C-9C84-48FD-9D2D-8441983B61E8/Xcode14-iOS11_Bug.app/PlugIns/Xcode14-iOS11_BugTests.xctest/Xcode14-iOS11_BugTests): Library not loaded: /usr/lib/swift/libswiftCoreGraphics.dylib Referenced from: /private/var/containers/Bundle/Application/5E87802C-9C84-48FD-9D2D-8441983B61E8/Xcode14-iOS11_Bug.app/Frameworks/libXCTestSwiftSupport.dylib Reason: image not found" UserInfo={NSLocalizedFailureReason=The bundle is damaged or missing necessary resources., NSLocalizedRecoverySuggestion=Try reinstalling the bundle., NSFilePath=/var/containers/Bundle/Application/5E87802C-9C84-48FD-9D2D-8441983B61E8/Xcode14-iOS11_Bug.app/PlugIns/Xcode14-iOS11_BugTests.xctest/Xcode14-iOS11_BugTests, NSDebugDescription=dlopen_preflight(/var/containers/Bundle/Application/5E87802C-9C84-48FD-9D2D-8441983B61E8/Xcode14-iOS11_Bug.app/PlugIns/Xcode14-iOS11_BugTests.xctest/Xcode14-iOS11_BugTests): Library not loaded: /usr/lib/swift/libswiftCoreGraphics.dylib Referenced from: /private/var/containers/Bundle/Application/5E87802C-9C84-48FD-9D2D-8441983B61E8/Xcode14-iOS11_Bug.app/Frameworks/libXCTestSwiftSupport.dylib Reason: image not found, NSBundlePath=/var/containers/Bundle/Application/5E87802C-9C84-48FD-9D2D-8441983B61E8/Xcode14-iOS11_Bug.app/PlugIns/Xcode14-iOS11_BugTests.xctest, NSLocalizedDescription=The bundle “Xcode14-iOS11_BugTests” couldn’t be loaded because it is damaged or missing necessary resources.} 2022-09-14 15:19:01.221551-0400 Xcode14-iOS11_Bug[616:100103] The bundle “Xcode14-iOS11_BugTests” couldn’t be loaded because it is damaged or missing necessary resources. Try reinstalling the bundle. 2022-09-14 15:19:01.221599-0400 Xcode14-iOS11_Bug[616:100103] (dlopen_preflight(/var/containers/Bundle/Application/5E87802C-9C84-48FD-9D2D-8441983B61E8/Xcode14-iOS11_Bug.app/PlugIns/Xcode14-iOS11_BugTests.xctest/Xcode14-iOS11_BugTests): Library not loaded: /usr/lib/swift/libswiftCoreGraphics.dylib Referenced from: /private/var/containers/Bundle/Application/5E87802C-9C84-48FD-9D2D-8441983B61E8/Xcode14-iOS11_Bug.app/Frameworks/libXCTestSwiftSupport.dylib Reason: image not found) From what I have read, Xcode 14 is still supposed to have iOS 11 support, so it would appear something is broken. I have filed FB11512459 for this issue.
3
3
3k
Sep ’22
Binary distributable XCFrameworks with Property Wrappers Issue
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 Int64s... 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.
1
1
487
Mar ’23