Skip to content

Commit 98bde6b

Browse files
authored
feat: use C api from Swift (#13)
1 parent da8109b commit 98bde6b

11 files changed

+681
-625
lines changed

React-jsc.podspec

+2
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ Pod::Spec.new do |s|
2626
s.source_files = "common/*.{cpp,h}", "ios/*.{mm,h}"
2727
s.compiler_flags = folly_compiler_flags + ' ' + boost_compiler_flags
2828
s.weak_framework = "JavaScriptCore"
29+
s.pod_target_xcconfig = { "DEFINES_MODULE" => "YES" }
30+
s.module_name = "ReactJSC"
2931

3032
s.dependency "RCT-Folly", folly_version
3133
s.dependency "DoubleConversion"

common/JSCRuntime.h

+4
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77

88
#pragma once
99

10+
#ifdef __cplusplus
11+
1012
#include <jsi/jsi.h>
1113
#include <memory.h>
1214

@@ -17,3 +19,5 @@ std::unique_ptr<jsi::Runtime> makeJSCRuntime();
1719

1820
} // namespace jsc
1921
} // namespace facebook
22+
23+
#endif

example/ios/JSCExample/AppDelegate.swift

+5
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import UIKit
22
import React
33
import React_RCTAppDelegate
44
import ReactAppDependencyProvider
5+
import ReactJSC
56

67
@main
78
class AppDelegate: RCTAppDelegate {
@@ -27,4 +28,8 @@ class AppDelegate: RCTAppDelegate {
2728
Bundle.main.url(forResource: "main", withExtension: "jsbundle")
2829
#endif
2930
}
31+
32+
override func createJSRuntimeFactory() -> JSRuntimeFactoryRef {
33+
return jsrt_create_jsc_factory()
34+
}
3035
}

example/ios/Podfile

+2
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ prepare_react_native_project!
1010

1111
# Disable linking of internal JSC
1212
ENV['USE_THIRD_PARTY_JSC'] = '1'
13+
# Extracted JSC works only with new arch
14+
ENV['RCT_NEW_ARCH_ENABLED'] = '1'
1315

1416
linkage = ENV['USE_FRAMEWORKS']
1517
if linkage != nil

0 commit comments

Comments
 (0)