Baffled by build errors with Swift package generated by apollo-ios-cli

This is the first time I’ve tried using apollo-ios-cli to generate Swift packages for a couple of different APIs. To keep things simple, I’ll just deal with one of them, CommonGraphQL.

I’ve got a configuration file that appears to work. I can fetch the schema and generate a Swift package using "moduleType" : { "swiftPackageManager" : {} }.

I see all of the expected Swift files in the package tree at the root of my project.

I add this as a local package in Xcode and it shows fine in the project explorer.

However, when I try to build the app, I get file not found errors for every .graphql files that was used to generate the Swift code. It’s also looking for those files in the root of the project, rather than where they reside.

I’m sure I’m missing something simple, so any help would be appreciated.

{
  "schemaNamespace" : "CommonGraphQL",
  "input" : {
    "operationSearchPaths" : [
      "./Sources/Common/GraphQL/**/*.graphql"
    ],
    "schemaSearchPaths" : [
      "./Sources/Common/GraphQL/**/*.graphqls"
    ],
  },
  "output" : {
    "testMocks" : {
      "swiftPackage" : {
      }
    },
    "schemaTypes" : {
      "path" : "./CommonGraphQL",
      "moduleType" : {
        "swiftPackageManager" : {
        }
      }
    },
    "operations" : {
      "inSchemaModule" : {
      }
    }
  },
  "schemaDownloadConfiguration" : {
    "downloadMethod": {
        "introspection": {
            "endpointURL": "https://foo.com/consumer-mobile/graphql",
            "httpMethod": {
                "POST": {}
            },
            "includeDeprecatedInputValues": false,
            "outputFormat": "SDL"
        }
    },
    "downloadTimeout": 60,
    "headers": [],
    "outputPath": "./Sources/Common/GraphQL/schema/CommonSchema.graphqls"
  },
  "options": {
      "queryStringLiteralFormat": "multiline",
      "schemaDocumentation": "include",
      "apqs": "disabled",
      "cocoapodsCompatibleImportStatements": false,
      "warningsOnDeprecatedUsage": "include",
      "conversionStrategies": {
          "enumCases": "camelCase"
      },
      "pruneGeneratedFiles": true
  }
}

ProjectExplorer

NoSuchFile

FileLayout

Hi @dnedrow :wave: - I think it might be that the .graphql/.graphqls files are added to the project as source files when they shouldn’t be. They’re only useful to the codegen engine, not the Xcode project. You don’t need to remove them from them project completely, just from the target so they’re not part of the source code to be compiled.

1 Like