becvert / cordova-plugin-zeroconf

Cordova ZeroConf Plugin
MIT License
81 stars 57 forks source link

Unable to build application on Phonegap 5.1.1 #9

Closed radek-anuszewski closed 7 years ago

radek-anuszewski commented 8 years ago

Hi! I have tried to build phonegap application using your plugin, here's how I included it in config.xml:

    <gap:plugin name="cordova-plugin-zeroconf" source="npm" />
    <preference name="deployment-target" value="7.0" />

But I got this error:

** BUILD FAILED **

The following build commands failed:
    CompileSwift normal arm64 /project/AcmlControl/Plugins/cordova-plugin-zeroconf/ZeroConf.swift
    CompileSwiftSources normal arm64 com.apple.xcode.tools.swift.compiler
(2 failures)

Here is full stack trace from Phonegap ios log:

CompileSwift normal arm64 /project/AcmlControl/Plugins/cordova-plugin-zeroconf/ZeroConf.swift
    cd /project
    /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift -frontend -c -primary-file /project/AcmlControl/Plugins/cordova-plugin-zeroconf/ZeroConf.swift -target arm64-apple-ios7.0 -Xllvm -aarch64-use-tbi -enable-objc-interop -sdk /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS9.1.sdk -I /project/build -F /project/build -g -serialize-debugging-options -Xcc -I/project/build/AcmlControl.build/Release-iphoneos/AcmlControl.build/swift-overrides.hmap -Xcc -iquote -Xcc /project/build/AcmlControl.build/Release-iphoneos/AcmlControl.build/AcmlControl-generated-files.hmap -Xcc -I/project/build/AcmlControl.build/Release-iphoneos/AcmlControl.build/AcmlControl-own-target-headers.hmap -Xcc -I/project/build/AcmlControl.build/Release-iphoneos/AcmlControl.build/AcmlControl-all-target-headers.hmap -Xcc -iquote -Xcc /project/build/AcmlControl.build/Release-iphoneos/AcmlControl.build/AcmlControl-project-headers.hmap -Xcc -I/project/build/include -Xcc -I/project/build/usr/local/lib/include -Xcc -I/project/build/UninstalledProducts/include -Xcc -I/project/build -Xcc -I/project/build/AcmlControl.build/Release-iphoneos/AcmlControl.build/DerivedSources/arm64 -Xcc -I/project/build/AcmlControl.build/Release-iphoneos/AcmlControl.build/DerivedSources -Xcc -working-directory/project -emit-module-doc-path /project/build/AcmlControl.build/Release-iphoneos/AcmlControl.build/Objects-normal/arm64/ZeroConf~partial.swiftdoc -O -parse-as-library -module-name AcmlControl -emit-module-path /project/build/AcmlControl.build/Release-iphoneos/AcmlControl.build/Objects-normal/arm64/ZeroConf~partial.swiftmodule -serialize-diagnostics-path /project/build/AcmlControl.build/Release-iphoneos/AcmlControl.build/Objects-normal/arm64/ZeroConf.dia -emit-dependencies-path /project/build/AcmlControl.build/Release-iphoneos/AcmlControl.build/Objects-normal/arm64/ZeroConf.d -emit-reference-dependencies-path /project/build/AcmlControl.build/Release-iphoneos/AcmlControl.build/Objects-normal/arm64/ZeroConf.swiftdeps -o /project/build/AcmlControl.build/Release-iphoneos/AcmlControl.build/Objects-normal/arm64/ZeroConf.o
