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

macOS Support #1057

Closed
Closed

Conversation

safaiyeh
Copy link

@safaiyeh safaiyeh commented Aug 15, 2020

Description

Added support for macOS. This is the beginning of macOS support. Currently did enough to get the build to work on macOS, I'll spend the next couple of days making sure the returned values are correct!

I do not mind PRs to help out 😁

One thing I noticed is now the iOS folder has implementations for iOS, tvOS, and macOS. A common scheme Microsoft uses and react-native-webview uses is naming the directory apple, should we follow that scheme? Changed to apple πŸ‘

Possible functions that need more expertise to be implemented or more time outside the scope of this:
getBatteryLevel(): https://developer.apple.com/documentation/kernel/iopmpowersource#//apple_ref/doc/uid/TP40012438
isCameraPresent(): https://developer.apple.com/documentation/avfoundation/avcapturedevice
getInstallerPackageName(): is this the same as getBundleId()?

Check List before ready for merge

  • Update documentation
  • GitHub Action CI similar to Windows implementation
  • Go through each method, determine if possible for macOS & what it should return (updating table as progress is made)
Method Return Type Β  Possible? Return value
getAndroidId() Promise<string> ❌ unknown
getApiLevel() Promise<number> ❌ -1
getApplicationName() string βœ… DeviceInfoTest
getAvailableLocationProviders() Promise<Object> βœ… { headingAvailable: false, locationServicesEnabled: true, significantLocationChangeMonitoringAvailable: true }
getBaseOs() Promise<string> βœ… macOS
getBuildId() Promise<string> βœ… 19G73
getBatteryLevel() Promise<number>
getBootloader() Promise<string> ❌ unknown
getBrand() string βœ… Apple
getBuildNumber() string βœ… 1
getBundleId() string βœ… org.reactjs.native.DeviceInfoTest
isCameraPresent() Promise<boolean>
getCarrier() Promise<string> ❌ unknown
getCodename() Promise<string> ❌ unknown
getDevice() Promise<string> ❌ unknown
getDeviceId() string βœ… Macmini8,1
getDeviceType() string βœ… Mac
getDisplay() Promise<string> ❌ unknown
getDeviceName() Promise<string> βœ… Jasons-Mac-Mini
getDeviceToken() Promise<string> βœ… [Error: The operation couldn’t be completed. (com.apple.devicecheck.error error 0.)]
getFirstInstallTime() Promise<number> ❌ -1
getFingerprint() Promise<string> ❌ unknown
getFontScale() Promise<number> ❌ -1
getFreeDiskStorage() Promise<number> βœ… 100742909952
getHardware() Promise<string> ❌ unknown
getHost() Promise<string> ❌ unknown
getIpAddress() Promise<string> βœ… 192.xxx.xxx.xx (redacted)
getIncremental() Promise<string> ❌ unknown
getInstallerPackageName() Promise<string>
getInstallReferrer() Promise<string> ❌ unknown
getInstanceId() Promise<string> ❌ unknown
getLastUpdateTime() Promise<number> ❌ -1
getMacAddress() Promise<string> ❌ unknown
getManufacturer() Promise<string> βœ… Apple
getMaxMemory() Promise<number> ❌ -1
getModel() string βœ… Mac mini (2018)
getPhoneNumber() Promise<string> ❌ unknown
getPowerState() Promise<object>
getProduct() Promise<string>
getPreviewSdkInt() Promise<number>
getReadableVersion() string
getSerialNumber() Promise<string>
getSecurityPatch() Promise<string>
getSystemAvailableFeatures() Promise<string[]>
getSystemName() string
getSystemVersion() string
getTags() Promise<string>
getType() Promise<string>
getTotalDiskCapacity() Promise<number>
getTotalMemory() Promise<number>
getUniqueId() string
getUsedMemory() Promise<number>
getUserAgent() Promise<string>
getVersion() string
hasNotch() boolean
hasSystemFeature() Promise<boolean>
isAirplaneMode() Promise<boolean>
isBatteryCharging() Promise<boolean>
isEmulator() Promise<boolean>
isLandscape() Promise<boolean>
isLocationEnabled() Promise<boolean>
isHeadphonesConnected() Promise<boolean>
isPinOrFingerprintSet() Promise<boolean>
isTablet() boolean
supported32BitAbis() Promise<string[]>
supported64BitAbis() Promise<string[]>
supportedAbis() Promise<string[]>
syncUniqueId() Promise<string>

