Граф коммитов

36 Коммитов

Автор SHA1 Сообщение Дата
Makar Kotlov 83777cb4fb Fix Xcode bundler in staging and release (#29477)
Summary:
Revert "feat: improve monorepo support by removing redundant PROJECT_ROOT (https://github.com/facebook/react-native/issues/28354)"

This reverts commit a8e85026cf.

This commit a8e85026cf somehow broke the bundler when making a staging or release build in Xcode that results in unresolved files and main.jsbundle nonexistance issue. I figured this out by replacing react-native-xcode.sh from RN v0.63.2 by the one from v0.62.2 where everything works just fine and then reverting the changes line by line. It seems like this pr will fix similar issues stated here https://stackoverflow.com/questions/62806319/main-jsbundle-does-not-exist-this-must-be-a-bug-with-main-jsbundle-issue-afte/62829256#62829256 and here https://github.com/facebook/react-native/issues/29205

## Changelog

[iOS] [Fixed] - fix "main.jsbundle does not exist" issue

Pull Request resolved: https://github.com/facebook/react-native/pull/29477

Test Plan:
With react-native-xcode.sh from RN v0.63.2
![image](https://user-images.githubusercontent.com/32848434/88342113-7ce55d80-cd47-11ea-9dab-bf41ec6d6ab5.png)

With my changes
![image](https://user-images.githubusercontent.com/32848434/88342376-f0876a80-cd47-11ea-9c08-96b892784da1.png)

Reviewed By: sammy-SC

Differential Revision: D23817847

Pulled By: hramos

fbshipit-source-id: 4b729c1231d30e89073b2520aeadee944c84421c
2020-09-22 06:16:38 -07:00
Eloy Durán 941bc0ec19 Upstream RN macOS Hermes integration bits (#29748)
Summary:
Microsoft’s RN for macOS fork supports the Hermes engine nowadays https://github.com/microsoft/react-native-macos/pull/473. As a longer term work item, we’ve started moving bits that are not invasive for iOS but _are_ a maintenance burden on us—mostly when merging—upstream. Seeing as this one is a recent addition, it seemed like a good candidate to start with.

As to the actual changes, these include:

* Sharing Android’s Hermes executor with the objc side of the codebase.
* Adding a CocoaPods subspec to build the Hermes inspector source and its dependencies (`Folly/Futures`, `libevent`).
* Adding the bits to the Xcode build phase script that creates the JS bundle for release builds to compile Hermes bytecode and source-maps…
* …coincidentally it turns out that the Xcode build phase script did _not_ by default output source-maps for iOS, which is now fixed too.

All of the Hermes bits are automatically enabled, on macOS, when providing the `hermes-engine-darwin` [npm package](https://www.npmjs.com/package/hermes-engine-darwin) and enabling the Hermes pods.

## Changelog

[General] [Added] - Upstream RN macOS Hermes integration bits

Pull Request resolved: https://github.com/facebook/react-native/pull/29748

Test Plan:
Building RNTester for iOS and Android still works as before.

To test the actual changes themselves, you’ll have to use the macOS target in RNTester in the macOS fork, or create a new application from `master`:

<img width="812" alt="Screenshot 2020-08-18 at 16 55 06" src="https://user-images.githubusercontent.com/2320/90547606-160f6480-e18c-11ea-9a98-edbbaa755800.png">

Reviewed By: TheSavior

Differential Revision: D23304618

Pulled By: fkgozali

fbshipit-source-id: 4ef0e0f60d909f3c59f9cfc87c667189df656a3b
2020-08-27 01:18:33 -07:00
Petr Bela e73208e2ca Better error message when missing entry file (#29012)
Summary:
If the entry file has been renamed (e.g., to `index.ts`), the script currently fails silently and prints out that the bundle file does not exist.

This change will print the correct error message instead.

## Changelog

[iOS] [Fixed] - Better error message when missing entry file
Pull Request resolved: https://github.com/facebook/react-native/pull/29012

Test Plan: N/A

Reviewed By: hramos

Differential Revision: D22109657

Pulled By: TheSavior

fbshipit-source-id: edd7b6f88becc954ee41ed01ae43efb4481adc95
2020-06-18 13:35:36 -07:00
Mark Lord b2b23a2017 Check en0..en8 when generating ip.txt for iOS debug builds (#28764)
Summary:
When generating ip.txt in an iOS debug build, search en0 through en8 for an IP address rather than only checking en0 and en1.  For example, on my Mac, the IP address I needed to use was on en5 and the IP address actually detected was a private network of one of my Parallels virtual machines (interface vnic0).

## Changelog

<!-- Help reviewers and the release process by writing your own changelog entry. For an example, see:
https://github.com/facebook/react-native/wiki/Changelog
-->

[iOS] [Fixed] - Search en0 through en8 for the Metro Bundler's IP address when generating iOS debug builds
Pull Request resolved: https://github.com/facebook/react-native/pull/28764

Test Plan: Should make no difference to users for whom react-native-xcode.sh already worked. On a Mac with multiple virtual machines installed, should prevent ip.txt getting the private IP address of a virtual machine.

Differential Revision: D21280671

Pulled By: shergin

fbshipit-source-id: e6fe9c8344146626df96129968981462463201f7
2020-04-28 09:32:55 -07:00
Mike Grabowski a8e85026cf feat: improve monorepo support by removing redundant PROJECT_ROOT (#28354)
Summary:
Historically, React Native didn't support a lot of custom project structures apart from the standard flat directory with `ios` and `android` folders. The CLI had to be explicitly started from the project root, otherwise Metro didn't work right.

In order to resolve the project root in the most accurate way, React Native assumed that project root is always `../../` from its location in `node_modules` - this is not true when the installation gets hoisted (e.g. in a monorepo).

To address that, janicduplessis brought support for custom [`PROJECT_ROOT`](9ccde378b6) that allowed overriding the `../../` in case it wasn't true.

Today, CLI is able to automatically resolve the project root, no matter where it's started. It will traverse the tree of the directories upwards and stop as soon as it meets `package.json`.

As a result, it doesn't really matter from where we start the CLI anymore as a part of `react-native-xcode.sh`.

By replacing the default value of `$REACT_NATIVE_DIR/../../` with `$PWD, that is default for all Xcode scripts, we can make the setup for monorepo easier - nobody will need to set `$PROJECT_ROOT` in order to override the incorrect defaults.

By default, all scripts defined in Xcode run from `$PWD` directory, which is the location of the iOS project. In the future, we will be able to remove `cd` entirely.

To better understand this PR, let's look a few hypothetical structures as an example:

#### Monorepo:

> tl;dr works out of the box, no need to mess around with paths

```
- package.json
- packages/
  - my-app/
     - index.js
     - package.json
     - ios/
        - MyApp.xcodeproj
```

**Before this PR**, the `react-native-xcode.sh` will start the CLI like this:

```bash
cd $REACT_NATIVE_DIR/../../
node <absolute_path_to_cli.js> bundle --entry-point index.js
```

- Because we change the directory to the root of monorepo, CLI throws an error. All in all, there's no `react-native` dependency at the workspace root.

- Some users turn `no hoist` in an act of troubleshooting the errors, which resolves the problem - `react-native` is moved under `my-app/node_modules` which makes this mechanism resolve properly.

- Some users find out about `PROJECT_ROOT` and set it to overwrite the default value. For example, setting `export PROJECT_ROOT = "$PWD/../` will set the directory to `my-app`, which has a dependency on `react-native` in a `package.json` and makes the CLI happy.

**After this PR**, the `react-native-xcode.sh` will start the CLI like this:

```bash
cd $PWD
node <absolute_path_to_cli.js> bundle --entry-point index.js
```

- The `$PWD` is `packages/my-app/ios/` because that's where the Xcode project is located. CLI will automatically set the root to `../` because that's where it finds `package.json` with `react-native` dependency. It will pass that root to Metro, unless users have set a different one themselves. Thanks to that, all paths to JavaScript files remain working and unaffected.

- No need to set `PROJECT_ROOT` anymore.

- We don't rely on the location of `node_modules`, which is cleaner and future proof.

#### Standard:

> tl;dr no changes

```
- ios/
   - MyApp.xcodeproj
- index.js
- package.json
```

**Before this PR**, the `react-native-xcode.sh` will start the CLI like this:

```bash
cd $REACT_NATIVE_DIR/../../
node <absolute_path_to_cli.js> bundle --entry-point index.js
```

- Everything works fine. Path from `react-native` inside `node_modules` is correct - the project root is set right to `/`

**After this PR**, the `react-native-xcode.sh` will start the CLI like this:

```bash
cd $PWD
node <absolute_path_to_cli.js> bundle --entry-point index.js
```

- The root will be set to where Xcode project is located, which is `/ios`. This is the PWD for all Xcode scripts.

CLI will look for the `package.json` going upwards from `ios` folder. Will stop at `/`, find out it has `react-native` dependency, load it and its commands and proceed further.

## Changelog

[iOS] [Feature] - Better monorepo support when building release apk
Pull Request resolved: https://github.com/facebook/react-native/pull/28354

Test Plan:
- All projects (standard/monorepo) run without issues.
- PROJECT_ROOT is not needed.

CC: Titozzz (who wrote monorepo guide), alloy, bartolkaruza

Reviewed By: cpojer

Differential Revision: D20558005

Pulled By: hramos

fbshipit-source-id: 2551120beadcfd4c2f1393ce8a2c2fa6b93c9290
2020-03-20 11:36:46 -07:00
Oleg E. Bakharev d1e6f8d3c4 Fix LAN instead of Wi-Fi device bundle config (#27575)
Summary:
React-native server-device connection must be via Wi-Fi. But if the OS-X server has LAN & Wi-Fi interfaces, then device bundle can be incorrectly configured to  use LAN interface instead of Wi-Fi. This patch fix this issue. It greps for "baseT" (e.g. media: autoselect (1000baseT <full-duplex>)) and skip interface if it is.

## Changelog

[iOS] [Fixed] - Fix LAN instead of Wi-Fi device bundle configuration
Pull Request resolved: https://github.com/facebook/react-native/pull/27575

Test Plan:
To reproduce an issue setup Mac OS 10.15.1 with LAN and Wi-Fi active interfaces. And connect
real device (not simulator).

And "ifconfig en0" in console should display LAN interface e.g.:
```
en0: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500
	options=50b<RXCSUM,TXCSUM,VLAN_HWTAGGING,AV,CHANNEL_IO>
	ether 78:7b:8a:d8:61:42
	inet 10.15.61.16 netmask 0xffffff00 broadcast 10.15.61.255
	nd6 options=201<PERFORMNUD,DAD>
	media: autoselect (1000baseT <full-duplex>)
	status: active

```
"ifconfig eg1" in console should display WiFi interface e.g.:
```
en1: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500
	options=400<CHANNEL_IO>
	ether 14:20:5e:03:5b:2a
	inet6 fe80::10e6:1cb6:54ec:1b41%en1 prefixlen 64 secured scopeid 0x5
	inet 10.15.91.27 netmask 0xffffff00 broadcast 10.15.91.255
	nd6 options=201<PERFORMNUD,DAD>
	media: autoselect
	status: active
```

In this case device bundle in react-native-xcode.sh script wood be incorrectly configured to use en0 (LAN interface) instead of en1(Wi-Fi) interface.

My patch fixes this issue.

fragment of script output before patch:
```
...
++ ipconfig getifaddr en0
+ IP=10.15.61.16
+ '[' -z 10.15.61.16 ']
+ '[' -z 10.15.61.16 ']'
+ echo 10.15.61.16
+ [[ -n '' ]]
...
```
After start project ob device we have time lag about 20s then debug out:
`
2019-12-20 16:58:57.530538+0300 AwesomeProject[4590:1923358] Task <164D9AB0-8473-4BA3-BD1A-EC0E92887C17>.<1> finished with error [-1001] Error Domain=NSURLErrorDomain Code=-1001 "The request timed out." UserInfo={NSUnderlyingError=0x2838dc2d0 {Error Domain=kCFErrorDomainCFNetwork Code=-1001 "(null)" UserInfo={_kCFStreamErrorCodeKey=-2102, _kCFStreamErrorDomainKey=4}}, NSErrorFailingURLStringKey=http://10.15.61.16:8081/status, NSErrorFailingURLKey=http://10.15.61.16:8081/status, _kCFStreamErrorDomainKey=4, _kCFStreamErrorCodeKey=-2102, NSLocalizedDescription=The request timed out.}
`

fragment of script output after apply patch:
```
...
++ ipconfig getifaddr en0
+ IP=10.15.61.16
+ [[ -z 10.15.61.16 ]]
++ ifconfig
++ grep baseT
+ [[ -n 	media: autoselect (1000baseT <full-duplex>)
	media: autoselect (100baseTX <full-duplex>) ]]
++ ipconfig getifaddr en1
+ IP=10.15.91.27
+ '[' -z 10.15.91.27 ']'
+ echo 10.15.91.27
+ [[ -n '' ]]
...
```

App start OK.

On iPhone /iPad simulator works too.

Differential Revision: D19200334

Pulled By: hramos

fbshipit-source-id: 22d791b657abd16a92d075515682b4fa961b489c
2019-12-20 12:43:22 -08:00
Andres Suarez e1cfeaddd4 Move non-license comments out of license header
Summary: Changelog: [General] [Fixed] - License header cleanup

Reviewed By: cpojer

Differential Revision: D17749100

fbshipit-source-id: edca9c73a065e9fc311109cd6efeb1f75451a55a
2019-10-15 20:12:12 -07:00
Christoph Nakazawa 88d0ac17e8 Metro Bundler -> Metro
Summary: This bothers me, we renamed the project to drop the "Metro" a while ago.

Reviewed By: rubennorte

Differential Revision: D16831281

fbshipit-source-id: bb6de412eccda61b617580f3660e3e635f2d2815
2019-08-16 10:37:10 -07:00
Richard Hyatt 4a5a909264 iOS build - en0 and en1 used when generating ip.txt file (#25462)
Summary:
When `en0` is not assigned and `en1` is in use along with another interface present on the machine that uses a self-assigned address (169.254.xxx.xxx), the ip.txt file contains the self-assigned address. This causes the app reload/debug actions to fail when deployed to a physical device. see https://github.com/facebook/react-native/issues/25460

Code change looks at the value assigned to `en1` if `en0` is not set. If `en1` is not available on the machine or not set, then it will be empty. If both `en0` and `en1` are not set, the existing code was modified exclude addresses that are self-assigned, as they will most likely be unavailable to the connected device (iPhone, iPad, etc.).

## Changelog

[Internal] [Fixed] - en0 and en1 are used when generating the ip.txt file for iOS device debug builds
Pull Request resolved: https://github.com/facebook/react-native/pull/25462

Test Plan:
execute `ifconfig`:

```
lo0: flags=8049<UP,LOOPBACK,RUNNING,MULTICAST> mtu 16384
	options=1203<RXCSUM,TXCSUM,TXSTATUS,SW_TIMESTAMP>
	inet 127.0.0.1 netmask 0xff000000
	inet6 ::1 prefixlen 128
	inet6 fe80::1%lo0 prefixlen 64 scopeid 0x1
	nd6 options=201<PERFORMNUD,DAD>
gif0: flags=8010<POINTOPOINT,MULTICAST> mtu 1280
stf0: flags=0<> mtu 1280
XHC20: flags=0<> mtu 0
XHC0: flags=0<> mtu 0
en0: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500
	options=10b<RXCSUM,TXCSUM,VLAN_HWTAGGING,AV>
	ether 38:f9:d3:0d:aa:fe
	nd6 options=201<PERFORMNUD,DAD>
	media: autoselect (none)
	status: inactive
en2: flags=8963<UP,BROADCAST,SMART,RUNNING,PROMISC,SIMPLEX,MULTICAST> mtu 1500
	options=60<TSO4,TSO6>
	ether 42:00:84:a8:f6:00
	media: autoselect <full-duplex>
	status: inactive
en3: flags=8963<UP,BROADCAST,SMART,RUNNING,PROMISC,SIMPLEX,MULTICAST> mtu 1500
	options=60<TSO4,TSO6>
	ether 42:00:84:a8:f6:01
	media: autoselect <full-duplex>
	status: active
bridge0: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500
	options=63<RXCSUM,TXCSUM,TSO4,TSO6>
	ether 42:00:84:a8:f6:00
	inet6 fe80::e:80be:b322:79b7%bridge0 prefixlen 64 secured scopeid 0x9
	inet 169.254.209.63 netmask 0xffff0000 broadcast 169.254.255.255
	Configuration:
		id 0:0:0:0:0:0 priority 0 hellotime 0 fwddelay 0
		maxage 0 holdcnt 0 proto stp maxaddr 100 timeout 1200
		root id 0:0:0:0:0:0 priority 0 ifcost 0 port 0
		ipfilter disabled flags 0x2
	member: en2 flags=3<LEARNING,DISCOVER>
	        ifmaxaddr 0 port 7 priority 0 path cost 0
	member: en3 flags=3<LEARNING,DISCOVER>
	        ifmaxaddr 0 port 8 priority 0 path cost 0
	nd6 options=201<PERFORMNUD,DAD>
	media: autoselect
	status: active
ap1: flags=8802<BROADCAST,SIMPLEX,MULTICAST> mtu 1500
	ether 3a:f9:d3:9a:14:05
	media: autoselect
	status: inactive
en1: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500
	ether 38:f9:d3:9a:14:05
	inet6 fe80::1444:113e:d65:5fb3%en1 prefixlen 64 secured scopeid 0xb
	inet 192.168.1.115 netmask 0xffffff00 broadcast 192.168.1.255
	nd6 options=201<PERFORMNUD,DAD>
	media: autoselect
	status: active
p2p0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 2304
	ether 0a:f9:d3:9a:14:05
	media: autoselect
	status: inactive
awdl0: flags=8943<UP,BROADCAST,RUNNING,PROMISC,SIMPLEX,MULTICAST> mtu 1484
	ether 6a:fe:9d:f0:39:3f
	inet6 fe80::68fe:9dff:fef0:393f%awdl0 prefixlen 64 scopeid 0xd
	nd6 options=201<PERFORMNUD,DAD>
	media: autoselect
	status: active
utun0: flags=8051<UP,POINTOPOINT,RUNNING,MULTICAST> mtu 2000
	inet6 fe80::c992:4ed:9399:85bc%utun0 prefixlen 64 scopeid 0xe
	nd6 options=201<PERFORMNUD,DAD>
utun1: flags=8051<UP,POINTOPOINT,RUNNING,MULTICAST> mtu 1380
	inet6 fe80::f5de:860a:fd07:ee87%utun1 prefixlen 64 scopeid 0xf
	nd6 options=201<PERFORMNUD,DAD>
utun2: flags=8051<UP,POINTOPOINT,RUNNING,MULTICAST> mtu 1380
	inet6 fe80::3115:b6a0:6625:23ee%utun2 prefixlen 64 scopeid 0x11
	nd6 options=201<PERFORMNUD,DAD>
en5: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500
	ether e2:33:8e:95:93:9b
	inet6 fe80::cea:8f7a:b379:ebcd%en5 prefixlen 64 secured scopeid 0x10
	inet 169.254.167.11 netmask 0xffff0000 broadcast 169.254.255.255
	nd6 options=201<PERFORMNUD,DAD>
	media: autoselect (100baseTX <full-duplex>)
	status: active
```

execute `ipconfig getifaddr en0`:  (produces nothing)

execute `ipconfig getifaddr en1`:
```
192.168.1.115
```

execute `ipconfig getifaddr en99`:  (produces nothing - non-existent case)

existing code `ifconfig | grep 'inet ' | grep -v ' 127.' | cut -d\   -f2  | awk 'NR==1{print $1}'` yields:

```
169.254.209.63
```

modified code ` ifconfig | grep 'inet ' | grep -v ' 127.' | grep -v ' 169.254.' | cut -d\   -f2  | awk 'NR==1{print $1}'` yields:

```
192.168.1.115
```

Differential Revision: D16099639

Pulled By: cpojer

fbshipit-source-id: bd480a5f638efc58611d22cef4ba5193052b713d
2019-07-03 02:39:49 -07:00
Pierre Reimertz f0770b6b37 fixes Xcode path issues containing whitespace when building Release (#24810)
Summary:
Some users (me included) have projects located in quirky places, resulting whitespaces in the path.
An example, , I symlink into my iCloud drive which result in the following path

```
/Users/r/Library/Mobile Documents/com~apple~CloudDocs/_/work/{a_company}/repos.nosync/app
```

This commit quotes the variable to make sure it gets properly passed to the CLI.

For reference, similar issue that has been resolved: 7d4e94edcc
Pull Request resolved: https://github.com/facebook/react-native/pull/24810

Differential Revision: D15316898

Pulled By: cpojer

fbshipit-source-id: 4ed2c8391d65d1680e836bfce8c51dfb5763caed
2019-05-13 07:29:50 -07:00
Héctor Ramos b92f30dcc5 Fix `test_javascript` e2e tests (#24658)
Summary:
Fix regression in JavaScript e2e tests.

[General] [Fixed] - Fixed JavaScript e2e tests.
Pull Request resolved: https://github.com/facebook/react-native/pull/24658

Differential Revision: D15146466

Pulled By: cpojer

fbshipit-source-id: 05baa99e3b1cdd3ef02bc3f97cf2987dd8ba80f4
2019-04-30 03:08:46 -07:00
Kacper Wiszczuk 265ae58038 Fix: use NODE_BINARY when starting packager (#24156)
Summary:
Fix packager script to use `NODE_BINARY` env variable.

Should fix #22868

[iOS] [Fixed] - Use `NODE_BINARY` env variable in `packager.sh` script
Pull Request resolved: https://github.com/facebook/react-native/pull/24156

Differential Revision: D14870783

Pulled By: cpojer

fbshipit-source-id: 27ecf8bf59883920ab51478b8a4d8f0780e34664
2019-04-10 07:39:23 -07:00
Bruno Lemos 22b3528e7b - Allow overriding ENTRY_FILE on react-native-xcode.sh script (#23667)
Summary:
1. Feature parity with Android, that already have this extensibility point on `build.gradle`:
7c9805ce16/react.gradle (L12)

2. Helps with using react-native on a monorepo project (yarn workspaces) without having to use the no-hoist feature (e.g. in my case the `ENTRY_FILE` is on `root/packages/mobile/index.js` instead of `root/index.ios.js`)

[iOS] [Added] - Allow overriding ENTRY_FILE on react-native-xcode.sh script
Pull Request resolved: https://github.com/facebook/react-native/pull/23667

Differential Revision: D14247236

Pulled By: hramos

fbshipit-source-id: 2f678c65eb898fc04549ab738b62e5864d753afd
2019-02-27 13:37:22 -08:00
Janic Duplessis 9ccde378b6 Allow changing the project path in react-native-xcode.sh (#23273)
Summary:
When using react-native inside a monorepo with yarn workspaces the react-native installation can get hoisted and the assumption that the project is located in the folder where node_modules is is no longer true.

To handle this case I added an option to pass the path of the project root.

For example when using yarn workspace we can use something like this in the xcode scripts:

Assumes the following folder structure
/packages/myapp
/node_modules/react-native

```sh
export NODE_BINARY=node
export PROJECT_ROOT=$PWD/..
../../../node_modules/react-native/scripts/react-native-xcode.sh
```

It could be possible to change the default to `$PWD/..` since pwd is where the xcode project is located but then it would break if the native project structure is not the one we assume. To avoid the breaking change I decided to just keep the existing behaviour and allow changing the path with `PROJECT_ROOT`.

[ios] [added] - Allow changing the project path in react-native-xcode.sh
Pull Request resolved: https://github.com/facebook/react-native/pull/23273

Differential Revision: D13941793

Pulled By: cpojer

fbshipit-source-id: f394641b1c9d01f32bc4169097e39fc14df8191f
2019-02-04 08:01:24 -08:00
Mike Grabowski 9a9370481f Fix Detox tests after upgrading to latest CLI (#23191)
Summary:
Latest changes inside CLI now require that Metro configuration is provided when building RNTester app. This is to let CLI know that instead of looking for "react-native" under "node_modules" (that is obviously not present since we are running from source), it should check the paths provided.

When running "npm start", it finds the configuration at the root. However, when building through Xcode (e.g. "react-native bundle" or "xcodebuild" in Release scheme), it runs "react-native-xcode.sh" that works in different folder and makes Metro not detect the configuration file.

This PR explicitly sets path to the configuration via `BUNDLE_CONFIG`.

It also removes `pwd` from being prepended to all `BUNDLE_CONFIG` values. In my case, `pwd` was `/Users/grabbou` and the RNTester files where inside `/Users/grabbou/Repositories/react-native`. I was unable to point the script to correct location without making it aware of the folder structure - which is not going to work on the CI.
Pull Request resolved: https://github.com/facebook/react-native/pull/23191

Differential Revision: D13851741

Pulled By: hramos

fbshipit-source-id: d920353fd68d39468bd33bd1ad47e03b017a7727
2019-01-28 20:29:58 -08:00
Takagi Kensuke c3bbce449c - Fix failing to bundle in Release build with ndenv of anyenv by supporting anyenv (#22875)
Summary:
refer: https://github.com/riywo/anyenv

Changelog:
----------

[iOS] [Fixed] - Fix failing to bundle in Release build with ndenv of anyenv by supporting anyenv
Pull Request resolved: https://github.com/facebook/react-native/pull/22875

Differential Revision: D13682773

Pulled By: hramos

fbshipit-source-id: 0baacc95bd215d4724ba418ff187d51b11126326
2019-01-15 16:49:44 -08:00
Christoph Nakazawa 63a6bb7637 Remove remaining references to local-cli
Summary: This removes the remaining references to `local-cli`. We already have a `cli.js` file on the root that was just forwarding to the local-cli folder, so I removed that. It also seems that `setupBabel.js` is no longer necessary in RN.

Reviewed By: TheSavior

Differential Revision: D13396218

fbshipit-source-id: a945cb91dae39c4b58c5cabcca6b0f0328fc4717
2018-12-10 19:08:10 -08:00
Kuchitama 003dbaa3d3 Accept node arguments when iOS app is built (#22423)
Summary:
Fixes #22421

If this PR fixes an issue, type "Fixes #issueNumber" to automatically close the issue when the PR is merged.

_Pull requests that expand test coverage are more likely to get reviewed. Add a test case whenever possible!_
Pull Request resolved: https://github.com/facebook/react-native/pull/22423

Differential Revision: D13287099

Pulled By: TheSavior

fbshipit-source-id: e4ac0fb930107dde092541fd17d4c81907c8cc34
2018-11-30 17:31:47 -08:00
Ryan Sundberg 7d4e94edcc Quote "$NODE_BINARY" in react-native-xcode.sh (#21383)
Summary:
Fix build errors when path to $NODE_BINARY contains spaces:

error: Can't find '/Path/With Spaces/To/node' binary to build React Native bundle

Why would $NODE_BINARY contain spaces? In my case, I am using sentry-cli which wraps the NODE_BINARY in it's own executable. The local path to the project, and thus the $NODE_BINARY, contains a space on my GoCD build agent.

'/Users/go/Library/Application Support/Go Agent/pipelines/my-ios-app/node_modules/sentry/cli/sentry-cli

See https://github.com/getsentry/react-native-sentry/issues/484 https://github.com/getsentry/react-native-sentry/issues/389
Pull Request resolved: https://github.com/facebook/react-native/pull/21383

Differential Revision: D10851141

Pulled By: yungsters

fbshipit-source-id: f46853ac8b57957864e0d1a76b8513403223fccb
2018-10-25 00:52:19 -07:00
Héctor Ramos 1151c096da Update copyright headers to yearless format
Summary: This change drops the year from the copyright headers and the LICENSE file.

Reviewed By: yungsters

Differential Revision: D9727774

fbshipit-source-id: df4fc1e4390733fe774b1a160dd41b4a3d83302a
2018-09-11 15:33:07 -07:00
Héctor Ramos fe4f03517c Add missing copyright headers (#21000)
Summary:
One of our automated project tools noted that these were all missing their copyright headers.
Pull Request resolved: https://github.com/facebook/react-native/pull/21000

Differential Revision: D9721495

Pulled By: hramos

fbshipit-source-id: 6ccf0f37165a0fe16cf06bd996d615f2286101dc
2018-09-07 13:17:38 -07:00
Keaton Greve 9c1ea45d38 Generate ip.txt before SKIP_BUNDLING check (#20554)
Summary:
Fixes #20553.

Re-applies the change as described in https://github.com/facebook/react-native/pull/16533, which was closed for being stale. Thanks to emusgrave for the original PR/change.
Pull Request resolved: https://github.com/facebook/react-native/pull/20554

Differential Revision: D9414933

Pulled By: hramos

fbshipit-source-id: 8ebca57e32b905c4ecfd661524ca415f51162545
2018-08-20 18:32:04 -07:00
Zdravko Nikolovski 079bf3f206 Packager linking when using custom debug configuration on iOS device (#16451)
Summary:
In many projects we have different environments that we connect to. For these environments (for example: Test, Staging, Production) we have custom configurations (Debug and Release). While this is not a problem on Android, it is a problem on iOS. With the current implementation of the react-native-xcode.sh script, when using a custom Debug configuration, the app started on iOS device, can't contact the Packager. This pull request solves this issue.

Connect a real device, start the app with a custom debug configuration in Xcode. Shake and Reload.

[IOS][BUGFIX][./scripts/react-native-xcode.sh] Add support for connecting to the Packager when running the iOS app on device when using custom Debug configuration.
Closes https://github.com/facebook/react-native/pull/16451

Differential Revision: D8730537

Pulled By: hramos

fbshipit-source-id: a36007776e8fe9e401c38015040abd2c2bbd7c58
2018-07-03 18:18:30 -07:00
Sho Ikeda 0964135a17 react-native-xcode.sh: Support Homebrew-installed nodenv
Summary:
As well as nvm.

9d315f4a1e/scripts/react-native-xcode.sh (L56-L60)

Build React Native iOS app with Release configuration and run the script using `node` command which is installed through Homebrew-installed `nodenv` and `node-build`.

None.

[IOS] [ENHANCEMENT] [scripts/react-native-xcode.sh] - Support Homebrew-installed nodenv
Closes https://github.com/facebook/react-native/pull/19509

Differential Revision: D8243181

Pulled By: hramos

fbshipit-source-id: fbd75f377f4aebf89ce35b96a47c59238e62e9ce
2018-06-01 16:03:51 -07:00
Sophie Alpert 1490ab12ef Update license headers for MIT license
Summary:
Includes React Native and its dependencies Fresco, Metro, and Yoga. Excludes samples/examples/docs.

find: ^(?:( *)|( *(?:[\*~#]|::))( )? *)?Copyright (?:\(c\) )?(\d{4})\b.+Facebook[\s\S]+?BSD[\s\S]+?(?:this source tree|the same directory)\.$
replace: $1$2$3Copyright (c) $4-present, Facebook, Inc.\n$2\n$1$2$3This source code is licensed under the MIT license found in the\n$1$2$3LICENSE file in the root directory of this source tree.

Reviewed By: TheSavior, yungsters

Differential Revision: D7007050

fbshipit-source-id: 37dd6bf0ffec0923bfc99c260bb330683f35553e
2018-02-16 18:31:53 -08:00
Jani Eväkallio 8aa568e867 Fix Xcode Archive task failing if project path contains whitespace
Summary:
Currently, Xcodebuild Archive task "Bundle React Native code and images" step fails if the project path contains whitespace characters. This is due to `react-native-xcode.sh` not escaping the local CLI path.

Ideally, of course, folks would use sane directory names, but this affects people in the community. I have seen this at a beginner hackathon, as well as Stack Overflow, e.g. https://stackoverflow.com/questions/48209829/cannot-create-offline-bundle-for-react-native-ios

```
mkdir Bad\ Name
cd Bad\ Name
react-native init TestProject
cd TestProject
open ios/TestProject.xcodeproj
```
* Run `Build > Archive`
* `cli.js bundle` command fails with "Cannot find module '.../Bad'"

* Patch `/node_modules/react-native/scripts/react-native-xcode.sh` with changed file
* Run `Build > Archive`
* Build succeeds

<!--
Help reviewers and the release process by writing your own release notes

**INTERNAL and MINOR tagged notes will not be included in the next version's final release notes.**

  CATEGORY
[----------]        TYPE
[ CLI      ]   [-------------]      LOCATION
[ DOCS     ]   [ BREAKING    ]   [-------------]
[ GENERAL  ]   [ BUGFIX      ]   [-{Component}-]
[ INTERNAL ]   [ ENHANCEMENT ]   [ {File}      ]
[ IOS      ]   [ FEATURE     ]   [ {Directory} ]   |-----------|
[ ANDROID  ]   [ MINOR       ]   [ {Framework} ] - | {Message} |
[----------]   [-------------]   [-------------]   |-----------|

[CATEGORY] [TYPE] [LOCATION] - MESSAGE

 EXAMPLES:

 [IOS] [BREAKING] [FlatList] - Change a thing that breaks other things
 [ANDROID] [BUGFIX] [TextInput] - Did a thing to TextInput
 [CLI] [FEATURE] [local-cli/info/info.js] - CLI easier to do things with
 [DOCS] [BUGFIX] [GettingStarted.md] - Accidentally a thing/word
 [GENERAL] [ENHANCEMENT] [Yoga] - Added new yoga thing/position
 [INTERNAL] [FEATURE] [./scrip] - Added thing to script that nobody will see
-->

 [IOS] [MINOR] [scripts/react-native-xcode.sh] - Escape directory paths with spaces
Closes https://github.com/facebook/react-native/pull/17628

Differential Revision: D6806418

Pulled By: hramos

fbshipit-source-id: 7ef3943d91807d0086f0717e436e1988f9faf03d
2018-01-26 13:47:37 -08:00
Job Vranish 40a8434bde Removed use of xip.io, as it's not needed.
Summary:
By default, when a react-native app launches in development mode on a physical iOS device, it attempts to load the JS bundle from a packager at `http://_your-local-ip-address_.xip.io:8081/`.

This change removes the use of `xip.io`, which changes that url to: `http://_your-local-ip-address_:8081/`

<!--
Thank you for sending the PR! We appreciate you spending the time to work on these changes.

Help us understand your motivation by explaining why you decided to make this change.

You can learn more about contributing to React Native here: http://facebook.github.io/react-native/docs/contributing.html

Happy contributing!

-->

Background:
The automatic IP detection feature (introduced [here](https://github.com/facebook/react-native/pull/8091)) is super handy. However, it’s use of `xip.io` has caused myself and others much grief.  Some routers do not allow or have intermittent errors when trying to resolve DNS names to local IP addresses. This prompted the introduction of a [DISABLE_XIP feature](https://github.com/facebook/react-native/pull/13326), which helps.

However, I don’t believe the use of `xip.io` is needed at all.

Based on [this comment](8c29a52c54 (commitcomment-18224788)), it appears the original reason for using `xip.io` was to “circumvent the numeric IP address limitation in ATS”.

But, the reason you can’t create ATS exceptions for raw IP addresses is that ATS is not enforced for raw IP addresses _at all_. You can read the Apple documentation [here](https://developer.apple.com/library/content/documentation/General/Reference/InfoPlistKeyReference/Articles/CocoaKeys.html), the relevant portion is:

> App Transport Security (ATS) applies only to connections made to public host names. The system does not provide ATS protection to connections made to:
> * Internet protocol (IP) addresses
> * Unqualified host names
> * Local hosts employing the .local top-level domain (TLD)

For example, in iOS, if you attempt to make an http request (note: _not_ https) to `http://www.google.com` you will get an error due to ATS.
However, you can make the same request to `http://172.217.6.14/`  (which for me is the same server) and the request will succeed.

And in fact, if an ATS exception _was_ needed, the DISABLE_XIP feature shouldn’t work at all, but it does.

In short, using `xip.io` with ATS exceptions is unnecessary, causes some very annoying problems for some people, and I think it should just be removed.

Run the app on a physical iOS device and verify that it can load the JS bundle from the host computer's IP.

[Implemented automatic IP detection for iOS #8091](https://github.com/facebook/react-native/pull/8091)
[Added option to disable xip #13326](https://github.com/facebook/react-native/pull/13326)

<!--
Help reviewers and the release process by writing your own release notes

**INTERNAL and MINOR tagged notes will not be included in the next version's final release notes.**

  CATEGORY
[----------]        TYPE
[ CLI      ]   [-------------]      LOCATION
[ DOCS     ]   [ BREAKING    ]   [-------------]
[ GENERAL  ]   [ BUGFIX      ]   [-{Component}-]
[ INTERNAL ]   [ ENHANCEMENT ]   [ {File}      ]
[ IOS      ]   [ FEATURE     ]   [ {Directory} ]   |-----------|
[ ANDROID  ]   [ MINOR       ]   [ {Framework} ] - | {Message} |
[----------]   [-------------]   [-------------]   |-----------|

[CATEGORY] [TYPE] [LOCATION] - MESSAGE

 EXAMPLES:

 [IOS] [BREAKING] [FlatList] - Change a thing that breaks other things
 [ANDROID] [BUGFIX] [TextInput] - Did a thing to TextInput
 [CLI] [FEATURE] [local-cli/info/info.js] - CLI easier to do things with
 [DOCS] [BUGFIX] [GettingStarted.md] - Accidentally a thing/word
 [GENERAL] [ENHANCEMENT] [Yoga] - Added new yoga thing/position
 [INTERNAL] [FEATURE] [./scripts] - Added thing to script that nobody will see
-->
 [INTERNAL] [BUGFIX] [./scripts] - Removed use of xip.io
Closes https://github.com/facebook/react-native/pull/17642

Differential Revision: D6814609

Pulled By: hramos

fbshipit-source-id: f2faebd6a29b0b211d78cdfe8e195906307ab552
2018-01-25 16:46:46 -08:00
Michael Lee 42c410ac84 Fix permissions on test script
Reviewed By: yungsters

Differential Revision: D6791810

fbshipit-source-id: 849cffd3810eb53a6050e5e1a37d84a5e4ccb62a
2018-01-23 17:01:40 -08:00
Tim Yung b8c86b8dec RN: Revive `react-native-xcode.sh`
Reviewed By: mmmulani

Differential Revision: D6775989

fbshipit-source-id: da17748c373dd152a743aa1ed8a5f075074415d3
2018-01-22 12:33:14 -08:00
Bruno Lemos 0d4ff1b7ea Add extensibility point on react-native-xcode.sh script
Summary:
Original pull request: #12863

Useful for generating source maps, for example.

Feature parity with Android, that already have this extensibility point on `build.gradle`:
```
project.ext.react = [
    extraPackagerArgs: [...]
]
```

Xcode > Build Phases > Bundle React Native code and Images
```
export NODE_BINARY=node
export EXTRA_PACKAGER_ARGS="--sourcemap-output ${SRCROOT}/build/main.jsbundle.map"
../node_modules/react-native/scripts/react-native-xcode.sh
```

[IOS] [FEATURE] [./react-native-xcode.sh] - Added $EXTRA_PACKAGER_ARGS extensibility point
Closes https://github.com/facebook/react-native/pull/16933

Differential Revision: D6771709

Pulled By: yungsters

fbshipit-source-id: a33614b45b1e3537daeb31504fdd3a402dc70ff0
2018-01-22 08:07:10 -08:00
Daniel Mueller e268883fdc Improve support for unbundle feature
Summary:
unbundle is a useful feature, and it should be exposed. In order to get the most use out of
we expose it as an option at build time in the Build Phase on XCode and the project.ext.react
config in the build.gradle.

Because it is best used with inline requires we add a section under performance that describes
how inline requires can be implemented and how to use with the unbundling feature.

Testing:

- Added a section of the doc which explains how the feature can be enabled
- Use the instructions, build a build on iOS + android (using release so that the bundle is created) and confirm that the bundle has the binary header information.
Closes https://github.com/facebook/react-native/pull/15317

Differential Revision: D6054642

Pulled By: hramos

fbshipit-source-id: 067f4d2f78d91215709bd3e3636f460bc2b17e99
2017-10-13 17:28:28 -07:00
Gabriel Bull 743dc20aac Fixed issue with path containing spaces
Summary:
If the project is in a folder with a path containing a space, the project won't build. This fixes this issue.
Closes https://github.com/facebook/react-native/pull/15608

Differential Revision: D5686861

Pulled By: shergin

fbshipit-source-id: 74ce5b4f0261c18070c1a48966aae24f1ca75492
2017-08-22 23:30:06 -07:00
Ville Immonen 6e99e314b2 Move HelloWorld template to a single index.js entry point
Summary:
This change (initially discussed in https://github.com/react-community/create-react-native-app/issues/26) moves the HelloWorld project template from two nearly identical entry points (`index.android.js` and `index.ios.js`) to a single, minimal `index.js` entry point. The root component is created in `App.js`. This unifies the project structure between `react-native init` and Create React Native App and allows CRNA's eject to use the entry point from the HelloWorld template without any hacks to customize it. Also examples in the docs can be just copy-pasted to `App.js` the same way in both HelloWorld and CRNA apps without having to first learn about  `AppRegistry.registerComponent`.

* Created a new project from the template using `./scripts/test-manual-e2e.sh` and verified that:
  * The app builds, starts and runs both on Android and iOS.
  * Editing and reloading changes works.
  * The new files (`index.js`, `App.js`, `__tests__/App.js`) get created in the project folder.

<img width="559" alt="screen shot 2017-08-01 at 19 10 51" src="https://user-images.githubusercontent.com/497214/28835171-300a12b6-76ed-11e7-81b2-623639c3b8f6.png">
<img width="467" alt="screen shot 2017-08-01 at 19 09 12" src="https://user-images.githubusercontent.com/497214/28835180-33d285e0-76ed-11e7-8d68-2b3bc44bf585.png">

<!--
Thank you for sending the PR!

If you changed any code, please provide us with clear instructions on how you verified your changes work. In other words, a test plan is *required*. Bonus points for screenshots and videos!

Please read the Contribution Guidelines at https://github.com/facebook/react-native/blob/master/CONTRIBUTING.md to learn more about contributing to React Native.

Happy contributing!
-->
Closes https://github.com/facebook/react-native/pull/15312

Differential Revision: D5556276

Pulled By: hramos

fbshipit-source-id: 068fdf7e51381c2bc50321522f2be0db47296c5e
2017-08-03 14:02:43 -07:00
Kevin Cooper 0681887347 Add FORCE/SKIP_BUNDLING flags for iOS builds
Summary:
*See discussion below for updated motivation.*

Anything running in Debug should use the packager anyway; no need to bundle. This saves a **huge amount of time** during development when testing things like push notifications that require a real device.

The code being modified was originally moved here in 9ae3714f4b to make sure bundles are always created in `Release`, but the change can be applied to real devices, too. Ideally there should be very little difference in how a simulator is treated compared to a physical device.

Run a Debug build in Xcode targeting a physical device before and after this commit.

You can use the `FORCE_BUNDLING` and `SKIP_BUNDLING` flags to manually change the default behavior. For example, under **Build Phases** > **Bundle React Native code and images**:

```bash
export SKIP_BUNDLING=true
../node_modules/react-native/packager/react-native-xcode.sh
```
Closes https://github.com/facebook/react-native/pull/14731

Differential Revision: D5444352

Pulled By: javache

fbshipit-source-id: 68324fc0be7976e106fe0f9b31d763afd2b460a9
2017-07-18 11:45:47 -07:00
Hank Brekke 3840618a01 Fix Incorrect Build Script Bash False-Matching
Summary:
When attempting to inverse a Bash boolean, the `!` character converts the meaning to become `[[ ! -n false ]]` (checking that the string "false" is empty) which never matches, and therefore this condition can never occur.

See https://stackoverflow.com/a/2953673
Closes https://github.com/facebook/react-native/pull/14190

Differential Revision: D5137013

Pulled By: javache

fbshipit-source-id: 7df52cc90a4ab79c7b5da54dbfb6c99fba3e8b80
2017-05-26 02:45:20 -07:00
David Aurelio a710f9a81e Move packager launcher scripts outside of `packager/`
Summary: in order to prepare open sourcing React Native Packager, we have to move scripts specific to React Native to a directory that will continue to exist.

Reviewed By: javache

Differential Revision: D5112193

fbshipit-source-id: eac77d0d981aecef7ee52365a6856340420a5638
2017-05-23 16:17:09 -07:00