becvert / cordova-plugin-zeroconf

Cordova ZeroConf Plugin
MIT License
81 stars 57 forks source link

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

Open alanjohnson opened 3 years ago

alanjohnson commented 3 years ago

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 commented 3 years ago

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:

alanjohnson commented 3 years ago

I'm running:

Cordova 10.0.0 iOS 14.7.1 xCode Version 12.5.1 (12E507)

emcniece commented 3 years ago

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

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

alanjohnson commented 3 years ago

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 commented 3 years ago

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 commented 2 years ago

i have same error. xcode 13.1