akofman / cordova-plugin-add-swift-support

:hammer: Swiftify your Cordova app !
MIT License
116 stars 107 forks source link

IOS build failure #34

Open omerh86 opened 6 years ago

omerh86 commented 6 years ago

HI , After implementing this plugin I am getting "Use Legacy Swift Language Version" error when build on IOS. I am using X-code 8.2 which uses swift 2.3 as legacy version. if im disabling "use swift leagacy version" checkbox in X-code settings it works fine however I am willing to let Cordova do it by configuration. i have tried to add "<preference name="UseLegacySwiftLanguageVersion" value="false" to my config xml but it didnt help. Any other suggestions? Thanks head Omer

nero120 commented 6 years ago

I get the same error on xcode 8.3.3 (swift 3), even when adding <preference name="UseSwiftLanguageVersion" value="3" /> to config.xml.

DavidTalamona commented 6 years ago

I have the same issue as @nero120 when builiding my project with <preference name="UseSwiftLanguageVersion" value="3" /> in my config.xml, after updating to xcode 8.3.3.

        === BUILD TARGET ... OF PROJECT ... WITH CONFIGURATION Debug ===

        Check dependencies
        “Swift Language Version” (SWIFT_VERSION) is required to be configured correctly for targets which use 
        Swift. Use the [Edit > Convert > To Current Swift Syntax…] menu to choose a Swift version or use the Build 
        Settings editor to configure the build setting directly.

        ** BUILD FAILED **

I'm using the following plugin https://github.com/NiklasMerz/cordova-plugin-fingerprint-aio, which defines cordova-plugin-add-swift-support as a dependancy.

When I open xcode I get a message asking to convert to actual swift syntax. I say later and manually set the Swift language version from unspecified to Swift 3 and build the project with xcode, it works.
Run ionic cordova build ios again and the same error pops up again. After going back to xcode the Swift language version is reset back to unspecified.

Not shure but I think this setting should be set by your plugin and is not directly related to the fingerprint one, is it?

Here's my environment info:

cli packages:
    @ionic/cli-utils  : 1.9.2
    ionic (Ionic CLI) : 3.9.2

global packages:
    Cordova CLI : 7.0.1

local packages:
    @ionic/app-scripts : 2.1.3
    Cordova Platforms  : android 6.1.2 ios 4.4.0
    Ionic Framework    : ionic-angular 3.6.0

System:
    ios-deploy : 1.9.2 
    ios-sim    : 4.1.1 
    Node       : v6.11.3
    npm        : 4.6.0 
    OS         : macOS Sierra
    Xcode      : Xcode 8.3.3 Build version 8E3004b 
nero120 commented 6 years ago

@DavidTalamona It's working for me now. The plugin updates the xcode project settings during the after_prepare, after_platform_add and after_plugin_add events. If you clear your Platforms and Plugins folders in your Cordova project folder, then run cordova prepare, it should set the Swift Language Version in Build Settings gets set to Swift 3 automatically and you won't get the build error (though you'll still be prompted to convert swift syntax when you open the project in xcode).

DavidTalamona commented 6 years ago

Just did that (and so I did yesterday) without success.

Tried to let the ionic cloud build it for me - build / package failed and guess what the output was ...

=== BUILD TARGET ... OF PROJECT ... WITH CONFIGURATION Release ===

Check dependencies
“Use Legacy Swift Language Version” (SWIFT_VERSION) is required to be configured correctly for targets which use Swift. Use the [Edit > Convert > To Current Swift Syntax…] menu to choose a Swift version or use the Build Settings editor to configure the build setting directly.
“Use Legacy Swift Language Version” (SWIFT_VERSION) is required to be configured correctly for targets which use Swift. Use the [Edit > Convert > To Current Swift Syntax…] menu to choose a Swift version or use the Build Settings editor to configure the build setting directly.

** ARCHIVE FAILED **

They build the project from scratch with my source "injected", so no crappy / corrupt platform which needs cordova prepare.

DavidTalamona commented 6 years ago

The problem seems to be related to xcode 8.3(x). After downgrading to xcode 8.2 the build suceeds.

Think it's related to this: https://stackoverflow.com/questions/43107179/xcode-8-3-cant-support-swift-2-3

NiklasMerz commented 6 years ago

I have similar problems with XCode 9 (beta and GM).

svenemtell commented 6 years ago

I have the same problem with Xcode 9. I guess the XCode project file (project.pbxproj) is written to disk at line 12868 of add-swift-support.js: _fs2.default.writeFileSync(pbxprojPath, xcodeProject.writeSync());

Right before the above line I therefore wrote the output of xcodeProject.writeSync() to console.log and while running cordova platform add ios@4.5.1 --save I could see all the expected settings, like: ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;and SWIFT_VERSION = 3.0;

But when inspecting the XCode project file afterwards the settings are not there! I also logged pbxprojPathso I know it is using the right XCode project file.

Any ideas?

jsb8908 commented 5 years ago

@DavidTalamona Is there a way to downgrade the version of XCode that ionic cloud uses?

vwasteels commented 5 years ago

same here with xcode 9.2, trying to use Geofence plugin, which needs swift plugin ...

spacesuitdiver commented 5 years ago

What I found is another plugin was overwriting the pbx value. In this case cordova-plugin-localization-strings.

spacesuitdiver commented 5 years ago

Issue is documented here for that plugin. https://github.com/kelvinhokk/cordova-plugin-localization-strings/issues/33

pantomath91 commented 4 years ago

I also got the same error with xcode 11.3.1 but this happens to me randomly, looks like xcodeProject.updateBuildProperty('SWIFT_VERSION', '5.0', buildConfig.name); is not setting correctly the swift compiler version.

Ref: https://github.com/akofman/cordova-plugin-add-swift-support/blob/master/src/add-swift-support.js#L149