mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
c95ee5ac18
Summary: This PR makes it possible to build iOS applications with Hermes. Note that it doesn't work with `use_frameworks!` just yet. Fixes https://github.com/facebook/react-native/issues/27845 (by downgrading iOS deployment target for RCT-Folly to 9.0) Fixes https://github.com/facebook/react-native/issues/28810 (as above) Checklist: - [x] Adjust release scripts to create Hermes bytecode bundle - [x] Release new Hermes npm package that includes iOS files (unreleased right now, if you want to try locally, you have to clone Hermes and `yarn link` its master to this project) - [x] Test on a new React Native application in both Debug and Release (Device) - [x] Test on an RNTester application in both Debug and Release (Device) - [x] Add missing `i386` to Hermes framework and enable Bitcode - [x] Inspect CI failures for possible regressions - [x] Resolve Folly issue as reported https://github.com/facebook/react-native/issues/27845 and https://github.com/facebook/react-native/issues/28810 - [x] Release new Hermes and test against it that everything works ## Changelog [IOS] [FEATURE] - Enable Hermes on iOS [INTERNAL] - Upgrade to CocoaPods 1.10.0 to resolve Xcode 12.0 issues [INTERNAL] - Upgrade to Xcode 12.0 on the CircleCI [INTERNAL] - Fix building RNTester in Release mode [INTERNAL] - Fix build-time errors of `libevent` with `use_frameworks!` [INTERNAL] - Introduce `USE_HERMES` variable and test all RNTester configurations on the CI [INTERNAL] - Do not fetch CocoaPods repository since we're using CDN anyway Pull Request resolved: https://github.com/facebook/react-native/pull/29914 Test Plan: Turn on `hermes_enabled` to true in your `Podfile`, install pods, and run the iOS application. Your app should be running Hermes now. Preview: (note "Engine: Hermes") <img width="395" alt="Screenshot 2020-09-09 at 19 22 32" src="https://user-images.githubusercontent.com/2464966/92631584-d7c01d80-f2d1-11ea-9b40-33d73db96a53.png"> Reviewed By: hramos Differential Revision: D24684845 Pulled By: cpojer fbshipit-source-id: 900cbe3bf9398a6fd4a773d552899a001bf5146b
88 lines
2.4 KiB
JavaScript
88 lines
2.4 KiB
JavaScript
/**
|
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
*
|
|
* This source code is licensed under the MIT license found in the
|
|
* LICENSE file in the root directory of this source tree.
|
|
*
|
|
* @format
|
|
* @flow strict-local
|
|
*/
|
|
|
|
'use strict';
|
|
|
|
import type {ExtendedError} from 'react-native/Libraries/Core/Devtools/parseErrorStack';
|
|
|
|
const React = require('react');
|
|
const ReactNative = require('react-native');
|
|
const parseErrorStack = require('react-native/Libraries/Core/Devtools/parseErrorStack');
|
|
const {View} = ReactNative;
|
|
|
|
const {TestModule} = ReactNative.NativeModules;
|
|
|
|
class GlobalEvalWithSourceUrlTest extends React.Component<{...}> {
|
|
componentDidMount() {
|
|
if (typeof global.globalEvalWithSourceUrl !== 'function') {
|
|
throw new Error(
|
|
'Expected to find globalEvalWithSourceUrl function on global object but found ' +
|
|
typeof global.globalEvalWithSourceUrl,
|
|
);
|
|
}
|
|
const value = global.globalEvalWithSourceUrl('42');
|
|
if (value !== 42) {
|
|
throw new Error(
|
|
'Expected globalEvalWithSourceUrl(expression) to return a value',
|
|
);
|
|
}
|
|
let syntaxError: ?ExtendedError;
|
|
try {
|
|
global.globalEvalWithSourceUrl('{');
|
|
} catch (e) {
|
|
syntaxError = e;
|
|
}
|
|
if (!syntaxError) {
|
|
throw new Error(
|
|
'Expected globalEvalWithSourceUrl to throw on a syntax error',
|
|
);
|
|
}
|
|
// Hermes throws an Error instead of a SyntaxError
|
|
// https://github.com/facebook/hermes/issues/400
|
|
if (
|
|
syntaxError.jsEngine !== 'hermes' &&
|
|
!(syntaxError instanceof SyntaxError)
|
|
) {
|
|
throw new Error(
|
|
'Expected globalEvalWithSourceUrl to throw SyntaxError on a syntax error',
|
|
);
|
|
}
|
|
const url = 'http://example.com/foo.js';
|
|
let error;
|
|
try {
|
|
global.globalEvalWithSourceUrl('throw new Error()', url);
|
|
} catch (e) {
|
|
error = e;
|
|
}
|
|
if (!error) {
|
|
throw new Error(
|
|
'Expected globalEvalWithSourceUrl to throw an Error object',
|
|
);
|
|
}
|
|
const parsedStack = parseErrorStack(error?.stack);
|
|
if (parsedStack[0].file !== url) {
|
|
throw new Error(
|
|
`Expected first eval stack frame to be in ${url} but found ${String(
|
|
parsedStack[0].file,
|
|
)}`,
|
|
);
|
|
}
|
|
TestModule.markTestCompleted();
|
|
}
|
|
|
|
render(): React.Node {
|
|
return <View />;
|
|
}
|
|
}
|
|
|
|
GlobalEvalWithSourceUrlTest.displayName = 'GlobalEvalWithSourceUrlTest';
|
|
|
|
module.exports = GlobalEvalWithSourceUrlTest;
|