Errors after importing Obj-C files through bridging header
Asked Answered
S

1

6

I am trying to import this project into my swift project. What I have done is add the PanoromaView.h and PanoromaView.m files, and added #import "PanoramaView.h" to my bridging header. I have also added the OpenGLES.framework and GLKit.Framework to my project.

I am now getting errors saying

Cannot find interface declaration for 'GLKView', superclass of 'PanoramaView'

and

Unknown type name 'GLKVector3'

This is an image of the errors in the code:

enter image description here

If anybody can help explain what these are how I remove them that would be great.

Thanks

EDIT:

I have also tried installing through Cocoapods and still get the exact same errors, very strange?

Slipway answered 8/5, 2016 at 13:21 Comment(6)
You need to import whatever PanoramaView depends on. You should double check the source of those files and follow very closely the installation guidelines.Obtuse
There are no installation guidelines, as you can see on the link. So I'm trying to work it out myself and I am stuck at this point. I thought I had importing everything it depends on I'm not sure what else is needed?Slipway
Oh, well... it's a pod. Just use CocoaPods to install it? pod 'PanoramaView'Obtuse
I have never used pods before but I will give this a try also then. ThanksSlipway
@Obtuse I have now installed with CocoaPods but still get the exact same errors? Can you assist any further?Slipway
Try to not use Parse. It's about to close.Eiten
D
7

In order to make it work, I had to add this into PanoramaView.h:

#import <GLKit/GLKit.h>

Suggested on the github code does not work for me from the box. Also I had to modify ViewController:

import UIKit

class ViewController: GLKViewController {

    var panoramaView = PanoramaView()

    override func loadView() {
        panoramaView.setImageWithName("park_2048.jpg")
        panoramaView.touchToPan = true          // Use touch input to pan
        panoramaView.orientToDevice = false     // Use motion sensors to pan
        panoramaView.pinchToZoom = true         // Use pinch gesture to zoom
        panoramaView.showTouches = true         // Show touches
        self.view = panoramaView
    }

    override func glkView(view: GLKView, drawInRect rect: CGRect) {
        panoramaView.draw()
    }
}

This is my sample app:

https://github.com/melifaro-/Swift-PanoramaSample

Hope it helps.

BTW, I did not use CocoaPods. I use PanoramaView.h and PanoramaView.m files only.

Dene answered 13/5, 2016 at 14:20 Comment(11)
Thank you this is brilliant, just what I needed. I am not sure if you could also help me partially further. I want to be able to load the panoroma inside a view rather then a viewController? I know I have to use the GLKView but do you have any example code on this also would be great. thanks againSlipway
Yep, sure. That won't be difficult.Dene
Thank you, where will I find this?Slipway
That shouldn't, but that is. I had to modify PanoramaView class itself. You can check out my sample on github. I have pushed changes there.Dene
This isn't inside a GLKView, this is inside a GLKViewController?Slipway
Oh Sorry I see what you have done now, Thanks for this - although I meant done programmatically, I do not like to use the IB... If you know how to do with just the code that would be great.Slipway
Hmm, I don't know how to do thatDene
Ok thanks for your help then. What you have created is a GLKViewController in the IB. Do you know how to add a GLKView through the IB rather then through code then?Slipway
If my understanding is corrent you need both for correct work. Actually in the latest version there are presented both GLKViewController and GLKView (PanoramaView) in the storyboard file.Dene
Yes but I want to be able to do is change the GLKViews frame size, what you have provided the view is embedded in the VC and the dimensions cannot be changed?Slipway
Right, It occupies all the available space. Not sure how to change the GLKView frame size.Dene

© 2022 - 2024 — McMap. All rights reserved.