Skip to content

Commit 0fb1fce

Browse files
authored
Merge pull request #257 from PSPDFKit/rad/cocoapods-integration
Update Integration Steps to use CocoaPods by default starting with React Native 0.60.x
2 parents 610e292 + 7d12fc4 commit 0fb1fce

File tree

10 files changed

+67
-160
lines changed

10 files changed

+67
-160
lines changed

README.md

Lines changed: 61 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,12 @@ The [PSPDFKit SDK](https://pspdfkit.com/) is a framework that allows you to view
2828
#### Requirements
2929

3030
- Xcode 10.2.1
31-
- PSPDFKit 8.4.0 for iOS or later
32-
- react-native >= 0.59.9
31+
- PSPDFKit 8.4.2 for iOS or later
32+
- react-native >= 0.60.3
33+
- CocoaPods >= 1.7.4
3334

3435
#### Getting Started
3536

36-
**Note:** If you want to integrate PSPDFKit using CocoaPods, use [these instructions](ios/cocoapods.md) instead.
37-
3837
Let's create a simple app that integrates PSPDFKit and uses the `react-native-pspdfkit` module.
3938

4039
1. Make sure `react-native-cli` is installed: `yarn global add react-native-cli`
@@ -43,30 +42,56 @@ Let's create a simple app that integrates PSPDFKit and uses the `react-native-ps
4342
4. Install `react-native-pspdfkit` from GitHub: `yarn add github:PSPDFKit/react-native`
4443
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.)
4544
6. Link module `react-native-pspdfkit`: `react-native link react-native-pspdfkit`.
46-
7. Create the folder `ios/PSPDFKit` and copy `PSPDFKit.framework` and `PSPDFKitUI.framework` into it.
47-
8. Open `ios/YourApp.xcodeproj` in Xcode: `open ios/YourApp.xcodeproj`
48-
9. Make sure the deployment target is set to 11.0 or higher:
49-
![Deployment Target](screenshots/deployment-target.png)
50-
10. Change "View controller-based status bar appearance" to `YES` in `Info.plist`:
51-
![View Controller-Based Status Bar Appearance](screenshots/view-controller-based-status-bar-appearance.png)
52-
11. Link with the `libRCTPSPDFKit.a` static library (if `libRCTPSPDFKit.a` is already there but greyed out, delete it and link it again):
53-
![Linking Static Library](screenshots/linking-static-library.png)
54-
12. Embed `PSPDFKit.framework` and `PSPDFKitUI.framework` 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 Framworks and Libraries" section:
55-
![Embedding PSPDFKit](screenshots/embedding-pspdfkit.png)
56-
13. Add a new `Run Script Phase` in your target’s `Build Phases`.
57-
**IMPORTANT:** Make sure this `Run Script Phase` is below the `Embed Frameworks` build phase.
58-
You can drag and drop build phases to rearrange them.
59-
Paste the following line in the script text field of `Run Script Phase`:
60-
61-
```sh
62-
bash "$BUILT_PRODUCTS_DIR/$FRAMEWORKS_FOLDER_PATH/PSPDFKit.framework/strip-framework.sh"
63-
```
64-
65-
![Run Script Phase](screenshots/run-script-phase.png)
45+
7. Open `ios/Podile` in a text editor: `open ios/Podfile`, update the platform to iOS 11, and add your CocoaPods URL.
6646

