Giphy / giphy-ios-sdk

Home of the GIPHY SDK iOS example app, along with iOS SDK documentation, issue tracking, & release notes.
https://developers.giphy.com/
Mozilla Public License 2.0
116 stars 52 forks source link

Cannot build SDK using Xcode 14.3 beta #221

Closed lukeredpath closed 1 year ago

lukeredpath commented 1 year ago

🐛 Bug Report

A new Xcode beta is out and we cannot currently use it to compile our app because of our dependency on GiphyUISDK.

There are two errors:

Failed to build module 'GiphyUISDK'; 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.

I don't remember seeing this error with previous betas, I thought binary frameworks were supposed to be forwards compatible.

Also lots of errors about the main actor:

Showing Recent Messages
/Users/luke/Library/Developer/Xcode/DerivedData/[redacted]-antubctorcznljcwxglwmvdeclef/Build/Products/Development-iphonesimulator/GiphyUISDK.framework/Modules/GiphyUISDK.swiftmodule/x86_64-apple-ios-simulator.private.swiftinterface:852:17: 'MainActor' is only available in iOS 13.0 or newer

To Reproduce

Open a project that depends on GiphyUISDK in Xcode 14.3 beta and try to build.

Expected behavior

I'd hoped it would build.

Actual Behavior

It does not build.

(Write what happened. Add screenshots, if applicable.)

Your Environment

lukeredpath commented 1 year ago

Has the framework been compiled with the BUILD_LIBRARY_FOR_DISTRIBUTION setting enabled? AFAIU this is what's required to support forwards compatibility.

cgmaier commented 1 year ago

hey @lukeredpath thanks for flagging this. we'll take a look

cgmaier commented 1 year ago

hey @lukeredpath. BUILD_LIBRARY_FOR_DISTRIBUTION has been enabled for quite a while. We haven't seen Xcode / Swift version incompatibility problems for a few years now.

It seems like a lot of libraries distributed as precompiled xcframeworks are facing this very same issue.

I made a branch xcode-14.3-beta (which you should be able to reference through SPM) in this repo which hosts the GiphyUISDK.xcframework compiled with the Xcode 14.3 Beta command line tools. This is also available through CocoaPods via the entry:

pod 'Giphy', :podspec => 'https://s3.amazonaws.com/sdk.mobile.giphy.com/SDK/2.2.2-xcode-14.3b/Giphy.podspec

Unfortunately it was also necessary to increase the xcframeworks iOS Deployment Target to 13.0 to get rid of the MainActor compilation errors when running in 14.3 Beta. I'm not sure if it's possible to get around this, or if developers feel strongly about whether we continue to support iOS 12.

This xcframework also appears to work in Xcode 14.2, so it looks like the latest compiler changes are back-compatible but not forward.

lukeredpath commented 1 year ago

@cgmaier thank you, I appreciate you getting that branch up. It should at least unblock me from taking the Xcode beta for a proper spin.

cgmaier commented 1 year ago

@lukeredpath sweet! let me know if you have any issues.

lukeredpath commented 1 year ago

@cgmaier sorry I forgot to check back in, but the re-built binary on that branch worked for me.

xmollv commented 1 year ago

@cgmaier Is a release planned to solve this issue or the 'official' way is to point to the xcode-14.3-beta branch? We've started hitting that issue last night on Xcode Cloud because Apple released Xcode 14.3 RC, and I'm guessing that it'll be made public next Tuesday, so more people will be facing this.

Failed to build module 'GiphyUISDK'; 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.124.1 clang-1403.0.22.11.100)'). Please select a toolchain which matches the SDK.

cgmaier commented 1 year ago

hey @xmollv thanks for the heads up!

the plan was to make an official release as soon as Xcode 14.3 is released - was thinking there is chance that the final release includes changes that could effect the compiling of the SDK, and there's some risk in the assumption that a xcframework compiled with the beta ot RC won't be compatible with or optimal for the official release. but that's probably negligible.

will download the RC now and keep you posted

xmollv commented 1 year ago

hey @xmollv thanks for the heads up!

the plan was to make an official release as soon as Xcode 14.3 is released - was thinking there is chance that the final release includes changes that could effect the compiling of the SDK, and there's some risk in the assumption that a xcframework compiled with the beta ot RC won't be compatible with or optimal for the official release. but that's probably negligible.

will download the RC now and keep you posted

Awesome, ty! Loos like Lottie has a similar issue and they also seem to wait for the final Xcode 14.3 version to take action, seems reasonable to me!

cgmaier commented 1 year ago

went forward and made an official release using Xcode 14.3 RC 2 https://github.com/Giphy/giphy-ios-sdk/releases/tag/v2.2.3

xmollv commented 1 year ago

went forward and made an official release using Xcode 14.3 RC 2 https://github.com/Giphy/giphy-ios-sdk/releases/tag/v2.2.3

Hey! I'm not sure if it's really needed in the end. I did try on Monday to build our app again with Xcode 14.3 RC2 on Xcode Cloud and the build that previously failed now passed. I haven't tried yet on my local machine (waiting for next week's final Xcode release). With that I mean that we were still using the 2.2.2 release of Giphy and the build passed without issues.

image
cgmaier commented 1 year ago

haha dang!! thanks for sharing that. I just confirmed that 2.2.2 can indeed successfully run in Xcode RC2.

it's reassuring to see that Apple has not broken their promise of 'module stability'. I wonder if this original issue was an unintended bug, or if Apple intended to accept the reality of xcframework incompatibility (presumably as a tradeoff for some other end) until developers complained, especially since there are some big name vendors of closed source projects.

next time I'll be sure to do a deeper dive into the Xcode release notes and ensure I don't miss anything!

as I was under the impression it was necessary to increase min dev target to iOS 13 in order to support Xcode 14.3, I will do a new release to decrease it back down to 10. unfortunately I'm unable to make a new release for a few weeks.