# \[iOS\] ApolloInterceptor protocol conformance

**URL:** <https://community.apollographql.com/t/ios-apollointerceptor-protocol-conformance/7527>\
**Category:** Client SDKs\
**Tags:** ios\
**Created:** [May 17, 2024, 6:32am UTC](https://community.apollographql.com/t/ios-apollointerceptor-protocol-conformance/7527 "2024-05-17T06:32:32Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![TimK](https://avatars.discourse-cdn.com/v4/letter/t/da6949/32.png) [@TimK](https://community.apollographql.com/u/TimK)\
**Post date:** [May 17, 2024, 6:32am UTC](https://community.apollographql.com/t/ios-apollointerceptor-protocol-conformance/7527/1 "2024-05-17T06:32:33Z")

</div>

I am current getting the following errors when trying to create an interceptor.

 ![Screenshot 2024-05-17 at 4.21.10 PM](https://us1.discourse-cdn.com/flex019/uploads/apollographql/original/2X/3/3a0641079ff5319006f30761e8d869e4db3e1562.png)

I’m using Apollo version 1.11.0 using swift package manager.

I’m on Xcode 15.3 on an M3 Apple Silicon machine. The version on the demo code is 1.2. I tried to change to that but is still didn’t. If I change the version on the demo project it fails with similar messages. I’ve tried other variants of code. Interestingly if I let Xcode add the stubs it still says it doesn’t conform. The second error is weird too because if I try to add ‘any Error’ in the closure Xcode treats that as error. Anyone encountered similar issues? I’m sure if the problem is with Xcode or Apollo.  
Here is my class.

````import
import Apollo
import ApolloAPI

class AuthorizationInterceptor: ApolloInterceptor {
    
    func interceptAsync<Operation>(
        chain: RequestChain,
        request: HTTPRequest<Operation>,
        response: HTTPResponse<Operation>?,
        completion: @escaping (Result<GraphQLResult<Operation.Data>, Error>) -> Void
    ) where Operation : GraphQLOperation {
        let keychain = KeychainSwift()
        if let token = keychain.get(LoginView.loginKeychainKey) {
            request.addHeader(name: "Authorization", value: token)
        }
        
        chain.proceedAsync(request: request,
                           response: response,
                           completion: completion)
    }
    
}```
````

---

<div class="post-metadata">

**Author:** ![calvincestari](https://sea1.discourse-cdn.com/flex019/user_avatar/community.apollographql.com/calvincestari/32/339_2.png) [@calvincestari](https://community.apollographql.com/u/calvincestari)\
**Post date:** [May 17, 2024, 4:53pm UTC](https://community.apollographql.com/t/ios-apollointerceptor-protocol-conformance/7527/2 "2024-05-17T16:53:09Z")

</div>

Hi @TimK - I think this is just that the demo project hasn’t been updated as the function definitions have changed. I’ll get that updated and get back to you here.

---

<div class="post-metadata">

**Author:** ![calvincestari](https://sea1.discourse-cdn.com/flex019/user_avatar/community.apollographql.com/calvincestari/32/339_2.png) [@calvincestari](https://community.apollographql.com/u/calvincestari)\
**Post date:** [May 17, 2024, 9:45pm UTC](https://community.apollographql.com/t/ios-apollointerceptor-protocol-conformance/7527/3 "2024-05-17T21:45:39Z")

</div>

OK, I’ve updated the tutorial to build successfully with the latest version of Apollo iOS. The changes you specifically mentioned above can be found in [iOSTutorial/final/RocketReserver/AuthorizationInterceptor.swift at main · apollographql/iOSTutorial · GitHub](https://github.com/apollographql/iOSTutorial/blob/main/final/RocketReserver/AuthorizationInterceptor.swift). If you pull the latest you’ll have a project that builds again, apologies for the inconvenience.

---

<div class="post-metadata">

**Author:** ![TimK](https://avatars.discourse-cdn.com/v4/letter/t/da6949/32.png) [@TimK](https://community.apollographql.com/u/TimK)\
**Post date:** [May 18, 2024, 12:05am UTC](https://community.apollographql.com/t/ios-apollointerceptor-protocol-conformance/7527/4 "2024-05-18T00:05:48Z")

</div>

Thanks Calvin. The demo project now works with higher versions but when I insert the interceptor code in to my own project I get the same errors. I’m now testing against Apollo 1.7. 0. I can also get the code to work in a test project with the same dependencies. It think it must be something in my build settings.

---

<div class="post-metadata">

**Author:** ![TimK](https://avatars.discourse-cdn.com/v4/letter/t/da6949/32.png) [@TimK](https://community.apollographql.com/u/TimK)\
**Post date:** [May 18, 2024, 3:56am UTC](https://community.apollographql.com/t/ios-apollointerceptor-protocol-conformance/7527/5 "2024-05-18T03:56:50Z")

</div>

Found the problem. There was a redeclaration (rather than extension) of Error in my code which was causing this to fail. Thanks again for updating the code @calvincestari . It did help unravel this issue.

---

<div class="post-metadata">

**Author:** ![calvincestari](https://sea1.discourse-cdn.com/flex019/user_avatar/community.apollographql.com/calvincestari/32/339_2.png) [@calvincestari](https://community.apollographql.com/u/calvincestari)\
**Post date:** [May 21, 2024, 4:02pm UTC](https://community.apollographql.com/t/ios-apollointerceptor-protocol-conformance/7527/6 "2024-05-21T16:02:39Z")

</div>

Hi @TimK - would you mind filling out a 1-minute survey to help us understand more about your experience with Apollo iOS? What do you like best? What needs to be improved? Your honest feedback will help us make the best library possible, thank you.

> **[Apollo Clients User Survey](https://docs.google.com/forms/d/e/1FAIpQLSczNDXfJne3ZUOXjk9Ursm9JYvhTh1_nFTDfdq3XBAFWCzplQ/viewform?usp=pp_url&entry.204965213=Direct%2BOutreach)**
>
> • This survey is for users of all open-source GraphQL client libraries maintained by Apollo: Apollo Client, Apollo iOS, and Apollo Kotlin.
> • Your responses will be recorded and used to improve the product.
> • Please DO NOT include any personal...
