Skip to content

Commit 584d491

Browse files
author
Rad Azzouz
committed
Updated cocoapods.md
1 parent 42d1702 commit 584d491

File tree

1 file changed

+76
-76
lines changed

1 file changed

+76
-76
lines changed

ios/cocoapods.md

Lines changed: 76 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,42 @@
1-
Integrate PSPDFKit for React Native on iOS using CocoaPods
2-
3-
4-
1. Create the app with react-native init YourApp.
5-
2. Step into your newly created app folder: cd YourApp
6-
3. Install react-native-pspdfkit from GitHub: yarn add github:PSPDFKit/react-native#rad/podspec (#rad/podspec is temporary, as the change is only on that branch)
7-
4. IMPORTANT: Do not link module react-native-pspdfkit: Do not use react-native link react-native-pspdfkit
8-
5. Create the folder PSPDFKit and copy PSPDFKit.framework into it.
9-
6. Open ios/YourApp.xcodeproj in Xcode: open ios/YourApp.xcodeproj
10-
7. Make sure the deployment target is set to 9.0 or higher:
1+
## PSPDFKit for React Native
2+
3+
### CocoaPods integration
4+
5+
#### Requirements
6+
- Xcode 8.3.3
7+
- PSPDFKit >=6.8
8+
- react-native >= 0.46.4
9+
- CocoaPods >= 1.2.1
10+
11+
#### Getting Started
12+
13+
Lets create a simple app that integrates `PSPDFKit.framework` using CocoaPods.
14+
15+
1. Make sure `react-native-cli` is installed: `yarn global add react-native-cli`
16+
2. Create the app with `react-native init YourApp`.
17+
3. Step into your newly created app folder: `cd YourApp`
18+
4. Install `react-native-pspdfkit` from GitHub: `yarn add github:PSPDFKit/react-native`
19+
5. IMPORTANT: Do not link module react-native-pspdfkit: Do not use react-native link react-native-pspdfkit
20+
6. Create the folder `ios/PSPDFKit` and copy `PSPDFKit.framework` into it.
21+
7. Open ios/YourApp.xcodeproj in Xcode: open ios/YourApp.xcodeproj
22+
8. Make sure the deployment target is set to 9.0 or higher:
23+
![Deployment Target](../screenshots/deployment-target.png)
24+
9. Change "View controller-based status bar appearance" to YES in Info.plist:
1125
deployment-target.png
26+
10. Close the Xcode project
27+
11. Go back to the Terminal, `cd ios` then run `pod init`
28+
12. Replace the content of your newly created `Podfile` with this:
1229

