Skip to content

Commit d9ee6e5

Browse files
Fatme HavaluovaFatme Havaluova
Fatme Havaluova
authored and
Fatme Havaluova
committed
Cocoapods.md
1 parent a58717e commit d9ee6e5

File tree

1 file changed

+87
-0
lines changed

1 file changed

+87
-0
lines changed

CocoaPods.md

+87
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
# Using CocoaPods
2+
3+
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+
```
14+
$ sudo gem install cocoapods
15+
```
16+
> **NOTE:** All operations and code in this article are verified against CocoaPods 0.38.2.
17+
18+
To check your current version, run the following command.
19+
20+
```
21+
$ pod --version
22+
```
23+
24+
To update CocoaPods, just run the installation command again.
25+
```
26+
sudo gem install cocoapods
27+
```
28+
29+
## Create CLI Project
30+
To start, create a project and add the iOS platform.
31+
32+
```bash
33+
$ tns create MYCocoaPods
34+
$ cd MYCocoaPods
35+
$ tns platform add ios
36+
```
37+
38+
## Create NativeScript plugin with Podfile
39+
40+
For more information about working with NativeScript plugins, click here: [NativeScript plugins](#PLUGINS.md)
41+
42+
```
43+
cd ..
44+
mkdir my-plugin
45+
cd my-plugin
46+
```
47+
48+
Create a package.json file with the following content:
49+
50+
```
51+
{
52+
"name": "myplugin",
53+
"version": "0.0.1",
54+
"nativescript": {
55+
"platforms": {
56+
"ios": "1.3.0"
57+
}
58+
}
59+
}
60+
```
61+
62+
Create a [Podfile](https://guides.cocoapods.org/syntax/podfile.html) and move it to platforms/ios folder.
63+
64+
```
65+
my-plugin/
66+
├── package.json
67+
└── platforms/
68+
└── ios/
69+
└── Podfile
70+
```
71+
72+
Next, install the plugin:
73+
74+
```
75+
tns plugin add ../my-plugin
76+
```
77+
78+
## Build the project
79+
80+
```
81+
tns build ios
82+
```
83+
84+
This modifies the `MYCocoaPods.xcodeproj` and creates a workspace with the same name.
85+
86+
> **IMPORTANT:** You will no longer be able to run the `xcodeproj` alone. NativeScript CLI will build the newly created workspace and produce the correct .ipa.
87+

0 commit comments

Comments
 (0)