DavidPeicho / unity-swiftui-example

Integration example of the Unity engine in a SwiftUI-based application
MIT License
71 stars 16 forks source link

Error for UnityBridge swift file #2

Closed BraveEvidence closed 3 years ago

BraveEvidence commented 3 years ago

Hi, can you help me with this. I have followed all the steps of integrating unity library recommended in the repo

Screenshot 2021-04-14 at 8 02 45 PM
DavidPeicho commented 3 years ago

Hi, I believe your issue is simply that your dependencies are wrong and so the API defined in UnityBridge isnt visible. Did you set the header to public?

BraveEvidence commented 3 years ago

Yes

DavidPeicho commented 3 years ago

I will need a bit more context to help here, but It definitely is a small build issue

dandepeched commented 3 years ago

@DavidPeicho , I have same problem when trying to use your files in my own project. Your project is working perfect, but when I took UnityBridge.swift and NativeCallProxy-Bridging-Header.h for my project, it now cannot be builded. I'm using same unity sample project and files dependencies are the same in it. My project is just swift, without swiftui. Screenshot 2021-06-07 at 09 18 53 Screenshot 2021-06-07 at 09 21 00 Screenshot 2021-06-07 at 09 19 52 Screenshot 2021-06-07 at 09 19 05

DavidPeicho commented 3 years ago

Hey @dandepeched, you need to set the NativeCallProxy.h as a bridging header. It's an ObjectiveC file, and the swift need some info about that. Please have a look at the Apple documentation

dandepeched commented 3 years ago

Yes, I was missing path to the NativeCallProxy-Bridging-Header.h in the Build Settings/Objective-С Bridging Header. Now I can build the project. Thanks for your help!