forcedotcom / SalesforceMobileSDK-CordovaPlugin

Cordova plugin for the Salesforce Mobile SDK
Other
48 stars 114 forks source link

Cordova iOS Build with Salesforce SDK 10.2.0 is failing on Xcode 14 #610

Closed sinothomasAppno closed 1 year ago

sinothomasAppno commented 1 year ago

Legacy build option was used with 13.4 for build to pass. After updating Xcode from 13.4 to 14.0.1.

This is related to https://github.com/forcedotcom/SalesforceMobileSDK-CordovaPlugin/issues/577

cordova build ios is throwing Error:

error: Multiple commands produce '/Users/.../Development/newton-app-opera-hybrid cordova-update/platforms/ios/build/emulator/Cordova.framework'
    note: Target 'Cordova' (project 'CordovaLib') has create directory command with output '/Users/.../Development/newton-app-opera-hybrid cordova-update/platforms/ios/build/emulator/Cordova.framework'
    note: Target 'Cordova' (project 'Pods') has create directory command with output '/Users/.../Development/newton-app-opera-hybrid cordova-update/platforms/ios/build/emulator/Cordova.framework'
error: Multiple commands produce '/Users/.../Development/newton-app-opera-hybrid cordova-update/platforms/ios/build/emulator/Cordova.framework/Cordova'
    note: Target 'Cordova' (project 'CordovaLib') has link command with output '/Users/.../Development/newton-app-opera-hybrid cordova-update/platforms/ios/build/emulator/Cordova.framework/Cordova'
    note: Target 'Cordova' (project 'Pods') has link command with output '/Users/.../Development/newton-app-opera-hybrid cordova-update/platforms/ios/build/emulator/Cordova.framework/Cordova'

Xcode build error:

image

System Info

Ionic:
Ionic CLI          : 6.20.1
Ionic Framework    : @ionic/angular 6.0.10

Cordova:
Cordova CLI        : 10.0.0 (cordova-lib@10.1.0)
Cordova Platforms  : ios 6.2.0
Cordova Plugins    : com.salesforce 10.2.0 "SalesforceMobileSDK Plugins"

Utility:
cordova-res        : 0.15.4
native-run         : 1.7.0

System:
ios-sim            : 8.0.2
NodeJS             : v16.15.1
npm                : 8.11.0
OS                 : macOS Monterey
Xcode              : Xcode 14.0.1 Build version 14A400

iOS build only throws this error when SalesforceMobileSDK-CordovaPlugin is added. Without it build is passing.

wmathurin commented 1 year ago

Are you generating your application with forcehybrid?

sinothomasAppno commented 1 year ago

yes @wmathurin, project was created with forcehybrid.

We found the cause of this error. The cause of this issue is that the generated platforms/ios/podfile is different when given target platform ios vs ios,android during forcehybrid create prompt Enter the target platform(s) separated by commas (ios, android):

when project created with target platform is ios, Podfile contains

# DO NOT MODIFY -- auto-generated by Apache Cordova
source 'https://cdn.cocoapods.org'
platform :ios, '14.0'

target 'forcehybrid_Local_ios' do
    project 'forcehybrid_Local_ios.xcodeproj'
    pod 'SalesforceHybridSDK', :tag => 'v10.2.0', :git => 'https://github.com/forcedotcom/SalesforceMobileSDK-iOS-Hybrid'
    pod 'MobileSync', :tag => 'v10.2.0', :git => 'https://github.com/forcedotcom/SalesforceMobileSDK-iOS'
    pod 'SmartStore', :tag => 'v10.2.0', :git => 'https://github.com/forcedotcom/SalesforceMobileSDK-iOS'
    pod 'FMDB/SQLCipher', :tag => '2.7.5', :git => 'https://github.com/ccgus/fmdb'
    pod 'SQLCipher', :tag => 'v4.5.2', :git => 'https://github.com/sqlcipher/sqlcipher'
    pod 'SalesforceSDKCore', :tag => 'v10.2.0', :git => 'https://github.com/forcedotcom/SalesforceMobileSDK-iOS'
    pod 'SalesforceAnalytics', :tag => 'v10.2.0', :git => 'https://github.com/forcedotcom/SalesforceMobileSDK-iOS'
    pod 'SalesforceSDKCommon', :tag => 'v10.2.0', :git => 'https://github.com/forcedotcom/SalesforceMobileSDK-iOS'
    pod 'Cordova', :tag => '6.2.0', :git => 'https://github.com/apache/cordova-ios'
end

