Invalid redeclaration of 'variable.storage' in Swift 4.2 after updating to Xcode 10.2
Asked Answered
S

2

17

We have an iOS project. The Swift language version is 4.2. We were previously building it in Xcode 10.1 with no compile errors.

After updating to Xcode 10.2 (but keeping Swift 4.2), the project is now riddled with errors like Invalid redeclaration of 'variable.storage' (where variable is the name of some variable). These errors appear next to private, lazily-inited variables with names that are commonly used throughout the project, but are not redeclarations within their scope; the error seems to relate to the storage part of the message. A clean-and-rebuild did not resolve the issue. Any suggestions?

EDIT: These errors only showed up in two classes. There was also another legitimate compile error (new in Xcode 10.2, but legitimate enough) that I missed because of all these redeclaration errors. After messing around a bit**, I got the errors to go away. Seems like a bug in the compiler.

** My messing-around steps were (1) un-nest the first class I was getting these errors in, (2) created a new class with the same content as the non-compiling one and pointed references to it, (3) commented out the failing class, (4) found and fixed the legitimate compile error. At this point, I didn't need to mess around with the other class that was also giving the redeclaration errors; the code now compiled. So then (5) reverted the first class. So it's possible that these redeclaration errors are just a misdirect; if you find and fix all your migration-related errors, hopefully you won't see any of these.

Symbol answered 29/3, 2019 at 8:31 Comment(1)
(Added the swift5 tag because you're using the Swift 5 compiler, in 4.2-backwards-compatibility mode.)Dizon
G
19

I had the same errors, which also masked some other errors. Once I resolved the other errors, the Invalid redeclaration of 'variable.storage' didn't occur anymore.

Gnni answered 4/4, 2019 at 8:25 Comment(1)
@DylanReich The issue here has nothing to do with Xcode; the issue is with the Swift compiler. You'll find the same results if using the Swift 5 compiler from the command line, or from another platform (e.g. Linux).Dizon
S
0

I have the same issue after removing a pod framework, and no other type errors. Can't find what's wrong. Trying with Xcode11 swift5.1 ...

Spume answered 10/7, 2019 at 2:46 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.