-
-
Notifications
You must be signed in to change notification settings - Fork 197
Cocoapods.md #914
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Cocoapods.md #914
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
# Using CocoaPods | ||
|
||
When you develop for iOS, you can quickly add third-party libraries to your NativeScript projects via the [CocoaPods](https://cocoapods.org/) dependency manager. | ||
|
||
To work with such libraries, you need to wrap them as a custom NativeScript plugin and add them to your project. | ||
|
||
* [Install CocoaPods](#install-cocoapods) | ||
* [Create CLI Project](#create-cli-project) | ||
* [Wrap the Library as NativeScript Plugin](#wrap-the-library-as-nativescript-plugin) | ||
* [Build the Project](#build-the-project) | ||
|
||
## Install CocoaPods | ||
You need to install CocoaPods. If you haven't yet, you can do so by running: | ||
|
||
``` | ||
$ sudo gem install cocoapods | ||
``` | ||
> **NOTE:** All operations and code in this article are verified against CocoaPods 0.38.2. | ||
|
||
To check your current version, run the following command. | ||
|
||
``` | ||
$ pod --version | ||
``` | ||
|
||
To update CocoaPods, just run the installation command again. | ||
|
||
``` | ||
sudo gem install cocoapods | ||
``` | ||
|
||
## Create CLI Project | ||
To start, create a project and add the iOS platform. | ||
|
||
```bash | ||
$ tns create MYCocoaPods | ||
$ cd MYCocoaPods | ||
$ tns platform add ios | ||
``` | ||
|
||
## Wrap the Library as NativeScript Plugin | ||
|
||
For more information about working with NativeScript plugins, click [here](PLUGINS.md). | ||
|
||
``` | ||
cd .. | ||
mkdir my-plugin | ||
cd my-plugin | ||
``` | ||
|
||
Create a package.json file with the following content: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Didn't the |
||
|
||
``` | ||
{ | ||
"name": "myplugin", | ||
"version": "0.0.1", | ||
"nativescript": { | ||
"platforms": { | ||
"ios": "1.3.0" | ||
} | ||
} | ||
} | ||
``` | ||
|
||
Create a [Podfile](https://guides.cocoapods.org/syntax/podfile.html) which describes the dependency to the library that you want to use. Move it to the `platforms/ios` folder. | ||
|
||
``` | ||
my-plugin/ | ||
├── package.json | ||
└── platforms/ | ||
└── ios/ | ||
└── Podfile | ||
``` | ||
|
||
Next, install the plugin: | ||
|
||
``` | ||
tns plugin add ../my-plugin | ||
``` | ||
|
||
## Build the project | ||
|
||
``` | ||
tns build ios | ||
``` | ||
|
||
This modifies the `MYCocoaPods.xcodeproj` and creates a workspace with the same name. | ||
|
||
> **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. |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You might need an empty line before this one for proper rendering. (This applies to all code blocks.)