cordova-plugin-zeroconf icon indicating copy to clipboard operation
cordova-plugin-zeroconf copied to clipboard

iOS Build error: Cannot find 'Hostname' in scope

Open alanjohnson opened this issue 4 years ago • 6 comments

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

alanjohnson avatar Aug 17 '21 14:08 alanjohnson

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?

emcniece avatar Aug 17 '21 15:08 emcniece

I'm running:

Cordova 10.0.0 iOS 14.7.1 xCode Version 12.5.1 (12E507)

alanjohnson avatar Aug 17 '21 17:08 alanjohnson

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

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

emcniece avatar Aug 17 '21 18:08 emcniece

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. 🤷‍♂️

alanjohnson avatar Aug 17 '21 21:08 alanjohnson

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.

emcniece avatar Aug 17 '21 22:08 emcniece

i have same error. xcode 13.1

coloz avatar Oct 30 '21 02:10 coloz