Kudo / react-native-v8

Opt-in V8 runtime for React Native Android
MIT License
922 stars 69 forks source link

⛱ iOS support #31

Open Kudo opened 4 years ago

Kudo commented 4 years ago

This is an umbrella task issue for iOS support. In theory, most of works could be shared from current Android version as V8 supports iOS and JSI runtime implementation is cross platform. There are still some tweaks to publish as library.

V8 buildscripts

react-native-v8 package

akshetpandey commented 4 years ago

Whats the size of the dylib without bitcode? Also, would love to help if you can push the build script branch/repo.

Kudo commented 4 years ago

Whats the size of the dylib without bitcode?

About 30MB for Intl version.

Also, would love to help if you can push the build script branch/repo.

Thank you so much. The build script part is relatively easy, will complete later today.

ItsNoHax commented 4 years ago

@Kudo I'm curious if it's even legally allowed by Apple in the app store? I thought it was similar to browsers.

akshetpandey commented 4 years ago

As long as you don't use codepush and all your js in bundled into the app when submitting to apple its allowed. Source: latest Apple TOS agreement, and I have previously shipped games that used a custom fork of webkit.

4.7 HTML5 Games, Bots, etc. Apps may contain or run code that is not embedded in the binary (e.g. HTML5-based games, bots, etc.), as long as code distribution isn’t the main purpose of the app, the code is not offered in a store or store-like interface, and provided that the software (1) is free or purchased using in-app purchase; (2) only uses capabilities available in a standard WebKit view (e.g. it must open and run natively in Safari without modifications or additional software); your app must use WebKit and JavaScript Core to run third-party software and should not attempt to extend or expose native platform APIs to third-party software; (3) is offered by developers that have joined the Apple Developer Program and signed the Apple Developer Program License Agreement; (4) does not provide access to real money gaming, lotteries, or charitable donations; (5) adheres to the terms of these App Review Guidelines (e.g. does not include objectionable content); and (6) does not support digital commerce. Upon request, you must provide an index of software and metadata available in your app. It must include Apple Developer Program Team IDs for the providers of the software along with a URL which App Review can use to confirm that the software complies with the requirements above.

Notice the requirement of using webkit/jsc only applies to third party software. Which would be source code downloaded at runtime not created/bundled by you. Mostly about ads/trackers or downloadable content that is coming from a source not controlled by you.

Looks like the guideline is even more relaxed now and allows code push now.

Kudo commented 4 years ago

Some update that I've created a demonstration project from scratch. You should be able to check detailed steps from commit logs: https://github.com/Kudo/RNV8Test/commits/master

Next TODO should be ship the V8Executor.framework as deliverable library. Is it possible to patch project files automatically, maybe leverage CocoaPods?

$ git diff --diff-filter=MR 8d35b4be..74c97a69 -- ios/

diff --git a/ios/Podfile b/ios/Podfile
index d846596..dff6889 100644
--- a/ios/Podfile
+++ b/ios/Podfile
@@ -1,7 +1,11 @@
 platform :ios, '9.0'
 require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules'

+workspace 'RNV8Test'
+
 target 'RNV8Test' do
+  project 'RNV8Test.xcodeproj'
+
   # Pods for RNV8Test
   pod 'FBLazyVector', :path => "../node_modules/react-native/Libraries/FBLazyVector"
   pod 'FBReactNativeSpec', :path => "../node_modules/react-native/Libraries/FBReactNativeSpec"
@@ -42,7 +46,21 @@ target 'RNV8Test' do
   use_native_modules!
 end

+target 'V8Executor' do
+  project '../v8-ios/V8Executor/V8Executor.xcodeproj'
+
+  pod 'React-Core', :path => '../node_modules/react-native/'
+  pod 'React-Core/DevSupport', :path => '../node_modules/react-native/'
+  pod 'React-cxxreact', :path => '../node_modules/react-native/ReactCommon/cxxreact'
+  pod 'React-jsi', :path => '../node_modules/react-native/ReactCommon/jsi'
+  pod 'React-jsiexecutor', :path => '../node_modules/react-native/ReactCommon/jsiexecutor'
+  pod 'React-jsinspector', :path => '../node_modules/react-native/ReactCommon/jsinspector'
+
+  pod 'Folly', :podspec => '../node_modules/react-native/third-party-podspecs/Folly.podspec'
+end
+
 target 'RNV8Test-tvOS' do
