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

ImageResource type seems to be conflicting with Xcode 15's new type, causing a compile error. #2095

Closed
JohnnyTseng opened this issue Jun 12, 2023 · 3 comments

Comments

@JohnnyTseng
Copy link

JohnnyTseng commented Jun 12, 2023

Check List

Issue Description

Kingfisher's ImageResource type name conflicts with new type name generated by Xcode 15.
This code raises an error:

let resource = ImageResource(downloadURL: URL(string: "https://www.google.com.tw")!)
KingfisherManager.shared.retrieveImage(with: resource, options: []) { [weak self] result in }
Screenshot 2023-06-12 at 14 27 27

What

Xcode 15 introduces a new feature that allows developers to use Image assets without hard-coding the file name, example:
Old way:

UIImage(named: "demoAsset")

New way:

UIImage(resource: .demoAsset)

This is done by Xcode, generating the symbol for developers.
And because the type of property resource is also called ImageResource, this conflicts with Kingfisher's ImageResource symbol, causing a compile error.

Screenshot 2023-06-12 at 14 18 59

Reproduce

Clone and build this project: https://github.com/JohnnyTseng/KingfisherXcode15Demo

Other Comment

Environment:

  • Xcode 15.0 beta (15A5160n)
  • macOS Ventura 13.4

Note that if you setup a new project to reproduce this issue, remember to set deployment target to < iOS 17.0
It seems like with deployment target iOS 17.0, Xcode adds an extra namespace called DeveloperToolsSupport before ImageResource, causing we can't reproduce this issue.

Screenshot 2023-06-12 at 15 02 41
@JohnnyTseng JohnnyTseng changed the title ImageResource type seems to be conflicting with Xcode 15's new type ImageResource type seems to be conflicting with Xcode 15's new type, causing a compile error. Jun 12, 2023
@JohnnyTseng
Copy link
Author

Simply changing the name ImageResource would be a simple solution, but it introduces a breaking change, I'm not sure how we could deal with this in a better way 🤔

@onevcat
Copy link
Owner

onevcat commented Jun 12, 2023

This was discussed in #2090 and I pushed some commits in #2092

There is no good way to solve it without any pain. Hopefully the related changes can improve the transition experience a bit.

@JohnnyTseng
Copy link
Author

Ooops, I've searched Xcode 15 and related words, didn't notice this issue, sorry for the duplicated issue 😅

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

2 participants