This differential implements Objective C compatibility class for AESCryptoModule that internally calls the same functionality as AESCryptoModule expo module. It also introduces necessary refactors and build config files changes so that we can
use Compatibility class from any pure Objective C place like NSE.
Details
- Change NSE code according to: https://gist.github.com/marcinwasowicz/442f91ecb3e9781ab4e6e997692e3a46 (literally copy paste).
- Send notification to the app running on physical device.
- Examine NSE logs in console app.
Diff Detail
- Repository
- rCOMM Comm
- Lint
Lint Not Applicable - Unit
Tests Not Applicable
Event Timeline
native/expo-modules/comm-expo-package/ios/CommExpoPackage.podspec | ||
---|---|---|
22–35 ↗ | (On Diff #28385) | |
native/expo-modules/comm-expo-package/ios/CommExpoPackageObjCCompat.h | ||
1–3 ↗ | (On Diff #28385) | This is inspired by: https://github.com/expo/expo/blob/895fafd4aa32e64fa5b77e9e88d6d4f8c3638f9c/packages/expo-modules-core/ios/Swift.h#L10-L16 |
Logic / podfile changes look good, just some comments about organizing the code. Feel free to re-request if you feel it doesn't make sense
native/expo-modules/comm-expo-package/ios/AESCryptoModule.swift | ||
---|---|---|
8 ↗ | (On Diff #28385) | I'd add a comment here to make it clear why we have two separate module definitions |
12–14 ↗ | (On Diff #28385) | I'd delete the private func generateKey() definitions that only call try! generateKeyCommon() and do it directly from here. (suggestion only for the first function, repeat for others) This will make the code cleaner and you won't have to redefine them twice. To conclude:
|
18 ↗ | (On Diff #28385) | |
78 ↗ | (On Diff #28385) | Nit: I like the convention of having pointers suffixed with Ptr |
native/expo-modules/comm-expo-package/ios/CommExpoPackageObjCCompat.h | ||
1–3 ↗ | (On Diff #28385) | That's a smart trick! |
One more thing:
I'd add to the test plan that you tried sending/receiving encrypted media and it still works.
You would need to create a community with a special ID or edit the shouldEncryptMedia() in input-state-container.react.js to always return true.
Alternatively, call these from JS and console.log the results, the same way as you did in the attached NSE snippet (they're in native/utils/aes-crypto-module.js)
- Remove Common methods. Use closures in JS exported functions.
- Add Ptr suffix to pointer types.
- Add comments separating RN/Native code
- Add comment to compatibility header explaining used solution.
native/expo-modules/comm-expo-package/ios/AESCryptoModule.swift | ||
---|---|---|
45 ↗ | (On Diff #28403) | I changed method signatures to Compat to mitigate a bug in Swift compiler: https://github.com/apple/swift/issues/56300 |
I made a mistake and landed version of this differential with invalid Podfile.lock - @bartek reported to me that the content of this file (CommExpoPackage check sum in particular) changes upon pod install.I am reopening this differential to update Podfile.lock and re-land it in a correct form.