+  project 'RNV8Test.xcodeproj'
   # Pods for RNV8Test-tvOS

   target 'RNV8Test-tvOSTests' do
diff --git a/ios/Podfile.lock b/ios/Podfile.lock
index 43be67d..b35f80b 100644
--- a/ios/Podfile.lock
+++ b/ios/Podfile.lock
@@ -333,6 +333,6 @@ SPEC CHECKSUMS:
   ReactCommon: 198c7c8d3591f975e5431bec1b0b3b581aa1c5dd
   Yoga: f2a7cd4280bfe2cca5a7aed98ba0eb3d1310f18b

-PODFILE CHECKSUM: 018e9a902e567d4432ca1b4f5dd1704699605482
+PODFILE CHECKSUM: b6abbedfcb4a9c63f5c7969d282b82f2f69709d3

 COCOAPODS: 1.8.3
diff --git a/ios/RNV8Test.xcodeproj/project.pbxproj b/ios/RNV8Test.xcodeproj/project.pbxproj
index 0c66ad7..01c88b5 100644
--- a/ios/RNV8Test.xcodeproj/project.pbxproj
+++ b/ios/RNV8Test.xcodeproj/project.pbxproj
@@ -8,17 +8,19 @@

 /* Begin PBXBuildFile section */
        00E356F31AD99517003FC87E /* RNV8TestTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 00E356F21AD99517003FC87E /* RNV8TestTests.m */; };
-       13B07FBC1A68108700A75B9A /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 13B07FB01A68108700A75B9A /* AppDelegate.m */; };
+       13B07FBC1A68108700A75B9A /* AppDelegate.mm in Sources */ = {isa = PBXBuildFile; fileRef = 13B07FB01A68108700A75B9A /* AppDelegate.mm */; };
        13B07FBD1A68108700A75B9A /* LaunchScreen.xib in Resources */ = {isa = PBXBuildFile; fileRef = 13B07FB11A68108700A75B9A /* LaunchScreen.xib */; };
        13B07FBF1A68108700A75B9A /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 13B07FB51A68108700A75B9A /* Images.xcassets */; };
-       13B07FC11A68108700A75B9A /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 13B07FB71A68108700A75B9A /* main.m */; };
-       2D02E4BC1E0B4A80006451C7 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 13B07FB01A68108700A75B9A /* AppDelegate.m */; };
+       13B07FC11A68108700A75B9A /* main.mm in Sources */ = {isa = PBXBuildFile; fileRef = 13B07FB71A68108700A75B9A /* main.mm */; };
+       2D02E4BC1E0B4A80006451C7 /* AppDelegate.mm in Sources */ = {isa = PBXBuildFile; fileRef = 13B07FB01A68108700A75B9A /* AppDelegate.mm */; };
        2D02E4BD1E0B4A84006451C7 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 13B07FB51A68108700A75B9A /* Images.xcassets */; };
-       2D02E4BF1E0B4AB3006451C7 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 13B07FB71A68108700A75B9A /* main.m */; };
+       2D02E4BF1E0B4AB3006451C7 /* main.mm in Sources */ = {isa = PBXBuildFile; fileRef = 13B07FB71A68108700A75B9A /* main.mm */; };
        2DCD954D1E0B4F2C00145EB5 /* RNV8TestTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 00E356F21AD99517003FC87E /* RNV8TestTests.m */; };
        33CB96B78458A5CA9A3CDC77 /* libPods-RNV8Test.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 2DB4406FF81A3AF77576E7F4 /* libPods-RNV8Test.a */; };
        5856A132A068EC638A48BF42 /* libPods-RNV8TestTests.a in Frameworks */ = {isa = PBXBuildFile; fileRef = C41E8788B3D8D72AC75FE5AB /* libPods-RNV8TestTests.a */; };
        684609CA64644AF0A42C4807 /* libPods-RNV8Test-tvOSTests.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 792795BE093497FB5647909A /* libPods-RNV8Test-tvOSTests.a */; };
+       83380F0E239175FB003D31DB /* V8Executor.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 83380F0D239175FB003D31DB /* V8Executor.framework */; };
+       83380F0F239175FB003D31DB /* V8Executor.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 83380F0D239175FB003D31DB /* V8Executor.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
        ED16FEBDE85075B02C00227F /* libPods-RNV8Test-tvOS.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 4B0A8628DADAF0BC5C314609 /* libPods-RNV8Test-tvOS.a */; };
 /* End PBXBuildFile section */

@@ -39,6 +41,20 @@
        };
 /* End PBXContainerItemProxy section */

+/* Begin PBXCopyFilesBuildPhase section */
+       83380F082391675F003D31DB /* Embed Frameworks */ = {
+           isa = PBXCopyFilesBuildPhase;
+           buildActionMask = 2147483647;
+           dstPath = "";
+           dstSubfolderSpec = 10;
+           files = (
+               83380F0F239175FB003D31DB /* V8Executor.framework in Embed Frameworks */,
+           );
+           name = "Embed Frameworks";
+           runOnlyForDeploymentPostprocessing = 0;
+       };
+/* End PBXCopyFilesBuildPhase section */
+
 /* Begin PBXFileReference section */
        008F07F21AC5B25A0029DE68 /* main.jsbundle */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = main.jsbundle; sourceTree = "<group>"; };
        00E356EE1AD99517003FC87E /* RNV8TestTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = RNV8TestTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
@@ -46,11 +62,11 @@
        00E356F21AD99517003FC87E /* RNV8TestTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = RNV8TestTests.m; sourceTree = "<group>"; };
        13B07F961A680F5B00A75B9A /* RNV8Test.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = RNV8Test.app; sourceTree = BUILT_PRODUCTS_DIR; };
        13B07FAF1A68108700A75B9A /* AppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = AppDelegate.h; path = RNV8Test/AppDelegate.h; sourceTree = "<group>"; };
-       13B07FB01A68108700A75B9A /* AppDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = AppDelegate.m; path = RNV8Test/AppDelegate.m; sourceTree = "<group>"; };
+       13B07FB01A68108700A75B9A /* AppDelegate.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = AppDelegate.mm; path = RNV8Test/AppDelegate.mm; sourceTree = "<group>"; };
        13B07FB21A68108700A75B9A /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/LaunchScreen.xib; sourceTree = "<group>"; };
        13B07FB51A68108700A75B9A /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; name = Images.xcassets; path = RNV8Test/Images.xcassets; sourceTree = "<group>"; };
        13B07FB61A68108700A75B9A /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = Info.plist; path = RNV8Test/Info.plist; sourceTree = "<group>"; };
-       13B07FB71A68108700A75B9A /* main.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = main.m; path = RNV8Test/main.m; sourceTree = "<group>"; };
+       13B07FB71A68108700A75B9A /* main.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = main.mm; path = RNV8Test/main.mm; sourceTree = "<group>"; };
        2D02E47B1E0B4A5D006451C7 /* RNV8Test-tvOS.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "RNV8Test-tvOS.app"; sourceTree = BUILT_PRODUCTS_DIR; };
        2D02E4901E0B4A5D006451C7 /* RNV8Test-tvOSTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = "RNV8Test-tvOSTests.xctest"; sourceTree = BUILT_PRODUCTS_DIR; };
        2DB4406FF81A3AF77576E7F4 /* libPods-RNV8Test.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-RNV8Test.a"; sourceTree = BUILT_PRODUCTS_DIR; };
@@ -61,6 +77,7 @@
        5B1387E21043545F3298CF6A /* Pods-RNV8Test-tvOSTests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-RNV8Test-tvOSTests.release.xcconfig"; path = "Target Support Files/Pods-RNV8Test-tvOSTests/Pods-RNV8Test-tvOSTests.release.xcconfig"; sourceTree = "<group>"; };
        5EDDD818988217C59A5F9446 /* Pods-RNV8Test-tvOSTests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-RNV8Test-tvOSTests.debug.xcconfig"; path = "Target Support Files/Pods-RNV8Test-tvOSTests/Pods-RNV8Test-tvOSTests.debug.xcconfig"; sourceTree = "<group>"; };
        792795BE093497FB5647909A /* libPods-RNV8Test-tvOSTests.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-RNV8Test-tvOSTests.a"; sourceTree = BUILT_PRODUCTS_DIR; };
+       83380F0D239175FB003D31DB /* V8Executor.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; path = V8Executor.framework; sourceTree = BUILT_PRODUCTS_DIR; };
        C41E8788B3D8D72AC75FE5AB /* libPods-RNV8TestTests.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-RNV8TestTests.a"; sourceTree = BUILT_PRODUCTS_DIR; };
        D8B1D5AF982981DE4DD408D7 /* Pods-RNV8TestTests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-RNV8TestTests.release.xcconfig"; path = "Target Support Files/Pods-RNV8TestTests/Pods-RNV8TestTests.release.xcconfig"; sourceTree = "<group>"; };
        ED297162215061F000B7C4FE /* JavaScriptCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = JavaScriptCore.framework; path = System/Library/Frameworks/JavaScriptCore.framework; sourceTree = SDKROOT; };
@@ -83,6 +100,7 @@
            buildActionMask = 2147483647;
            files = (
                33CB96B78458A5CA9A3CDC77 /* libPods-RNV8Test.a in Frameworks */,
+               83380F0E239175FB003D31DB /* V8Executor.framework in Frameworks */,
            );
            runOnlyForDeploymentPostprocessing = 0;
        };
@@ -127,11 +145,11 @@
            children = (
                008F07F21AC5B25A0029DE68 /* main.jsbundle */,
                13B07FAF1A68108700A75B9A /* AppDelegate.h */,
-               13B07FB01A68108700A75B9A /* AppDelegate.m */,
+               13B07FB01A68108700A75B9A /* AppDelegate.mm */,
                13B07FB51A68108700A75B9A /* Images.xcassets */,
                13B07FB61A68108700A75B9A /* Info.plist */,
                13B07FB11A68108700A75B9A /* LaunchScreen.xib */,
-               13B07FB71A68108700A75B9A /* main.m */,
+               13B07FB71A68108700A75B9A /* main.mm */,
            );
            name = RNV8Test;
            sourceTree = "<group>";
@@ -159,6 +177,7 @@
        83CBB9F61A601CBA00E9B192 = {
            isa = PBXGroup;
            children = (
+               83380F0D239175FB003D31DB /* V8Executor.framework */,
                13B07FAE1A68108700A75B9A /* RNV8Test */,
                832341AE1AAA6A7D00B99B32 /* Libraries */,
                00E356EF1AD99517003FC87E /* RNV8TestTests */,
@@ -194,7 +213,6 @@
                58434652BDFDE46E9400F08F /* Pods-RNV8TestTests.debug.xcconfig */,
                D8B1D5AF982981DE4DD408D7 /* Pods-RNV8TestTests.release.xcconfig */,
            );
-           name = Pods;
            path = Pods;
            sourceTree = "<group>";
        };
@@ -230,6 +248,7 @@
                13B07F8C1A680F5B00A75B9A /* Frameworks */,
                13B07F8E1A680F5B00A75B9A /* Resources */,
                00DD1BFF1BD5951E006B06BC /* Bundle React Native code and images */,
+               83380F082391675F003D31DB /* Embed Frameworks */,
            );
            buildRules = (
            );
@@ -308,6 +327,7 @@
            developmentRegion = English;
            hasScannedForEncodings = 0;
            knownRegions = (
+               English,
                en,
                Base,
            );
@@ -528,8 +548,8 @@
            isa = PBXSourcesBuildPhase;
            buildActionMask = 2147483647;
            files = (
-               13B07FBC1A68108700A75B9A /* AppDelegate.m in Sources */,
-               13B07FC11A68108700A75B9A /* main.m in Sources */,
+               13B07FBC1A68108700A75B9A /* AppDelegate.mm in Sources */,
+               13B07FC11A68108700A75B9A /* main.mm in Sources */,
            );
            runOnlyForDeploymentPostprocessing = 0;
        };
@@ -537,8 +557,8 @@
            isa = PBXSourcesBuildPhase;
            buildActionMask = 2147483647;
            files = (
-               2D02E4BF1E0B4AB3006451C7 /* main.m in Sources */,
-               2D02E4BC1E0B4A80006451C7 /* AppDelegate.m in Sources */,
+               2D02E4BF1E0B4AB3006451C7 /* main.mm in Sources */,
+               2D02E4BC1E0B4A80006451C7 /* AppDelegate.mm in Sources */,
            );
            runOnlyForDeploymentPostprocessing = 0;
        };
@@ -626,8 +646,31 @@
            baseConfigurationReference = FBB8192251647F39C0BAD14D /* Pods-RNV8Test.debug.xcconfig */;
            buildSettings = {
                ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
+               CLANG_CXX_LANGUAGE_STANDARD = "c++14";
                CURRENT_PROJECT_VERSION = 1;
                DEAD_CODE_STRIPPING = NO;
+               HEADER_SEARCH_PATHS = (
+                   "$(inherited)",
+                   "\"${PODS_ROOT}/Headers/Public\"",
+                   "\"${PODS_ROOT}/Headers/Public/DoubleConversion\"",
+                   "\"${PODS_ROOT}/Headers/Public/FBLazyVector\"",
+                   "\"${PODS_ROOT}/Headers/Public/FBReactNativeSpec\"",
+                   "\"${PODS_ROOT}/Headers/Public/RCTRequired\"",
+                   "\"${PODS_ROOT}/Headers/Public/RCTTypeSafety\"",
+                   "\"${PODS_ROOT}/Headers/Public/React-Core\"",
+                   "\"${PODS_ROOT}/Headers/Public/React-RCTBlob\"",
+                   "\"${PODS_ROOT}/Headers/Public/React-RCTText\"",
+                   "\"${PODS_ROOT}/Headers/Public/React-cxxreact\"",
+                   "\"${PODS_ROOT}/Headers/Public/React-jsi\"",
+                   "\"${PODS_ROOT}/Headers/Public/React-jsiexecutor\"",
+                   "\"${PODS_ROOT}/Headers/Public/React-jsinspector\"",
+                   "\"${PODS_ROOT}/Headers/Public/ReactCommon\"",
+                   "\"${PODS_ROOT}/Headers/Public/Yoga\"",
+                   "\"${PODS_ROOT}/Headers/Public/glog\"",
+                   "\"$(PODS_ROOT)/Headers/Private/React-Core\"",
+                   "\"$(PODS_ROOT)/boost-for-react-native\"",
+                   "\"$(PODS_ROOT)/Folly\"",
+               );
                INFOPLIST_FILE = RNV8Test/Info.plist;
                LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
                OTHER_LDFLAGS = (
@@ -646,9 +689,33 @@
            baseConfigurationReference = 51F55D254C952F8C5427FCFB /* Pods-RNV8Test.release.xcconfig */;
            buildSettings = {
                ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
+               CLANG_CXX_LANGUAGE_STANDARD = "c++14";
                CURRENT_PROJECT_VERSION = 1;
+               HEADER_SEARCH_PATHS = (
+                   "$(inherited)",
+                   "\"${PODS_ROOT}/Headers/Public\"",
+                   "\"${PODS_ROOT}/Headers/Public/DoubleConversion\"",
+                   "\"${PODS_ROOT}/Headers/Public/FBLazyVector\"",
+                   "\"${PODS_ROOT}/Headers/Public/FBReactNativeSpec\"",
+                   "\"${PODS_ROOT}/Headers/Public/RCTRequired\"",
+                   "\"${PODS_ROOT}/Headers/Public/RCTTypeSafety\"",
+                   "\"${PODS_ROOT}/Headers/Public/React-Core\"",
+                   "\"${PODS_ROOT}/Headers/Public/React-RCTBlob\"",
+                   "\"${PODS_ROOT}/Headers/Public/React-RCTText\"",
+                   "\"${PODS_ROOT}/Headers/Public/React-cxxreact\"",
+                   "\"${PODS_ROOT}/Headers/Public/React-jsi\"",
+                   "\"${PODS_ROOT}/Headers/Public/React-jsiexecutor\"",
+                   "\"${PODS_ROOT}/Headers/Public/React-jsinspector\"",
+                   "\"${PODS_ROOT}/Headers/Public/ReactCommon\"",
+                   "\"${PODS_ROOT}/Headers/Public/Yoga\"",
+                   "\"${PODS_ROOT}/Headers/Public/glog\"",
+                   "\"$(PODS_ROOT)/Headers/Private/React-Core\"",
+                   "\"$(PODS_ROOT)/boost-for-react-native\"",
+                   "\"$(PODS_ROOT)/Folly\"",
+               );
                INFOPLIST_FILE = RNV8Test/Info.plist;
                LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
+               ONLY_ACTIVE_ARCH = YES;
                OTHER_LDFLAGS = (
                    "$(inherited)",
                    "-ObjC",
@@ -799,6 +866,7 @@
                CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
                "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
                COPY_PHASE_STRIP = NO;
+               ENABLE_BITCODE = NO;
                ENABLE_STRICT_OBJC_MSGSEND = YES;
                ENABLE_TESTABILITY = YES;
                GCC_C_LANGUAGE_STANDARD = gnu99;
@@ -852,6 +920,7 @@
                CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
                "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
                COPY_PHASE_STRIP = YES;
+               ENABLE_BITCODE = NO;
                ENABLE_NS_ASSERTIONS = NO;
                ENABLE_STRICT_OBJC_MSGSEND = YES;
                GCC_C_LANGUAGE_STANDARD = gnu99;
@@ -864,6 +933,7 @@
                GCC_WARN_UNUSED_VARIABLE = YES;
                IPHONEOS_DEPLOYMENT_TARGET = 9.0;
                MTL_ENABLE_DEBUG_INFO = NO;
+               ONLY_ACTIVE_ARCH = YES;
                SDKROOT = iphoneos;
                VALIDATE_PRODUCT = YES;
            };
diff --git a/ios/RNV8Test.xcworkspace/contents.xcworkspacedata b/ios/RNV8Test.xcworkspace/contents.xcworkspacedata
index eeb765b..5d6434a 100644
--- a/ios/RNV8Test.xcworkspace/contents.xcworkspacedata
+++ b/ios/RNV8Test.xcworkspace/contents.xcworkspacedata
@@ -7,4 +7,7 @@
    <FileRef
       location = "group:Pods/Pods.xcodeproj">
    </FileRef>
+   <FileRef
+      location = "group:../v8-ios/V8Executor/V8Executor.xcodeproj">
+   </FileRef>
 </Workspace>
diff --git a/ios/RNV8Test/AppDelegate.h b/ios/RNV8Test/AppDelegate.h
index 2726d5e..75be216 100644
--- a/ios/RNV8Test/AppDelegate.h
+++ b/ios/RNV8Test/AppDelegate.h
@@ -6,9 +6,13 @@
  */

 #import <React/RCTBridgeDelegate.h>
+#import <React/RCTCxxBridgeDelegate.h>
 #import <UIKit/UIKit.h>

-@interface AppDelegate : UIResponder <UIApplicationDelegate, RCTBridgeDelegate>
+@interface AppDelegate : UIResponder <
+  UIApplicationDelegate,
+  RCTBridgeDelegate,
+  RCTCxxBridgeDelegate>

 @property (nonatomic, strong) UIWindow *window;

diff --git a/ios/RNV8Test/AppDelegate.m b/ios/RNV8Test/AppDelegate.mm
similarity index 78%
rename from ios/RNV8Test/AppDelegate.m
rename to ios/RNV8Test/AppDelegate.mm
index 41ffc74..593e70e 100644
--- a/ios/RNV8Test/AppDelegate.m
+++ b/ios/RNV8Test/AppDelegate.mm
@@ -7,9 +7,17 @@

 #import "AppDelegate.h"

+#define FOLLY_NO_CONFIG 1
+#define FOLLY_MOBILE 1
+#define FOLLY_USE_LIBCPP 1
+#define FOLLY_HAVE_PTHREAD 1
+
 #import <React/RCTBridge.h>
 #import <React/RCTBundleURLProvider.h>
 #import <React/RCTRootView.h>
+#import <V8Executor/V8Executor.h>
+
+#import <memory>

 @implementation AppDelegate

@@ -39,4 +47,11 @@
 #endif
 }

+# pragma mark - RCTCxxBridgeDelegate
+
+- (std::unique_ptr<facebook::react::JSExecutorFactory>)jsExecutorFactoryForBridge:(RCTBridge *)bridge
+  {
+    return std::make_unique<facebook::react::V8ExecutorFactory>(nullptr);
+  }
+
 @end
diff --git a/ios/RNV8Test/main.m b/ios/RNV8Test/main.mm
similarity index 100%
rename from ios/RNV8Test/main.m
rename to ios/RNV8Test/main.mm
chaffeqa commented 4 years ago

Just was curious on react native stance on this, but wanted to see if the information that NativeScript recently created a v8 runtime for iOS could help / share code in this attempt:

https://github.com/NativeScript/ns-v8ios-runtime

nonewcode commented 4 years ago

@Kudo Any update on this mate or has it taken a back seat?

akshetpandey commented 4 years ago

@codecog this may be helpful https://github.com/microsoft/v8-jsi

Kudo commented 4 years ago

I am sorry that I don't have progress yet.

The most difficulty is about writing some utilities to patch user's existing project layout. E.g. Renaming AppDelegate.m to AppDelegate.mm or patching xcodeproj to add V8Executor project. Maybe it's better to write CocoaPods utilities. I just don't have much time to do this.

jesse-savary commented 4 years ago

@Kudo My team is interested in helping with this feature but we're not entirely sure where to start.

Do you have any references on how we would go about writing CocaoPods utilities?

Kudo commented 4 years ago

@jesse-savary Thanks for willing to help on this. The desired output might be something like the diff or real project. I am not familiar CocoaPods utility and may not able to provide some good reference for you.

Well, another approach may to use the xcode npm module to patch xcodeproj file - https://github.com/apache/cordova-node-xcode. react-native-cli seems to use this. I also had a code snippet to rename AppDelegate.m -> AppDelegate.mm

Please feel free to let me know if you have any ideas.

Kudo commented 4 years ago

Mentioned react-native-cli, that reminds me yet another approach, to simply scratch from a hand made project layout and added as a react-native-cli template. That might be easier. I'll take some time to try.

Kudo commented 4 years ago

Dears, I have added a template and looks mostly working fine. Please have a try and give me feedback if there are any problems.

  1. npx react-native init RNV8IOS --template react-native-template-v8
  2. There is still an handy action, please open RNV8IOS/ios/RNV8IOS.xcworkspace, selecting V8Executor target and drag "Codesign libv8.dylib" after "[CP] Copy Pods Resources". Like the attached screenshot. V8Executor_xcodeproj
RZulfikri commented 3 years ago

@Kudo I'm trying to implement this in my project based on react-native-template-v8 that you mention. it works on simulator and devices, but one I'm trying to archive then upload I got this error. does anyone know how to solve this issue?

Screenshot 2020-11-28 at 02 34 16
Glaubenio commented 2 years ago

@RZulfikri i'm having the exact same issue, any progress on solving this?

RZulfikri commented 2 years ago

@Glaubenio no idea, I end up not using v8 in IOS.

Kudo commented 2 years ago

i'm sorry not updating v8-ios for a while. i'm also curious what's the intention to use v8 on ios? even though neither JIT nor WebAssembly are supported on ios.

jesse-savary commented 2 years ago

@Kudo keeping things standardized, experimenting with performance, etc. We (try to) build our app against each Javascript engine for research purposes :)

Glaubenio commented 2 years ago

@Kudo for me, it solves a performance problem with VirtualizedList on the default engine.