0

I added the swift bridge and changed the proper settings to allow swift in the objc project. But my big issue is that the swift3 code that I am trying to bridge is coming up all errors in my project as it shows it has no members, no types etc.. Along with that Parse is giving off errors and not wanting to work.. I don't know if its the foundation of the project if its too old and can't do this as the project is 2 years old or what...

Swift Errors of member issues

Parse Errors

Here are some of the errors that I see and I am hoping to be pointed in the correct direction.

tltr- Some of the big issues I'm facing as I see is that Type 'UIApplication' has no member 'shared' and Use of unresolved identifier 'Parse' along with Value of type 'UIImage' has no member 'draw'

codeNinjaBro
  • 78
  • 10
  • The Swift errors of member issues are mostly things that have auto-suggested fixes, so just keep clicking on those. The parse library is another story. I'm under the impression that that was discontinued. See their migration guide here: https://parse.com/migration – matt.writes.code Nov 17 '16 at 15:45
  • Why not create a Swift 3 project and bridge the objc code into it? – MwcsMac Nov 17 '16 at 15:46
  • @MwcsMac we can't do that because the objective c project is much bigger than the swift3 code – codeNinjaBro Nov 17 '16 at 16:22

1 Answers1

0

You need to import ProjectName-Swift.h. Note that it's the project name - the other answers make the mistake of using the class name.

This single file is an autogenerated header that defines Objective-C interfaces for all Swift classes in your project that are either annotated @objc or inherit from NSObject.

If your project name contain spaces, replace them with underscores (e.g. "My Project" becomes "My_Project-Swift.h")

Hiroki Murahi
  • 270
  • 1
  • 5
  • I already created this and all the errors still happen. Some of the big issues I'm facing as I see is that Type 'UIApplication' has no member 'shared' and Use of unresolved identifier 'Parse' along with Value of type 'UIImage' has no member 'draw' – codeNinjaBro Nov 17 '16 at 16:42
  • Don't create the header file yourself. Delete the one you created. Make sure your Swift classes are tagged with @objc or inherit from a class that derives (directly or indirectly) from NSObject. Xcode won't generate the file if you have any compiler errors in your project - make sure your project builds cleanly. – Hiroki Murahi Nov 17 '16 at 16:45
  • please check this: http://pinkstone.co.uk/how-to-use-swift-classes-in-objective-c/ – Hiroki Murahi Nov 17 '16 at 16:46
  • Ok so I've fixed up the foundation with correcting the syntax. Now it seems I am down to Use of undeclared type 'IndexPath' for my collection views. How do I go about modifying this without breaking the code here: func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell { let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "cellid", for: indexPath) as! ItemCollectionViewCell – codeNinjaBro Nov 17 '16 at 18:03
  • any ideas how I go about that last issue? – codeNinjaBro Nov 17 '16 at 19:19