$dynamic_framework = ['SalesforceAnalytics', 'SalesforceSDKCore', 'SalesforceSDKCommon', 'SmartStore', 'FMDB', 'SQLCipher', 'MobileSync']
pre_install do |installer|
  installer.pod_targets.each do |pod|
    if $dynamic_framework.include?(pod.name)
      def pod.build_type
        Pod::BuildType.dynamic_framework
      end
    end
  end
end

Where as, when project created with target platform is ios,android, Podfile is different

# DO NOT MODIFY -- auto-generated by Apache Cordova
source 'https://cdn.cocoapods.org'
platform :ios, '14.0'
use_frameworks!
target 'forcehybird_Local_ios_android' do
    project 'forcehybird_Local_ios_android.xcodeproj'
    pod 'SalesforceHybridSDK', :tag => 'v10.2.0', :git => 'https://github.com/forcedotcom/SalesforceMobileSDK-iOS-Hybrid'
    pod 'MobileSync', :tag => 'v10.2.0', :git => 'https://github.com/forcedotcom/SalesforceMobileSDK-iOS'
    pod 'SmartStore', :tag => 'v10.2.0', :git => 'https://github.com/forcedotcom/SalesforceMobileSDK-iOS'
    pod 'FMDB/SQLCipher', :tag => '2.7.5', :git => 'https://github.com/ccgus/fmdb'
    pod 'SQLCipher', :tag => 'v4.5.2', :git => 'https://github.com/sqlcipher/sqlcipher'
    pod 'SalesforceSDKCore', :tag => 'v10.2.0', :git => 'https://github.com/forcedotcom/SalesforceMobileSDK-iOS'
    pod 'SalesforceAnalytics', :tag => 'v10.2.0', :git => 'https://github.com/forcedotcom/SalesforceMobileSDK-iOS'
    pod 'SalesforceSDKCommon', :tag => 'v10.2.0', :git => 'https://github.com/forcedotcom/SalesforceMobileSDK-iOS'
    pod 'Cordova', :tag => '6.2.0', :git => 'https://github.com/apache/cordova-ios'
end

After using Podfile generated with target platform is ios. Xcode build is passing, but cordova build ios is falling with error:

note: Building targets in dependency order
error: Multiple commands produce '/Users/.../Development/tests/forcehybrid_Local_ios/platforms/ios/build/emulator/libCordova.a'
    note: Target 'Cordova' (project 'Pods'): Libtool /Users/.../Development/tests/forcehybrid_Local_ios/platforms/ios/build/emulator/libCordova.a normal
    note: Target 'CordovaLib' (project 'CordovaLib'): Libtool /Users/.../Development/tests/forcehybrid_Local_ios/platforms/ios/build/emulator/libCordova.a normal
error: Multiple commands produce '<Linked Binary /Users/.../Development/tests/forcehybrid_Local_ios/platforms/ios/build/emulator/libCordova.a>'
    note: Target 'Cordova' (project 'Pods'): Libtool /Users/.../Development/tests/forcehybrid_Local_ios/platforms/ios/build/emulator/libCordova.a normal
    note: Target 'CordovaLib' (project 'CordovaLib'): Libtool /Users/.../Development/tests/forcehybrid_Local_ios/platforms/ios/build/emulator/libCordova.a normal
/Users/.../Development/tests/forcehybrid_Local_ios/platforms/ios/Pods/Pods.xcodeproj: warning: The iOS Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 4.3, but the range of supported deployment target versions is 11.0 to 16.0.99. (in target 'FMDB' from project 'Pods')
wmathurin commented 1 year ago

The first podfile is the right one. We will investigate why the generated pod file are different. For now could you edit your podfile. Make sure to remove the line

use_frameworks!

And add the following at the end

$dynamic_framework = ['SalesforceAnalytics', 'SalesforceSDKCore', 'SalesforceSDKCommon', 'SmartStore', 'FMDB', 'SQLCipher', 'MobileSync']
pre_install do |installer|
  installer.pod_targets.each do |pod|
    if $dynamic_framework.include?(pod.name)
      def pod.build_type
        Pod::BuildType.dynamic_framework
      end
    end
  end
end
wmathurin commented 1 year ago

The fix for forcehybrid will be in the next release (see https://github.com/forcedotcom/SalesforceMobileSDK-Package/pull/272). The problem is that that when doing platform=ios,android the post-install fixes to the ios project were not happening.

One thing you could do for now is run forcehybrid twice, once for ios and once for android and then merge the two (basically copy platforms/ios under platforms of the other one or vice-versa).

sinothomasAppno commented 1 year ago

issue solved closing issue.