Skip to content

Commit 31fc200

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

File tree

1 file changed

+83
-0
lines changed

1 file changed

+83
-0
lines changed

CocoaPods.md

+83
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
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 Swift and Objective-C Cocoa projects.
4+
5+
## Table of Contents
6+
* [Install CocoaPods](#install-cocoapods)
7+
* [Create CLI Project](#create-cli-project)
8+
* [Create NativeScript plugin with Podfile](#create-nativescript-plugin-with-podfile)
9+
* [Build the Project](#build-the-project)
10+
11+
## Install CocoaPods
12+
You need to install CocoaPods. If you haven't yet, you can do so by:
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+
You can check your current version using:
19+
```
20+
$ pod --version
21+
```
22+
23+
To update CocoaPods just install the gem again with:
24+
```
25+
sudo gem install cocoapods
26+
```
27+
28+
## Create CLI Project
29+
To start, create a project, add the iOS platform.
30+
```bash
31+
$ tns create MYCocoaPods
32+
$ cd MYCocoaPods
33+
$ tns platform add ios
34+
```
35+
36+
## Create NativeScript plugin with Podfile
37+
38+
For more information see [NativeScript plugins](#PLUGINS.md)
39+
40+
```
41+
cd ..
42+
mkdir my-plugin
43+
cd my-plugin
44+
touch package.json
45+
```
46+
47+
Create a package.json file with the following content:
48+
```
49+
{
50+
"name": "myplugin",
51+
"version": "0.0.1",
52+
"nativescript": {
53+
"platforms": {
54+
"ios": "1.3.0"
55+
}
56+
}
57+
}
58+
```
59+
60+
Create a [Podfile](https://guides.cocoapods.org/syntax/podfile.html) and move it to platforms/ios folder.
61+
62+
```
63+
my-plugin/
64+
├── package.json
65+
└── platforms/
66+
└── ios/
67+
└── Podfile
68+
```
69+
70+
Next install the plugin:
71+
```
72+
tns plugin add ../my-plugin
73+
```
74+
75+
## Build the project
76+
```
77+
tns build ios
78+
```
79+
80+
This modifies the `MYCocoaPods.xcodeproj` and creates a workspace with the same name.
81+
82+
> **IMPORTANT:** You will no longer be able to run the `xcodeproj` alone. {N} CLI will build the newly created workspace and produce correct .ipa.
83+

0 commit comments

Comments
 (0)