Comments (8)
Linking SwiftProtobufTestSuite_iOS
Undefined symbols for architecture i386:
"(extension in SwiftProtobuf):SwiftProtobuf.ProtobufWrapper.init (A.WrappedType.BaseType) -> A", referenced from:
SwiftProtobufTestSuite_iOS.Test_Api.testInitializer () -> () in Test_Api.o
SwiftProtobufTestSuite_iOS.Test_Conformance.(testRepeatedBoolWrapper () -> ()).(closure #1) in Test_Conformance.o
SwiftProtobufTestSuite_iOS.Test_Conformance.(testRepeatedBoolWrapper () -> ()).(closure #2) in Test_Conformance.o
SwiftProtobufTestSuite_iOS.Test_Wrappers.testDoubleValue () throws -> () in Test_Wrappers.o
SwiftProtobufTestSuite_iOS.Test_Wrappers.testFloatValue () throws -> () in Test_Wrappers.o
SwiftProtobufTestSuite_iOS.Test_Wrappers.(testStringValue () throws -> ()).(implicit closure #11) in Test_Wrappers.o
SwiftProtobufTestSuite_iOS.Test_Wrappers.(testStringValue () throws -> ()).(implicit closure #13) in Test_Wrappers.o
...
"protocol witness table for SwiftProtobuf.Google_Protobuf_BoolValue : SwiftProtobuf.ProtobufWrapper in SwiftProtobuf", referenced from:
SwiftProtobufTestSuite_iOS.Test_Conformance.(testRepeatedBoolWrapper () -> ()).(closure #1) in Test_Conformance.o
SwiftProtobufTestSuite_iOS.Test_Conformance.(testRepeatedBoolWrapper () -> ()).(closure #2) in Test_Conformance.o
"protocol witness table for SwiftProtobuf.Google_Protobuf_FloatValue : SwiftProtobuf.ProtobufWrapper in SwiftProtobuf", referenced from:
SwiftProtobufTestSuite_iOS.Test_Wrappers.testFloatValue () throws -> () in Test_Wrappers.o
"protocol witness table for SwiftProtobuf.Google_Protobuf_DoubleValue : SwiftProtobuf.ProtobufWrapper in SwiftProtobuf", referenced from:
SwiftProtobufTestSuite_iOS.Test_Wrappers.testDoubleValue () throws -> () in Test_Wrappers.o
"protocol witness table for SwiftProtobuf.Google_Protobuf_StringValue : SwiftProtobuf.ProtobufWrapper in SwiftProtobuf", referenced from:
SwiftProtobufTestSuite_iOS.Test_Api.testInitializer () -> () in Test_Api.o
SwiftProtobufTestSuite_iOS.Test_Wrappers.(testStringValue () throws -> ()).(implicit closure #11) in Test_Wrappers.o
SwiftProtobufTestSuite_iOS.Test_Wrappers.(testStringValue () throws -> ()).(implicit closure #13) in Test_Wrappers.o
SwiftProtobufTestSuite_iOS.Test_Api.testInitializer () -> () in Test_Api.o
SwiftProtobufTestSuite_iOS.Test_Wrappers.(testStringValue () throws -> ()).(implicit closure #11) in Test_Wrappers.o
SwiftProtobufTestSuite_iOS.Test_Wrappers.(testStringValue () throws -> ()).(implicit closure #13) in Test_Wrappers.o
ld: symbol(s) not found for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)
from swift-protobuf.
repeats for both macOS and iOS release builds.
from swift-protobuf.
At first glance, this looks like a potential compiler/linker bug to me, where it's possibly getting confused because we have external code (the test module) trying to call an initializer that's defined on an internal protocol, even though the initializer is re-declared public in the extension where the default is implemented.
One way to test it would be to move the public init(_ value: WrappedType.BaseType)
impl into the individual wrapper extensions to see if that fixes the visibility issue.
Will investigate further.
from swift-protobuf.
Confirmed: adding the initializer into the concrete wrapper type instead of the protocol extension fixes the issue. I'll have a PR shortly that copies the initializer into each of the concrete types; unfortunately this will create a small amount of duplication in the runtime library.
I'll see if I can isolate this into a small example that can be submitted as a Swift bug. My understanding is that one of two things should be happening here:
- Designating a method as public on an extension of an internal protocol should be allowed and the linker should be able to see that method when resolving calls from externally linked code.
- Designating a method as public on an extension of an internal protocol should not be allowed and the compiler should flag this as an error before it ever gets to the linker.
Presumably this only occurs on release builds due to stripping or optimization settings that reduce the visibility of certain symbols.
from swift-protobuf.
Thanks. Lets make sure we track (maybe make a label for them and open issues for tracking them) these sort things (that are possibly compiler bugs). I'm a little worried about making sure we under stand them as if they are settings related, this could show up multiple times (the checked in project, CocoaPods generated projects, Swift package manager).
from swift-protobuf.
I've filed https://bugs.swift.org/browse/SR-2925 about this to see if what we were trying to do should be allowed.
from swift-protobuf.
@allevato can you clarify your temporary fix? I am running into what looks like a similar issue, when I reference one of my generated classes' (GTFS) initializers I am getting linking errors:
Undefined symbols for architecture x86_64:
"default argument 1 of (extension in SwiftProtobuf):SwiftProtobuf.Message.init(serializedData: Foundation.Data, extensions: SwiftProtobuf.ExtensionMap?, partial: Swift.Bool, options: SwiftProtobuf.BinaryDecodingOptions) throws -> A", referenced from:
GTFSRealtimeKitTests.GTFSRealtimeBindingsTests.testGTFSRealtimeAPI_FeedMessage_decode() -> () in gtfs-realtime.pb.o
"default argument 2 of (extension in SwiftProtobuf):SwiftProtobuf.Message.init(serializedData: Foundation.Data, extensions: SwiftProtobuf.ExtensionMap?, partial: Swift.Bool, options: SwiftProtobuf.BinaryDecodingOptions) throws -> A", referenced from:
GTFSRealtimeKitTests.GTFSRealtimeBindingsTests.testGTFSRealtimeAPI_FeedMessage_decode() -> () in gtfs-realtime.pb.o
"default argument 3 of (extension in SwiftProtobuf):SwiftProtobuf.Message.init(serializedData: Foundation.Data, extensions: SwiftProtobuf.ExtensionMap?, partial: Swift.Bool, options: SwiftProtobuf.BinaryDecodingOptions) throws -> A", referenced from:
GTFSRealtimeKitTests.GTFSRealtimeBindingsTests.testGTFSRealtimeAPI_FeedMessage_decode() -> () in gtfs-realtime.pb.o
"(extension in SwiftProtobuf):SwiftProtobuf.Message.init(serializedData: Foundation.Data, extensions: SwiftProtobuf.ExtensionMap?, partial: Swift.Bool, options: SwiftProtobuf.BinaryDecodingOptions) throws -> A", referenced from:
GTFSRealtimeKitTests.GTFSRealtimeBindingsTests.testGTFSRealtimeAPI_FeedMessage_decode() -> () in gtfs-realtime.pb.o
ld: symbol(s) not found for architecture x86_64
from swift-protobuf.
The fix I describe above was solely internal to the runtime library, so it shouldn't be affecting any user code. The tl;dr is that I defined an internal protocol and a default implementation of a method in that protocol so I could share its implementation across all conformers. I made that method public because I wanted it to be exposed without exposing the protocol itself. That visibility mixing shouldn't have been allowed, and in release builds, the method wasn't visible.
Are you doing a debug or release build? Is this something that worked before but stopped working with a newer release, or is this the first time you're trying it? Any additional information would be helpful.
from swift-protobuf.
Related Issues (20)
- Revisit `_NameMap` in light of Swift 5 changing the default `String` encoding HOT 1
- 2 .proto has the same message names, which is why the project is not going to be built HOT 1
- Package Resolution Failed in Xcode 15.3 HOT 1
- Can I use SwiftProtobufPluginLibrary or SwiftProtobuf as a Protobuf-parser in Swift project? HOT 1
- The "thread" sanitizer testing is failing HOT 8
- The fuzz regression tests seem to have stopped working. HOT 2
- Need to Add a Privacy Manifest for Apple Validation store for sprint 2024 HOT 1
- Add a PrivacyInfo file HOT 1
- TextFormat seems like it might not be to spec for "inf", "infinity", or "nan" HOT 2
- PR approved back in July 2022 and changes still not included in a release HOT 7
- Unable to verify code signature when installing app to iOS from XCode HOT 4
- Primitive one-of type always passes nil as its argument for decoder HOT 8
- Serialization is not generated HOT 8
- Support for Protobuf Editions HOT 2
- Un-revert breaking changes before releasing v2
- Consider support for newer concepts like `BitwiseCopyable` HOT 1
- SwiftProtobuf.xcodeproj cannot be opened because it is missing its project.pbxproj file. HOT 4
- New `CodeGenerator` protocol should allow customising the `Google_Protobuf_Compiler_CodeGeneratorRequest` HOT 7
- SwiftProtobufPluginLibrary.FileDescriptor.proto is deprecated HOT 13
- xCode shell script doesn't run HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from swift-protobuf.