<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: Andre Nunes</title>
    <description>The latest articles on Forem by Andre Nunes (@andrenunes).</description>
    <link>https://forem.com/andrenunes</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F322398%2Ff161a387-be4f-4309-be07-c8d151813c89.jpg</url>
      <title>Forem: Andre Nunes</title>
      <link>https://forem.com/andrenunes</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/andrenunes"/>
    <language>en</language>
    <item>
      <title>How to use Prettier to lint Ruby files</title>
      <dc:creator>Andre Nunes</dc:creator>
      <pubDate>Tue, 27 Jun 2023 11:16:04 +0000</pubDate>
      <link>https://forem.com/andrenunes/how-to-use-prettier-to-lint-ruby-files-46i1</link>
      <guid>https://forem.com/andrenunes/how-to-use-prettier-to-lint-ruby-files-46i1</guid>
      <description>&lt;p&gt;When it comes to maintaining clean and consistent code in Ruby on Rails applications, proper linting is crucial. Prettier is a popular code formatter that can be used to enforce consistent code style and formatting in your Ruby files. In this blog post, we will guide you through the process of setting up Prettier as a code formatter for your Ruby files in Visual Studio Code (VSCode).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 1:&lt;/strong&gt; Install the Prettier Extension in VSCode&lt;br&gt;
The first step is to install the Prettier extension in VSCode. Open the Extensions sidebar, search for "&lt;strong&gt;Prettier - Code Formatter&lt;/strong&gt;", and click the Install button.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 2:&lt;/strong&gt; Install Prettier for Ruby on Rails&lt;br&gt;
Next, we need to install the &lt;a href="https://github.com/prettier/plugin-ruby"&gt;Prettier package for Ruby on Rails&lt;/a&gt;. Open your project's terminal and run the following command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm &lt;span class="nb"&gt;install&lt;/span&gt; &lt;span class="nt"&gt;--save-dev&lt;/span&gt; prettier @prettier/plugin-ruby
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Step 3:&lt;/strong&gt; Install Ruby Dependencies for Prettier&lt;br&gt;
To ensure Prettier works seamlessly with Ruby, we need to install some Ruby dependencies. Run the following command in your terminal:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;gem &lt;span class="nb"&gt;install &lt;/span&gt;bundler prettier_print syntax_tree syntax_tree-haml syntax_tree-rbs
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Step 4:&lt;/strong&gt; Create a Default Prettier Configuration File&lt;br&gt;
Prettier allows you to customize the formatting options according to your preferences. Create a file named &lt;code&gt;.prettierrc.yml&lt;/code&gt; in the root directory of your Rails application and add the following content:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;tabWidth&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="m"&gt;2&lt;/span&gt;
&lt;span class="na"&gt;semi&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="no"&gt;false&lt;/span&gt;
&lt;span class="na"&gt;singleQuote&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="no"&gt;true&lt;/span&gt;
&lt;span class="na"&gt;trailingComma&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;none"&lt;/span&gt;

&lt;span class="na"&gt;rubyArrayLiteral&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="no"&gt;true&lt;/span&gt;
&lt;span class="na"&gt;rubyHashLabel&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="no"&gt;true&lt;/span&gt;
&lt;span class="na"&gt;rubyModifier&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="no"&gt;true&lt;/span&gt;
&lt;span class="na"&gt;rubySingleQuote&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="no"&gt;true&lt;/span&gt;
&lt;span class="na"&gt;rubyToProc&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="no"&gt;false&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;All the ruby properties are available &lt;a href="https://github.com/prettier/plugin-ruby"&gt;here&lt;/a&gt; so feel free to modify these options based on your desired code style.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 5:&lt;/strong&gt; Update VSCode Settings&lt;br&gt;
To set Prettier as the default formatter for Ruby files in VSCode, we need to update the settings. Open your VSCode settings file (&lt;code&gt;settings.json&lt;/code&gt;) and add the following configuration:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"[ruby]"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"editor.defaultFormatter"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"esbenp.prettier-vscode"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"editor.formatOnSave"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"editor.tabSize"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"ruby.lint"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"rubocop"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;These settings specify that Prettier should be the default formatter for Ruby files and that formatting should be applied automatically on save. Additionally, we enable the RuboCop linter for Ruby files to ensure both code style and quality are maintained.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Tip:&lt;/strong&gt; You can add &lt;code&gt;node_modules&lt;/code&gt;, &lt;code&gt;package.json&lt;/code&gt; and &lt;code&gt;package-lock.json&lt;/code&gt; to &lt;code&gt;.gitignore&lt;/code&gt; to not commit them to git.&lt;/p&gt;

