cordova-plugin-add-swift-support icon indicating copy to clipboard operation
cordova-plugin-add-swift-support copied to clipboard

IOS build failure

Open omerh86 opened this issue 8 years ago • 12 comments

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

omerh86 avatar Aug 01 '17 13:08 omerh86

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

nero120 avatar Aug 21 '17 21:08 nero120

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 

DavidTalamona avatar Sep 07 '17 13:09 DavidTalamona

@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).

nero120 avatar Sep 07 '17 14:09 nero120

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 avatar Sep 07 '17 15:09 DavidTalamona

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

DavidTalamona avatar Sep 08 '17 10:09 DavidTalamona

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

NiklasMerz avatar Sep 17 '17 08:09 NiklasMerz

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 [email protected] --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?

svenemtell avatar Oct 16 '17 18:10 svenemtell

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

jsb8908 avatar Aug 02 '18 02:08 jsb8908

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

vwasteels avatar Sep 14 '18 12:09 vwasteels

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

leblancexplores avatar Nov 09 '18 19:11 leblancexplores

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

leblancexplores avatar Nov 09 '18 20:11 leblancexplores

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

pantomath91 avatar May 24 '20 16:05 pantomath91