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

Xcode tries to use AppKit when compiling with Mac Catalyst #4233

Closed
1 task done
jacobcxdev opened this issue Nov 27, 2019 · 3 comments
Closed
1 task done

Xcode tries to use AppKit when compiling with Mac Catalyst #4233

jacobcxdev opened this issue Nov 27, 2019 · 3 comments

Comments

@jacobcxdev
Copy link

What did you do?

Checked the Mac target in project settings.

What did you expect to happen?

For the project to compile without error.

What happened instead?

There were errors due to #if canImport(AppKit) being used — the target is a Mac so it can be imported, but Mac Catalyst won't build if it is.

Charts Environment

Charts version/Branch/Commit Number: master
Xcode version: 11.3 beta (11C24b)
Swift version: 5
Platform(s) running Charts: iOS, Mac Catalyst
macOS version running Xcode: 10.15.2 Beta (19C46a)

Demo Project

[Literally just use any Charts project and check the Mac target such that it uses Mac Catalyst].

@liuxuan30
Copy link
Member

I'm not sure whose bug it is -

the target is a Mac so it can be imported, but Mac Catalyst won't build if it is.

I guess you have to file a radar for Apple and see what's their response.

Because this library does support macOS, but combining the case the catalyst, I'm not sure how the catalyst works especially for our case.

If you got the source code, you can simply delete these macros and see if you can run it and let us know the result.

@jjatie any idea?

@CAPIStkidd
Copy link
Contributor

I think the issue is that Catalyst is in this weird limbo state where some things about Mac development apply to it and some don't, so some of the recent tech decisions made by the Charts project present issues since Charts is aiming to be compatible with Mac development proper.

For a project I did for the iPad, I had taken a build/version based off of the 90e8cd0 commit and it worked fine in Catalyst for macOS. However the most recent build on master, commit 61ba666, does not work.

Between those two commits it looks like the "Platform+" concept took hold, with source files like "Platform+Color.swift" and "Platform+Graphics.swift", etc. This is where the #if canImport(AppKit) lines that @jacobcxdev noticed are located.

Just as a quick proof of concept hack, I changed these lines to be

#if canImport(AppKit) && !targetEnvironment(macCatalyst)

And everything works fine. The lines in the AppKit causing issues are trying to alias things like NSColor when NSColor doesn't exist in Catalyst since, essentially, Catalyst is trying to be "UIKIt for Mac" and so it needs to use UIKit equivalents like UIColor.

Some of this is just due to Catalyst being a half-baked concept but as a band-aid of sorts this should work.

@CAPIStkidd
Copy link
Contributor

Created a PR to address this.

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