Skip to content

Commit 3c3a9b3

Browse files
author
Rad Azzouz
committed
Updare integration steps
1 parent c023294 commit 3c3a9b3

File tree

6 files changed

+71
-165
lines changed

6 files changed

+71
-165
lines changed

README.md

Lines changed: 71 additions & 49 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.2
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,54 +42,79 @@ 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)
66-
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:
68-
![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.)
45+
7. Open `ios/Podile` in a text editor: `open ios/Podfile`, update the platform to iOS 11, and add your CocoaPods URL.
46+
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. Go back to the Terminal, `cd ios` then run `pod install`
87+
9. Open `ios/YourApp.xcworkspace` in Xcode: `open ios/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+
93+
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:
94+
![Adding PDF](../screenshots/adding-pdf.png)
95+
13. Replace the default component from `index.ios.js` with a simple touch area to present the bundled PDF:
7096

7197
```javascript
72-
import React, { Component } from "react";
98+
import React, { Component } from 'react';
7399
import {
74100
AppRegistry,
75101
StyleSheet,
76102
NativeModules,
77103
Text,
78104
TouchableHighlight,
79105
View
80-
} from "react-native";
106+
} from 'react-native';
81107

82108
const PSPDFKit = NativeModules.PSPDFKit;
83-
PSPDFKit.setLicenseKey("YOUR_LICENSE_KEY_GOES_HERE");
84109

85-
export default class App extends Component<Props> {
110+
PSPDFKit.setLicenseKey('INSERT_YOUR_LICENSE_KEY_HERE');
111+
112+
// Change 'YourApp' to your app's name.
113+
export default class YourApp extends Component<Props> {
86114
_onPressButton() {
87-
PSPDFKit.present("document.pdf", {
88-
pageTransition: "scrollContinuous",
89-
scrollDirection: "vertical",
90-
documentLabelEnabled: true
91-
});
115+
PSPDFKit.present('document.pdf', {})
92116
}
93-
117+
94118
render() {
95119
return (
96120
<View style={styles.container}>
@@ -105,21 +129,19 @@ export default class App extends Component<Props> {
105129
const styles = StyleSheet.create({
106130
container: {
107131
flex: 1,
108-
justifyContent: "center",
109-
alignItems: "center",
110-
backgroundColor: "#F5FCFF"
132+
justifyContent: 'center',
133+
alignItems: 'center',
134+
backgroundColor: '#F5FCFF',
111135
},
112-
welcome: {
136+
text: {
113137
fontSize: 20,
114-
textAlign: "center",
115-
margin: 10
116-
},
117-
instructions: {
118-
textAlign: "center",
119-
color: "#333333",
120-
marginBottom: 5
138+
textAlign: 'center',
139+
margin: 10,
121140
}
122141
});
142+
143+
// Change both 'YourApp's to your app's name.
144+
AppRegistry.registerComponent('YourApp', () => YourApp);
123145
```
124146

125147
Your app is now ready to launch. Run the app in Xcode or type `react-native run-ios` in the terminal.

ios/cocoapods.md

Lines changed: 0 additions & 116 deletions
This file was deleted.
-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)