apollographql / apollo-ios

📱  A strongly-typed, caching GraphQL client for iOS, written in Swift.
https://www.apollographql.com/docs/ios/
MIT License
3.89k stars 728 forks source link

apollo-ios-xcframework fails to build #3439

Closed CraigSiemens closed 2 months ago

CraigSiemens commented 2 months ago

Summary

It appears that the apollo-ios-xcframework repo no longer contains any shared or generated schemes causing carthage to be unable to build.

Related to https://github.com/apollographql/apollo-ios/issues/3308

Version

Tried with the latest version 1.15.1. Possibly occurs on older versions, we're very slow to update 🐢.

Steps to reproduce the behavior

pushd "$(mktemp -d)" || exit
echo 'github "apollographql/apollo-ios-xcframework"' > Cartfile
carthage bootstrap
popd || exit

Logs

*** No Cartfile.resolved found, updating dependencies
*** Fetching apollo-ios-xcframework
*** Checking out apollo-ios-xcframework at "1.15.1"
*** xcodebuild output can be found in /var/folders/_x/0yf9v78x1zzfd4pk03vx7f440000gq/T/carthage-xcodebuild.JiLsUV.log
*** Skipped building apollo-ios-xcframework due to the error:
Dependency "apollo-ios-xcframework" has no shared framework schemes

If you believe this to be an error, please file an issue with the maintainers at https://github.com/apollographql/apollo-ios-xcframework/issues/new

Anything else?

Also, I tried manually calling the makefile to build the frameworks but that also results in an error since it appears the iphoneos.xcarchive doesn't contain a framework.

make build-apollo-xc-framework
xcodebuild -create-xcframework -output ./build/Apollo.xcframework -framework ./build/iphonesimulator.xcarchive/Products/Library/Frameworks/Apollo.framework -framework ./build/iphoneos.xcarchive/Products/Library/Frameworks/Apollo.framework
error: the path does not point to a valid framework: .../Carthage/Checkouts/apollo-ios-xcframework/build/iphoneos.xcarchive/Products/Library/Frameworks/Apollo.framework
make: *** [build-apollo-xc-framework] Error 70

I think it's also caused by there being no shared schemes. If I manually create a new scheme in the project, it shows the project targets and the package targets.

out

I'd guess the xcodebuild command picks the package target when specifying -scheme Apollo and building for iOS. After manually creating the schemes, it produces the xcframeworks.

BobaFetters commented 2 months ago

@CraigSiemens thanks for the detailed report, I'll have a look at this so we can get it fixed.

BobaFetters commented 2 months ago

Looked into this briefly so far, it looks like the schemes available in the project are shared, and there are targets for the package products but not actually schemes, so I'm not positive the schemes are the root issue here.

I did notice when running make build-apollo-xc-framework I saw the same error you reported and it looks like the Library/Frameworks/Apollo.framework is missing from the iphoneos build for some reason, however if i individually run the 3 xcodebuild commands from the make command in succession everything works as expected and the Library/Frameworks/Apollo.framework does exist as it should. Wondering if theres something with the make command somehow causing the issue.

Will look into this some more soon to see if I can narrow it down further.

CraigSiemens commented 2 months ago

Looked into this briefly so far, it looks like the schemes available in the project are shared, and there are targets for the package products but not actually schemes, so I'm not positive the schemes are the root issue here.

Since the schemes are missing from Apollo.xcodeproj/xcshareddata/xcschemes maybe they're ignored by git? A fresh clone for me only shows the scheme Apollo-Workspace.

BobaFetters commented 2 months ago

Hmmm I can check that, although the Apollo-Workspace scheme is only in the workspace, and all the other schemes are in the Apollo.xcodeproj, but if Carthage is running off the workspace I guess that could explain that issue but not the issue with the make command, or why we are just now seeing the issue.

BobaFetters commented 2 months ago

@CraigSiemens So I was playing around with this, turned off the option in Tuist that was disable the auto-generation of schemes and regenerated the project/workspace and the make command started working as expected again. I have a pull request up with for the potential fix, would you be able to point to that branch and see if it solves your Carthage issue?

https://github.com/apollographql/apollo-ios-xcframework/pull/19

CraigSiemens commented 2 months ago

Yeah, I'll try it out.

github-actions[bot] commented 2 months ago

Do you have any feedback for the maintainers? Please tell us by taking a one-minute survey. Your responses will help us understand Apollo iOS usage and allow us to serve you better.