Skip to content

Commit 6477edc

Browse files
hannojgmrousavy
andauthored
feat: Build iOS and link filament
Co-authored-by: Marc Rousavy <[email protected]>
1 parent 194ac66 commit 6477edc

26 files changed

+375
-148
lines changed

package/example/ios/FilamentExample.xcodeproj/project.pbxproj

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -466,6 +466,7 @@
466466
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
467467
CLANG_ENABLE_MODULES = YES;
468468
CURRENT_PROJECT_VERSION = 1;
469+
DEVELOPMENT_TEAM = "";
469470
ENABLE_BITCODE = NO;
470471
INFOPLIST_FILE = FilamentExample/Info.plist;
471472
LD_RUNPATH_SEARCH_PATHS = (
@@ -478,7 +479,7 @@
478479
"-ObjC",
479480
"-lc++",
480481
);
481-
PRODUCT_BUNDLE_IDENTIFIER = "org.reactjs.native.example.$(PRODUCT_NAME:rfc1034identifier)";
482+
PRODUCT_BUNDLE_IDENTIFIER = com.mrousavy.FilamentExample;
482483
PRODUCT_NAME = FilamentExample;
483484
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
484485
SWIFT_VERSION = 5.0;
@@ -493,6 +494,7 @@
493494
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
494495
CLANG_ENABLE_MODULES = YES;
495496
CURRENT_PROJECT_VERSION = 1;
497+
DEVELOPMENT_TEAM = "";
496498
INFOPLIST_FILE = FilamentExample/Info.plist;
497499
LD_RUNPATH_SEARCH_PATHS = (
498500
"$(inherited)",
@@ -504,7 +506,7 @@
504506
"-ObjC",
505507
"-lc++",
506508
);
507-
PRODUCT_BUNDLE_IDENTIFIER = "org.reactjs.native.example.$(PRODUCT_NAME:rfc1034identifier)";
509+
PRODUCT_BUNDLE_IDENTIFIER = com.mrousavy.FilamentExample;
508510
PRODUCT_NAME = FilamentExample;
509511
SWIFT_VERSION = 5.0;
510512
VERSIONING_SYSTEM = "apple-generic";
@@ -580,10 +582,7 @@
580582
"-DFOLLY_USE_LIBCPP=1",
581583
"-DFOLLY_CFG_NO_COROUTINES=1",
582584
);
583-
OTHER_LDFLAGS = (
584-
"$(inherited)",
585-
" ",
586-
);
585+
OTHER_LDFLAGS = "$(inherited) ";
587586
REACT_NATIVE_PATH = "${PODS_ROOT}/../../node_modules/react-native";
588587
SDKROOT = iphoneos;
589588
USE_HERMES = true;
@@ -651,10 +650,7 @@
651650
"-DFOLLY_USE_LIBCPP=1",
652651
"-DFOLLY_CFG_NO_COROUTINES=1",
653652
);
654-
OTHER_LDFLAGS = (
655-
"$(inherited)",
656-
" ",
657-
);
653+
OTHER_LDFLAGS = "$(inherited) ";
658654
REACT_NATIVE_PATH = "${PODS_ROOT}/../../node_modules/react-native";
659655
SDKROOT = iphoneos;
660656
USE_HERMES = true;

package/example/ios/FilamentExample/Info.plist

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
<true/>
2727
<key>NSAppTransportSecurity</key>
2828
<dict>
29-
<!-- Do not change NSAllowsArbitraryLoads to true, or you will risk app rejection! -->
3029
<key>NSAllowsArbitraryLoads</key>
3130
<false/>
3231
<key>NSAllowsLocalNetworking</key>

package/example/ios/Podfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ target 'FilamentExample' do
3030