Compatibility

OS Implemented
iOS ❌
Android ❌
Windows ❌
macOS βœ…

Checklist

  • I have tested this on a device/simulator for each compatible OS
  • I added the documentation in README.md
  • I mentioned this change in CHANGELOG.md
  • I updated the typings files (privateTypes.ts, types.ts)
  • I added a sample use of the API (example/App.js)

@kaiyes
Copy link

kaiyes commented Aug 15, 2020

I felt that folder structure is pretty intuitive. You can go to each folder and do things there separately without affecting other ones. It has become a second habit for me to go the mac folder and run - mac which is an alias for npx react-native run-macos.

@@ -72,7 +72,7 @@ - (NSDictionary *)constantsToExport {
- (id)init
{
if ((self = [super init])) {
#if !TARGET_OS_TV
#if (!TARGET_OS_TV && !TARGET_OS_OSX)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I recognize it's draft and you're just getting compile to work, but seems OSX should likely have battery information as well? Laptop use case?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Collaborator

@mikehardy mikehardy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Exciting! I won't approve or reject now since it's just draft, but I left some collaborating comments. Thanks for proposing this

@@ -21,7 +21,7 @@ if (!RNDeviceInfo) {
throw new Error(`@react-native-community/react-native-device-info: NativeModule.RNDeviceInfo is null. To fix this issue try these steps:
β€’ For react-native <= 0.59: Run \`react-native link react-native-device-info\` in the project root.
β€’ Rebuild and re-run the app.
β€’ If you are using CocoaPods on iOS, run \`pod install\` in the \`ios\` directory and then rebuild and re-run the app. You may also need to re-open Xcode to get the new pods.
β€’ If you are using CocoaPods on iOS or macOS, run \`pod install\` in the \`ios\` or \`macos\` directory and then rebuild and re-run the app. You may also need to re-open Xcode to get the new pods.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
β€’ If you are using CocoaPods on iOS or macOS, run \`pod install\` in the \`ios\` or \`macos\` directory and then rebuild and re-run the app. You may also need to re-open Xcode to get the new pods.
β€’ If you are using CocoaPods for apple targets, run \`pod install\` in the \`macos\` directory, then rebuild and re-run the app. You may also need to re-open Xcode to get the new pods.

I think this is more accurate? I'm always iffy on wording and documentation though, feel free to mash the words around, but I don't think the ios directory will exist so that at least should be removed

@mikehardy
Copy link
Collaborator

You are steadily chewing through this! nice

@safaiyeh
Copy link
Author

Yup! Aiming to finish this week 😁

@mikehardy
Copy link
Collaborator

Excellent! I'm not making any promises (open source and all...) but I've been reading about github actions and I hope to have some CI up including a catalyst and macos build target CI check so that none of us accidentally silently break your work in the future :)

@safaiyeh
Copy link
Author

Sounds good! I can take a stab at it too after I finish up the functions

@rndi-bot
Copy link
Collaborator

Hello πŸ‘‹, this PR has been opened for more than 2 months with no activity on it. If you think this is a mi stake please comment and ping a maintainer to get this merged ASAP! Thanks for contributing! You have 7 days until this gets closed a utomatically

@rndi-bot rndi-bot added stale and removed stale labels Feb 27, 2022
@mikehardy
Copy link
Collaborator

maintainer pinging themselves ;-)

@rndi-bot
Copy link
Collaborator

Hello πŸ‘‹, this PR has been opened for more than 2 months with no activity on it. If you think this is a mi stake please comment and ping a maintainer to get this merged ASAP! Thanks for contributing! You have 7 days until this gets closed a utomatically

@rndi-bot rndi-bot added the stale label Apr 28, 2022
@mikehardy
Copy link
Collaborator

still on my list, just contract work killin' me at the moment

@rndi-bot rndi-bot removed the stale label Apr 28, 2022
@rndi-bot
Copy link
Collaborator

Hello πŸ‘‹, this PR has been opened for more than 2 months with no activity on it. If you think this is a mi stake please comment and ping a maintainer to get this merged ASAP! Thanks for contributing! You have 7 days until this gets closed a utomatically

@rndi-bot rndi-bot added the stale label Jun 27, 2022
@rndi-bot rndi-bot closed this Jul 5, 2022
@mikehardy mikehardy reopened this Jul 5, 2022
@mikehardy
Copy link
Collaborator

I continue to be sad I haven't had the time to get this in yet. Some day...

@rndi-bot rndi-bot removed the stale label Jul 5, 2022
@elmcapp
Copy link

elmcapp commented Sep 1, 2022

Any updates as of Sep 1st 2022. is there support for macOS yet

@mikehardy
Copy link
Collaborator

No sorry, this is eternally back-burner. It's something I want to do but I just don't have the time and the time I do have is better spent on higher value (that is: impacts more users) projects, like getting macCatalyst to even work with react-native, which I did this Spring.

I'd love for anyone to take this up, and I'm sorry I could get it done but that's living...

@elmcapp
Copy link

elmcapp commented Sep 2, 2022

Where you able to get macCatalyst working with React Native. if so do you have a GitHub link to that project. I have been looking to use macCatalyst with React Native as well

@mikehardy
Copy link
Collaborator

mikehardy commented Sep 2, 2022

@elmcapp I have a fully scripted demonstration (you'll need to set your DEVELOPMENT_TEAM_ID) though, with react-native-firebase working, on macCatalyst, here: https://github.com/mikehardy/rnfbdemo/blob/main/make-demo.sh

In particular there used to be (through react-native 0.69) a number of workarounds involved:

https://github.com/mikehardy/rnfbdemo/blob/058dc304ca739f40698225753c12164875af1907/make-demo.sh#L249-L282

but myself and a few others got them upstream in a single flag now - https://github.com/facebook/react-native/blob/12e5842e11ecd53755f43e99c592135b58ac694b/template/ios/Podfile#L37-L39

Those will release with react-native 0.70

@rndi-bot
Copy link
Collaborator

rndi-bot commented Nov 1, 2022

Hello πŸ‘‹, this PR has been opened for more than 2 months with no activity on it. If you think this is a mi stake please comment and ping a maintainer to get this merged ASAP! Thanks for contributing! You have 7 days until this gets closed a utomatically

@rndi-bot rndi-bot added the stale label Nov 1, 2022
@rndi-bot rndi-bot closed this Nov 8, 2022
@fi-nik
Copy link

fi-nik commented Nov 8, 2022

Hey @mikehardy, i'm willing to give it a shot, try to solve this one out. As i can see, it's required to support all methods, which could be possible on macOS?

@mikehardy
Copy link
Collaborator

@fi-nik that is the general idea - support all the methods that could be possible - but incremental progress (supporting the methods that are important to you) would be a fine start

@mikehardy mikehardy reopened this Nov 9, 2022
@rndi-bot rndi-bot removed the stale label Nov 9, 2022
@fi-nik fi-nik mentioned this pull request Dec 15, 2022
7 tasks
@fi-nik
Copy link

fi-nik commented Dec 15, 2022

@fi-nik that is the general idea - support all the methods that could be possible - but incremental progress (supporting the methods that are important to you) would be a fine start
@mikehardy
I have created draft PR for support. #1490
Everything is working on sample app, but i just need to see if any of those with ❓ can be implemented, and if they can, what are those with highest priority for now

@rndi-bot
Copy link
Collaborator

Hello πŸ‘‹, this PR has been opened for more than 2 months with no activity on it. If you think this is a mi stake please comment and ping a maintainer to get this merged ASAP! Thanks for contributing! You have 7 days until this gets closed a utomatically

@rndi-bot rndi-bot added the stale label Feb 13, 2023
@rndi-bot rndi-bot closed this Feb 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet