1

I am planning to add two files from objective C, [PendulumView.h and PendulumView.m] to swift. But if I try to create bridging header, I am unable to create Bridging header. Xcode doesn't ask me "Would you like to create bridging header?". That dialog box also not appeared. If I proceed and I imported my header file, I am receiving error.

(Command + N) -> iOS -> Source -> Objective-C/Header file. No Bridging header is creating. Automatically, .h or .m file is created.

pendulum_header.h file

#ifndef pendul_test_pendul_Header_h
#define pendul_test_pendul_Header_h

#import "PendulumView.h"

#endif

ViewController file

override func viewDidLoad() {
    super.viewDidLoad()

    var pendul_object = PendulumView() //Error Receiving. Unresolved Identifier PendulumView

}

Screen shot is below:

enter image description here

enter image description here

enter image description here

15
  • possible duplicate of Reference types defined in Objective C Library from Swift Application Commented Apr 16, 2015 at 10:44
  • Same issue,, that dialog box is not appearing. I have tried another way, Same issue happening. Bridging header file is not creating. Commented Apr 16, 2015 at 11:08
  • read to the bottom of my answer there. Commented Apr 16, 2015 at 11:21
  • Still now not clear. Can u guide me? according to my output. Commented Apr 16, 2015 at 11:45
  • Did you follow the steps in my answer there, all the way through the entire answer? What part is unclear? Commented Apr 16, 2015 at 12:08

2 Answers 2

2

Mistake is completely my side.

What I did?

  1. Open new project -> Imported that .h and .m file.
  2. Right Click -> New File -> "iOS -> Source -> Objective-C.m"
  3. .m file has been created, but bridging header not created.

What should do?

  1. Open new project
  2. Right Click -> New File -> "iOS -> Source -> Objective-C.m"
  3. Bridging header has been created with .m file.
  4. Then, Import that .h and .m file.
Sign up to request clarification or add additional context in comments.

Comments

0

Try go to your project settings. In the Build Settings tabs go to the search field and search for bridging. In the following search result you should see: Swift Compiler - Code Generation with a setting for Objective-C Bridging Header. Change the value to your project path (where your project files are stored in) and you should be good to go.

4 Comments

At the top left corner, theres a button for Basic and All. Press the All button and it should show.
ya got it. How to find project path??
One easy way to do it is: click on a random (swift) file in your project. In your utilities panel (with all the options etc) there should be two icons. Click on the left icon looking like a document if it's not already selected. In the second section there's the full path of that file. Use that path (minus the file name you've clicked).
Objective C Bridging Header /Users/xxxxxyyyy/Desktop/POC_PROJ/FULL_Swift/pendul_test/

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.