facebook-ios-sdk icon indicating copy to clipboard operation
facebook-ios-sdk copied to clipboard

Pre-built XCFrameworks cannot be used with Xcode 14.3 / Swift 5.8

Open username0x0a opened this issue 2 years ago • 14 comments

Checklist before submitting a bug report

Xcode version

14.3 Beta

Facebook iOS SDK version

16.0.0

Dependency Manager

Prebuilt Binaries

SDK Framework

Core

Goals

Compile a project with pre-built Facebook SDKs linked.

Expected results

The project compiles successfully.

Actual results

I'm getting a following error:

.../FacebookAnalyticsWrapper.swift:4:8 Failed to build module 'FBSDKCoreKit'; this SDK is not supported by the compiler
(the SDK is built with 'Apple Swift version 5.7.2 (swiftlang-5.7.2.135.5 clang-1400.0.29.51)', 
while this compiler is 'Apple Swift version 5.8 (swiftlang-5.8.0.117.11 clang-1403.0.22.8.60)').
Please select a toolchain which matches the SDK.

The same applies to 15.1.0 binaries complaining about being built with Swift 5.6. In both cases, both Static and Dynamic ones result in this error.

As the configuration seems to already use BUILD_LIBRARY_FOR_DISTRIBUTION=YES, I have really no quick idea how to solve this. 🤔 SKIP_INSTALL=NO could have some potential, but I can't really say…

Testing

Test case here would be a successful linking in a project with both Xcode 14.2 and 14.3.

Escalation

I know that Xcode 14.3 is still in Beta, but I guess this needs to be addressed ASAP, on top of that I've got no issues with other pre-built SDKs like Firebase for example, which means that something's already wrong with the XCFrameworks distribution setup that would cause this issue regularly with Apple updating the compiler version in Xcode.

username0x0a avatar Feb 18 '23 19:02 username0x0a

image /Users/triwin/liveBingoWork/Xcode/Libraries/FacebookSDK/SDK/Editor/iOS/Swift/FBSDKTournamentUpdater.swift:21:8: Failed to build module 'FBSDKCoreKit'; this SDK is not supported by the compiler (the SDK is built with 'Apple Swift version 5.7.2 (swiftlang-5.7.2.135.5 clang-1400.0.29.51)', while this compiler is 'Apple Swift version 5.6 (swiftlang-5.6.0.323.62 clang-1316.0.20.8)'). Please select a toolchain which matches the SDK.

same issue ,where 5.6 compiler

sunlighing avatar Feb 22 '23 01:02 sunlighing

Experiencing the same issue with Xcode 14.3 Beta 1 and Beta 2:

Failed to build module 'FBSDKCoreKit'; 
this SDK is not supported by the compiler (the SDK is built with 'Apple Swift 
version 5.7.2 (swiftlang-5.7.2.135.5 clang-1400.0.29.51)', while this compiler 
is 'Apple Swift version 5.8 (swiftlang-5.8.0.119.11 clang-1403.0.22.11.100)'). 
Please select a toolchain which matches the SDK.

ecant avatar Feb 28 '23 21:02 ecant

Same issue with Xcode 14.3 Beta 2. https://github.com/facebook/facebook-ios-sdk/issues/2186

NigamAnkit avatar Mar 04 '23 09:03 NigamAnkit

@sunlighing: Your issue looks similar, but is actually different – you can't use frameworks built by a newer Swift compiler version in Xcode/app using an older compiler version. Basically tl;dr: the newer compiler may generate chunks in the Swift module interface potentially not yet known by your (older) compiler version, so Library distribution only allows the framework to be consumed by the same or newer compiler version.

For the other guys: it won't differ with future Betas 'cause there's an issue with Library distribution/Module compatibility in place. The weird thing here is it complains about FBSDKCoreKit which has Swift interface included while I'd rather expect FBSDKCoreKit_Basics to be an issue as that one doesn't 🤔 but we'll see what Facebook devs have to say about the setup.

username0x0a avatar Mar 05 '23 23:03 username0x0a

There is a work around for cocoapods, add these code to Podfile

post_install do |installer|

  installer.pods_project.targets.each do |target|
    target.build_configurations.each do |config|
      config.build_settings['BUILD_LIBRARY_FOR_DISTRIBUTION'] = 'YES'
    end
  end
end

It works with FBSDK 16.0 and Xcode Version 14.3 beta 2 (14E5207e)

SunZhiC avatar Mar 08 '23 09:03 SunZhiC

This workaround is not working on the RC for us. With version 15 & 16.

Dimillian avatar Mar 24 '23 10:03 Dimillian

Well, isn't CocoaPods building the libs from source? 🤔 In that case, the workaround isn't really needed…

TL;DR: SKIP_INSTALL=NO and BUILD_LIBRARY_FOR_DISTRIBUTION=YES needs to be set properly for building (in Xcode 14.2 so that it's then working with 14.2 and 14.3 as well); in this case in the xcconfig files. 👍 The patch/fix should be quite easy here, but I'll verify it in my setup first.

username0x0a avatar Mar 27 '23 20:03 username0x0a

This issue has been fixed in Xcode 14.3 RC2. The app compiles and builds successfully for me 🎉

From the Relese Notes:

Fixed: The Swift compiler may fail to build modules for XCFramework dependencies that were built with BUILD_LIBRARY_FOR_DISTRIBUTION enabled. These failures will occur when the XCFramework contains public Swift declarations that have @MainActor constraints implicitly added, such as subclasses of UIView or NSView. The Swift compiler expects those declarations to be marked @available for an operating system version where Swift concurrency is available. (105610970)

raxityo avatar Mar 27 '23 21:03 raxityo

We see the same issue building binary xcframeworks for distribution with Xcode 14.1 and are considering continuing to build our binary distributions with Xcode 13.3.1 - https://github.com/firebase/firebase-ios-sdk/pull/11010

paulb777 avatar Mar 28 '23 16:03 paulb777

@paulb777 Weeeell…Apple will make it simple for us (with 14.1 minimum requirement), as every year. 😄

https://twitter.com/9to5mac/status/1640772265787760640

username0x0a avatar Mar 28 '23 18:03 username0x0a

Hi!! Any solution on this? 😭

pastelcode avatar Apr 19 '23 02:04 pastelcode

I am facing the same issue with Xcode 13.2

Rokon-556 avatar Jul 10 '23 08:07 Rokon-556

Cocoapod version 1.11.3 works for me

shahbazhashmi avatar Jul 19 '23 17:07 shahbazhashmi

Can we resolve this issue by using the same Xcode version 13.2.1?

vijaycoderkube avatar Sep 25 '23 11:09 vijaycoderkube