Граф коммитов

77 Коммитов

Автор SHA1 Сообщение Дата
Moti Zilberman 850a8352c9 Manage redbox updates by comparing exception IDs
Summary:
Refines the condition for ignoring updates to an already-open redbox on iOS.

Previously we would only update the stack trace if the message string in the update was exactly the same as in the initial redbox. With this diff we rely on the `exceptionId` parameter instead, and only fall back to string comparison if it's omitted (i.e. for non-JS uses of redbox on iOS).

NOTE: `exceptionId` is part of the existing ExceptionsManager API and is already supported on Android.

Reviewed By: sammy-SC

Differential Revision: D17226179

fbshipit-source-id: 5940110bf4e4358a8a1b3477e8d2cf8b224dd9f8
2019-09-06 10:13:05 -07:00
Kevin Gozali 67fe9b29e8 iOS Appearance: default to light
Summary:
For iOS < 13, default to "light" appearance, just like in Android (instead of `nil`).

This fixes the following redbox:

{F205818545}

Reviewed By: cpojer

Differential Revision: D17147970

fbshipit-source-id: b2adccd349a0a0ff7668c2f30e93164d23c3eea6
2019-09-04 09:16:32 -07:00
Héctor Ramos 63fa3f21c5 Add Appearance native module
Summary:
Implements the Appearance native module as discussed in https://github.com/react-native-community/discussions-and-proposals/issues/126.

The purpose of the Appearance native module is to expose the user's appearance preferences. It provides a basic get() API that returns the user's preferred color scheme on iOS 13 devices, also known as Dark Mode. It also provides the ability to subscribe to events whenever an appearance preference changes.

The name, "Appearance", was chosen purposefully to allow for future expansion to cover other appearance preferences such as reduced motion, reduced transparency, or high contrast modes.

Changelog:

[iOS] [Added] - The Appearance native module can be used to prepare your app for Dark Mode on iOS 13.

Reviewed By: yungsters

Differential Revision: D16699954

fbshipit-source-id: 03b4cc5d2a1a69f31f3a6d9bece23f6867b774ea
2019-08-30 17:07:57 -07:00
Kevin Gozali 15b2353382 iOS Pods: added missing deps for React-CoreModules
Summary:
This is needed for use_frameworks! support with CocoaPods. Also, with recent changes to RCTImageLoader etc (moved to CoreModules), we need to add a dep to `React-RCTImage` pod.

If this approach works for 0.61 branch as well, it should be beneficial to pick. Note that https://github.com/facebook/react-native/pull/26151 attempts to fix similar things, but in 0.61 branch, not master.

Reviewed By: axe-fb

Differential Revision: D17120352