67-
14. 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:
47+
```diff
48+
- platform :ios, '9.0'
49+
+ platform :ios, '11.0'
50+
require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules'
51+
52+
target 'YourApp' do
53+
# Pods for YourApp
54+
pod 'React', :path => '../node_modules/react-native/'
55+
pod 'React-Core', :path => '../node_modules/react-native/React'
56+
pod 'React-DevSupport', :path => '../node_modules/react-native/React'
57+
pod 'React-fishhook', :path => '../node_modules/react-native/Libraries/fishhook'
58+
pod 'React-RCTActionSheet', :path => '../node_modules/react-native/Libraries/ActionSheetIOS'
59+
pod 'React-RCTAnimation', :path => '../node_modules/react-native/Libraries/NativeAnimation'
60+
pod 'React-RCTBlob', :path => '../node_modules/react-native/Libraries/Blob'
61+
pod 'React-RCTImage', :path => '../node_modules/react-native/Libraries/Image'
62+
pod 'React-RCTLinking', :path => '../node_modules/react-native/Libraries/LinkingIOS'
63+
pod 'React-RCTNetwork', :path => '../node_modules/react-native/Libraries/Network'
64+
pod 'React-RCTSettings', :path => '../node_modules/react-native/Libraries/Settings'
65+
pod 'React-RCTText', :path => '../node_modules/react-native/Libraries/Text'
66+
pod 'React-RCTVibration', :path => '../node_modules/react-native/Libraries/Vibration'
67+
pod 'React-RCTWebSocket', :path => '../node_modules/react-native/Libraries/WebSocket'
68+
69+
pod 'React-cxxreact', :path => '../node_modules/react-native/ReactCommon/cxxreact'
70+
pod 'React-jsi', :path => '../node_modules/react-native/ReactCommon/jsi'
71+
pod 'React-jsiexecutor', :path => '../node_modules/react-native/ReactCommon/jsiexecutor'
72+
pod 'React-jsinspector', :path => '../node_modules/react-native/ReactCommon/jsinspector'
73+
pod 'yoga', :path => '../node_modules/react-native/ReactCommon/yoga'
74+
75+
pod 'DoubleConversion', :podspec => '../node_modules/react-native/third-party-podspecs/DoubleConversion.podspec'
76+
pod 'glog', :podspec => '../node_modules/react-native/third-party-podspecs/glog.podspec'
77+
pod 'Folly', :podspec => '../node_modules/react-native/third-party-podspecs/Folly.podspec'
78+
79+
pod 'react-native-pspdfkit', :path => '../node_modules/react-native-pspdfkit'
80+
+ pod 'PSPDFKit', podspec: 'https://customers.pspdfkit.com/cocoapods/YOUR_COCOAPODS_KEY_GOES_HERE/pspdfkit/latest.podspec'
81+
82+
use_native_modules!
83+
end
84+
```
85+
86+
8. `cd ios` then run `pod install`.
87+
9. Open `YourApp.xcworkspace` in Xcode: `open YourApp.xcworkspace`.
88+
10. Make sure the deployment target is set to 11.0 or higher:
89+
![Deployment Target](screenshots/deployment-target.png)
90+
11. Change "View controller-based status bar appearance" to `YES` in `Info.plist`:
91+
![View Controller-Based Status Bar Appearance](screenshots/view-controller-based-status-bar-appearance.png)
92+
12. 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:
6893
![Adding PDF](screenshots/adding-pdf.png)
69-
15. Replace the default component from `App.js` with a simple touch area to present the bundled PDF. (Note that you can also use a [Native UI Component](#native-ui-component) to show a PDF.)
94+
13. Replace the default component from `App.js` with a simple touch area to present the bundled PDF. (Note that you can also use a [Native UI Component](#native-ui-component) to show a PDF.)
7095

7196
```javascript
7297
import React, { Component } from "react";
@@ -80,15 +105,13 @@ import {
80105
} from "react-native";
81106

82107
const PSPDFKit = NativeModules.PSPDFKit;
83-
PSPDFKit.setLicenseKey("YOUR_LICENSE_KEY_GOES_HERE");
84108

85-
export default class App extends Component<Props> {
109+
PSPDFKit.setLicenseKey("INSERT_YOUR_LICENSE_KEY_HERE");
110+
111+
// Change 'YourApp' to your app's name.
112+
export default class YourApp extends Component<Props> {
86113
_onPressButton() {
87-
PSPDFKit.present("document.pdf", {
88-
pageTransition: "scrollContinuous",
89-
scrollDirection: "vertical",
90-
documentLabelEnabled: true
91-
});
114+
PSPDFKit.present("document.pdf", {});
92115
}
93116

94117
render() {
@@ -109,20 +132,18 @@ const styles = StyleSheet.create({
109132
alignItems: "center",
110133
backgroundColor: "#F5FCFF"
111134
},
112-
welcome: {
135+
text: {
113136
fontSize: 20,
114137
textAlign: "center",
115138
margin: 10
116-
},
117-
instructions: {
118-
textAlign: "center",
119-
color: "#333333",
120-
marginBottom: 5
121139
}
122140
});
141+
142+
// Change both 'YourApp's to your app's name.
143+
AppRegistry.registerComponent("YourApp", () => YourApp);
123144
```
124145

125-
Your app is now ready to launch. Run the app in Xcode or type `react-native run-ios` in the terminal.
146+
Your app is now ready to launch. Run the app in Xcode or go back to the Terminal, then run `cd ..`, and `react-native run-ios`.
126147

127148
### Usage
128149

ios/cocoapods.md

Lines changed: 0 additions & 116 deletions
This file was deleted.

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-native-pspdfkit",
3-
"version": "1.24.6",
3+
"version": "1.24.7",
44
"description": "A React Native module for the PSPDFKit library.",
55
"keywords": [
66
"react native",

react-native-pspdfkit.podspec

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,12 @@ Pod::Spec.new do |s|
99
s.authors = ["PSPDFKit"]
1010
s.homepage = "https://github.com/PSPDFKit/react-native#readme"
1111
s.license = package['license']
12-
s.platform = :ios, "10.0"
12+
s.platform = :ios, "11.0"
1313
s.module_name = 'PSPDFKitReactNativeiOS'
1414
s.source = { :git => "https://github.com/PSPDFKit/react-native" }
1515
s.source_files = "ios/*.{xcodeproj}", "ios/RCTPSPDFKit/*.{h,m,swift}", "ios/RCTPSPDFKit/Converters/*.{h,m,swift}"
1616
s.dependency 'React'
17+
s.dependency 'PSPDFKit'
1718
s.frameworks = 'UIKit'
19+
s.xcconfig = { 'FRAMEWORK_SEARCH_PATHS' => '/PSPDFKit/' }
1820
end

samples/Catalog/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "Catalog",
3-
"version": "1.24.6",
3+
"version": "1.24.7",
44
"private": true,
55
"scripts": {
66
"start": "node node_modules/react-native/local-cli/cli.js start"
-83.4 KB
Binary file not shown.

screenshots/embedding-pspdfkit.png

-357 KB
Binary file not shown.
-491 KB
Binary file not shown.

screenshots/run-script-phase.png

-237 KB
Binary file not shown.

0 commit comments

Comments
 (0)