0

I have an old project that I built on iOS 7 with Xcode 5. Recently I upgraded to Xcode 6 GM. I opened that project in new Xcode and tried adding this swift code to one of my method in v1Album.m file.

let alertController = UIAlertController(title: "Hey AppCoda", message: "What do you want to do?", preferredStyle: .Alert)

I get an error saying Use of undeclared identified let

enter image description here

I have been searching, trying to see what I need to do, what settings I need to change in my project in order for it to start recognizing swift code. Every tutorial online I see is explaining how to start writing swift code in a brand new project. All I need is to be pointed in the right direction.

EDIT: What I have read so far on migrating project to swift from Apple Doc here is that

  • in order to write swift code I need a brand new swift class
  • I need to rewire all my objective-c code from v1Album.m to v1Album.swift
  • Then I deselect v1Album.m from my project.
  • I cannot use swift code directly in v1Album.m without first defining that method in v1Album.swift file and then using a bridging header.
  • Basically I cannot do what I am trying to do i.e. write straight up swift code in *.m file.

Please correct me, I maybe completely wrong.

Cœur
  • 37,241
  • 25
  • 195
  • 267
Sam B
  • 27,273
  • 15
  • 84
  • 121
  • You can't put Swift code in an Objective-C method (or a .m file for that matter). – rmaddy Sep 28 '14 at 00:00
  • possible duplicate of [Is it possible to have Swift & Objective-C code in the same file?](http://stackoverflow.com/questions/24413401/is-it-possible-to-have-swift-objective-c-code-in-the-same-file) – rmaddy Sep 28 '14 at 00:02

0 Answers0