Uploaded image for project: 'Apache Cordova'
  1. Apache Cordova
  2. CB-8254

Swift support: Cordova build only uses xcconfig with --device flag (please also enable without)

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 3.5.0, 4.1.3
    • 3.8.0
    • cordova-cli, cordova-ios
    • All (iOS)

    Description

      I have written a plugin in Swift that won't build with a deployment target < iOS 7.0. This breaks "cordova build ios":

      Swift is unavailable on iOS earlier than 7.0; please set IPHONEOS_DEPLOYMENT_TARGET to 7.0 or later (currently it is '6.0').
      (** BUILD FAILED **)

      I know I can `cordova prepare ios` and manually add the changes to my xcode project, but as a plugin author this manual approach is unsatisfactory. Instead, I have added a hook to my plugin that adds the required options to build.xcconfig:

      "IPHONEOS_DEPLOYMENT_TARGET = 7.0"
      "SWIFT_OBJC_BRIDGING_HEADER = $SRCDIR/Bridging-Header.h"

      This allows the code to build with `cordova build ios --device`

      The problem is that `cordova build ios` alone doesn't pay any attention to the any of the three build.xcconfig files, because there is no -xcconfig option present for EMULATOR mode in the build script (see $PROJECT/platforms/ios/cordova/build).

      -------

      The solution:

      The ideal solution would be the option to provide custom build options to `cordova prepare ios` that get directly integrated into the Xcode project. But I gather Apple doesn't provide us the option to edit Xcode projects outside of Xcode (and 3rd party solutions are far from reliable).

      Which appears to leave us with two reasonable options:

      (1) Provide another Xcode project for Swift plugins. Back maybe this isn't so reasonable after all: it's inconsistent, has the issue of setting a Bridging Header without knowing where it is in advance. What happens when we add a swift plugin to an existing project. Does the existing Xcode project get deleted?

      (2) Add the same -xcconfig param to the EMULATOR section at the bottom of the `ios/cordova/build` file. This has the drawback of potentially confusing people when they open the Xcode project, but I think this is favourable to having the project not build at all from the command line.

      Is there any reason that (2) couldn't be implemented effectively immediately?

      Attachments

        Issue Links

          Activity

            People

              shazron Shazron Abdullah
              geojay Geordie Jay
              Votes:
              1 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - 2h
                  2h
                  Remaining:
                  Remaining Estimate - 2h
                  2h
                  Logged:
                  Time Spent - Not Specified
                  Not Specified