&lt;h2&gt;
  
  
  Extra
&lt;/h2&gt;

&lt;p&gt;From &lt;a href="https://github.com/prettier/plugin-ruby"&gt;plugin-ruby repo&lt;/a&gt; we can use Prettier and Rubocop.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Prettier provides a RuboCop configuration file to disable the rules which would clash. To enable this file, add the following configuration at the top of your project's &lt;code&gt;.rubocop.yml&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;
&lt;/blockquote&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;inherit_from&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;node_modules/@prettier/plugin-ruby/rubocop.yml&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If you don't have a &lt;code&gt;.rubocop.yml&lt;/code&gt; file in your project the default &lt;strong&gt;plugin-ruby&lt;/strong&gt; will use the default ones present on the plugin.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;By following these steps, you can easily set up Prettier as a code formatter for your Ruby files in VSCode. With Prettier's powerful formatting capabilities, you can enforce consistent code style and improve the readability of your Ruby on Rails applications. Happy coding!&lt;/p&gt;

&lt;p&gt;Source: &lt;a href="https://github.com/prettier/plugin-ruby"&gt;https://github.com/prettier/plugin-ruby&lt;/a&gt;&lt;/p&gt;

</description>
      <category>ruby</category>
      <category>rails</category>
      <category>vscode</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Connecting React Native to localhost</title>
      <dc:creator>Andre Nunes</dc:creator>
      <pubDate>Tue, 28 Apr 2020 08:44:21 +0000</pubDate>
      <link>https://forem.com/runtime-revolution/connecting-react-native-to-localhost-f88</link>
      <guid>https://forem.com/runtime-revolution/connecting-react-native-to-localhost-f88</guid>
      <description>&lt;p&gt;This is something that happens to me on every React Native project.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;How can I make a request to my local API (that runs on localhost)&lt;/em&gt;&lt;/strong&gt;?&lt;/p&gt;

&lt;p&gt;To be able to do a request to your local machine you have to do two things.&lt;/p&gt;

&lt;p&gt;First, you must use your &lt;strong&gt;machine IP&lt;/strong&gt; as the base URL for the request.&lt;/p&gt;

&lt;p&gt;To discover your IP, just type this command on your console and look for the &lt;strong&gt;inet&lt;/strong&gt; that looks like &lt;strong&gt;192.168.1.200&lt;/strong&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ifconfig | grep inet

---

**inet** 192.168.1.200 netmask ...
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;After that you will need to update your Android and iOS configurations.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Android&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;One of the problems may be related to &lt;strong&gt;CLEARTEXT HTTP,&lt;/strong&gt; which protects apps from accidental usage of cleartext traffic.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Starting with Android 9 (API level 28), cleartext support is disabled by default.&lt;/p&gt;

&lt;p&gt;* from &lt;a href="https://android-developers.googleblog.com/2018/04/protecting-users-with-tls-by-default-in.html"&gt;Android Developers&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Which means that Android can only make a request to &lt;strong&gt;HTTPS&lt;/strong&gt; sources. So we need to allow our application to use &lt;strong&gt;HTTP&lt;/strong&gt;  sources.&lt;/p&gt;

&lt;p&gt;In the &lt;strong&gt;AndroidManifest.xml&lt;/strong&gt; file, we need to add these lines:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight xml"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;manifest&lt;/span&gt; &lt;span class="err"&gt;...&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;uses-permission&lt;/span&gt; &lt;span class="na"&gt;android:name=&lt;/span&gt;&lt;span class="s"&gt;"android.permission.INTERNET"&lt;/span&gt; &lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;

  &lt;span class="nt"&gt;&amp;lt;application&lt;/span&gt;
    &lt;span class="na"&gt;android:name=&lt;/span&gt;&lt;span class="s"&gt;".MainApplication"&lt;/span&gt;
    &lt;span class="na"&gt;android:usesCleartextTraffic=&lt;/span&gt;&lt;span class="s"&gt;"true"&lt;/span&gt;  
    &lt;span class="na"&gt;android:networkSecurityConfig=&lt;/span&gt;&lt;span class="s"&gt;"@xml/network\_security\_config"&lt;/span&gt;&lt;span class="err"&gt;...&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;

    &lt;span class="nt"&gt;&amp;lt;activity&lt;/span&gt; &lt;span class="na"&gt;android:name=&lt;/span&gt;&lt;span class="s"&gt;".MainActivity"&lt;/span&gt; &lt;span class="err"&gt;...&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
      ...
    &lt;span class="nt"&gt;&amp;lt;/activity&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;/application&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/manifest&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This will allow our application to connect to &lt;strong&gt;EVERY HTTP&lt;/strong&gt; source. But we want to allow only your machine’s IP. So to do that we will need to create the &lt;strong&gt;network_security_config.xml&lt;/strong&gt; file in the folder &lt;strong&gt;main/res/xml&lt;/strong&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight xml"&gt;&lt;code&gt;&lt;span class="cp"&gt;&amp;lt;?xml version="1.0" encoding="utf-8"?&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;network-security-config&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;domain-config&lt;/span&gt; &lt;span class="na"&gt;cleartextTrafficPermitted=&lt;/span&gt;&lt;span class="s"&gt;"true"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;domain&lt;/span&gt; &lt;span class="na"&gt;includeSubdomains=&lt;/span&gt;&lt;span class="s"&gt;"false"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt; localhost &lt;span class="nt"&gt;&amp;lt;/domain&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;domain&lt;/span&gt; &lt;span class="na"&gt;includeSubdomains=&lt;/span&gt;&lt;span class="s"&gt;"false"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt; 10.0.2.2 &lt;span class="nt"&gt;&amp;lt;/domain&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;domain&lt;/span&gt; &lt;span class="na"&gt;includeSubdomains=&lt;/span&gt;&lt;span class="s"&gt;"false"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt; 192.168.1.200 &lt;span class="nt"&gt;&amp;lt;/domain&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;base-config&lt;/span&gt; &lt;span class="na"&gt;cleartextTrafficPermitted=&lt;/span&gt;&lt;span class="s"&gt;"true"&lt;/span&gt;&lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;/domain-config&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/network-security-config&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This file restricts the &lt;strong&gt;HTTP&lt;/strong&gt; domains that our app can communicate with. The IP &lt;strong&gt;10.0.2.2&lt;/strong&gt; is an alias for the emulator to &lt;strong&gt;127.0.0.1,&lt;/strong&gt; and &lt;strong&gt;192.168.1.200&lt;/strong&gt; is our machine’s IP.&lt;/p&gt;

&lt;p&gt;After that we need to set the domain url on the Android emulator. So open &lt;strong&gt;Dev Settings by&lt;/strong&gt; clicking &lt;strong&gt;CMD + M&lt;/strong&gt; and then click on &lt;strong&gt;Debug server host &amp;amp; port for device.&lt;/strong&gt; On this modal we add our machine’s IP &lt;strong&gt;192.168.1.200.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--2_LHMXNH--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/718/1%2A_bb-PXxubZrZTV2fsILL9Q.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--2_LHMXNH--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/718/1%2A_bb-PXxubZrZTV2fsILL9Q.png" alt="" width="718" height="1072"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;iOS&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;On the iOS side we will have the same issue, we need to allow our app to do requests to *&lt;em&gt;HTTP *&lt;/em&gt; sources.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;By default, iOS will block any request that’s not encrypted using &lt;a href="https://hosting.review/web-hosting-glossary/#12"&gt;SSL&lt;/a&gt;. If you need to fetch from a cleartext URL (one that begins with http) you will first need to &lt;a href="https://reactnative.dev/docs/integration-with-existing-apps#test-your-integration"&gt;add an App Transport Security exception&lt;/a&gt;. If you know ahead of time what domains you will need access to, it is more secure to add exceptions only for those domains; if the domains are not known until runtime you can &lt;a href="https://reactnative.dev/docs/integration-with-existing-apps#app-transport-security"&gt;disable ATS completely&lt;/a&gt;. Note however that from January 2017, &lt;a href="https://forums.developer.apple.com/thread/48979"&gt;Apple's App Store review will require reasonable justification for disabling ATS&lt;/a&gt;. See &lt;a href="https://developer.apple.com/library/ios/documentation/General/Reference/InfoPlistKeyReference/Articles/CocoaKeys.html#//apple_ref/doc/uid/TP40009251-SW33"&gt;Apple's documentation&lt;/a&gt; for more information.  &lt;/p&gt;

&lt;p&gt;* from &lt;a href="https://reactnative.dev/docs/network"&gt;React Native&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;To do that we will need to update our &lt;strong&gt;Info.plist&lt;/strong&gt; file and add the &lt;strong&gt;NSAppTransportSecurity&lt;/strong&gt; key.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight xml"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;key&amp;gt;&lt;/span&gt;NSAppTransportSecurity&lt;span class="nt"&gt;&amp;lt;/key&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;dict&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;key&amp;gt;&lt;/span&gt;NSExceptionDomains&lt;span class="nt"&gt;&amp;lt;/key&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;dict&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;key&amp;gt;&lt;/span&gt;localhost&lt;span class="nt"&gt;&amp;lt;/key&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;dict&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;key&amp;gt;&lt;/span&gt;NSTemporaryExceptionAllowsInsecureHTTPLoads&lt;span class="nt"&gt;&amp;lt;/key&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;true/&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;/dict&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;/dict&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/dict&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;On iOS we don’t need to define our machine’s IP because it translates &lt;strong&gt;localhost&lt;/strong&gt; to that.&lt;/p&gt;

&lt;p&gt;After that all we need to do is re-install our app on the emulator and it’s done, with this you can now make requests to your local API.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; This should only be used on local development environment, don’t commit this to your production app.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Recommended links&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://developer.android.com/training/articles/security-config"&gt;https://developer.android.com/training/articles/security-config&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CocoaKeys.html#//apple_ref/doc/uid/TP40009251-SW33"&gt;https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CocoaKeys.html#//apple_ref/doc/uid/TP40009251-SW33&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://reactnative.dev/docs/network"&gt;https://reactnative.dev/docs/network&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;&lt;em&gt;I’m a software developer from Portugal, currently working at&lt;/em&gt; &lt;a href="https://www.runtime-revolution.com/"&gt;&lt;em&gt;Runtime Revolution&lt;/em&gt;&lt;/a&gt; &lt;em&gt;as a front-end and mobile developer.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.runtime-revolution.com/"&gt;Runtime Revolution&lt;/a&gt;&lt;br&gt;
&lt;a href="https://github.com/anunes9"&gt;anunes9 - Overview&lt;/a&gt;&lt;/p&gt;

</description>
      <category>reactnative</category>
      <category>todayilearned</category>
      <category>testing</category>
      <category>api</category>
    </item>
    <item>
      <title>How to start with React Native</title>
      <dc:creator>Andre Nunes</dc:creator>
      <pubDate>Tue, 17 Mar 2020 11:15:04 +0000</pubDate>
      <link>https://forem.com/runtime-revolution/how-to-start-with-react-native-1cbe</link>
      <guid>https://forem.com/runtime-revolution/how-to-start-with-react-native-1cbe</guid>
      <description>&lt;p&gt;In this article, I’ll tell you what you need to bootstrap a React Native app.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s---inbmZUw--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/1024/0%2A4hJESi7DgtPFHRfu" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s---inbmZUw--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/1024/0%2A4hJESi7DgtPFHRfu" alt=""&gt;&lt;/a&gt;Photo by &lt;a href="https://unsplash.com/@monicasauro?utm_source=medium&amp;amp;utm_medium=referral"&gt;Monica Sauro&lt;/a&gt; on &lt;a href="https://unsplash.com?utm_source=medium&amp;amp;utm_medium=referral"&gt;Unsplash&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;So what is React Native?&lt;/strong&gt;
&lt;/h3&gt;

&lt;blockquote&gt;
&lt;p&gt;React Native combines the best parts of native development with React, a best-in-class JavaScript library for building user interfaces. (…)&lt;/p&gt;

&lt;p&gt;* from &lt;a href="https://reactnative.dev/"&gt;React Native&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;React Native allows you to create Android and iOS applications with the same code base, that behave nearly the same using all the resources of React with a little tweak.&lt;/p&gt;

&lt;h3&gt;
  
  
  Setting Up Your Development Environment
&lt;/h3&gt;

