Skip to content

feat: use C api from Swift #13

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 4, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions React-jsc.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ Pod::Spec.new do |s|
s.source_files = "common/*.{cpp,h}", "ios/*.{mm,h}"
s.compiler_flags = folly_compiler_flags + ' ' + boost_compiler_flags
s.weak_framework = "JavaScriptCore"
s.pod_target_xcconfig = { "DEFINES_MODULE" => "YES" }
s.module_name = "ReactJSC"

s.dependency "RCT-Folly", folly_version
s.dependency "DoubleConversion"
Expand Down
4 changes: 4 additions & 0 deletions common/JSCRuntime.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@

#pragma once

#ifdef __cplusplus

#include <jsi/jsi.h>
#include <memory.h>

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

} // namespace jsc
} // namespace facebook

#endif
5 changes: 5 additions & 0 deletions example/ios/JSCExample/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import UIKit
import React
import React_RCTAppDelegate
import ReactAppDependencyProvider
import ReactJSC

@main
class AppDelegate: RCTAppDelegate {
Expand All @@ -27,4 +28,8 @@ class AppDelegate: RCTAppDelegate {
Bundle.main.url(forResource: "main", withExtension: "jsbundle")
#endif
}

override func createJSRuntimeFactory() -> JSRuntimeFactoryRef {
return jsrt_create_jsc_factory()
}
}
2 changes: 2 additions & 0 deletions example/ios/Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ prepare_react_native_project!

# Disable linking of internal JSC
ENV['USE_THIRD_PARTY_JSC'] = '1'
# Extracted JSC works only with new arch
ENV['RCT_NEW_ARCH_ENABLED'] = '1'

linkage = ENV['USE_FRAMEWORKS']
if linkage != nil
Expand Down
Loading