becvert / cordova-plugin-zeroconf

Cordova ZeroConf Plugin
MIT License
81 stars 57 forks source link

Can not build ios app by XCode 9 - swift issue #60

Closed NeoLSN closed 6 years ago

NeoLSN commented 6 years ago

Could you please upgrade this plugin into swift 3 or newer version?

becvert commented 6 years ago

it's already using swiftt 3. please re-install the plugin and its dependency (swift-support).

emcniece commented 6 years ago

I'm confused by this - I'm building with a forced Swift 3 version and everything compiles.

NeoLSN commented 6 years ago
Check dependencies
[17:19:28]  lint finished in 10.54 s
The “Swift Language Version” (SWIFT_VERSION) build setting must be set to a supported value for targets which use Swift. This setting can be set in the build settings editor.

I really don't have any idea about this. This issue happened in this morning after I re-added platforms. I've tried to re-install this plugin, but the issue is still there.

NeoLSN commented 6 years ago

After testing, seems it is an issue from cordova-plugin-add-swift-support@1.7.1 plugin.

  1. When you git clone a project and restore the platforms, the cordova-plugin-add-swift-support@1.7.1 plugin is not working. The swift has never been setup to correct version.
  2. You have an exist platform and just re-install this plugin. The cordova-plugin-add-swift-support@1.7.1 plugin is still not working. But since the project has been setup before, it will works fine.

Can some one help me to confirm that again? If it is true, I'll close this issue and report this bug on cordova-plugin-add-swift-support plugin.

emcniece commented 6 years ago

I wonder if this might be an XCode environment issue. What is your Swift Compiler / Swift Language Version variable set at?

screen shot 2018-01-05 at 10 01 35 am

NeoLSN commented 6 years ago

I tried several times. It is really a cordova-plugin-add-swift-support plugin issue.

The message when I install cordova-plugin-add-swift-support@1.7.0.

cordova plugin add cordova-plugin-add-swift-support@1.7.0 --save
Installing "cordova-plugin-add-swift-support" for android

ANDROID_HOME=/Users/JasonYang/Library/Android/sdk
JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_152.jdk/Contents/Home
Subproject Path: CordovaLib
Configuration 'compile' in project ':' is deprecated. Use 'implementation' instead.

The Task.leftShift(Closure) method has been deprecated and is scheduled to be removed in Gradle 5.0. Please use Task.doLast(Action) instead.

        at build_3y059ub8lgmys8azlddwlg7dg.run(<project_root>/platforms/android/build.gradle:143)

WARNING: The Jack toolchain is deprecated and will not run. To enable support for Java 8 language features built into the plugin, remove 'jackOptions { ... }' from your build.gradle file, and add

android.compileOptions.sourceCompatibility 1.8
android.compileOptions.targetCompatibility 1.8

Future versions of the plugin will not support usage of 'jackOptions' in build.gradle.
To learn more, go to https://d.android.com/r/tools/java-8-support-message.html

publishNonDefault is deprecated and has no effect anymore. All variants are now published.
:clean

:CordovaLib:clean
UP-TO-DATE

BUILD SUCCESSFUL in 1s
2 actionable tasks: 1 executed, 1 up-to-date
Installing "cordova-plugin-add-swift-support" for ios

Adding cordova-plugin-add-swift-support to package.json

Saved plugin info for "cordova-plugin-add-swift-support" to config.xml

Update IOS build setting SWIFT_OBJC_BRIDGING_HEADER to: "$(PROJECT_DIR)/$(PROJECT_NAME)/Bridging-Header.h" for build configuration Debug
Update IOS build setting SWIFT_OBJC_BRIDGING_HEADER to: "$(PROJECT_DIR)/$(PROJECT_NAME)/Bridging-Header.h" for build configuration Release
Importing ZeroConf-Bridging-Header.h into <project_root>/platforms/ios/Exosite Home Automation Micro-Vertical/Bridging-Header.h
Update IOS build setting ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES to: YES for build configuration Debug
Update SWIFT version to 3.0 Debug
Update IOS build setting SWIFT_OPTIMIZATION_LEVEL to: -Onone for build configuration Debug
Update IOS build setting ALWAYS_EMBE

This is when I install cordova-plugin-add-swift-support@1.7.1

cordova plugin add cordova-plugin-add-swift-support@1.7.1 --save
Installing "cordova-plugin-add-swift-support" for android

ANDROID_HOME=/Users/JasonYang/Library/Android/sdk
JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_152.jdk/Contents/Home
Subproject Path: CordovaLib
Configuration 'compile' in project ':' is deprecated. Use 'implementation' instead.
The Task.leftShift(Closure) method has been deprecated and is scheduled to be removed in Gradle 5.0. Please use Task.doLast(Action) instead.
        at build_3y059ub8lgmys8azlddwlg7dg.run(<project_root>/platforms/android/build.gradle:143)
WARNING: The Jack toolchain is deprecated and will not run. To enable support for Java 8 language features built into the plugin, remove 'jackOptions { ... }' from your build.gradle file, and add

android.compileOptions.sourceCompatibility 1.8
android.compileOptions.targetCompatibility 1.8

