Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generated code does not compile with Xcode 14/Swift 5.7 #153

Closed
haydgately opened this issue Sep 13, 2022 · 16 comments
Closed

Generated code does not compile with Xcode 14/Swift 5.7 #153

haydgately opened this issue Sep 13, 2022 · 16 comments

Comments

@haydgately
Copy link

pension_plan_kit/.build/checkouts/Get/Sources/Get/DataLoader.swift:156:50: error: incorrect argument label in call (have ':didCreateTask:', expected ':taskIsWaitingForConnectivity:')
handlers[task]?.delegate?.urlSession?(session, didCreateTask: task)

@liamnichols
Copy link
Member

Hmm interesting. Please can you share some information about your build environment.. Are you using Xcode or swift build? Which version of Xcode/Swift are you trying to build with.

Get/Sources/Get/DataLoader.swift

This is actually part of the Get library so it might be that we need to open an issue over there depending on what the problem is.

@haydgately
Copy link
Author

I am using swift build and latest stable which is 14.0

@liamnichols
Copy link
Member

liamnichols commented Sep 13, 2022

Thanks, I just tried and I can replicate the same issue but this is related to Get and not CreateAPI itself. Please could you open an issue in that repository providing the same information above? See comment below.

It looks like some things might have changed in the latest beta of Xcode. Note that CreateAPI doesn't support Get 2.0 yet so a version of Get 1.0 would also need to be released with a patch for this issue.

@liamnichols
Copy link
Member

liamnichols commented Sep 13, 2022

Actually, it looks like Get 2.x fixes the issue. But I wonder if we can get an updated version of Get 1.x that patches this issue too?

This is the required diff:

diff --git a/Sources/Get/DataLoader.swift b/Sources/Get/DataLoader.swift
index 9bfcc45..e4dca52 100644
--- a/Sources/Get/DataLoader.swift
+++ b/Sources/Get/DataLoader.swift
@@ -150,7 +150,7 @@ final class DataLoader: NSObject, URLSessionDataDelegate, URLSessionDownloadDele
         userTaskDelegate?.urlSession?(session, taskIsWaitingForConnectivity: task)
     }
 
-#if swift(>=5.7)
+#if !os(macOS) && !targetEnvironment(macCatalyst) && swift(>=5.7)
     func urlSession(_ session: URLSession, didCreateTask task: URLSessionTask) {
         if #available(iOS 16.0, macOS 13.0, tvOS 16.0, watchOS 9.0, *) {
             handlers[task]?.delegate?.urlSession?(session, didCreateTask: task)

cc @kean

I opened a separate ticket about moving CreateAPI to Get 2.0, but fixing this in a patch release of Get would help people who already use CreateAPI to use Xcode 14.

@haydgately
Copy link
Author

Should I wait for a resolution before trying again? Thanks for your assistance @liamnichols

@kean
Copy link
Member

kean commented Sep 13, 2022

Yes, I can release a patch for Get 1.0 as well. I'll do it later today.

@liamnichols
Copy link
Member

Thanks @kean!

@haydgately: Yep, once a patch for Get has been released, you should just be able to clear package caches and it'll pull in the newer version of Get to solve your issue.

@haydgately
Copy link
Author

Amazing thanks so much! I will try when it has been released :D @kean @liamnichols

@kean
Copy link
Member

kean commented Sep 13, 2022

Should be fixed in Get 1.0.3.

@haydgately
Copy link
Author

I tried to reinstall CreateAPI but it is still the same version:

Warning: create-api 0.1.0 is already installed and up-to-date.
To reinstall 0.1.0, run:
brew reinstall create-api

Is there a fix expected here for this to work?

@liamnichols
Copy link
Member

No need to update CreateAPI, you just need to run swift package reset and swift build on the package that you had already generated and it should clone the 1.0.3 version of Get instead.

If that doesn't work, try deleting the .swiftpm directory to force it to update the dependencies

@haydgately
Copy link
Author

Screenshot 2022-09-14 at 10 24 04

Sorry for this, but I am struggling to get it past 1.0.2

@liamnichols
Copy link
Member

Hmm, maybe try deleting Package.resolved? It might have 1.0.2 cached in there.

@haydgately
Copy link
Author

Screenshot 2022-09-14 at 14 52 45

Thanks, a new error but one for a separate issue probably, thanks for your help :)

@liamnichols
Copy link
Member

Well at least we're making progress 🙂 The errors look very odd to me, I'm not entirely sure what is going on here. Is the project private ? Are you able to share the generated output so I can try running it locally to reproduce the issue?

In the meantime, I'm just adding Xcode 14 support to our CI checks to check if any errors show up - #156

@liamnichols
Copy link
Member

I just saw your other ticket.. Will close this one and move the conversation over to #155 👍

@liamnichols liamnichols changed the title Issue running swift build Generated code does not compile with Xcode 14/Swift 5.7 Sep 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants