Skip to content

Commit

Permalink
feat(ios): add support for new architecture
Browse files Browse the repository at this point in the history
  • Loading branch information
ThibaultBee committed Jan 2, 2024
1 parent c9837bb commit 8f22eed
Show file tree
Hide file tree
Showing 8 changed files with 118 additions and 94 deletions.
11 changes: 0 additions & 11 deletions example/ios/_xcode.env

This file was deleted.

20 changes: 20 additions & 0 deletions ios/RNLiveStreamView.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// This guard prevent this file to be compiled in the old architecture.
#ifdef RCT_NEW_ARCH_ENABLED
#import <React/RCTViewComponentView.h>
#import <React/RCTConversions.h>
#import <WebKit/WKDataDetectorTypes.h>
#import <UIKit/UIKit.h>
#import <react/renderer/components/ApiVideoLiveStreamView/Props.h>

#ifndef RNLiveStreamView_h
#define RNLiveStreamView_h

NS_ASSUME_NONNULL_BEGIN

@interface RNLiveStreamView : RCTViewComponentView
@end

NS_ASSUME_NONNULL_END

#endif /* RNLiveStreamView_h */
#endif /* RCT_NEW_ARCH_ENABLED */
86 changes: 86 additions & 0 deletions ios/RNLiveStreamView.mm
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
// This guard prevent the code from being compiled in the old architecture
#ifdef RCT_NEW_ARCH_ENABLED
#import "RNLiveStreamView.h"

#import <react/renderer/components/ApiVideoLiveStreamView/ComponentDescriptors.h>
#import <react/renderer/components/ApiVideoLiveStreamView/EventEmitters.h>
#import <react/renderer/components/ApiVideoLiveStreamView/Props.h>
#import <react/renderer/components/ApiVideoLiveStreamView/RCTComponentViewHelpers.h>

#import "RCTFabricComponentsPlugins.h"

// MARK: Swift classes in ObjC++
#if __has_include("react-native-livestream/react-native-livestream-Swift.h")
#import "ReactNativeAvoidSoftinput/ReactNativeAvoidSoftinput-Swift.h"
#else
#import "react-native-livestream-Swift.h"
#endif

using namespace facebook::react;

@class RNLiveStreamViewImpl;

@interface RNLiveStreamView () <RCTApiVideoLiveStreamViewViewProtocol>

@end

// MARK: Implementation

@implementation RNLiveStreamView {
RNLiveStreamViewImpl * _view;
}

// MARK: Initializers
- (instancetype)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self) {
static const auto defaultProps = std::make_shared<const ApiVideoLiveStreamViewProps>();
_props = defaultProps;

_view = [[RNLiveStreamViewImpl alloc] init];

// TODO: events

self.contentView = _view;
}
return self;
}

// MARK: Props
- (void)updateProps:(Props::Shared const &)props oldProps:(Props::Shared const &)oldProps
{
const auto &oldViewProps = *std::static_pointer_cast<const ApiVideoLiveStreamViewProps>(_props);
const auto &newViewProps = *std::static_pointer_cast<const ApiVideoLiveStreamViewProps>(props);

RNLiveStreamViewImpl *view = (RNLiveStreamViewImpl *)self.contentView;

// TODO: props

[super updateProps:props oldProps:oldProps];
}

// MARK: RCTComponentViewProtocol
- (void)startStreaming:(NSString *)streamKey url:(NSString *)url
{
[_view startStreaming:streamKey url:url];
}

- (void)stopStreaming
{
[_view stopStreaming];
}

- (void)setZoomRatioCommand:(float)zoomRatio
{
[_view setZoomRatioCommand:zoomRatio];
}

@end

Class<RCTComponentViewProtocol> ApiVideoLiveStreamViewCls(void)
{
return RNLiveStreamView.class;
}

#endif
67 changes: 0 additions & 67 deletions ios/RNLiveStreamView.swift

This file was deleted.

1 change: 1 addition & 0 deletions ios/RNLiveStreamViewImpl.swift
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ extension AVCaptureDevice.Position {
}
}

