Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

iOS Build error: Cannot find 'Hostname' in scope #97

Open
alanjohnson opened this issue Aug 17, 2021 · 6 comments
Open

iOS Build error: Cannot find 'Hostname' in scope #97

alanjohnson opened this issue Aug 17, 2021 · 6 comments

Comments

@alanjohnson
Copy link

The plugin works perfect on android, but it seems to have broken my IOS build.

I'm seeing this error:

cordova-plugin-zeroconf/ZeroConf.swift:27:24: error: cannot find 'Hostname' in scope
        let hostname = Hostname.get() as String

I did the steps listed for iOS, but can't find any information on how to resolve this error

@emcniece
Copy link
Collaborator

Hostname is defined in Hostname.m, included in Hostname.h and wrapped up in ZeroConf-Bridging-Header.h.

ZeroConf-Bridging-Header.h is included in the project on https://github.com/becvert/cordova-plugin-zeroconf/blob/master/plugin.xml#L40.

If Hostname is undefined, I'd first ask if ZeroConf-Bridging-Header.h is being parsed properly. This has worked for a while, so what could have changed? Is this an XCode issue, or does iOS 15 change something, or is Capacitor no longer compatible?

@alanjohnson if you could provide some extra info:

  • Are you using Cordova or Capacitor? Which version?
  • What iOS version?
  • What XCode version?

@alanjohnson
Copy link
Author

I'm running:

Cordova 10.0.0
iOS 14.7.1
xCode Version 12.5.1 (12E507)

@emcniece
Copy link
Collaborator

Hm. Does ZeroConf-Bridging-Header.h show up in the project build settings?

Something like this: https://stackoverflow.com/a/37269127

@alanjohnson
Copy link
Author

No, I did not see it in there. If I manually update the Objective-C Bridging Header to point to that file, it starts to build again. Or if I make a new one (as per your provided link), and add the imports, it works as well.

Looks like after running cordova platforms add ios,it has "Objective-C Bridging Header" set to a generic file ($(PROJECT_DIR)/$(PROJECT_NAME)/Bridging-Header.h which doesn't appear to exist. 🤷‍♂️

@emcniece
Copy link
Collaborator

If I recall, Cordova is supposed to add the bridging header during cordova plugin add x, after running cordova platforms add ios. Strange that it didn't automatically happen, that could be an issue with Cordova or XCode.

I might recommend ensuring the header is present in the build settings manually, making a note in your project setup instructions, or even adding a Cordova hook to add it during after_plugin_add or before_build.

@coloz
Copy link

coloz commented Oct 30, 2021

i have same error. xcode 13.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants