Swift With Objective C Tip 1

If you’ve started down the road of incorporating Swift into an Objective C project, and run into an error when adding calling a method in your Swift class that Xcode says isn’t there, or doesn’t autocomplete, try the following:

  • Add your #import “module-Swift.h” to your Objective C .m file. (In my case it’s #import “AppName-Swift.h”.
  • If that doesn’t work, recompile. You’ve probably just added a method in your Swift file, and Xcode needs a chance to compile it and add it to that auto-generated module-Swift.h file

Hopefully I’ll have more tips as I use Swift more and more at work. Stay tuned.