Skip to content
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

Fix CocoaPods integration #235

Merged
merged 5 commits into from
Jun 19, 2019
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ The [PSPDFKit SDK](https://pspdfkit.com/) is a framework that allows you to view

#### Requirements

- Xcode 10.2
- PSPDFKit 8.2.3 for iOS or later
- react-native >= 0.57.8
- Xcode 10.2.1
- PSPDFKit 8.4.0 for iOS or later
- react-native >= 0.59.9

#### Getting Started

Expand Down Expand Up @@ -79,10 +79,10 @@ import {
View
} from "react-native";

var PSPDFKit = NativeModules.PSPDFKit;
const PSPDFKit = NativeModules.PSPDFKit;
PSPDFKit.setLicenseKey("YOUR_LICENSE_KEY_GOES_HERE");

export default class App extends Component<{}> {
export default class App extends Component<Props> {
_onPressButton() {
PSPDFKit.present("document.pdf", {
pageTransition: "scrollContinuous",
Expand Down
14 changes: 12 additions & 2 deletions ios/RCTPSPDFKit.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,11 @@
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
CLANG_WARN_SUSPICIOUS_MOVES = YES;
DEBUG_INFORMATION_FORMAT = dwarf;
FRAMEWORK_SEARCH_PATHS = (
"$(PROJECT_DIR)/../PSPDFKit",
"$(PROJECT_DIR)/../../../ios/PSPDFKit",
"$(PROJECT_DIR)/../../../ios/Pods/PSPDFKit",
);
OTHER_LDFLAGS = "-ObjC";
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
Expand All @@ -209,6 +214,11 @@
CLANG_WARN_SUSPICIOUS_MOVES = YES;
COPY_PHASE_STRIP = NO;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
FRAMEWORK_SEARCH_PATHS = (
"$(PROJECT_DIR)/../PSPDFKit",
"$(PROJECT_DIR)/../../../ios/PSPDFKit",
"$(PROJECT_DIR)/../../../ios/Pods/PSPDFKit",
);
OTHER_LDFLAGS = "-ObjC";
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
Expand Down Expand Up @@ -272,7 +282,7 @@
"$(SRCROOT)/../../react-native/React/**",
"$(SRCROOT)/../samples/Catalog/node_modules/react-native/React/**",
);
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
Expand Down Expand Up @@ -329,7 +339,7 @@
"$(SRCROOT)/../../react-native/React/**",
"$(SRCROOT)/../samples/Catalog/node_modules/react-native/React/**",
);
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
VALIDATE_PRODUCT = YES;
Expand Down
49 changes: 22 additions & 27 deletions ios/cocoapods.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
### CocoaPods integration

#### Requirements
- Xcode 10.1
- PSPDFKit 8.1.3 for iOS or later
- react-native >= 0.57.8
- CocoaPods >= 1.5.3
- Xcode 10.2.1
- PSPDFKit 8.4.0 for iOS or later
- react-native >= 0.59.9
- CocoaPods >= 1.7.2

#### Getting Started

Expand All @@ -15,23 +15,25 @@ Lets create a simple app that integrates PSPDFKit using CocoaPods.
1. Make sure `react-native-cli` is installed: `yarn global add react-native-cli`
2. Create the app with `react-native init YourApp`.
3. Step into your newly created app folder: `cd YourApp`
4. Install `react-native-pspdfkit` from GitHub: `yarn add github:PSPDFKit/react-native`
5. IMPORTANT: Do not link module react-native-pspdfkit: Do not use react-native link react-native-pspdfkit
6. Create the folder `ios/PSPDFKit` and copy `PSPDFKit.framework` and `PSPDFKitUI.framework` into it.
4. Install `react-native-pspdfkit` from GitHub: `yarn add https://github.com/PSPDFKit/react-native.git#rad/fix-cocoapods-integration`
5. Install all the dependencies for the project: `yarn install`. (Because of a [bug](https://github.com/yarnpkg/yarn/issues/2165) you may need to clean `yarn`'s cache with `yarn cache clean` before.)
6. Link module `react-native-pspdfkit`: `react-native link react-native-pspdfkit`.
7. Open ios/YourApp.xcodeproj in Xcode: open ios/YourApp.xcodeproj
8. Make sure the deployment target is set to 10.0 or higher:
8. Make sure the deployment target is set to 11.0 or higher:
![Deployment Target](../screenshots/deployment-target.png)
9. Change "View controller-based status bar appearance" to YES in Info.plist:
deployment-target.png
10. Close the Xcode project
11. Go back to the Terminal, `cd ios` then run `pod init`
12. Replace the content of your newly created `Podfile` with this:
9. Change "View controller-based status bar appearance" to `YES` in `Info.plist`:
![View Controller-Based Status Bar Appearance](../screenshots/view-controller-based-status-bar-appearance.png)
10. Link with the `libRCTPSPDFKit.a` static library (if `libRCTPSPDFKit.a` is already there but greyed out, delete it and link it again):
![Linking Static Library](../screenshots/linking-static-library.png)
11. Close the Xcode project
12. Go back to the Terminal, `cd ios` then run `pod init`
13. Replace the content of your newly created `Podfile` with this:

```podfile
target 'YourApp' do
use_frameworks!

pod 'react-native-pspdfkit', :path => '../node_modules/react-native-pspdfkit'
pod 'PSPDFKit', podspec: 'https://customers.pspdfkit.com/cocoapods/YOUR_COCOAPODS_KEY_GOES_HERE/pspdfkit/latest.podspec'

# Your 'node_modules' directory is probably in the root of your project,
# but if not, adjust the `:path` accordingly
Expand All @@ -55,18 +57,11 @@ target 'YourApp' do
end
```

13. Run `pod install`
14. Open the newly created workspace: `YourApp.workspace`
15. Copy `PSPDFKit.framework` and `PSPDFKitUI.framework` into the Pods folder: `YourApp/ios/Pods`
16. Drag and drop it from the Finder into the `RCTPSPDFKit` group:
![Deployment Target](../screenshots/embedding-pspdfkit-pods.png)
17. Add it to the `react-native-pspdfkit` framework:
![Deployment Target](../screenshots/adding-to-react-native-pspdfkit.png)
18. Embed `YourApp/ios/PSPDFKit/PSPDFKit.framework` and `YourApp/ios/PSPDFKit/PSPDFKitUI.framework` (not the copies from `YourApp/ios/Pods/`) by drag and dropping it into the "Embedded Binaries" section of the "YourApp" target (Select "Create groups"). This will also add it to the "Linked Frameworks and Libraries" section:
![Embedding PSPDFKit](../screenshots/embedding-pspdfkit.png)
19. Add a PDF by drag and dropping it into your Xcode project (Select "Create groups" and add to target "YourApp"). This will add the document to the "Copy Bundle Resources" build phase:
14. Run `pod install`
15. Open the newly created workspace: `YourApp.workspace`
16. Add a PDF by drag and dropping it into your Xcode project (Select "Create groups" and add to target "YourApp"). This will add the document to the "Copy Bundle Resources" build phase:
![Adding PDF](../screenshots/adding-pdf.png)
20. Replace the default component from `index.ios.js` with a simple touch area to present the bundled PDF:
17. Replace the default component from `index.ios.js` with a simple touch area to present the bundled PDF:

```javascript
import React, { Component } from 'react';
Expand All @@ -79,12 +74,12 @@ import {
View
} from 'react-native';

var PSPDFKit = NativeModules.PSPDFKit;
const PSPDFKit = NativeModules.PSPDFKit;

PSPDFKit.setLicenseKey('INSERT_YOUR_LICENSE_KEY_HERE');

// Change 'YourApp' to your app's name.
class YourApp extends Component {
export default class YourApp extends Component<Props> {
_onPressButton() {
PSPDFKit.present('document.pdf', {})
}
Expand Down
Binary file removed screenshots/embedding-pspdfkit-pods.png
Binary file not shown.