{"action":"created","issue":{"url":"https://api.github.com/repos/facebook/react-native/issues/4245","labels_url":"https://api.github.com/repos/facebook/react-native/issues/4245/labels{/name}","comments_url":"https://api.github.com/repos/facebook/react-native/issues/4245/comments","events_url":"https://api.github.com/repos/facebook/react-native/issues/4245/events","html_url":"https://github.com/facebook/react-native/issues/4245","id":117886473,"number":4245,"title":"Automated IP Switching for Simulator/Devices","user":{"login":"aphillipo","id":52347,"avatar_url":"https://avatars.githubusercontent.com/u/52347?v=3","gravatar_id":"","url":"https://api.github.com/users/aphillipo","html_url":"https://github.com/aphillipo","followers_url":"https://api.github.com/users/aphillipo/followers","following_url":"https://api.github.com/users/aphillipo/following{/other_user}","gists_url":"https://api.github.com/users/aphillipo/gists{/gist_id}","starred_url":"https://api.github.com/users/aphillipo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aphillipo/subscriptions","organizations_url":"https://api.github.com/users/aphillipo/orgs","repos_url":"https://api.github.com/users/aphillipo/repos","events_url":"https://api.github.com/users/aphillipo/events{/privacy}","received_events_url":"https://api.github.com/users/aphillipo/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/facebook/react-native/labels/iOS","name":"iOS","color":"c7def8"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":26,"created_at":"2015-11-19T19:16:34Z","updated_at":"2015-12-08T10:25:08Z","closed_at":null,"body":"I have no idea where to add this but here is how to automate (mostly, under some conditions, your milage may vary - your network connection must be en0 etc.) changing the IP address of your machine when you want to run on the device.\r\n\r\n1) Click Your Project -> Build Phases -> Click the + -> New Run Script Phase\r\n2) Add the following code:\r\n\r\n    INFOPLIST=\"${TARGET_BUILD_DIR}/${INFOPLIST_PATH}\"\r\n    echo \"writing to $INFOPLIST\"\r\n    PLISTCMD=\"Set :SERVER_IP $(ifconfig | grep inet\\ | tail -1 | cut -d \" \" -f 2)\"\r\n    echo -n \"$INFOPLIST\" | xargs -0 /usr/libexec/PlistBuddy -c \"$PLISTCMD\"\r\n\r\nNext add the following to AppDelegate.m replacing the usual jsCodeLocation line:\r\n\r\n    NSString *jsBundleUrlString;\r\n\r\n    if (TARGET_IPHONE_SIMULATOR) {\r\n      jsBundleUrlString = @\"http://localhost:8081/index.ios.bundle\";\r\n    } else {\r\n      NSString *serverIP = [[NSBundle mainBundle] objectForInfoDictionaryKey:@\"SERVER_IP\"];\r\n      NSString *jsCodeUrlString = [NSString stringWithFormat:@\"http://%@:8081/index.ios.bundle\", serverIP];\r\n      jsBundleUrlString = [jsCodeUrlString stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];\r\n    }\r\n\r\n    jsCodeLocation = [NSURL URLWithString:jsBundleUrlString];\r\n\r\nAnd that's it, you should now be able to switch between the simulator and a device without any thought about where you are...  Let me know if this works for you.\r\n \r\n"},"comment":{"url":"https://api.github.com/repos/facebook/react-native/issues/comments/162841692","html_url":"https://github.com/facebook/react-native/issues/4245#issuecomment-162841692","issue_url":"https://api.github.com/repos/facebook/react-native/issues/4245","id":162841692,"user":{"login":"adamterlson","id":2498418,"avatar_url":"https://avatars.githubusercontent.com/u/2498418?v=3","gravatar_id":"","url":"https://api.github.com/users/adamterlson","html_url":"https://github.com/adamterlson","followers_url":"https://api.github.com/users/adamterlson/followers","following_url":"https://api.github.com/users/adamterlson/following{/other_user}","gists_url":"https://api.github.com/users/adamterlson/gists{/gist_id}","starred_url":"https://api.github.com/users/adamterlson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/adamterlson/subscriptions","organizations_url":"https://api.github.com/users/adamterlson/orgs","repos_url":"https://api.github.com/users/adamterlson/repos","events_url":"https://api.github.com/users/adamterlson/events{/privacy}","received_events_url":"https://api.github.com/users/adamterlson/received_events","type":"User","site_admin":false},"created_at":"2015-12-08T10:25:08Z","updated_at":"2015-12-08T10:25:08Z","body":"@aphillipo \"For pointing APIs at my local machine does anyone know how I'd access the Info.plist value from the React/JS side of the app?\"\r\n\r\n(+1) On this.  Perhaps a different PR/effort, but this would be immensely useful."}}