<?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>DEV Community: Kevin Lee</title>
    <description>The latest articles on DEV Community by Kevin Lee (@mngyuan).</description>
    <link>https://dev.to/mngyuan</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%2F580280%2Fe5a43275-062d-4150-8787-bb1f311e07c4.jpeg</url>
      <title>DEV Community: Kevin Lee</title>
      <link>https://dev.to/mngyuan</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/mngyuan"/>
    <language>en</language>
    <item>
      <title>Updating React Native projects for M1 Mac development</title>
      <dc:creator>Kevin Lee</dc:creator>
      <pubDate>Tue, 16 Feb 2021 22:11:43 +0000</pubDate>
      <link>https://dev.to/mngyuan/updating-react-native-projects-for-m1-mac-development-1mk4</link>
      <guid>https://dev.to/mngyuan/updating-react-native-projects-for-m1-mac-development-1mk4</guid>
      <description>&lt;p&gt;In this post I'll walk through how to get the default React Native project to build in Xcode 12.4 on Apple silicon. The steps are the same as the ones I followed to update my app, but I'll use the default project to keep things relevant. You can follow along to update your own project, but keep in mind that different modules you've added and their pods (i.e. Firebase) might not have yet added support for Apple silicon.&lt;/p&gt;

&lt;p&gt;First, let's get a basic project to work with.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npx react-native init rntest
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Some common errors you might run into without any further changes are&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;/Users/mngyuan/git/personal/rntest/ios/rntest.xcodeproj The linked library 'libPods-rntest.a' is missing one or more architectures required by this target: arm64.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Undefined symbol: protocol descriptor for Swift.ExpressibleByFloatLiteral
...
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ld: in /Users/mngyuan/git/personal/rntest/ios/Pods/FirebaseAnalytics/Frameworks/FIRAnalyticsConnector.framework/FIRAnalyticsConnector(FIRAnalyticsConnector_e321ed8e3db06efc9803f6c008e67a34.o), building for iOS Simulator, but linking in object file built for iOS, file '/Users/mngyuan/git/personal/rntest/ios/Pods/FirebaseAnalytics/Frameworks/FIRAnalyticsConnector.framework/FIRAnalyticsConnector' for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The problem is that we're building for the x86_64 iOS simulator, but building and linking with arm64 libraries and code. We have some settings to change. First, open Xcode&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;cd &lt;/span&gt;rntest
open ios/rntest.xcworkspace
&lt;span class="c"&gt;# or xed -b ios&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We're going to exclude the arm64 architecture from our build. Under Targets, select your project -&amp;gt; Build Settings -&amp;gt; Excluded Architectures, and add Any IOS Simulator SDK : arm64 for both Debug and Release. Do the same for your Pods project.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4j2e9bnvlbwdm9hufj61.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4j2e9bnvlbwdm9hufj61.png" alt="Screen Shot 2021-02-16 at 10.08.25 PM"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2fi7118gvdjk0oo4aker.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2fi7118gvdjk0oo4aker.png" alt="Screen Shot 2021-02-16 at 10.08.30 PM"&gt;&lt;/a&gt;  &lt;/p&gt;

&lt;p&gt;If your project for some reason has &lt;code&gt;VALID_ARCHS&lt;/code&gt; set, you'll want to remove that key from your project as well (and the Pods project) at this stage.&lt;/p&gt;

&lt;p&gt;We're very close to done, but the version of Flipper installed in your pods is likely not new enough to include the fixes for M1 macs. Open &lt;code&gt;ios/Podfile&lt;/code&gt; and apply the following&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight diff"&gt;&lt;code&gt;&lt;span class="gd"&gt;- use_flipper!
&lt;/span&gt;&lt;span class="gi"&gt;+ use_flipper!({ 'Flipper' =&amp;gt; '0.75.0' })
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And update your Pods&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;cd ios/
# optionally reinstall all your Pods if you're still having issues
# pod deintegrate
pod update
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If you performed a build which failed, you might want to clear DerivedData like so&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;rm -rf ~/Library/Developer/Xcode/DerivedData/
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now, perform a clean build by clearing your build folder (Cmd+Shift+K) and building (Cmd+R).&lt;/p&gt;

&lt;p&gt;Everything should work now! If you're still having problems they may be related to a specific Pod which doesn't play nice with the M1 yet.&lt;/p&gt;

</description>
      <category>react</category>
      <category>reactnative</category>
    </item>
  </channel>
</rss>
