title: Invalid redeclaration of init() for iOS Swift Core Data Implementation RELEASE build only
body: <p>I am running into a strange situation that I am unsure how to fix.  </p>
  
  <p>I have an iOS app I am working on in Swift that uses Core Data that I have been successfully building and running as a Debug build for some time now.  I have now attempted to build for profiling of the release build, and subsequently just tried to do a release build without profiling, and either release build fails with the error 'Invalid redeclaration of init()' for a struct that defines the storage implementation portion of my code that sets up the storage components of Core Data.</p>
  
  <p>Here is the code that compiles and runs fine in debug, but fails to build in release...</p>
  
  <pre><code>struct MyStorage { //&lt;-- Invalid redeclaration of init() build error in release build only
  
  static var shared = MyStorage()
  
  @available(iOS 10.0, *)
  private lazy var persistentContainer: NSPersistentContainer = {
  
      let container = NSPersistentContainer(name: "MyStorage")
      container.loadPersistentStores { (storeDescription, error) in
          print("CoreData: Inited \(storeDescription)")
          guard error == nil else {
              print("CoreData: trying to create persistentContainer named Model and got Unresolved error \(String(describing: error))")
              return
          }
  
      }
      return container
  }()
  
  private lazy var persistenStoreCoordinator: NSPersistentStoreCoordinator? = {
      do {
          return try NSPersistentStoreCoordinator.coordinator(name:"MyStorage")
      } catch {
          print ("CoreData: trying to create persistenStoreCoordinator named Model and got Unresolved error \(error)")
      }
  
      return nil
  }()
  
  private lazy var managedObjectContext: NSManagedObjectContext = {
      let coordinator = self.persistenStoreCoordinator
      var managedObjectContext = NSManagedObjectContext(concurrencyType: .mainQueueConcurrencyType)
      managedObjectContext.persistentStoreCoordinator = coordinator
  
      print ("CoreData: initing and returning managedObjectContext")
  
      return managedObjectContext
  }()
  
  enum SaveStatus {
      case saved, rolledBack, hasNoChanges
  }
  
  var context: NSManagedObjectContext {
      mutating get {
          if #available(iOS 10.0, *) {  
              return persistentContainer.viewContext
          } else {
              return managedObjectContext
          }
      }
  }
  
  mutating func save() -&gt; SaveStatus {
      if context.hasChanges {
          do {
              try context.save()
              return .saved
          } catch {
              context.rollback()
              return .rolledBack
          }
      }
      return .hasNoChanges
  }
  </code></pre>
  
  <p>I cleaned the build (and option-cleaned to clean the build folder), both to no avail.  Can anyone help shed light on why the release build fails yet the debug build succeeds with this same code?</p>
  
  <p>Thanks in advance for any help or suggestions.</p>
  
  <p><strong>UPDATE</strong>: Per the suggestion below, I changed the MyStorage struct to a class and removed mutating and now the code can build in release configuration and can be profiled for released build.</p>