&lt;p&gt;The installation process that is described on the React Native site is well documented and easy to follow, but here is the short version. I use a MacBook Pro as my development machine so the commands will be for macOS.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Installation process&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Install &lt;a href="https://developer.apple.com/xcode/"&gt;Xcode&lt;/a&gt; and &lt;a href="https://developer.android.com/studio"&gt;Android Studio&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Install &lt;a href="https://nodejs.org/en/"&gt;node&lt;/a&gt; and &lt;a href="https://facebook.github.io/watchman/docs/nodejs.html"&gt;watchman&lt;/a&gt;
&lt;/li&gt;
&lt;/ol&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;ol&gt;
&lt;li&gt;Install Java SDK&lt;/li&gt;
&lt;/ol&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;ol&gt;
&lt;li&gt;Install Xcode command line tools&lt;/li&gt;
&lt;/ol&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;Open Xcode, then choose the &lt;strong&gt;Preferences…&lt;/strong&gt; menu.&lt;br&gt;&lt;br&gt;
Go to &lt;strong&gt;Locations&lt;/strong&gt; panel and install the tools by selecting the most recent version in the &lt;strong&gt;Command Line Tools&lt;/strong&gt; dropdown.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Install CocoaPods&lt;/li&gt;
&lt;/ol&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;ol&gt;
&lt;li&gt;Install &lt;a href="https://github.com/jhen0409/react-native-debugger"&gt;react-native-debugger&lt;/a&gt;
&lt;/li&gt;
&lt;/ol&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;And you are ready to go.&lt;/p&gt;

&lt;p&gt;Now what you need to do is bootstrap your application.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;React Native has a built-in command line interface, which you can use to generate a new project. You can access it without installing anything globally using npx, which ships with Node.js. (…)&lt;/p&gt;

&lt;p&gt;* from &lt;a href="https://reactnative.dev/"&gt;React Native&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;After you create your app you can choose to run the app on iOS or Android.&lt;/p&gt;

&lt;p&gt;To open the app on iOS just run this command, it will open the iOS simulator and install the app.&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;To open the app on Android you will need to create a virtual device on Android Studio, open the virtual device and run the following command.&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;And there you go, the app is running!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--V23bFAZR--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/249/1%2AWANqxyiI6zLXB981kE_g0A.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--V23bFAZR--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/249/1%2AWANqxyiI6zLXB981kE_g0A.png" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Debugging
&lt;/h3&gt;

&lt;p&gt;To use &lt;strong&gt;react-native-debugger&lt;/strong&gt; you need to enable remote JS debugging on the simulator option:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;On iOS press &lt;strong&gt;&lt;em&gt;CMD + D&lt;/em&gt;&lt;/strong&gt; and click on &lt;strong&gt;Debug JS Remotely&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;On Android press &lt;strong&gt;&lt;em&gt;CMD + P&lt;/em&gt;&lt;/strong&gt;  .&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;A nice feature of React Native is Hot Reloading, which allows you to see the code changes in real time without having to restart the app.&lt;/p&gt;

&lt;p&gt;To enable this option, open the simulator options and click on &lt;strong&gt;Enable Hot Reloading&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--EpdPDlpJ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/760/1%2ArA2F8oNEpGILBvujuuhTtg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--EpdPDlpJ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/760/1%2ArA2F8oNEpGILBvujuuhTtg.png" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;At this point you have your React Native environment set and ready to start coding some apps.&lt;/p&gt;

&lt;h3&gt;
  
  
  Recommended links
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://reactnative.dev/"&gt;React Native&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/react-native-community"&gt;React Native Community&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/jondot/awesome-react-native"&gt;Awesome React Native&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/microsoft/vscode-react-native"&gt;VSCode React Native&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://github.com/anunes9"&gt;anunes9 - Overview&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;If you have any questions or comments, don’t hesitate to reach out. I’d be happy to help you. Thanks for reading!&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;I’m a software developer from Portugal, currently working at&lt;/em&gt; &lt;a href="https://www.runtime-revolution.com/"&gt;&lt;em&gt;Runtime Revolution&lt;/em&gt;&lt;/a&gt; &lt;em&gt;as a front-end and mobile developer.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.runtime-revolution.com/"&gt;Runtime Revolution&lt;/a&gt;&lt;/p&gt;




</description>
      <category>softwaredevelopment</category>
      <category>reactnative</category>
      <category>ios</category>
      <category>android</category>
    </item>
  </channel>
</rss>
