Skip to content

[Swift] Xcode 10.2 and use of namespace causes compiler warnings. #1177

@ileitch

Description

@ileitch

With Xcode 10.2, a warning is now emitted when a public class/struct exists within a public extension.

For example, using apollo codegen:generate --target=swift --namespace="MyNamespace" and the following generated code:

import Apollo

public extension MyNamespace {
  public final class MyQuery: GraphQLQuery {
  }

  public struct MyFragment: GraphQLFragment {
  }
}

Swift will emit the warning 'public' modifier is redundant for class declared in a public extension for the MyQuery class and MyFragment struct.

The solution is to simply not include the public modifier for MyQuery when using a namespace.

This is not a language change, just a new warning. The fix should be compatible with all versions of Swift 4.

Note that it's quite common for Swift projects to treat warnings as errors, so this bug is a blocker for us.

Versions

Apollo 2.8.1

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions