Skip to content

Instantly share code, notes, and snippets.

@almost
almost / 1-react-native-simulator-and-device.md
Last active November 17, 2022 14:05
Test React Native on the simulator and on a device without editing the code each time!

In the default React Native app scaffolding you have to edit AppDelegate.m to change where it loads the code if you want to test on your device. I use the following snippet to detect if it's being compiled for Debug or Production and for the Simulator or a device. For Production it uses a copy of the code included in the bundle, for Debug on the simualtor it loads from a server on localhost and for Debug on a device it loads from a server on a given IP address.

NOTE: You need to edit YOUR-IP-HERE and change it to the IP to load the code from when in Debug mode on a device. You could use a service like ngrok to make this work from anywhere.

  NSURL *jsCodeLocation;

  // Loading JavaScript code
  #if DEBUG
    // For Debug build load from development server. Start the server from the repository root:
@damusnet
damusnet / ck.php
Created October 9, 2010 12:24
CKEditor Helper for CakePHP v1.3.4
<?php
/**
* Helper CKEditor pour CakePHP v1.3.4
* Code Original par Pierre-Emmanuel Fringant
* URL : http://www.formation-cakephp.com/388/ckeditor-helper
* Modifié par Damien Varron, 09/10/2010
*/
class CkHelper extends AppHelper