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

identify app running under macOS 13 Catalyst #214

Open
polymerchm opened this issue Oct 22, 2019 · 7 comments
Open

identify app running under macOS 13 Catalyst #214

polymerchm opened this issue Oct 22, 2019 · 7 comments

Comments

@polymerchm
Copy link

Self-explanatory

@polymerchm polymerchm changed the title identity macOS 13 Catalyst identify app running under macOS 13 Catalyst Oct 22, 2019
@Zandor300
Copy link
Member

You can do that in the following way:

#if targetEnvironment(macCatalyst)
    let catalyst = true
#else
    let catalyst = false
#endif

Or do you rather want a function like so?

Device.current.isMacCatalyst

@gabors
Copy link

gabors commented Nov 7, 2019

Hi @Zandor300 Thanks for this awesome project!

As per above

Device.current.description returns Simulator (iOS) when running in a Mac Catalyst app.

@phimage
Copy link
Contributor

phimage commented Nov 7, 2019

identifier return "x86_64" when using catalyst app

so


simulator(mapToDevice(identifier: ProcessInfo().environment["SIMULATOR_MODEL_IDENTIFIER"] ?? "iOS"))

return Simulator (iOS)


case mac must be added?
The difficulty is to respond correctly to some device attribute that changed according to device or even worst, the window/scene size

maybe a
case macCatalyst(mac) with mac an enum for all mac devices or a struct with mac definition like screen size etc...

@gabors
Copy link

gabors commented Nov 7, 2019

Identification of Mac models would be ideal but I’m not sure what’s the apple API for that.
For starters the description should probably fall back to a string like Mac if running under catalyst.

@phimage
Copy link
Contributor

phimage commented Nov 12, 2019

I make a PR for mac runtime and models #217

With some change I test it with mac catalyst inside an iOS app
My method to get device model identifier work on catalyst (ie. getting model identifier using Darwin.sysct )

So
S1 / we could add all mac models into enum devices
S2 / or add a macCatalyst(MacModel)
with MacModel a new enum available only with iOS runtimes, which contains the list of mac Models
S3 / just add macCatalyst case without macModel but S2 is possible , so why do the least...

@Zandor300
Copy link
Member

@phimage I think we don't need a macCatalyst(macModel) enum since the code that references the Mac models, in this case, will only be ran under an iOS/Catalyst target.

In case the code is in a framework that supports both iOS/Catalyst and native macOS, that can be checked using the following code I've posted here before:

#if targetEnvironment(macCatalyst)
    let catalyst = true
#else
    let catalyst = false
#endif

@phimage
Copy link
Contributor

phimage commented Nov 12, 2019

Yes but we could also identify a device without using DeviceKit

First I thinks it is crappy to return Simulator (iOS) on mac Catalyst when using Device.current, just macCatalyst at least
(today we could do Device.current.realDevice = .unknown("iOS"))

If we want to display the device name or we want to have a generic switch case code that rely on DeviceKit, making a special case each time using the #if targetEnvironment is annoying
I prefer

#if os(iOS)
 switch Device.current.realDevice {
 case .iPhone11Pro: 
    ...
 case .macCatalyst:
    ...
}
#endif

and yes I use `#if targetEnvironment(macCatalyst)` in my current test code for mac catalyst and DeviceKit to get mac model identifier instead of current "x86_64" 

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

4 participants