Skip to content

Commit 36d1d72

Browse files
authored
📚 Add instruction for M1 users to work with Cocoapods (#2974)
1 parent ebc1bdc commit 36d1d72

12 files changed

+49
-10
lines changed

‎docs/_getting-started-macos-ios.md‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import M1Cocoapods from './\_markdown-m1-cocoapods.mdx';
2+
13
## Installing dependencies
24

35
You will need Node, Watchman, the React Native command line interface, Xcode and CocoaPods.
@@ -45,6 +47,8 @@ sudo gem install cocoapods
4547

4648
For more information, please visit [CocoaPods Getting Started guide](https://guides.cocoapods.org/using/getting-started.html).
4749

50+
<M1Cocoapods />
51+
4852
### React Native Command Line Interface
4953

5054
React Native has a built-in command line interface. Rather than install and manage a specific version of the CLI globally, we recommend you access the current version at runtime using `npx`, which ships with Node.js. With `npx react-native <command>`, the current stable version of the CLI will be downloaded and executed at the time the command is run.

‎docs/_integration-with-exisiting-apps-objc.md‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import Tabs from '@theme/Tabs'; import TabItem from '@theme/TabItem'; import constants from '@site/core/TabsConstants';
1+
import Tabs from '@theme/Tabs'; import TabItem from '@theme/TabItem'; import constants from '@site/core/TabsConstants'; import M1Cocoapods from './\_markdown-m1-cocoapods.mdx';
22

33
## Key Concepts
44

@@ -186,6 +186,8 @@ Pod installation complete! There are 3 dependencies from the Podfile and 1 total
186186

187187
> If this fails with errors mentioning `xcrun`, make sure that in Xcode in **Preferences > Locations** the Command Line Tools are assigned.
188188
189+
<M1Cocoapods />
190+
189191
### Code integration
190192

191193
Now we will actually modify the native iOS application to integrate React Native. For our 2048 sample app, we will add a "High Score" screen in React Native.

‎docs/_integration-with-exisiting-apps-swift.md‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import M1Cocoapods from './\_markdown-m1-cocoapods.mdx';
2+
13
## Key Concepts
24

35
The keys to integrating React Native components into your iOS application are to:
@@ -152,6 +154,8 @@ Pod installation complete! There are 3 dependencies from the Podfile and 1 total
152154
153155
> If you get a warning such as "_The `swift-2048 [Debug]` target overrides the `FRAMEWORK_SEARCH_PATHS` build setting defined in `Pods/Target Support Files/Pods-swift-2048/Pods-swift-2048.debug.xcconfig`. This can lead to problems with the CocoaPods installation_", then make sure the `Framework Search Paths` in `Build Settings` for both `Debug` and `Release` only contain `$(inherited)`.
154156
157+
<M1Cocoapods />
158+
155159
### Code integration
156160

157161
Now we will actually modify the native iOS application to integrate React Native. For our 2048 sample app, we will add a "High Score" screen in React Native.
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<details>
2+
<summary>Note for Mac M1 users</summary>
3+
4+
Mac M1 architecture is not directly compatible with Cocoapods. If you encounter issues when installing pods, you can solve it by running:
5+
6+
- `sudo arch -x86_64 gem install ffi`
7+
- `arch -x86_64 pod install`
8+
9+
These commands install the `ffi` package, to load dynamically-linked libraries and let you run the `pod install` properly, and runs `pod install` with the proper architecture.
10+
11+
</details>

‎docs/hermes.md‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ id: hermes
33
title: Using Hermes
44
---
55

6+
import M1Cocoapods from './\_markdown-m1-cocoapods.mdx';
7+
68
<a href="https://hermesengine.dev">
79
<img width={300} height={300} style={{float: 'right', margin: '-30px 4px 0'}} src="/docs/assets/HermesLogo.svg" />
810
</a>
@@ -77,6 +79,8 @@ Next, install the Hermes pods:
7779
$ cd ios && pod install
7880
```
7981

82+
<M1Cocoapods />
83+
8084
That's it! You should now be able to develop and deploy your app as usual:
8185

8286
```shell

‎docs/libraries.md‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ authorURL: 'https://twitter.com/notbrent'
66
description: This guide introduces React Native developers to finding, installing, and using third-party libraries in their apps.
77
---
88

9-
import Tabs from '@theme/Tabs'; import TabItem from '@theme/TabItem'; import constants from '@site/core/TabsConstants';
9+
import Tabs from '@theme/Tabs'; import TabItem from '@theme/TabItem'; import constants from '@site/core/TabsConstants'; import M1Cocoapods from './\_markdown-m1-cocoapods.mdx';
1010

1111
React Native provides a set of built-in [Core Components and APIs](./components-and-apis) ready to use in your app. You're not limited to the components and APIs bundled with React Native. React Native has a community of thousands of developers. If the Core Components and APIs don't have what you are looking for, you may be able to find and install a library from the community to add the functionality to your app.
1212

@@ -51,6 +51,8 @@ Run `pod install` in our `ios` directory in order to link it to our native iOS p
5151
npx pod-install
5252
```
5353

54+
<M1Cocoapods />
55+
5456
Once this is complete, re-build the app binary to start using your new library:
5557

5658
```bash

‎docs/navigation.md‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ id: navigation
33
title: Navigating Between Screens
44
---
55

6+
import M1Cocoapods from './\_markdown-m1-cocoapods.mdx';
7+
68
Mobile apps are rarely made up of a single screen. Managing the presentation of, and transition between, multiple screens is typically handled by what is known as a navigator.
79

810
This guide covers the various navigation components available in React Native. If you are getting started with navigation, you will probably want to use [React Navigation](navigation.md#react-navigation). React Navigation provides a straightforward navigation solution, with the ability to present common stack navigation and tabbed navigation patterns on both Android and iOS.
@@ -45,6 +47,8 @@ Next, install the required peer dependencies. You need to run different commands
4547

4648
> Note: You might get warnings related to peer dependencies after installation. They are usually caused by incorrect version ranges specified in some packages. You can safely ignore most warnings as long as your app builds.
4749
50+
<M1Cocoapods />
51+
4852
Now, you need to wrap the whole app in `NavigationContainer`. Usually you'd do this in your entry file, such as `index.js` or `App.js`:
4953

5054
```jsx

‎docs/new-architecture-app-renderer-ios.md‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ id: new-architecture-app-renderer-ios
33
title: Enabling Fabric on iOS
44
---
55

6+
import M1Cocoapods from './\_markdown-m1-cocoapods.mdx';
7+
68
:::caution
79

810
This documentation is still **experimental** and details are subject to changes as we iterate. Feel free to share your feedback on the [react-native-website PR](https://github.com/facebook/react-native-website) for this page.
@@ -22,18 +24,14 @@ Add changes to your Podfile. You can see some examples in [RNTester](https://git
2224
# Codegen produces files/classes that share names, and it will show the warning.
2325
# deterministic_uuids option surpresses the warning.
2426
install! 'cocoapods', :deterministic_uuids => false
25-
2627
target 'Some App' do
2728
pods()
2829
end
29-
3030
def pods()
3131
# Get config
3232
config = use_native_modules!
33-
3433
# Use env variables to turn it on/off.
3534
fabric_enabled = ENV['USE_FABRIC']
36-
3735
use_react_native!(
3836
...
3937
# Modify here if your app root path isn't the same as this one.
@@ -110,3 +108,5 @@ module.exports = {
110108
// Run pod install with the flags
111109
USE_FABRIC=1 RCT_NEW_ARCH_ENABLED=1 pod install
112110
```
111+
112+
<M1Cocoapods />

‎docs/new-architecture-library-intro.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ On iOS, this generally requires your library to provide a Podspec (see [`react-n
9494
9595
:::info
9696
97-
To determine if your library is set up for autolinking, check the CocoaPods output after running `pod install` on an iOS project. If you see "auto linking library name", you are all set to go.
97+
To determine if your library is set up for autolinking, check the CocoaPods output after running `pod install` (or `arch -x86_64 pod install` in case of a Mac M1) on an iOS project. If you see "auto linking library name", you are all set to go.
9898
9999
:::
100100

‎docs/new-architecture-library-ios.md‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ id: new-architecture-library-ios
33
title: Enabling in iOS Library
44
---
55

6+
import M1Cocoapods from './\_markdown-m1-cocoapods.mdx';
7+
68
:::caution
79

810
This documentation is still **experimental** and details are subject to changes as we iterate. Feel free to share your feedback on the [react-native-website PR](https://github.com/facebook/react-native-website) for this page.
@@ -52,6 +54,8 @@ end
5254

5355
Currently, the Folly version used here must match the Folly version used by React Native. A version mismatch here may lead to errors when running `pod install`. If CocoaPods flags an issue with your Folly version, then you may have a version mismatch. Check which version is used by the core modules Podspecs (e.g. FBReactNativeSpec.podspec), and try running `pod install` again after editing your podspec with the correct Folly version.
5456

57+
<M1Cocoapods />
58+
5559
:::
5660

5761
### Enable codegen in your `package.json`

0 commit comments

Comments
 (0)