3131
use_react_native!(
3232
:path => config[:reactNativePath],
33+
:new_arch_enabled => false,
3334
# Enables Flipper.
3435
#
3536
# Note that if you have use_frameworks! enabled, Flipper will not work and

package/example/ios/Podfile.lock

Lines changed: 48 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,49 @@ PODS:
99
- React-Core (= 0.73.4)
1010
- React-jsi (= 0.73.4)
1111
- ReactCommon/turbomodule/core (= 0.73.4)
12+
- Filament (1.50.2):
13+
- Filament/camutils (= 1.50.2)
14+
- Filament/filamat (= 1.50.2)
15+
- Filament/filament (= 1.50.2)
16+
- Filament/filameshio (= 1.50.2)
17+
- Filament/gltfio_core (= 1.50.2)
18+
- Filament/image (= 1.50.2)
19+
- Filament/ktxreader (= 1.50.2)
20+
- Filament/math (= 1.50.2)
21+
- Filament/tsl (= 1.50.2)
22+
- Filament/uberz (= 1.50.2)
23+
- Filament/utils (= 1.50.2)
24+
- Filament/viewer (= 1.50.2)
25+
- Filament/camutils (1.50.2):
26+
- Filament/math
27+
- Filament/filamat (1.50.2):
28+
- Filament/math
29+
- Filament/utils
30+
- Filament/filament (1.50.2):
31+
- Filament/math
32+
- Filament/utils
33+
- Filament/filameshio (1.50.2):
34+
- Filament/filament
35+
- Filament/gltfio_core (1.50.2):
36+
- Filament/filament
37+
- Filament/ktxreader
38+
- Filament/uberz
39+
- Filament/image (1.50.2):
40+
- Filament/filament
41+
- Filament/ktxreader (1.50.2):
42+
- Filament/filament
43+
- Filament/image
44+
- Filament/math (1.50.2)
45+
- Filament/tsl (1.50.2)
46+
- Filament/uberz (1.50.2):
47+
- Filament/filamat
48+
- Filament/tsl
49+
- Filament/utils
50+
- Filament/utils (1.50.2):
51+
- Filament/tsl
52+
- Filament/viewer (1.50.2):
53+
- Filament/filament
54+
- Filament/gltfio_core
1255
- fmt (6.2.1)
1356
- glog (0.3.5)
1457
- hermes-engine (0.73.4):
@@ -887,6 +930,7 @@ PODS:
887930
- glog
888931
- React-debug
889932
- react-native-filament (0.0.1):
933+
- Filament
890934
- glog
891935
- RCT-Folly (= 2022.05.16.00)
892936
- React-Core
@@ -1116,6 +1160,7 @@ DEPENDENCIES:
11161160

11171161
SPEC REPOS:
11181162
trunk:
1163+
- Filament
11191164
- fmt
11201165
- libevent
11211166
- SocketRocket
@@ -1226,6 +1271,7 @@ SPEC CHECKSUMS:
12261271
DoubleConversion: fea03f2699887d960129cc54bba7e52542b6f953
12271272
FBLazyVector: 84f6edbe225f38aebd9deaf1540a4160b1f087d7
12281273
FBReactNativeSpec: d0086a479be91c44ce4687a962956a352d2dc697
1274+
Filament: 5dd90546dd8d074ff2c03ab64cd18d06d6fab76b
12291275
fmt: ff9d55029c625d3757ed641535fd4a75fedc7ce9
12301276
glog: c5d68082e772fa1c511173d6b30a9de2c05a69a2
12311277
hermes-engine: b2669ce35fc4ac14f523b307aff8896799829fe2
@@ -1251,7 +1297,7 @@ SPEC CHECKSUMS:
12511297
React-jsinspector: 9ac353eccf6ab54d1e0a33862ba91221d1e88460
12521298
React-logger: 0a57b68dd2aec7ff738195f081f0520724b35dab
12531299
React-Mapbuffer: 63913773ed7f96b814a2521e13e6d010282096ad
1254-
react-native-filament: dc218627465fa2bd615216810086a94220caa08a
1300+
react-native-filament: 457f8a2d45ec68ef004c0de3357e4457abdcd9de
12551301
React-nativeconfig: d7af5bae6da70fa15ce44f045621cf99ed24087c
12561302
React-NativeModulesApple: 0123905d5699853ac68519607555a9a4f5c7b3ac
12571303
React-perflogger: 8a1e1af5733004bdd91258dcefbde21e0d1faccd
@@ -1275,6 +1321,6 @@ SPEC CHECKSUMS:
12751321
SocketRocket: f32cd54efbe0f095c4d7594881e52619cfe80b17
12761322
Yoga: 64cd2a583ead952b0315d5135bf39e053ae9be70
12771323

1278-
PODFILE CHECKSUM: 51dbb7d1d6cbae06f02ad898d698577809744bba
1324+
PODFILE CHECKSUM: 064d1cdd719332a950b7df3b0ade3861fb731d25
12791325

12801326
COCOAPODS: 1.14.3

package/example/src/App.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { FilamentView } from 'react-native-filament'
66
export default function App() {
77
return (
88
<View style={styles.container}>
9-
<FilamentView style={styles.box} />
9+
<FilamentView style={styles.filamentView} />
1010
</View>
1111
)
1212
}
@@ -17,9 +17,9 @@ const styles = StyleSheet.create({
1717
alignItems: 'center',
1818
justifyContent: 'center',
1919
},
20-
box: {
21-
width: 60,
22-
height: 60,
23-
marginVertical: 20,
20+
filamentView: {
21+
width: 350,
22+
height: 350,
23+
backgroundColor: 'black',
2424
},
2525
})

package/ios/src/AppleFilamentProxy.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,10 @@
66
// Copyright © 2023 mrousavy. All rights reserved.
77
//
88

9+
#pragma once
10+
911
#include "FilamentProxy.h"
12+
#include "FilamentView.h"
1013
#include <ReactCommon/CallInvoker.h>
1114
#include <jsi/jsi.h>
1215

@@ -18,7 +21,8 @@ class AppleFilamentProxy : public FilamentProxy {
1821
~AppleFilamentProxy();
1922

2023
public:
21-
int loadModel(const std::string& path) override;
24+
int loadModel(std::string path) override;
25+
std::shared_ptr<FilamentView> findFilamentView(int modelId) override;
2226

2327
private:
2428
jsi::Runtime* _runtime;

package/ios/src/AppleFilamentProxy.mm

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,14 @@
66
//
77

88
#import "AppleFilamentProxy.h"
9+
#import "AppleFilamentView.h"
10+
#import "FilamentMetalView.h"
11+
#import "FilamentView.h"
912
#import <Foundation/Foundation.h>
13+
#import <React/RCTBridge+Private.h>
14+
#import <React/RCTBridge.h>
15+
#import <React/RCTUIManager.h>
16+
#import <React/RCTUtils.h>
1017

1118
namespace margelo {
1219

@@ -17,9 +24,22 @@
1724
// TODO(hanno): cleanup here?
1825
}
1926

20-
int AppleFilamentProxy::loadModel(const std::string& path) {
27+
int AppleFilamentProxy::loadModel(std::string path) {
2128
// TODO(hanno): Implement model loading here
2229
return 13;
2330
}
2431

32+
std::shared_ptr<FilamentView> AppleFilamentProxy::findFilamentView(int viewId) {
33+
// TODO(marc): Make this async when JSIConvert can do that
34+
std::shared_ptr<AppleFilamentView> result;
35+
RCTUnsafeExecuteOnMainQueueSync([viewId, &result]() {
36+
RCTBridge* currentBridge = [RCTBridge currentBridge]; // <-- from <React/RCTBridge+Private.h>
37+
RCTUIManager* uiManager = currentBridge.uiManager; // <-- from <React/RCTUIManager.h>
38+
UIView* anonymousView = [uiManager viewForReactTag:[NSNumber numberWithInt:viewId]];
39+
FilamentMetalView* view = (FilamentMetalView*)anonymousView;
40+
result.reset(new AppleFilamentView(view));
41+
});
42+
return std::static_pointer_cast<FilamentView>(result);
43+
}
44+
2545
} // namespace margelo
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
//
2+
// AppleFilamentView.h
3+
// react-native-filament
4+
//
5+
// Created by Marc Rousavy on 22.02.24.
6+
//
7+
8+
#pragma once
9+
10+
#include "FilamentMetalView.h"
11+
#include "FilamentView.h"
12+
#include "MetalSurfaceProvider.h"
13+
#include "SurfaceProvider.h"
14+
15+
namespace margelo {
16+
17+
class AppleFilamentView : public FilamentView {
18+
public:
19+
explicit AppleFilamentView(FilamentMetalView* view);
20+
21+
std::shared_ptr<SurfaceProvider> getSurfaceProvider() override;
22+
23+
private:
24+
FilamentMetalView* _view;
25+
std::shared_ptr<MetalSurfaceProvider> _surfaceProvider;
26+
};
27+
28+
} // namespace margelo
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
//
2+
// AppleFilamentView.cpp
3+
// react-native-filament
4+
//
5+
// Created by Marc Rousavy on 22.02.24.
6+
//
7+
8+
#include "AppleFilamentView.h"
9+
#include "MetalSurfaceProvider.h"
10+
11+
namespace margelo {
12+
13+
AppleFilamentView::AppleFilamentView(FilamentMetalView* view)
14+
: _view(view), _surfaceProvider(std::make_shared<MetalSurfaceProvider>(view.metalLayer)) {}
15+
16+
std::shared_ptr<SurfaceProvider> AppleFilamentView::getSurfaceProvider() {
17+
return std::static_pointer_cast<SurfaceProvider>(_surfaceProvider);
18+
}
19+
20+
} // namespace margelo

package/ios/src/BlockObserver.h

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
//
2+
// BlockObserver.h
3+
// Pods
4+
//
5+
// Created by Marc Rousavy on 22.02.24.
6+
//
7+
8+
#pragma once
9+
10+
#import <Foundation/Foundation.h>
11+
12+
typedef void (^ObservationBlock)(NSDictionary<NSKeyValueChangeKey, id>* change, void* context);
13+
14+
@interface BlockObserver : NSObject
15+
16+
- (instancetype)initWithBlock:(ObservationBlock)block;
17+
18+
@end

0 commit comments

Comments
 (0)