Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix swift protobuf build for swift below 5.0 #921

Merged
merged 1 commit into from
Nov 25, 2019

Conversation

ziwei2041
Copy link
Contributor

When compiling with swift version below 5.0, it complains that Data.withUnsafeBytes is internal and cannot be referenced from an @inlinable function, from https://github.com/apple/swift-protobuf/blob/master/Sources/SwiftProtobuf/Message%2BBinaryAdditions.swift#L146, which is newly introduced by 7f8daf3

In fact, Data.withUnsafeBytes is defined inside Data+Extensions (https://github.com/apple/swift-protobuf/blob/master/Sources/SwiftProtobuf/Data%2BExtensions.swift#L19) as internal, but not @usableFromInline. And according to Apple's documentation, @inlinable code "can interact with internal symbols declared in the same module that are marked with the usableFromInline attribute" (https://docs.swift.org/swift-book/ReferenceManual/Attributes.html).

Compiling with XCode 10.2 (using swift 5.0) and above does not reproduce this issue while compiling with XCode 10.1 (using swift 4.2) does.

References
XCode version and Swift version mapping: https://developer.apple.com/xcode/whats-new/#:~:targetText=Xcode%2010.1%20includes%20Swift%204.2.
xcode-version and swift-version flags: http://go/swift-monthly#swift-version-attribute-has-been-removed

When compiling with swift version below 5.0, it complains that `Data.withUnsafeBytes` is internal and cannot be referenced from an `@inlinable` function, from https://github.com/apple/swift-protobuf/blob/master/Sources/SwiftProtobuf/Message%2BBinaryAdditions.swift#L146, which is newly introduced by apple@7f8daf3

In fact, `Data.withUnsafeBytes` is defined inside `Data+Extensions` (https://github.com/apple/swift-protobuf/blob/master/Sources/SwiftProtobuf/Data%2BExtensions.swift#L19) as internal, but not `@usableFromInline`. And according to  Apple's documentation, `@inlinable` code "can interact with internal symbols declared in the same module that are marked with the usableFromInline attribute" (https://docs.swift.org/swift-book/ReferenceManual/Attributes.html).

Compiling with XCode 10.2 (using swift 5.0) and above does not reproduce this issue while compiling with XCode 10.1 (using swift 4.2) does.

References
XCode version and Swift version mapping: https://developer.apple.com/xcode/whats-new/#:~:targetText=Xcode%2010.1%20includes%20Swift%204.2.
xcode-version and swift-version flags: http://go/swift-monthly#swift-version-attribute-has-been-removed
@ziwei2041 ziwei2041 marked this pull request as ready for review November 25, 2019 06:40
@thomasvl
Copy link
Collaborator

Sorry about that. Thanks for the fix.

@thomasvl thomasvl merged commit 79d3adc into apple:master Nov 25, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants