Skip to content

Commit 5d22813

Browse files
authored
PSPDFViewController as an embedded Flutter view. (#57)
* Added pspdfviewcontroller as an embedded view.
1 parent a9a3bfb commit 5d22813

23 files changed

+2165
-471
lines changed

README.md

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -248,12 +248,14 @@ adb push /path/to/your/document.pdf /sdcard/document.pdf
248248

249249
![iOS View controller-based status bar appearance](screenshots/ios-info-plist-statusbarappearance.png)
250250

251-
8. If your application is targeting iOS versions **prior to iOS 12.2** and your application **does not already contain any Swift code**, then you need to make sure Xcode bundles Swift standard libraries with your application distribution. To to so, open your target Build Settings and enable `Always Embed Swift Standard Libraries`:
251+
8. In the `Info.plist`, create a new row with key: `io.flutter.embedded_views_preview` and type: `Boolean`. Set its value to `YES`.
252+
253+
9. If your application is targeting iOS versions **prior to iOS 12.2** and your application **does not already contain any Swift code**, then you need to make sure Xcode bundles Swift standard libraries with your application distribution. To to so, open your target Build Settings and enable `Always Embed Swift Standard Libraries`:
252254

253255
![Always Embed Swift Standard Libraries](screenshots/ios-always-embed-swift-standard-libraries.png)
254256

255-
9. Run `flutter packages get` to install the packages.
256-
10. Open the `Podfile`: `open ios/Podfile` and edit it as follows:
257+
10. Run `flutter packages get` to install the packages.
258+
11. Open the `Podfile`: `open ios/Podfile` and edit it as follows:
257259

258260
```diff
259261
# Uncomment this line to define a global platform for your project
@@ -269,7 +271,7 @@ target 'Runner' do
269271
end
270272
```
271273

272-
11. Open `lib/main.dart` and replace the whole content with a simple example that will load a PDF document from local device filesystem:
274+
12. Open `lib/main.dart` and replace the whole content with a simple example that will load a PDF document from local device filesystem:
273275

274276
```dart
275277
import 'dart:io';
@@ -373,9 +375,9 @@ class _MyAppState extends State<MyApp> {
373375
}
374376
```
375377

376-
12. In `lib/main.dart` replace `YOUR_LICENSE_KEY_GOES_HERE` with your PSPDFKit license key.
377-
13. Run `flutter emulators --launch apple_ios_simulator` to launch the iOS Simulator.
378-
14. Run `flutter run`.
378+
13. In `lib/main.dart` replace `YOUR_LICENSE_KEY_GOES_HERE` with your PSPDFKit license key.
379+
14. Run `flutter emulators --launch apple_ios_simulator` to launch the iOS Simulator.
380+
15. Run `flutter run`.
379381

380382
# Example
381383

android/src/main/java/com/pspdfkit/flutter/pspdfkit/PspdfkitPlugin.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ private PspdfkitPlugin(Registrar registrar) {
7777
* Plugin registration.
7878
*/
7979
public static void registerWith(Registrar registrar) {
80-
final MethodChannel channel = new MethodChannel(registrar.messenger(), "pspdfkit");
80+
final MethodChannel channel = new MethodChannel(registrar.messenger(), "com.pspdfkit.global");
8181
PspdfkitPlugin pspdfkitPlugin = new PspdfkitPlugin(registrar);
8282
channel.setMethodCallHandler(pspdfkitPlugin);
8383
eventDispatcher.setChannel(channel);

example/ios/Runner.xcodeproj/project.pbxproj

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
/* Begin PBXBuildFile section */
1010
1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */ = {isa = PBXBuildFile; fileRef = 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */; };
11+
3444C7237B84C2D6481926E7 /* libPods-Runner.a in Frameworks */ = {isa = PBXBuildFile; fileRef = A412063D763F88ABA5BD5713 /* libPods-Runner.a */; };
1112
3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */ = {isa = PBXBuildFile; fileRef = 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */; };
1213
978B8F6F1D3862AE00F588F7 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 7AFFD8EE1D35381100E5BB4D /* AppDelegate.m */; };
1314
97C146F31CF9000F007C117D /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 97C146F21CF9000F007C117D /* main.m */; };
@@ -36,6 +37,7 @@
3637
7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = Release.xcconfig; path = Flutter/Release.xcconfig; sourceTree = "<group>"; };
3738
7AFFD8ED1D35381100E5BB4D /* AppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = "<group>"; };
3839
7AFFD8EE1D35381100E5BB4D /* AppDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = "<group>"; };
40+
8F541A3573E512AF9FB49541 /* Pods-Runner.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.release.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"; sourceTree = "<group>"; };
3941
9740EEB21CF90195004384FC /* Debug.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Debug.xcconfig; path = Flutter/Debug.xcconfig; sourceTree = "<group>"; };
4042
9740EEB31CF90195004384FC /* Generated.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Generated.xcconfig; path = Flutter/Generated.xcconfig; sourceTree = "<group>"; };
4143
97C146EE1CF9000F007C117D /* Runner.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Runner.app; sourceTree = BUILT_PRODUCTS_DIR; };
@@ -44,13 +46,16 @@
4446
97C146FD1CF9000F007C117D /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
4547
97C147001CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
4648
97C147021CF9000F007C117D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
49+
A412063D763F88ABA5BD5713 /* libPods-Runner.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-Runner.a"; sourceTree = BUILT_PRODUCTS_DIR; };
50+
C3076FF4378A903F5B8F6AAC /* Pods-Runner.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.debug.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"; sourceTree = "<group>"; };
4751
/* End PBXFileReference section */
4852

