phonegap / build

This is the public repository for PhoneGap Build source and bug tracking
92 stars 33 forks source link

Swift not configured on PGB #630

Open MBuchalik opened 6 years ago

MBuchalik commented 6 years ago

Hi,

it looks like Swift isn't configured properly on PGB. When trying to include a plugin that uses Swift, you get the message

Check dependencies  
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.  

According to the Preferences Documentation (http://docs.phonegap.com/phonegap-build/configuring/preferences/#swift-version), a default Swift version is configured. Also, it is possible to set it using the swift-version preference. Unfortunately, it seems like this doesn't work.

Is this a problem with the new Xcode version or has the introduction of Cocoapods caused trouble?

(I have also posted this question on the PGB forum a few days ago, of course.)

For testing, I have created a really small application:

    <?xml version="1.0" encoding="UTF-8" ?>  
    <widget xmlns   = "http://www.w3.org/ns/widgets"  
            xmlns:android = "http://schemas.android.com/apk/res/android"  
            xmlns:gap   = "http://phonegap.com/ns/1.0"  
            id          = "com.example.example"  
            version        = "1.0.0"  
            versionCode = "1">  

        <name>Test-App</name>  
        <description>Example...</description>  
        <access origin="*" />  
        <platform name="ios"></platform>  

        <preference name="phonegap-version" value="cli-7.1.0" />  
        <preference name="pgb-builder-version" value="2" />  

        <preference name="swift-version" value="3.0" />      

        <plugin name="cordova-swift3-plugin-example" spec="https://github.com/ModusCreateOrg/cordova-swift3-plugin-example" />  

        <content src="index.html" />  
    </widget>  

The full log:

Build Date: 2018-05-06 01:43:59 -0700 -------------------------------------------------------------------------------- PREPARE OUTPUT -------------------------------------------------------------------------------- Generating platform-specific config.xml from defaults for iOS at /private/project/Test-App/config.xml Merging project's config.xml into platform-specific iOS config.xml Merging and updating files from [, ../../../../private/project/platform_www] to ../../../../private/project/www copy config.xml ../../../../private/project/www/config.xml (new file) mkdir ../../../../private/project/www/cordova-js-src copy ../../../../private/project/platform_www/cordova-js-src/exec.js ../../../../private/project/www/cordova-js-src/exec.js (new file) copy ../../../../private/project/platform_www/cordova-js-src/platform.js ../../../../private/project/www/cordova-js-src/platform.js (new file) mkdir ../../../../private/project/www/cordova-js-src/plugin mkdir ../../../../private/project/www/cordova-js-src/plugin/ios copy ../../../../private/project/platform_www/cordova-js-src/plugin/ios/console.js ../../../../private/project/www/cordova-js-src/plugin/ios/console.js (new file) copy ../../../../private/project/platform_www/cordova-js-src/plugin/ios/logger.js ../../../../private/project/www/cordova-js-src/plugin/ios/logger.js (new file) copy ../../../../private/project/platform_www/cordova.js ../../../../private/project/www/cordova.js (updated file) rmdir ../../../../private/project/www/css (no source) delete ../../../../private/project/www/css/index.css (no source) rmdir ../../../../private/project/www/img (no source) delete ../../../../private/project/www/img/logo.png (no source) copy index.html ../../../../private/project/www/index.html (updated file) rmdir ../../../../private/project/www/js (no source) delete ../../../../private/project/www/js/index.js (no source) copy splash.png ../../../../private/project/www/splash.png (new file) Current launch storyboard undefined Not changing launch storyboard setting in info plist. Wrote out iOS Bundle Identifier "de.mailanddrive.app" and iOS Bundle Version "1.0.0" to /private/project/Test-App/Test-App-Info.plist No need to update build settings for launch storyboard support. iOS Product Name has not changed (still "Test-App") This app does not have icons defined This app does not have splash screens defined Updating launch storyboard images at ../../../../private/project/Test-App/Images.xcassets/LaunchStoryboard.imageset/ Updating Storyboard image set contents.json This app does not have additional resource files defined Prepared iOS project successfully -------------------------------------------------------------------------------- PLUGIN OUTPUT -------------------------------------------------------------------------------- Fetching plugin "https://github.com/ModusCreateOrg/cordova-swift3-plugin-example" via git clone Using shallow clone Repository "https://github.com/ModusCreateOrg/cordova-swift3-plugin-example" checked out to git ref "master" at "dfcc73a". Installing "com-moduscreate-plugins-echoswift" at "0.0.1" for ios -------------------------------------------------------------------------------- COMPILE OUTPUT -------------------------------------------------------------------------------- Now using system ruby. Building project: /private/project/Test-App.xcworkspace Configuration: Release Platform: device User defaults from command line: IDEArchivePathOverride = /private/project/Test-App.xcarchive Build settings from command line: CONFIGURATION_BUILD_DIR = /private/project/build/device SHARED_PRECOMPS_DIR = /private/project/build/sharedpch Build settings from configuration file '/private/project/cordova/build-release.xcconfig': ARCHS = armv7 arm64 CLANG_ALLOW_NON_MODULAR_INCLUDES_IN_FRAMEWORK_MODULES = YES CODE_SIGN_ENTITLEMENTS = /project/app.entitlements CODE_SIGN_IDENTITY = iPhone Developer CONFIGURATION_BUILD_DIR = /project/build CORDOVALIB = /project/CordovaLib DEVELOPMENT_TEAM = FPBVRE9Z62 ENABLE_BITCODE = false HEADER_SEARCH_PATHS = "$(TARGET_BUILD_DIR)/usr/local/lib/include" "$(OBJROOT)/UninstalledProducts/include" "$(OBJROOT)/UninstalledProducts/$(PLATFORM_NAME)/include" "$(BUILT_PRODUCTS_DIR)" ONLY_ACTIVE_ARCH = NO OTHER_CODE_SIGN_FLAGS = --keychain /secure.keychain OTHER_LDFLAGS = -ObjC PROVISIONING_PROFILE = (My provisioning profile. I wasn't sure if that info is considered sensitive information so I removed it.) SWIFT_OBJC_BRIDGING_HEADER = $(PROJECT_DIR)/$(PROJECT_NAME)/Bridging-Header.h === BUILD TARGET CordovaLib OF PROJECT CordovaLib WITH CONFIGURATION Release === Check dependencies Write auxiliary files (Removed this part since Github doesn't allow such a long text.) Strip /Library/Developer/Xcode/DerivedData/Test-App-bxgxiduqvbcailgnvfiraymdaiao/Build/Intermediates.noindex/ArchiveIntermediates/Test-App/IntermediateBuildFilesPath/UninstalledProducts/iphoneos/libCordova.a cd /project/CordovaLib /Applications/Xcode92.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/strip -S -T /Library/Developer/Xcode/DerivedData/Test-App-bxgxiduqvbcailgnvfiraymdaiao/Build/Intermediates.noindex/ArchiveIntermediates/Test-App/IntermediateBuildFilesPath/UninstalledProducts/iphoneos/libCordova.a SetOwnerAndGroup phonegap:staff /Library/Developer/Xcode/DerivedData/Test-App-bxgxiduqvbcailgnvfiraymdaiao/Build/Intermediates.noindex/ArchiveIntermediates/Test-App/IntermediateBuildFilesPath/UninstalledProducts/iphoneos/libCordova.a cd /project/CordovaLib /usr/sbin/chown -RH phonegap:staff /Library/Developer/Xcode/DerivedData/Test-App-bxgxiduqvbcailgnvfiraymdaiao/Build/Intermediates.noindex/ArchiveIntermediates/Test-App/IntermediateBuildFilesPath/UninstalledProducts/iphoneos/libCordova.a SetMode u+w,go-w,a+rX /Library/Developer/Xcode/DerivedData/Test-App-bxgxiduqvbcailgnvfiraymdaiao/Build/Intermediates.noindex/ArchiveIntermediates/Test-App/IntermediateBuildFilesPath/UninstalledProducts/iphoneos/libCordova.a cd /project/CordovaLib /bin/chmod -RH u+w,go-w,a+rX /Library/Developer/Xcode/DerivedData/Test-App-bxgxiduqvbcailgnvfiraymdaiao/Build/Intermediates.noindex/ArchiveIntermediates/Test-App/IntermediateBuildFilesPath/UninstalledProducts/iphoneos/libCordova.a === BUILD TARGET Test-App OF PROJECT Test-App WITH CONFIGURATION Release === Check dependencies 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. 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. ** ARCHIVE FAILED ** The following build commands failed: Check dependencies (1 failure) Error code 65 for command: xcodebuild with args: -xcconfig,/private/project/cordova/build-release.xcconfig,-workspace,Test-App.xcworkspace,-scheme,Test-App,-configuration,Release,-destination,generic/platform=iOS,-archivePath,Test-App.xcarchive,archive,CONFIGURATION_BUILD_DIR=/private/project/build/device,SHARED_PRECOMPS_DIR=/private/project/build/sharedpch

Edit: @goya I saw in #521 that PGB did have Swift (beta) support in 2016. Has this been removed again or is it currently only a missing parameter somewhere?

phiasco12 commented 4 years ago

Did you ever manage to resolve this issue?

MBuchalik commented 4 years ago

Unfortunately, I don't have access to my sample project right now. But I am pretty sure that I managed to successfully compile the project after adding a Brigding Header to the Swift plugin.

I think this is how I did it (was a pretty long time ago so not sure if this is really the correct way).

At the beginning, I only had the file src/ios/Example.swift. This would not compile. Then, I added a Bridging Header: Created a file src/ios/Example-Bridging-Header.h. Here, I added the following content:

#import <Cordova/CDV.h>

In plugin.xml, you could originally only find this line:

<source-file src="src/ios/Example.swift" />

I added the reference to the Bridging Header:

<source-file src="src/ios/Example.swift" />
<header-file src="src/ios/Example-Bridging-Header.h" />

I believe this is all what needed to be done. Hope it helps. 😃 As far as I remember, nothing had to be changed in config.xml (except for referencing the new plugin branch of course).

Did not resolve the issue since I am not sure if it really fixes the problem in all cases.