Future versions of the plugin will not support usage of 'jackOptions' in build.gradle.
To learn more, go to https://d.android.com/r/tools/java-8-support-message.html

publishNonDefault is deprecated and has no effect anymore. All variants are now published.
:clean

:CordovaLib:clean

UP-TO-DATE

BUILD SUCCESSFUL in 2s
2 actionable tasks: 1 executed, 1 up-to-date
Installing "cordova-plugin-add-swift-support" for ios

Adding cordova-plugin-add-swift-support to package.json

Saved plugin info for "cordova-plugin-add-swift-support" to config.xml

The swift version has never been setup.

emcniece commented 6 years ago

Thanks for the data. I have encountered a few issues that I haven't found a way to fix without using XCode, and this is one of them.

Do you have XCode installed? What happens if you open yourApp/platforms/ios/yourApp.xcodeproj in XCode, specify the Swift Language Version variable, and then build?

I haven't tried updating to the new cordova-plugin-add-swift-support so the suggestions I'm making could absolutely be red herrings.

NeoLSN commented 6 years ago

I have and it is in latest version Version 9.2 (9C40b). And I have 2 options, v3.2 and v4.0, but no 3.0. When you open the project, XCode will tell you you have to setup your Swift version.

emcniece commented 6 years ago

Alright, I upgraded some packages and hit this problem. Fortunately I did work through it.

  1. Cordova updated - it's at version 8.0.0 now (though I tested 7.0.1 successfully too)
  2. Removed and re-added plugins to get latest versions:
    • cordova-plugin-zeroconf 1.3.1
    • cordova-plugin-add-swift-support 1.7.1
  3. Adjusted the SWIFT_VERSION in my iOS build config file to 4.0

Because I perform my iOS builds locally and remotely, I use Fastlane (+ Match) and a build-ios.json to specify XCode parameters. My package.json build script looks like this:

"build-ios": "ionic cordova build ios --buildConfig ./config/build-ios.json",

... and my build-ios.json file (newly updated with SWIFT_VERSION) looks like this:

{
    "ios": {
        "debug": {
            "codeSignIdentity": "iPhone Developer: my team (xxxxxxxxxxxxxxxxxxxx)",
            "developmentTeam": "xxxxxxxxxxxxxxxxxxxx",
            "provisioningProfile": "xxxxxxxxxxxxxxxxxxxx",
            "packageType": "development",
            "buildFlag": [
                "SWIFT_VERSION = 4.0",
                "EMBEDDED_CONTENT_CONTAINS_SWIFT = YES",
                "ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES=NO",
                "LD_RUNPATH_SEARCH_PATHS = \"@executable_path/Frameworks\""
            ]
        },
        "release": {
            "codeSignIdentity": "iPhone Distribution: my team (xxxxxxxxxxxxxxxxxxxx)",
            "developmentTeam": "xxxxxxxxxxxxxxxxxxxx",
            "provisioningProfile": "xxxxxxxxxxxxxxxxxxxx",
            "packageType": "app-store",
            "buildFlag": [
                "SWIFT_VERSION = 4.0",
                "EMBEDDED_CONTENT_CONTAINS_SWIFT = YES",
                "ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES=NO",
                "LD_RUNPATH_SEARCH_PATHS = \"@executable_path/Frameworks\""
            ]
        }
    }
}

Prior to adding SWIFT_VERSION to the build-ios.json file, I had defined this via XCode Build Settings. I'm just getting remote builds set up on CircleCI now, so I was forced to define this in a file - and it works great!

...
CodeSign build/emulator/Aurora.app
    cd /Users/distiller/project/platforms/ios
    export CODESIGN_ALLOCATE=/Applications/Xcode-9.1.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/codesign_allocate
    export PATH="/Applications/Xcode-9.1.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin:/Applications/Xcode-9.1.app/Contents/Developer/usr/bin:/Users/distiller/project/node_modules/.bin:/usr/local/lib/node_modules/npm/bin/node-gyp-bin:/Users/distiller/project/node_modules/.bin:/Users/distiller/.gem/ruby/2.4.2/bin:/Users/distiller/.rubies/ruby-2.4.2/lib/ruby/gems/2.4.0/bin:/Users/distiller/.rubies/ruby-2.4.2/bin:/usr/local/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin"

Signing Identity:     "-"

    /usr/bin/codesign --force --sign - --timestamp=none /Users/distiller/project/platforms/ios/build/emulator/Aurora.app

** BUILD SUCCEEDED **
NeoLSN commented 6 years ago

@emcniece The cordova-plugin-add-swift-support has been released version 1.7.2. Would you mind to release an 'rc' or 'beta' version for this issue?

emcniece commented 6 years ago

Yep, we can start building a release. There's another dependency update that needs to happen as well.

emcniece commented 6 years ago

Tracking in https://github.com/becvert/cordova-plugin-zeroconf/milestone/1

emcniece commented 6 years ago

Milestone 1.3.2 is now complete, and the cordova-plugin-add-swift-support has been published to NPM.

I ran a new build on a pristine OSX environment yesterday and encountered this issue. Confirmed that upgrading to cordova-plugin-add-swift-support:1.7.2 is the solution.

Marking as closed!