You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When you develop for iOS, you can quickly add third party libraries to your NativeScript projects via [CocoaPods](https://cocoapods.org/), a dependency manager for third-party projects.
4
+
5
+
*[Install CocoaPods](#install-cocoapods)
6
+
*[Create CLI Project](#create-cli-project)
7
+
*[Create NativeScript plugin with Podfile](#create-nativescript-plugin-with-podfile)
8
+
*[Build the Project](#build-the-project)
9
+
10
+
## Install CocoaPods
11
+
You need to install CocoaPods. If you haven't yet, you can do so by running:
12
+
```
13
+
$ sudo gem install cocoapods
14
+
```
15
+
> **NOTE:** All operations and code in this article are verified against CocoaPods 0.38.2.
16
+
17
+
You can check your current version using:
18
+
```
19
+
$ pod --version
20
+
```
21
+
22
+
To update CocoaPods just install the gem again with:
23
+
```
24
+
sudo gem install cocoapods
25
+
```
26
+
27
+
## Create CLI Project
28
+
To start, create a project, add the iOS platform.
29
+
```bash
30
+
$ tns create MYCocoaPods
31
+
$ cd MYCocoaPods
32
+
$ tns platform add ios
33
+
```
34
+
35
+
## Create NativeScript plugin with Podfile
36
+
37
+
For more information see [NativeScript plugins](#PLUGINS.md)
38
+
39
+
```
40
+
cd ..
41
+
mkdir my-plugin
42
+
cd my-plugin
43
+
touch package.json
44
+
```
45
+
46
+
Create a package.json file with the following content:
47
+
```
48
+
{
49
+
"name": "myplugin",
50
+
"version": "0.0.1",
51
+
"nativescript": {
52
+
"platforms": {
53
+
"ios": "1.3.0"
54
+
}
55
+
}
56
+
}
57
+
```
58
+
59
+
Create a [Podfile](https://guides.cocoapods.org/syntax/podfile.html) and move it to platforms/ios folder.
60
+
61
+
```
62
+
my-plugin/
63
+
├── package.json
64
+
└── platforms/
65
+
└── ios/
66
+
└── Podfile
67
+
```
68
+
69
+
Next install the plugin:
70
+
```
71
+
tns plugin add ../my-plugin
72
+
```
73
+
74
+
## Build the project
75
+
```
76
+
tns build ios
77
+
```
78
+
79
+
This modifies the `MYCocoaPods.xcodeproj` and creates a workspace with the same name.
80
+
81
+
> **IMPORTANT:** You will no longer be able to run the `xcodeproj` alone. {N} CLI will build the newly created workspace and produce correct .ipa.
0 commit comments