/project/AcmlControl/Plugins/cordova-plugin-zeroconf/ZeroConf.swift:10:34: error: use of undeclared type 'CDVPlugin'
@objc(ZeroConf) class ZeroConf : CDVPlugin  {
                                 ^~~~~~~~~
/project/AcmlControl/Plugins/cordova-plugin-zeroconf/ZeroConf.swift:10:2: error: only classes that inherit from NSObject can be declared @objc
@objc(ZeroConf) class ZeroConf : CDVPlugin  {
~^~~~
/project/AcmlControl/Plugins/cordova-plugin-zeroconf/ZeroConf.swift:15:19: error: method does not override any method from its superclass
    override func pluginInitialize() {
    ~~~~~~~~      ^
/project/AcmlControl/Plugins/cordova-plugin-zeroconf/ZeroConf.swift:20:19: error: method does not override any method from its superclass
    override func onAppTerminate() {
    ~~~~~~~~      ^
/project/AcmlControl/Plugins/cordova-plugin-zeroconf/ZeroConf.swift:32:28: error: use of undeclared type 'CDVInvokedUrlCommand'
    func register(command: CDVInvokedUrlCommand) {
                           ^~~~~~~~~~~~~~~~~~~~
/project/AcmlControl/Plugins/cordova-plugin-zeroconf/ZeroConf.swift:59:30: error: use of undeclared type 'CDVInvokedUrlCommand'
    func unregister(command: CDVInvokedUrlCommand) {
                             ^~~~~~~~~~~~~~~~~~~~
/project/AcmlControl/Plugins/cordova-plugin-zeroconf/ZeroConf.swift:75:24: error: use of undeclared type 'CDVInvokedUrlCommand'
    func stop(command: CDVInvokedUrlCommand) {
                       ^~~~~~~~~~~~~~~~~~~~
/project/AcmlControl/Plugins/cordova-plugin-zeroconf/ZeroConf.swift:86:25: error: use of undeclared type 'CDVInvokedUrlCommand'
    func watch(command: CDVInvokedUrlCommand) {
                        ^~~~~~~~~~~~~~~~~~~~
/project/AcmlControl/Plugins/cordova-plugin-zeroconf/ZeroConf.swift:104:27: error: use of undeclared type 'CDVInvokedUrlCommand'
    func unwatch(command: CDVInvokedUrlCommand) {
                          ^~~~~~~~~~~~~~~~~~~~
/project/AcmlControl/Plugins/cordova-plugin-zeroconf/ZeroConf.swift:119:25: error: use of undeclared type 'CDVInvokedUrlCommand'
    func close(command: CDVInvokedUrlCommand) {
                        ^~~~~~~~~~~~~~~~~~~~
/project/AcmlControl/Plugins/cordova-plugin-zeroconf/ZeroConf.swift:138:30: error: use of undeclared type 'CDVCommandDelegate'
        var commandDelegate: CDVCommandDelegate?
                             ^~~~~~~~~~~~~~~~~~
/project/AcmlControl/Plugins/cordova-plugin-zeroconf/ZeroConf.swift:194:30: error: use of undeclared type 'CDVCommandDelegate'
        var commandDelegate: CDVCommandDelegate?
                             ^~~~~~~~~~~~~~~~~~
/project/AcmlControl/Plugins/cordova-plugin-zeroconf/ZeroConf.swift:53:37: error: use of unresolved identifier 'commandDelegate'
        publisher.commandDelegate = commandDelegate
                                    ^~~~~~~~~~~~~~~
/project/AcmlControl/Plugins/cordova-plugin-zeroconf/ZeroConf.swift:98:35: error: use of unresolved identifier 'commandDelegate'
        browser.commandDelegate = commandDelegate
                                  ^~~~~~~~~~~~~~~
/project/AcmlControl/Plugins/cordova-plugin-zeroconf/ZeroConf.swift:213:32: error: use of unresolved identifier 'CDVPluginResult'
            let pluginResult = CDVPluginResult(status: CDVCommandStatus_NO_RESULT)
                               ^~~~~~~~~~~~~~~
/project/AcmlControl/Plugins/cordova-plugin-zeroconf/ZeroConf.swift:213:56: error: use of unresolved identifier 'CDVCommandStatus_NO_RESULT'
            let pluginResult = CDVPluginResult(status: CDVCommandStatus_NO_RESULT)
                                                       ^~~~~~~~~~~~~~~~~~~~~~~~~~
/project/AcmlControl/Plugins/cordova-plugin-zeroconf/ZeroConf.swift:231:32: error: use of unresolved identifier 'CDVPluginResult'
            let pluginResult = CDVPluginResult(status: CDVCommandStatus_NO_RESULT)
                               ^~~~~~~~~~~~~~~
/project/AcmlControl/Plugins/cordova-plugin-zeroconf/ZeroConf.swift:231:56: error: use of unresolved identifier 'CDVCommandStatus_NO_RESULT'
            let pluginResult = CDVPluginResult(status: CDVCommandStatus_NO_RESULT)
                                                       ^~~~~~~~~~~~~~~~~~~~~~~~~~
/project/AcmlControl/Plugins/cordova-plugin-zeroconf/ZeroConf.swift:269:36: error: use of unresolved identifier 'CDVPluginResult'
                let pluginResult = CDVPluginResult(status: CDVCommandStatus_OK, messageAsDictionary: message as [NSObject : AnyObject])
                                   ^~~~~~~~~~~~~~~
/project/AcmlControl/Plugins/cordova-plugin-zeroconf/ZeroConf.swift:269:60: error: use of unresolved identifier 'CDVCommandStatus_OK'
                let pluginResult = CDVPluginResult(status: CDVCommandStatus_OK, messageAsDictionary: message as [NSObject : AnyObject])
                                                           ^~~~~~~~~~~~~~~~~~~
/project/AcmlControl/Plugins/cordova-plugin-zeroconf/ZeroConf.swift:282:32: error: use of unresolved identifier 'CDVPluginResult'
            let pluginResult = CDVPluginResult(status: CDVCommandStatus_OK, messageAsDictionary: message as [NSObject : AnyObject])
                               ^~~~~~~~~~~~~~~
/project/AcmlControl/Plugins/cordova-plugin-zeroconf/ZeroConf.swift:282:56: error: use of unresolved identifier 'CDVCommandStatus_OK'
            let pluginResult = CDVPluginResult(status: CDVCommandStatus_OK, messageAsDictionary: message as [NSObject : AnyObject])
                                                       ^~~~~~~~~~~~~~~~~~~

** BUILD FAILED **

The following build commands failed:
    CompileSwift normal arm64 /project/AcmlControl/Plugins/cordova-plugin-zeroconf/ZeroConf.swift
    CompileSwiftSources normal arm64 com.apple.xcode.tools.swift.compiler
(2 failures)

I am using 5.1.1 version: <preference name="phonegap-version" value="cli-5.1.1" />

Please answer if you need more information, I will provide it as soon as possible. Thank you in advance for looking for this problem.

Greetings, Radek.

P.S.

It happened for both 1.0.1 and 1.1.0 versions.

becvert commented 8 years ago

Hi @radek-anuszewski Did you follow the installation section in the README? in particular this: Objective-C Bridging Header: YOUR_PROJECT/Bridging-Header.h Insert the content of the ZeroConf-Bridging-Header.h file in it.

radek-anuszewski commented 8 years ago

Thank @becvert to you for very fast answer, I placed Bridging-Header.h in www directory (which is zipped with config.xml to produce .zip for upload to Phonegap) with content: #import <Cordova/CDV.h> But I don't know how to set, for example - Embedded Content Contains Swift Code: YES - I am using Windows 7 for development, do I have to build it locally on Mac? I am grateful to you for your help.

becvert commented 8 years ago

I'm not familiar with Phonegap. The Bridging-header.h file goes into \platforms\ios\ Have you got access locally or remotely to the platforms/ios folder?

genox commented 8 years ago

This might pose a similar issue with current ionic package cloud builds. The way these builds work is that they usually only upload your config.xml plus a JSON that lists plugins with github/npm references. Anything you change in platform folders (that you'd use for local builds) won't work using cloud based building tools like phonegap or ionic build.

In order to get this to work with remote build services, I used https://github.com/akofman/cordova-plugin-add-swift-support

However, I just ran into another issue. When I build an app like that on ionic, everything works fine (zeroconf) but when submitting to the App Store I get the following error from Apple:

Invalid Swift Support - The SwiftSupport folder is missing. Rebuild your app using the current public (GM) version of Xcode and resubmit it.

Now I'm not sure wether this is an Ionic build issue, an issue of zeroconf plugin or the swift plugin.

However, when I use the latest Xcode and an Ionic generated xcode project, during compilation, I get a lot of "old swift syntax" errors.

becvert commented 8 years ago

Hi @genox

I think I'll add cordova-plugin-add-swift-support as a dependency to allow building on Phonegap and ionic.

I will update zeroconf with the latest Xcode and try to fix swift syntax errors. I may not be up-to-date.

All of this may help with the "invalid swift support". I don't know.

Thanks

genox commented 8 years ago

Hey @becvert - that would be great. Thank you.

becvert commented 8 years ago

Phonegap/Ionic builds should be supported now. Please let me know if it's working.

becvert commented 8 years ago

I have not encountered old swift syntax errors