@objc(RNLiveStreamViewImpl)
class RNLiveStreamViewImpl: UIView {
private var liveStream: ApiVideoLiveStream!
private var isStreaming: Bool = false
Expand Down
File renamed without changes.
25 changes: 10 additions & 15 deletions ios/RNLivestream.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,6 @@
objectVersion = 46;
objects = {

/* Begin PBXBuildFile section */
21237D972A866EFE00A5CDCD /* RNLiveStreamViewManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 21237D942A866EFE00A5CDCD /* RNLiveStreamViewManager.m */; };
21237D982A866EFE00A5CDCD /* RNLiveStreamViewManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 21237D952A866EFE00A5CDCD /* RNLiveStreamViewManager.swift */; };
21237D992A866EFE00A5CDCD /* RNLiveStreamView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 21237D962A866EFE00A5CDCD /* RNLiveStreamView.swift */; };
/* End PBXBuildFile section */

/* Begin PBXCopyFilesBuildPhase section */
58B511D91A9E6C8500147676 /* CopyFiles */ = {
isa = PBXCopyFilesBuildPhase;
Expand All @@ -27,9 +21,11 @@
/* Begin PBXFileReference section */
134814201AA4EA6300B7C361 /* libRNLivestream.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libRNLivestream.a; sourceTree = BUILT_PRODUCTS_DIR; };
21237D932A866EFD00A5CDCD /* RNLivestream-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "RNLivestream-Bridging-Header.h"; sourceTree = "<group>"; };
21237D942A866EFE00A5CDCD /* RNLiveStreamViewManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RNLiveStreamViewManager.m; sourceTree = "<group>"; };
21237D952A866EFE00A5CDCD /* RNLiveStreamViewManager.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RNLiveStreamViewManager.swift; sourceTree = "<group>"; };
21237D962A866EFE00A5CDCD /* RNLiveStreamView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RNLiveStreamView.swift; sourceTree = "<group>"; };
212E11F62B4468BC00FFDE96 /* RNLiveStreamViewManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RNLiveStreamViewManager.swift; sourceTree = "<group>"; };
212E11F72B4468BC00FFDE96 /* RNLiveStreamViewManager.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = RNLiveStreamViewManager.m; sourceTree = "<group>"; };
212E11F82B4468BD00FFDE96 /* RNLiveStreamViewImpl.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RNLiveStreamViewImpl.swift; sourceTree = "<group>"; };
212E11F92B4468BD00FFDE96 /* RNLiveStreamView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = RNLiveStreamView.m; sourceTree = "<group>"; };
212E11FA2B4468BD00FFDE96 /* RNLiveStreamView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RNLiveStreamView.h; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
Expand All @@ -54,9 +50,11 @@
58B511D21A9E6C8500147676 = {
isa = PBXGroup;
children = (
21237D962A866EFE00A5CDCD /* RNLiveStreamView.swift */,
21237D942A866EFE00A5CDCD /* RNLiveStreamViewManager.m */,
21237D952A866EFE00A5CDCD /* RNLiveStreamViewManager.swift */,
212E11FA2B4468BD00FFDE96 /* RNLiveStreamView.h */,
212E11F92B4468BD00FFDE96 /* RNLiveStreamView.m */,
212E11F82B4468BD00FFDE96 /* RNLiveStreamViewImpl.swift */,
212E11F72B4468BC00FFDE96 /* RNLiveStreamViewManager.m */,
212E11F62B4468BC00FFDE96 /* RNLiveStreamViewManager.swift */,
134814211AA4EA7D00B7C361 /* Products */,
21237D932A866EFD00A5CDCD /* RNLivestream-Bridging-Header.h */,
);
Expand Down Expand Up @@ -120,9 +118,6 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
21237D992A866EFE00A5CDCD /* RNLiveStreamView.swift in Sources */,
21237D982A866EFE00A5CDCD /* RNLiveStreamViewManager.swift in Sources */,
21237D972A866EFE00A5CDCD /* RNLiveStreamViewManager.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down
2 changes: 1 addition & 1 deletion react-native-livestream.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ Pod::Spec.new do |s|
s.pod_target_xcconfig = {
"HEADER_SEARCH_PATHS" => "\"$(PODS_ROOT)/boost\"",
"OTHER_CPLUSPLUSFLAGS" => "-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1",
"CLANG_CXX_LANGUAGE_STANDARD" => "c++17"
"CLANG_CXX_LANGUAGE_STANDARD" => "c++17",
}
s.dependency "React-RCTFabric"
s.dependency "React-Codegen"
Expand Down

0 comments on commit 8f22eed

Please sign in to comment.