title: iOS 11 Share Extensions Broken
body: <p>Before iOS 11 came out I created a share extension to my social media app. It worked perfectly fine. Once iOS 11 came out, the share extension quit working. I searched and debugged the extension until I found the source of the problem. When looping through the attachments inside the extensionContext.inputItems[0].attachments, none of the attachments has an item conforming to kUTTypeImage. So none of my code was running from that point on. I also had another strange outcome yesterday. This is part of my code inside the didSelectPost function.</p>
  
  <pre><code>    guard let content = extensionContext?.inputItems[0] as? NSExtensionItem else { return }
      guard let contentAttachments = content.attachments as? [NSItemProvider] else { return }
  
      let skyName = self.textView.text
  
      for attachment in contentAttachments {
          if attachment.hasItemConformingToTypeIdentifier(imageType) {
              attachment.loadItem(forTypeIdentifier: imageType, options: nil) { (data, error) in
  
                  guard error == nil, let url = data as? NSURL else { return }
                  self.imageFromAsset(url: url as URL)
                  if !self.selectedType.isEmpty {
                      do {
                          let imageData = try Data(contentsOf: url as URL)
                          self.skyImage = UIImage(data: imageData)
  
                          self.saveSkyImage()
  
                          guard let skyOriginalImageURL = self.skyOriginalImageURL else { return }
                          guard let skyImageURL = self.skyImageURL else { return }
  
                          let newSky = Sky(name: skyName ?? "Another Sky",
                                           type: self.selectedType,
                                           date: self.date,
                                           location: self.location,
                                           picture: CKAsset(fileURL: skyImageURL),
                                           likes: 0, flags: 0,
                                           likedBy: [CKReference](), flaggedBy: [CKReference](),
                                           originalImage: CKReference(record: CKRecord(recordType: "SkyImage"), action: .none))
                          let newSkyImage = SkyImageFullResolution(picture: CKAsset(fileURL: skyOriginalImageURL))
                          self.saveSky(sky: newSky, skyImage: newSkyImage)
                      } catch {
                          print(error.localizedDescription)
                          self.closePostWindow()
                      }
                  }
              }
          }
      }
  
      defer {
          closePostWindow()
      }
  </code></pre>