Skip to content

Commit

Permalink
CocoaPods frameworks compatibility: Step 2 (#25619)
Browse files Browse the repository at this point in the history
Summary:
This is my proposal for fixing `use_frameworks!` compatibility without breaking all `<React/*>` imports I outlined in #25393 (comment). If accepted, it will fix #25349.

It builds on the changes I made in #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 #25619 (comment).
- ~~`React-turbomodulesamples`'s headers now live under `<turbomodulesamples/*>`~~ Replaced by #25619 (comment).
- ~~`React-TypeSaferty`'s headers now live under `<TypeSafety/*>`~~ Replaced by #25619 (comment).
- ~~`React-jscallinvoker`'s headers now live under `<jscallinvoker/*>`~~ Replaced by #25619 (comment).
- 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 #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 3357351.
- 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: #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 [email protected]: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
  • Loading branch information
jtreanor authored and facebook-github-bot committed Jul 25, 2019
1 parent 7244bae commit 8131b7b
Show file tree
Hide file tree
Showing 150 changed files with 561 additions and 500 deletions.
2 changes: 1 addition & 1 deletion Libraries/ART/ARTGroup.m
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* LICENSE file in the root directory of this source tree.
*/

#import "ARTGroup.h"
#import <React/ARTGroup.h>

@implementation ARTGroup

Expand Down
4 changes: 2 additions & 2 deletions Libraries/ART/ARTNode.m
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
* LICENSE file in the root directory of this source tree.
*/

#import "ARTNode.h"
#import <React/ARTNode.h>

#import "ARTContainer.h"
#import <React/ARTContainer.h>

@implementation ARTNode

Expand Down
2 changes: 1 addition & 1 deletion Libraries/ART/ARTRenderable.m
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* LICENSE file in the root directory of this source tree.
*/

#import "ARTRenderable.h"
#import <React/ARTRenderable.h>

@implementation ARTRenderable

Expand Down
2 changes: 1 addition & 1 deletion Libraries/ART/ARTShape.m
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* LICENSE file in the root directory of this source tree.
*/

#import "ARTShape.h"
#import <React/ARTShape.h>

@implementation ARTShape

Expand Down
4 changes: 2 additions & 2 deletions Libraries/ART/ARTSurfaceView.m
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
* LICENSE file in the root directory of this source tree.
*/

#import "ARTSurfaceView.h"
#import <React/ARTSurfaceView.h>

#import <React/RCTLog.h>

#import "ARTNode.h"
#import <React/ARTNode.h>

@implementation ARTSurfaceView

Expand Down
2 changes: 1 addition & 1 deletion Libraries/ART/ARTText.m
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* LICENSE file in the root directory of this source tree.
*/

#import "ARTText.h"
#import <React/ARTText.h>

#import <CoreText/CoreText.h>

Expand Down
2 changes: 1 addition & 1 deletion Libraries/ART/Brushes/ARTBrush.m
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* LICENSE file in the root directory of this source tree.
*/

#import "ARTBrush.h"
#import <React/ARTBrush.h>

#import <React/RCTDefines.h>

Expand Down
2 changes: 1 addition & 1 deletion Libraries/ART/Brushes/ARTLinearGradient.m
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* LICENSE file in the root directory of this source tree.
*/

#import "ARTLinearGradient.h"
#import <React/ARTLinearGradient.h>

#import <React/RCTLog.h>

Expand Down
2 changes: 1 addition & 1 deletion Libraries/ART/Brushes/ARTPattern.m
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* LICENSE file in the root directory of this source tree.
*/

#import "ARTPattern.h"
#import <React/ARTPattern.h>

#import <React/RCTLog.h>

Expand Down
2 changes: 1 addition & 1 deletion Libraries/ART/Brushes/ARTRadialGradient.m
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* LICENSE file in the root directory of this source tree.
*/

#import "ARTRadialGradient.h"
#import <React/ARTRadialGradient.h>

#import <React/RCTLog.h>

Expand Down
2 changes: 1 addition & 1 deletion Libraries/ART/Brushes/ARTSolidColor.m
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* LICENSE file in the root directory of this source tree.
*/

#import "ARTSolidColor.h"
#import <React/ARTSolidColor.h>

#import <React/RCTLog.h>

Expand Down
8 changes: 4 additions & 4 deletions Libraries/ART/RCTConvert+ART.m
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
#import <React/RCTFont.h>
#import <React/RCTLog.h>

#import "ARTLinearGradient.h"
#import "ARTPattern.h"
#import "ARTRadialGradient.h"
#import "ARTSolidColor.h"
#import <React/ARTLinearGradient.h>
#import <React/ARTPattern.h>
#import <React/ARTRadialGradient.h>
#import <React/ARTSolidColor.h>

@implementation RCTConvert (ART)

Expand Down
7 changes: 4 additions & 3 deletions Libraries/ART/React-ART.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,10 @@ Pod::Spec.new do |s|
s.author = "Facebook, Inc. and its affiliates"
s.platforms = { :ios => "9.0", :tvos => "9.2" }
s.source = source
s.source_files = "**/*.{h,m}"
s.source_files = "**/*.{m}"
s.preserve_paths = "package.json", "LICENSE", "LICENSE-docs"
s.header_dir = "React"
s.header_dir = "ART"
s.static_framework = true

s.dependency "React-Core", version
s.dependency "React-Core/ARTHeaders", version
end
4 changes: 2 additions & 2 deletions Libraries/ART/ViewManagers/ARTGroupManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
* LICENSE file in the root directory of this source tree.
*/

#import "ARTGroupManager.h"
#import <React/ARTGroupManager.h>

#import "ARTGroup.h"
#import <React/ARTGroup.h>
#import "RCTConvert+ART.h"

@implementation ARTGroupManager
Expand Down
4 changes: 2 additions & 2 deletions Libraries/ART/ViewManagers/ARTNodeManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
* LICENSE file in the root directory of this source tree.
*/

#import "ARTNodeManager.h"
#import <React/ARTNodeManager.h>

#import "ARTNode.h"
#import <React/ARTNode.h>

@implementation ARTNodeManager

Expand Down
2 changes: 1 addition & 1 deletion Libraries/ART/ViewManagers/ARTRenderableManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* LICENSE file in the root directory of this source tree.
*/

#import "ARTRenderableManager.h"
#import <React/ARTRenderableManager.h>

#import "RCTConvert+ART.h"

Expand Down
4 changes: 2 additions & 2 deletions Libraries/ART/ViewManagers/ARTShapeManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
* LICENSE file in the root directory of this source tree.
*/

#import "ARTShapeManager.h"
#import <React/ARTShapeManager.h>

#import "ARTShape.h"
#import <React/ARTShape.h>
#import "RCTConvert+ART.h"

@implementation ARTShapeManager
Expand Down
4 changes: 2 additions & 2 deletions Libraries/ART/ViewManagers/ARTSurfaceViewManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
* LICENSE file in the root directory of this source tree.
*/

#import "ARTSurfaceViewManager.h"
#import <React/ARTSurfaceViewManager.h>

#import "ARTSurfaceView.h"
#import <React/ARTSurfaceView.h>

@implementation ARTSurfaceViewManager

Expand Down
4 changes: 2 additions & 2 deletions Libraries/ART/ViewManagers/ARTTextManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
* LICENSE file in the root directory of this source tree.
*/

#import "ARTTextManager.h"
#import <React/ARTTextManager.h>

#import "ARTText.h"
#import <React/ARTText.h>
#import "RCTConvert+ART.h"

@implementation ARTTextManager
Expand Down
2 changes: 1 addition & 1 deletion Libraries/ActionSheetIOS/RCTActionSheetManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* LICENSE file in the root directory of this source tree.
*/

#import "RCTActionSheetManager.h"
#import <React/RCTActionSheetManager.h>

#import <React/RCTBridge.h>
#import <React/RCTConvert.h>
Expand Down
7 changes: 4 additions & 3 deletions Libraries/ActionSheetIOS/React-RCTActionSheet.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,10 @@ Pod::Spec.new do |s|
s.author = "Facebook, Inc. and its affiliates"
s.platforms = { :ios => "9.0", :tvos => "9.2" }
s.source = source
s.source_files = "*.{h,m}"
s.source_files = "*.{m}"
s.preserve_paths = "package.json", "LICENSE", "LICENSE-docs"
s.header_dir = "React"
s.header_dir = "RCTActionSheet"
s.static_framework = true

s.dependency "React-Core", version
s.dependency "React-Core/RCTActionSheetHeaders", version
end
2 changes: 1 addition & 1 deletion Libraries/Blob/RCTBlobCollector.mm
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#import "RCTBlobCollector.h"

#import <React/RCTBridge+Private.h>
#import "RCTBlobManager.h"
#import <React/RCTBlobManager.h>

namespace facebook {
namespace react {
Expand Down
2 changes: 1 addition & 1 deletion Libraries/Blob/RCTBlobManager.mm
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* LICENSE file in the root directory of this source tree.
*/

#import "RCTBlobManager.h"
#import <React/RCTBlobManager.h>

#import <mutex>

Expand Down
4 changes: 2 additions & 2 deletions Libraries/Blob/RCTFileReaderModule.m
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@
*/


#import "RCTFileReaderModule.h"
#import <React/RCTFileReaderModule.h>

#import <React/RCTBridge.h>
#import <React/RCTConvert.h>

#import "RCTBlobManager.h"
#import <React/RCTBlobManager.h>


@implementation RCTFileReaderModule
Expand Down
9 changes: 6 additions & 3 deletions Libraries/Blob/React-RCTBlob.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,14 @@ Pod::Spec.new do |s|
s.author = "Facebook, Inc. and its affiliates"
s.platforms = { :ios => "9.0", :tvos => "9.2" }
s.source = source
s.source_files = "*.{h,m,mm}"
# RCTBlobCollector.h is not included in the React module as it has C++ code
s.source_files = "*.{m,mm}", "RCTBlobCollector.h"
s.preserve_paths = "package.json", "LICENSE", "LICENSE-docs"
s.header_dir = "React"
s.header_dir = "RCTBlob"
s.static_framework = true

s.dependency "React-Core", version
s.dependency "React-Core/RCTBlobHeaders", version
s.dependency "React-RCTNetwork", version
s.dependency "React-RCTWebSocket", version
s.dependency "React-jsi", version
end
1 change: 1 addition & 0 deletions Libraries/FBLazyVector/FBLazyVector.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,5 @@ Pod::Spec.new do |s|
s.source = source
s.source_files = "**/*.{c,h,m,mm,cpp}"
s.header_dir = "FBLazyVector"

end
1 change: 1 addition & 0 deletions Libraries/FBReactNativeSpec/FBReactNativeSpec.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ Pod::Spec.new do |s|
s.source = source
s.source_files = "**/*.{c,h,m,mm,cpp}"
s.header_dir = "FBReactNativeSpec"
s.static_framework = true

s.pod_target_xcconfig = {
"USE_HEADERMAP" => "YES",
Expand Down
2 changes: 1 addition & 1 deletion Libraries/Image/RCTAnimatedImage.m
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*/

#import <ImageIO/ImageIO.h>
#import "RCTAnimatedImage.h"
#import <React/RCTAnimatedImage.h>

@interface RCTGIFCoderFrame : NSObject

Expand Down
4 changes: 2 additions & 2 deletions Libraries/Image/RCTGIFImageDecoder.m
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
* LICENSE file in the root directory of this source tree.
*/

#import "RCTGIFImageDecoder.h"
#import <React/RCTGIFImageDecoder.h>

#import <ImageIO/ImageIO.h>
#import <QuartzCore/QuartzCore.h>

#import <React/RCTUtils.h>
#import "RCTAnimatedImage.h"
#import <React/RCTAnimatedImage.h>

@implementation RCTGIFImageDecoder

Expand Down
2 changes: 1 addition & 1 deletion Libraries/Image/RCTImageBlurUtils.m
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* LICENSE file in the root directory of this source tree.
*/

#import "RCTImageBlurUtils.h"
#import <React/RCTImageBlurUtils.h>

UIImage *RCTBlurredImageWithRadius(UIImage *inputImage, CGFloat radius)
{
Expand Down
4 changes: 2 additions & 2 deletions Libraries/Image/RCTImageCache.m
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* LICENSE file in the root directory of this source tree.
*/

#import "RCTImageCache.h"
#import <React/RCTImageCache.h>

#import <objc/runtime.h>

Expand All @@ -16,7 +16,7 @@
#import <React/RCTUtils.h>
#import <React/RCTResizeMode.h>

#import "RCTImageUtils.h"
#import <React/RCTImageUtils.h>

static const NSUInteger RCTMaxCachableDecodedImageSizeInBytes = 2097152; // 2 MB

Expand Down
8 changes: 4 additions & 4 deletions Libraries/Image/RCTImageEditingManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,17 @@
* LICENSE file in the root directory of this source tree.
*/

#import "RCTImageEditingManager.h"
#import <React/RCTImageEditingManager.h>

#import <UIKit/UIKit.h>

#import <React/RCTConvert.h>
#import <React/RCTLog.h>
#import <React/RCTUtils.h>

#import "RCTImageLoader.h"
#import "RCTImageStoreManager.h"
#import "RCTImageUtils.h"
#import <React/RCTImageLoader.h>
#import <React/RCTImageStoreManager.h>
#import <React/RCTImageUtils.h>

@implementation RCTImageEditingManager

Expand Down
4 changes: 2 additions & 2 deletions Libraries/Image/RCTImageLoader.m
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
#import <React/RCTNetworking.h>
#import <React/RCTUtils.h>

#import "RCTImageCache.h"
#import "RCTImageUtils.h"
#import <React/RCTImageCache.h>
#import <React/RCTImageUtils.h>

static NSInteger RCTImageBytesForImage(UIImage *image)
{
Expand Down
2 changes: 1 addition & 1 deletion Libraries/Image/RCTImageShadowView.m
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* LICENSE file in the root directory of this source tree.
*/

#import "RCTImageShadowView.h"
#import <React/RCTImageShadowView.h>

#import <React/RCTLog.h>

Expand Down
Loading

0 comments on commit 8131b7b

Please sign in to comment.