13-
1. Change "View controller-based status bar appearance" to YES in Info.plist:
14-
deployment-target.png
15-
16-
1. Change your bundle ID to match the one for which you have a PSPDFKit license
17-
2. Close the Xcode project
18-
3. Run react-native run-ios to make sure your app runs before adding PSPDFKit
19-
4. Go back to the terminal and run pod init
20-
5. Replace the content of your newly created Podfile with this:
21-
22-
30+
```
2331
target 'YourApp' do
2432
# Native Navigation uses Swift, so this line is required!
2533
use_frameworks!
2634
27-
2835
pod 'react-native-pspdfkit', :path => '../node_modules/react-native-pspdfkit'
2936
30-
3137
# To use CocoaPods with React Native, you need to add this specific Yoga spec as well
3238
pod 'Yoga', :path => '../node_modules/react-native/ReactCommon/yoga/Yoga.podspec'
3339
34-
3540
# You don't necessarily need all of these subspecs, but this would be a typical setup.
3641
pod 'React', :path => '../node_modules/react-native', :subspecs => [
3742
'Core',
@@ -45,38 +50,33 @@ target 'YourApp' do
4550
# Add any other subspecs you want to use in your project
4651
]
4752
48-
4953
# Add any other dependencies here, including any 3rd party native libraries that you depend on for
5054
# React Native.
5155
end
52-
53-
54-
1. Run pod install
55-
2. Open the newly created workspace: YourApp.workspace
56-
3. Copy PSPDFKit into the Pods folder: YourApp/ios/Pods[a]
57-
4. Drag and drop if from the Finder into the RCTPSPDFKit group:
58-
drag-and-drop.png
59-
60-
1. Add it to the react-native-pspdfkit framework:
61-
add-to-react-native-pspdfkit.png
62-
63-
1. Embed YourApp/ios/PSPDFKit/PSPDFKit.framework (not the copy from YourApp/ios/Pods/PSPDFKit.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 Frameworks and Libraries" section:
64-
embedding-pspdfkit.png
65-
66-
1. 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:
67-
adding-pdf.png
68-
69-
1. Replace the default component from index.ios.js with a simple touch area to present the bundled PDF:
70-
71-
56+
```
57+
58+
13. Run `pod install`
59+
14. Open the newly created workspace: `YourApp.workspace`
60+
15. Copy `PSPDFKit.framework` into the Pods folder: `YourApp/ios/Pods`
61+
16. Drag and drop if from the Finder into the `RCTPSPDFKit` group:
62+
![Deployment Target](../screenshots/embedding-pspdfkit-pods.png)
63+
17. Add it to the `react-native-pspdfkit` framework:
64+
![Deployment Target](../screenshots/adding-to-react-native-pspdfkit.png)
65+
18. Embed `YourApp/ios/PSPDFKit/PSPDFKit.framework` (not the copy from `YourApp/ios/Pods/PSPDFKit.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 Frameworks and Libraries" section:
66+
![Embedding PSPDFKit](../screenshots/embedding-pspdfkit.png)
67+
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:
68+
![Adding PDF](../screenshots/adding-pdf.png)
69+
20. Replace the default component from index.ios.js`` with a simple touch area to present the bundled PDF:
70+
71+
```javascript
7272
import React, { Component } from 'react';
7373
import {
74-
AppRegistry,
75-
StyleSheet,
76-
NativeModules,
77-
Text,
78-
TouchableHighlight,
79-
View
74+
AppRegistry,
75+
StyleSheet,
76+
NativeModules,
77+
Text,
78+
TouchableHighlight,
79+
View
8080
} from 'react-native';
8181

8282
var PSPDFKit = NativeModules.PSPDFKit;
@@ -85,37 +85,37 @@ PSPDFKit.setLicenseKey('INSERT_YOUR_LICENSE_KEY_HERE');
8585

8686
// Change 'YourApp' to your app's name.
8787
class YourApp extends Component {
88-
_onPressButton() {
89-
PSPDFKit.present('document.pdf', {})
90-
}
91-
92-
render() {
93-
return (
94-
<View style={styles.container}>
95-
<TouchableHighlight onPress={this._onPressButton}>
96-
<Text style={styles.text}>Tap to Open Document</Text>
97-
</TouchableHighlight>
98-
</View>
99-
);
100-
}
88+
_onPressButton() {
89+
PSPDFKit.present('document.pdf', {})
90+
}
91+
92+
render() {
93+
return (
94+
<View style={styles.container}>
95+
<TouchableHighlight onPress={this._onPressButton}>
96+
<Text style={styles.text}>Tap to Open Document</Text>
97+
</TouchableHighlight>
98+
</View>
99+
);
100+
}
101101
}
102102

103103
const styles = StyleSheet.create({
104-
container: {
105-
flex: 1,
106-
justifyContent: 'center',
107-
alignItems: 'center',
108-
backgroundColor: '#F5FCFF',
109-
},
110-
text: {
111-
fontSize: 20,
112-
textAlign: 'center',
113-
margin: 10,
114-
}
104+
container: {
105+
flex: 1,
106+
justifyContent: 'center',
107+
alignItems: 'center',
108+
backgroundColor: '#F5FCFF',
109+
},
110+
text: {
111+
fontSize: 20,
112+
textAlign: 'center',
113+
margin: 10,
114+
}
115115
});
116116

117117
// Change both 'YourApp's to your app's name.
118118
AppRegistry.registerComponent('YourApp', () => YourApp);
119+
```
119120

120-
121-
[a]Symlink does not work. We have to have two instances of PSPDFKit.framework on disk. We need to do better here.
121+
Your app is now ready to launch. Run the app in Xcode or type `react-native run-ios` in the terminal.

0 commit comments

Comments
 (0)