Skip to content

Removing @objc inference warnings when migrating from Swift3 to Swift4

   

When I switch from Xcode8 to Xcode9 and convert to Swift4, I get the following error. Here's how to make it disappear.

The use of Swift 3 @objc inference in Swift 4 mode is deprecated. Please address deprecated @objc inference warnings, test your code with “Use of deprecated Swift 3 @objc inference” logging enabled, and then disable inference by changing the "Swift 3 @objc Inference" build setting to "Default" for the "TargetName" target.

Select each target -> Build Settings -> Search for inference in the search window -> Set Swift @objc inference to Default 
If there are other targets (UITest and UnitTest), set them to Default too.
It should be gone now!

  1. Pinch to zoom in and out on an image with UIScrollView
  2. Removing the back button in UINavigationController.
  3. Execute after ○ seconds, execute every second
  4. Setting a header in UITableView
  5. Adding a Custom Cell to UICollectionView
  6. UICollectionView
  7. Skip the Export Compliance Wizard