4953
/* Begin PBXFrameworksBuildPhase section */
5054
97C146EB1CF9000F007C117D /* Frameworks */ = {
5155
isa = PBXFrameworksBuildPhase;
5256
buildActionMask = 2147483647;
5357
files = (
58+
3444C7237B84C2D6481926E7 /* libPods-Runner.a in Frameworks */,
5459
);
5560
runOnlyForDeploymentPostprocessing = 0;
5661
};
@@ -74,6 +79,8 @@
7479
9740EEB11CF90186004384FC /* Flutter */,
7580
97C146F01CF9000F007C117D /* Runner */,
7681
97C146EF1CF9000F007C117D /* Products */,
82+
9C5BE75403D7D8EE8D2D0254 /* Pods */,
83+
AE5C3B56BFC9B202761928CF /* Frameworks */,
7784
);
7885
sourceTree = "<group>";
7986
};
@@ -109,19 +116,39 @@
109116
name = "Supporting Files";
110117
sourceTree = "<group>";
111118
};
119+
9C5BE75403D7D8EE8D2D0254 /* Pods */ = {
120+
isa = PBXGroup;
121+
children = (
122+
C3076FF4378A903F5B8F6AAC /* Pods-Runner.debug.xcconfig */,
123+
8F541A3573E512AF9FB49541 /* Pods-Runner.release.xcconfig */,
124+
);
125+
name = Pods;
126+
path = Pods;
127+
sourceTree = "<group>";
128+
};
129+
AE5C3B56BFC9B202761928CF /* Frameworks */ = {
130+
isa = PBXGroup;
131+
children = (
132+
A412063D763F88ABA5BD5713 /* libPods-Runner.a */,
133+
);
134+
name = Frameworks;
135+
sourceTree = "<group>";
136+
};
112137
/* End PBXGroup section */
113138

114139
/* Begin PBXNativeTarget section */
115140
97C146ED1CF9000F007C117D /* Runner */ = {
116141
isa = PBXNativeTarget;
117142
buildConfigurationList = 97C147051CF9000F007C117D /* Build configuration list for PBXNativeTarget "Runner" */;
118143
buildPhases = (
144+
9ACC9FBCDE0EA80563B47B8C /* [CP] Check Pods Manifest.lock */,
119145
9740EEB61CF901F6004384FC /* Run Script */,
120146
97C146EA1CF9000F007C117D /* Sources */,
121147
97C146EB1CF9000F007C117D /* Frameworks */,
122148
97C146EC1CF9000F007C117D /* Resources */,
123149
9705A1C41CF9048500538489 /* Embed Frameworks */,
124150
3B06AD1E1E4923F5004D2608 /* Thin Binary */,
151+
2CAD281880438BCF3C693E84 /* [CP] Embed Pods Frameworks */,
125152
);
126153
buildRules = (
127154
);
@@ -179,6 +206,26 @@
179206
/* End PBXResourcesBuildPhase section */
180207

181208
/* Begin PBXShellScriptBuildPhase section */
209+
2CAD281880438BCF3C693E84 /* [CP] Embed Pods Frameworks */ = {
210+
isa = PBXShellScriptBuildPhase;
211+
buildActionMask = 2147483647;
212+
files = (
213+
);
214+
inputPaths = (
215+
"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh",
216+
"${PODS_XCFRAMEWORKS_BUILD_DIR}/PSPDFKit/PSPDFKit.framework/PSPDFKit",
217+
"${PODS_XCFRAMEWORKS_BUILD_DIR}/PSPDFKitUI/PSPDFKitUI.framework/PSPDFKitUI",
218+
);
219+
name = "[CP] Embed Pods Frameworks";
220+
outputPaths = (
221+
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/PSPDFKit.framework",
222+
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/PSPDFKitUI.framework",
223+
);
224+
runOnlyForDeploymentPostprocessing = 0;
225+
shellPath = /bin/sh;
226+
shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh\"\n";
227+
showEnvVarsInLog = 0;
228+
};
182229
3B06AD1E1E4923F5004D2608 /* Thin Binary */ = {
183230
isa = PBXShellScriptBuildPhase;
184231
buildActionMask = 2147483647;
@@ -207,6 +254,28 @@
207254
shellPath = /bin/sh;
208255
shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" build";
209256
};
257+
9ACC9FBCDE0EA80563B47B8C /* [CP] Check Pods Manifest.lock */ = {
258+
isa = PBXShellScriptBuildPhase;
259+
buildActionMask = 2147483647;
260+
files = (
261+
);
262+
inputFileListPaths = (
263+
);
264+
inputPaths = (
265+
"${PODS_PODFILE_DIR_PATH}/Podfile.lock",
266+
"${PODS_ROOT}/Manifest.lock",
267+
);
268+
name = "[CP] Check Pods Manifest.lock";
269+
outputFileListPaths = (
270+
);
271+
outputPaths = (
272+
"$(DERIVED_FILE_DIR)/Pods-Runner-checkManifestLockResult.txt",
273+
);
274+
runOnlyForDeploymentPostprocessing = 0;
275+
shellPath = /bin/sh;
276+
shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n";
277+
showEnvVarsInLog = 0;
278+
};
210279
/* End PBXShellScriptBuildPhase section */
211280

212281
/* Begin PBXSourcesBuildPhase section */

example/ios/Runner/Info.plist

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,5 +45,7 @@
4545
</array>
4646
<key>UIViewControllerBasedStatusBarAppearance</key>
4747
<true/>
48+
<key>io.flutter.embedded_views_preview</key>
49+
<true/>
4850
</dict>
4951
</plist>

0 commit comments

Comments
 (0)