fbshipit-source-id: ca96a7a61a6422a6f9fc3a4bf3add51e6f33f4f1
2019-08-29 14:31:38 -07:00
Peter Argany f229d67498 Make RCTAccessibilityManger a TurboModule
Summary:
Move RCTAccessibilityManager to CoreModules (since that's the only dir that supports TM).

Fixup some variable names to match spec.

Reviewed By: RSNara

Differential Revision: D16861739

fbshipit-source-id: a0a53b221dcc172979d1f2c83851ab92e23f2333
2019-08-23 12:01:52 -07:00
Ramanpreet Nara 80f64f1e5b Ensure ImageLoader is lazily loaded as necessary
Summary: In D16805827, I moved ImageLoader to CoreModules. In the process, I migrated usages of `[_bridge moduleForClass:[RCTImageLoader class]]` to `[_bridge moduleForName:@"ImageLoader"]`. These two APIs aren't equivalent, however, since `[_bridge moduleForClass:[RCTImageLoader class]]` by default lazily loads the requested NativeModule, but `[_bridge moduleForName:@"ImageLoader"]` doesn't. So, I had to explicitly set `lazilyLoadIfNecessary` to `YES` in all the call-sites I migrated, to ensure that ImageLoader is correctly initialized when necessary.

Reviewed By: PeteTheHeat

Differential Revision: D16948165

fbshipit-source-id: 434697637dfa5e32de1c398744f9c28c19a6fd94
2019-08-21 16:11:32 -07:00
Peter Argany 685c15a955 Make RCTDeviceInfo a TurboModule
Summary: Follow pattern laid out by Kevin in D16001262 to convert a Core OSS native module to use TM generated spec.

Reviewed By: RSNara

Differential Revision: D16016391

fbshipit-source-id: f517777be44c68367d786f04c50cf12f240eed00
2019-08-21 14:31:02 -07:00
Albert Sun 5808973964 Fix bridge.imageLoader warning message
Summary: Missing space was causing this to show up as "themoduleForClass".

Reviewed By: shergin

Differential Revision: D16918867

fbshipit-source-id: c4bd19ca873d07e30e3fe8fc2c20277aab2d26d5
2019-08-20 10:18:50 -07:00
Peter Argany 6991e28653 Move RCTExceptionsManager to CoreModules and make it conform to spec
Summary:
`NativeExceptionsManager.js` contains the JS spec for this native module. This diff moves the objc code to CoreModules (since it's the only directory that supports TM at the moment) and makes it conform to the spec.

NOTE: I will update podfiles after this diff is reviewed, before I land. Adding those generated changes makes it really hard to review.

Reviewed By: RSNara

Differential Revision: D16812212

fbshipit-source-id: 38b6e9a20ce15e7e9995df34493b37ed7adb2911
2019-08-15 20:25:23 -07:00
Peter Argany 30c1196d7d Convert RCTImageLoader to TurboModules [4/N]
Summary:
This diff adds a JS spec for RCTImageLoader, and conforms to it in ObjC++. Since RCTImageLoader isn't called from JS, the js spec is empty. Since `/CoreModules/` is the only dir in OSS which supports TM, move the ObjC++ impl there.

The change in `NativeExceptionsManager.js` fixes a weird bug I was hitting in codegen, where the codegen cpp file wouldn't compile due to unused variable.

Reviewed By: JoshuaGross

Differential Revision: D16495674

fbshipit-source-id: 191897b87730a6b0b96022eedc6412551fae04a6
2019-08-15 11:33:37 -07:00
Ramanpreet Nara bf78d7969a Migrate RCTImage NativeModules to CoreModules
Summary:
This diff moves RCTImageLoader, RCTImageEditingManager, and RCTImageStoreManager to CoreModules. This is necessary for us to convert all these NativeModules to TurboModules.

**Note:** As a part of this diff, I had to break apart `RCTImageLoader.h`. All the protocols that were in `RCTImageLoader` are now in their own headers. Furthermore, `RCTImageLoader`'s methods are defined in `RCTImageLoaderProtocol`, so that we can call them from classes like `RCTImageViewManager` in `RCTImage`.

Reviewed By: PeteTheHeat

Differential Revision: D16805827

fbshipit-source-id: 89f6728b0766c30b74e25f7af1be8e6b8a7e6397
2019-08-14 13:39:30 -07:00
Adam Ernst 724fe11472 Add reexport_all_header_dependencies to (yet more) misc rules
Summary: Currently this is the default, but I plan to toggle the default to False shortly. False is better for build speed, as it forces you to separate deps and exported_deps.

Reviewed By: williamtwilson

Differential Revision: D16785991

fbshipit-source-id: 8cb73b87f1dfa50f21c0c12df1579054cdc99e6e
2019-08-13 11:14:06 -07:00
Kevin Gozali 28e18e4105 iOS fixed up inconsistent boolean convertion logic in RCTPlatform
Summary: For some reason the conversion from a BOOL object to `bool` (C++ style) may lead to incorrect boolean value. This fixes the value provided to the builder to be of `bool` type instead.

Reviewed By: JoshuaGross

Differential Revision: D16657766

fbshipit-source-id: b66922aceadd20d16226a07f73b24ee0a3b825dc
2019-08-05 17:34:52 -07:00
Michał Osadnik 2956eb266f Switch Platform Constansts to use typedConstants structs
Summary: It's actually the first module in OSS which is typed with taking advantages of codegen.

Reviewed By: RSNara

Differential Revision: D16620334

fbshipit-source-id: 65d6656506f2a4c68d493939ecfa65ba975abead
2019-08-05 04:23:16 -07:00
James Treanor ca9e108110 Remove 's.static_framework = true' requirement for podspec (#25816)
Summary:
As part of the fix for https://github.com/facebook/react-native/issues/25349 I added `s.static_framework = true` to each podspec in repo (see https://github.com/facebook/react-native/pull/25619#discussion_r306993309 for more context).

This was required to ensure the existing conditional compilation with `#if RCT_DEV` and `__has_include` still worked correctly when `use_frameworks!` is enabled.

However, fkgozali pointed out that it would be ideal if we didn't have this requirement as it could make life difficult for third-party libraries.

This removes the requirement by moving `React-DevSupport.podspec` and `React-RCTWebSocket.podspec` into `React-Core.podspec` as subspecs. This means the symbols are present when `React-Core.podspec` is built dynamically so `s.static_framework = true` isn't required.

This means that any `Podfile` that refers to `React-DevSupport` or `React-RCTWebSocket` will need to be updated to avoid errors.

## Changelog

I don't think this needs a changelog entry since its just a refinement of https://github.com/facebook/react-native/pull/25619.
Pull Request resolved: https://github.com/facebook/react-native/pull/25816

Test Plan:
Check `RNTesterPods` still works both with and without `use_frameworks!`:

1. Go to the `RNTester` directory and run `pod install`.
2. Run the tests in `RNTesterPods.xcworkspace` to see that everything still works fine.
3. Uncomment the `use_frameworks!` line at the top of `RNTester/Podfile` and run `pod install` again.
4. Run the tests again and see that it still works with frameworks enabled.

Reviewed By: hramos

Differential Revision: D16495030

Pulled By: fkgozali

fbshipit-source-id: 2708ac9fd20cd04cb0aea61b2e8ab0d931dfb6d5
2019-07-25 11:46:43 -07:00
James Treanor 8131b7bb7b CocoaPods frameworks compatibility: Step 2 (#25619)
Summary:
This is my proposal for fixing `use_frameworks!` compatibility without breaking all `<React/*>` imports I outlined in https://github.com/facebook/react-native/pull/25393#issuecomment-508457700. If accepted, it will fix https://github.com/facebook/react-native/issues/25349.

It builds on the changes I made in https://github.com/facebook/react-native/pull/25496 by ensuring each podspec has a unique value for `header_dir` so that framework imports do not conflict. Every podspec which should be included in the `<React/*>` namespace now includes it's headers from `React-Core.podspec`.

The following pods can still be imported with `<React/*>` and so should not have breaking changes: `React-ART`,`React-DevSupport`, `React-CoreModules`, `React-RCTActionSheet`, `React-RCTAnimation`, `React-RCTBlob`, `React-RCTImage`, `React-RCTLinking`, `React-RCTNetwork`, `React-RCTPushNotification`, `React-RCTSettings`, `React-RCTText`, `React-RCTSettings`, `React-RCTVibration`, `React-RCTWebSocket` .

There are still a few breaking changes which I hope will be acceptable:

- `React-Core.podspec` has been moved to the root of the project. Any `Podfile` that references it will need to update the path.
- ~~`React-turbomodule-core`'s headers now live under `<turbomodule/*>`~~ Replaced by https://github.com/facebook/react-native/pull/25619#issuecomment-511091823.
- ~~`React-turbomodulesamples`'s headers now live under `<turbomodulesamples/*>`~~ Replaced by https://github.com/facebook/react-native/pull/25619#issuecomment-511091823.
- ~~`React-TypeSaferty`'s headers now live under `<TypeSafety/*>`~~ Replaced by https://github.com/facebook/react-native/pull/25619#issuecomment-511040967.
- ~~`React-jscallinvoker`'s headers now live under `<jscallinvoker/*>`~~ Replaced by https://github.com/facebook/react-native/pull/25619#issuecomment-511091823.
- Each podspec now uses `s.static_framework = true`. This means that a minimum of CocoaPods 1.5 ([released in April 2018](http://blog.cocoapods.org/CocoaPods-1.5.0/)) is now required. This is needed so that the ` __has_include` conditions can still work when frameworks are enabled.

Still to do:

- ~~Including `React-turbomodule-core` with `use_frameworks!` enabled causes the C++ import failures we saw in https://github.com/facebook/react-native/issues/25349. I'm sure it will be possible to fix this but I need to dig deeper (perhaps a custom modulemap would be needed).~~ Addressed by 33573511f0.
- I haven't got Fabric working yet. I wonder if it would be acceptable to move Fabric out of the `<React/*>` namespace since it is new? �

## Changelog

[iOS] [Fixed] - Fixed compatibility with CocoaPods frameworks.
Pull Request resolved: https://github.com/facebook/react-native/pull/25619

Test Plan:
### FB

```
buck build catalyst
```

### Sample Project

Everything should work exactly as before, where `use_frameworks!` is not in `Podfile`s. I have a branch on my [sample project](https://github.com/jtreanor/react-native-cocoapods-frameworks) here which has `use_frameworks!` in its `Podfile` to demonstrate this is fixed.

You can see that it works with these steps:

1. `git clone git@github.com:jtreanor/react-native-cocoapods-frameworks.git`
2. `git checkout fix-frameworks-subspecs`
3. `cd ios && pod install`
4. `cd .. && react-native run-ios`

The sample app will build and run successfully. To see that it still works without frameworks, remove `use_frameworks!` from the `Podfile` and do steps 3 and 4 again.

### RNTesterPods

`RNTesterPodsPods` can now work with or without `use_frameworks!`.

1. Go to the `RNTester` directory and run `pod install`.
2. Run the tests in `RNTesterPods.xcworkspace` to see that everything still works fine.
3. Uncomment the `use_frameworks!` line at the top of `RNTester/Podfile` and run `pod install` again.
4. Run the tests again and see that it still works with frameworks enabled.

Reviewed By: PeteTheHeat

Differential Revision: D16465247

Pulled By: PeteTheHeat

fbshipit-source-id: cad837e9cced06d30cc5b372af1c65c7780b9e7a
2019-07-24 23:27:09 -07:00
Kevin Gozali 549c46975e iOS: suppress nullability completeness warning in TM generated spec file
Summary: For now, suppress this warning - they are harmless.

Reviewed By: mdvacca

Differential Revision: D16198994

fbshipit-source-id: b167d0e98bbc4abcd0461d50f01f364d8d560aec
2019-07-11 12:02:39 -07:00
Kevin Gozali 725e034128 TM iOS: Run RCTPlatform methods on the main queue
Summary:
This module expects to compute main queue stuffs inside getConstants(), mark it so. This address crashes when running tests:

```
Main Thread Checker: UI API called on a background thread: -[UIApplication keyWindow]
PID: 88318, TID: 22602153, Thread name: com.facebook.react.JavaScript, Queue name: com.apple.root.default-qos.overcommit, QoS: 0
Backtrace:
4   RNTester                            0x0000000100beece8 RCTKeyWindow + 72
5   RNTester                            0x0000000100beeee4 RCTForceTouchAvailable + 148
6   RNTester                            0x0000000100c0b54d -[RCTPlatform getConstants] + 109
```

Sample CI failure: https://circleci.com/gh/facebook/react-native/101079

Reviewed By: PeteTheHeat

Differential Revision: D16198720

fbshipit-source-id: 272eaccf5027d0bf5b2838ed9623ae079fac148e
2019-07-11 12:02:39 -07:00
Kevin Gozali 987e5197f0 TM iOS: autogenerate plugins map based on FB build system
Summary: This adds internal script to automatically sync the plugins definition. For github consumption, the CoreModulesPlugins.* will stay checked in, nothing change.

Reviewed By: RSNara

Differential Revision: D16102352

fbshipit-source-id: 8f74ea9dde046183ae620682fd7e181b4cc95a94
2019-07-04 11:21:56 -07:00
Kevin Gozali 9c56be2721 TM iOS: Introduce OSS-compatible RCTCoreModulesClassProvider()
Summary: To look up TurboModule Class based on its name, this new function `RCTCoreModulesClassProvider()` can be used to find a TurboModule impl in the app. For now this is manually maintained and sync'ed with FB internal version. Only modules that live under React/CoreModules/ should be handled here.

Reviewed By: PeteTheHeat

Differential Revision: D16100291

fbshipit-source-id: 6b7556dec1fa83d1e081c7e8c0fe295187934274
2019-07-04 11:21:55 -07:00
Kevin Gozali 737b784b8c TM iOS: removed CoreModulesAppleHeader BUCK workaround
Summary:
We should be able to just use `header_path_prefix` and normal `glob(["**/*.h"])` patterns, and that should be compatible with the build system.
This also allows `RCTPlatform.mm` to import `"RCTPlatform.h"` directly without any namespace.

Reviewed By: RSNara

Differential Revision: D16096779

fbshipit-source-id: b17b79baf958f1e9a63085a928b64663cb29bbbb
2019-07-04 11:21:55 -07:00
Kevin Gozali e883197807 Reland: [RN] iOS OSS: define plugin entries for OSS NativeModules
Summary: A reland of f26ffbf561

Reviewed By: sammy-SC

Differential Revision: D16091073

fbshipit-source-id: 09660ba987c3035333eac55e6bb94373fad9252b
2019-07-02 10:35:18 -07:00
Ben Blackburne b476ad78b5 Revert D16082484: [RN] iOS OSS: define plugin entries for OSS NativeModules
Differential Revision:
D16082484

Original commit changeset: 81d9f20b2041

fbshipit-source-id: 682476fccff7320de9ffd541b9a9ff3cae4da3bd
2019-07-02 00:14:26 -07:00
Kevin Gozali f26ffbf561 iOS OSS: define plugin entries for OSS NativeModules
Summary: This is an attempt to use internal iOS plugin system for NativeModules in github.

Reviewed By: RSNara

Differential Revision: D16082484

fbshipit-source-id: 81d9f20b20419e9613a2babdd56d0e037705bf4e
2019-07-01 20:33:34 -07:00
Kevin Gozali cde1a99940 TM iOS: Make RCTPlatform a TurboModule
Summary: First attempt to make RCTPlatform module implement the generated specs for TurboModule.

Reviewed By: PeteTheHeat

Differential Revision: D16001262

fbshipit-source-id: 24067c2840b9aa2be224c0c7c82fe7edc98d40d9
2019-07-01 15:20:02 -07:00
Kevin Gozali fde8a4cf93 TM iOS: Set up CocoaPods specs for the TM specs
Summary: This defines various sub specs to support building TurboModules that implement the codegen'ed specs.

Reviewed By: PeteTheHeat

Differential Revision: D16043221

fbshipit-source-id: 27ed532be929c11c8fe648632da8a72061cbc8b0
2019-07-01 15:20:01 -07:00
Kevin Gozali 020c11cc7b iOS Buck: Create CoreModules sub-target
Summary: Right now the entire RN core code lives inside one giant internal Buck target. This makes it hard to refactor the infra and to roll out TurboModules. For now, create a baseline for how RN core dir can be structured.

Reviewed By: PeteTheHeat

Differential Revision: D16001260

fbshipit-source-id: bba947e2fb75576a2e1f3f4c816575f1157dcb03
2019-07-01 15:20:01 -07:00