Linking breaks when implementing an extension that implements a protocol for a struct defined in a framework
Originator: | alberto | ||
Number: | rdar://20648441 | Date Originated: | |
Status: | Open | Resolved: | |
Product: | iOS SDK | Product Version: | |
Classification: | Reproducible: | Yes |
Summary: The code can not be linked. Please check the attached code sample Readme.md file or this github project for specific details https://github.com/Karumi/ExtensionProtocolforStruct Steps to Reproduce: When compiling the ExtensionProtocolforStruct project the linker crash with the following error message: Undefined symbols for architecture x86_64: "__TFV9submodule10testStructg3fooSS", referenced from: __TTWV9submodule10testStruct26ExtensionProtocolforStruct12testProtocolS1_FS2_g3fooSS in ProtocolExtension.o ld: symbol(s) not found for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation) The setup is: 1 - Declare a public struct in a framework public struct TestStruct { public let foo: String = "" } 2 - Declare a protocol that matches the property names of the struct in your project protocol TestProtocol { var foo: String { get } } 3 - Declare an extension for the struct that implements the protocol extension TestStruct : TestProtocol { } Expected Results: Expected: The code compiles and runs Actual Results: Actual: The linking breaks with the error described at the beginning. Note: If the struct in the framework is replaced with a public class, the code works as expected Version: OSX 10.3, Xcode 6.3.1 (it happened also in 6.3) Notes: Configuration: rMBP 13 inches mid 2015 See: https://github.com/Karumi/ExtensionProtocolforStruct
Comments
Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!