Skip to content

Commit c6f3560

Browse files
authored
Merge pull request #68 from PSPDFKit/rad/update-for-v10-for-ios
Update for PSPDFKit 10 for iOS, Xcode 12
2 parents 4df3c21 + 25976b2 commit c6f3560

File tree

6 files changed

+51
-82
lines changed

6 files changed

+51
-82
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ unlinked_spec.ds
8686
!**/ios/**/default.pbxuser
8787
!**/ios/**/default.perspectivev3
8888
!/packages/flutter_tools/test/data/dart_dependencies_test/**/.packages
89+
/example/ios/Flutter/.last_build_id
8990
/example/ios/Flutter/flutter_export_environment.sh
9091
/example/ios/Flutter/Flutter.podspec
9192
/example/.flutter-plugins-dependencies

README.md

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -204,9 +204,18 @@ adb push /path/to/your/document.pdf /sdcard/document.pdf
204204

205205
9. The app is ready to start! From `myapp` run `flutter run`.
206206

207-
## iOS
207+
### iOS
208208

209-
1. Run `flutter create --org com.example.myapp myapp`.
209+
#### Requirements
210+
211+
- Xcode 12
212+
- PSPDFKit 10.0.0 for iOS or later
213+
- Flutter 1.21.0-9.2.pre or later
214+
- CocoaPods 1.10.0.rc.1 or later
215+
216+
#### Getting Started
217+
218+
1. Run `flutter create --org com.example.myapp myapp`
210219
2. Step into your newly created app folder: `cd myapp`
211220
3. Open `pubspec.yaml` and under `dependencies` add
212221

@@ -243,14 +252,16 @@ adb push /path/to/your/document.pdf /sdcard/document.pdf
243252

244253
```diff
245254
# Uncomment this line to define a global platform for your project
246-
- # platform :ios, '9.0'
247-
+ platform :ios, '12.0'
255+
- # platform :ios, '9.0'
256+
+ platform :ios, '12.0'
248257
...
249258
target 'Runner' do
250-
use_frameworks!
251-
+ pod 'PSPDFKit', podspec:'https://customers.pspdfkit.com/pspdfkit-ios/latest-framework.podspec'
252-
...
253-
end
259+
use_frameworks!
260+
use_modular_headers!
261+
262+
flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__))
263+
+ pod 'PSPDFKit', podspec:'https://customers.pspdfkit.com/pspdfkit-ios/latest.podspec'
264+
end
254265
```
255266

256267
11. Open `lib/main.dart` and replace the whole content with a simple example that will load a PDF document from local device filesystem:

example/ios/Podfile

Lines changed: 15 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
# Uncomment this line to define a global platform for your project
22
platform :ios, '12.0'
3-
use_frameworks!
43

54
# CocoaPods analytics sends network stats synchronously affecting flutter build latency.
65
ENV['COCOAPODS_DISABLE_STATS'] = 'true'
@@ -11,79 +10,30 @@ project 'Runner', {
1110
'Release' => :release,
1211
}
1312

14-
def parse_KV_file(file, separator='=')
15-
file_abs_path = File.expand_path(file)
16-
if !File.exists? file_abs_path
17-
return [];
13+
def flutter_root
14+
generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'Generated.xcconfig'), __FILE__)
15+
unless File.exist?(generated_xcode_build_settings_path)
16+
raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure flutter pub get is executed first"
1817
end
19-
generated_key_values = {}
20-
skip_line_start_symbols = ["#", "/"]
21-
File.foreach(file_abs_path) do |line|
22-
next if skip_line_start_symbols.any? { |symbol| line =~ /^\s*#{symbol}/ }
23-
plugin = line.split(pattern=separator)
24-
if plugin.length == 2
25-
podname = plugin[0].strip()
26-
path = plugin[1].strip()
27-
podpath = File.expand_path("#{path}", file_abs_path)
28-
generated_key_values[podname] = podpath
29-
else
30-
puts "Invalid plugin specification: #{line}"
31-
end
32-
end
33-
generated_key_values
34-
end
35-
36-
target 'Runner' do
37-
# Flutter Pod
38-
39-
copied_flutter_dir = File.join(__dir__, 'Flutter')
40-
copied_framework_path = File.join(copied_flutter_dir, 'Flutter.framework')
41-
copied_podspec_path = File.join(copied_flutter_dir, 'Flutter.podspec')
42-
unless File.exist?(copied_framework_path) && File.exist?(copied_podspec_path)
43-
# Copy Flutter.framework and Flutter.podspec to Flutter/ to have something to link against if the xcode backend script has not run yet.
44-
# That script will copy the correct debug/profile/release version of the framework based on the currently selected Xcode configuration.
45-
# CocoaPods will not embed the framework on pod install (before any build phases can generate) if the dylib does not exist.
4618

47-
generated_xcode_build_settings_path = File.join(copied_flutter_dir, 'Generated.xcconfig')
48-
unless File.exist?(generated_xcode_build_settings_path)
49-
raise "Generated.xcconfig must exist. If you're running pod install manually, make sure flutter pub get is executed first"
50-
end
51-
generated_xcode_build_settings = parse_KV_file(generated_xcode_build_settings_path)
52-
cached_framework_dir = generated_xcode_build_settings['FLUTTER_FRAMEWORK_DIR'];
53-
54-
unless File.exist?(copied_framework_path)
55-
FileUtils.cp_r(File.join(cached_framework_dir, 'Flutter.framework'), copied_flutter_dir)
56-
end
57-
unless File.exist?(copied_podspec_path)
58-
FileUtils.cp(File.join(cached_framework_dir, 'Flutter.podspec'), copied_flutter_dir)
59-
end
19+
File.foreach(generated_xcode_build_settings_path) do |line|
20+
matches = line.match(/FLUTTER_ROOT\=(.*)/)
21+
return matches[1].strip if matches
6022
end
23+
raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Generated.xcconfig, then run flutter pub get"
24+
end
6125

62-
# Keep pod path relative so it can be checked into Podfile.lock.
63-
pod 'Flutter', :path => 'Flutter'
26+
require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root)
6427

65-
# Plugin Pods
66-
pod 'PSPDFKit', podspec:'https://customers.pspdfkit.com/pspdfkit-ios/latest-framework.podspec'
28+
flutter_ios_podfile_setup
6729

68-
# Prepare symlinks folder. We use symlinks to avoid having Podfile.lock
69-
# referring to absolute paths on developers' machines.
70-
system('rm -rf .symlinks')
71-
system('mkdir -p .symlinks/plugins')
72-
plugin_pods = parse_KV_file('../.flutter-plugins')
73-
plugin_pods.each do |name, path|
74-
symlink = File.join('.symlinks', 'plugins', name)
75-
File.symlink(path, symlink)
76-
pod name, :path => File.join(symlink, 'ios')
77-
end
30+
target 'Runner' do
31+
flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__))
32+
pod 'PSPDFKit', podspec:'https://customers.pspdfkit.com/pspdfkit-ios/latest.podspec'
7833
end
7934

80-
# Prevent Cocoapods from embedding a second Flutter framework and causing an error with the new Xcode build system.
81-
install! 'cocoapods', :disable_input_output_paths => true
82-
8335
post_install do |installer|
8436
installer.pods_project.targets.each do |target|
85-
target.build_configurations.each do |config|
86-
config.build_settings['ENABLE_BITCODE'] = 'NO'
87-
end
37+
flutter_additional_ios_build_settings(target)
8838
end
8939
end

example/ios/Runner.xcodeproj/project.pbxproj

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@
99
/* Begin PBXBuildFile section */
1010
1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */ = {isa = PBXBuildFile; fileRef = 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */; };
1111
3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */ = {isa = PBXBuildFile; fileRef = 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */; };
12+
6E58FD42C5C650D180E8B6F7 /* libPods-Runner.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 9222D47AA509D70776A755B3 /* libPods-Runner.a */; };
1213
978B8F6F1D3862AE00F588F7 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 7AFFD8EE1D35381100E5BB4D /* AppDelegate.m */; };
1314
97C146F31CF9000F007C117D /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 97C146F21CF9000F007C117D /* main.m */; };
1415
97C146FC1CF9000F007C117D /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FA1CF9000F007C117D /* Main.storyboard */; };
1516
97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FD1CF9000F007C117D /* Assets.xcassets */; };
1617
97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */; };
17-
D58F315FF3A96F57CA38DB6C /* Pods_Runner.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C44A19A748A1840F027BB796 /* Pods_Runner.framework */; };
1818
/* End PBXBuildFile section */
1919

2020
/* Begin PBXCopyFilesBuildPhase section */
@@ -38,6 +38,7 @@
3838
7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = Release.xcconfig; path = Flutter/Release.xcconfig; sourceTree = "<group>"; };
3939
7AFFD8ED1D35381100E5BB4D /* AppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = "<group>"; };
4040
7AFFD8EE1D35381100E5BB4D /* AppDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = "<group>"; };
41+
9222D47AA509D70776A755B3 /* libPods-Runner.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-Runner.a"; sourceTree = BUILT_PRODUCTS_DIR; };
4142
9740EEB21CF90195004384FC /* Debug.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Debug.xcconfig; path = Flutter/Debug.xcconfig; sourceTree = "<group>"; };
4243
9740EEB31CF90195004384FC /* Generated.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Generated.xcconfig; path = Flutter/Generated.xcconfig; sourceTree = "<group>"; };
4344
97C146EE1CF9000F007C117D /* Runner.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Runner.app; sourceTree = BUILT_PRODUCTS_DIR; };
@@ -46,7 +47,6 @@
4647
97C146FD1CF9000F007C117D /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
4748
97C147001CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
4849
97C147021CF9000F007C117D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
49-
C44A19A748A1840F027BB796 /* Pods_Runner.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Runner.framework; sourceTree = BUILT_PRODUCTS_DIR; };
5050
EA8AE65FF465391772EFF6C0 /* Pods-Runner.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.release.xcconfig"; path = "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"; sourceTree = "<group>"; };
5151
/* End PBXFileReference section */
5252

@@ -55,7 +55,7 @@
5555
isa = PBXFrameworksBuildPhase;
5656
buildActionMask = 2147483647;
5757
files = (
58-
D58F315FF3A96F57CA38DB6C /* Pods_Runner.framework in Frameworks */,
58+
6E58FD42C5C650D180E8B6F7 /* libPods-Runner.a in Frameworks */,
5959
);
6060
runOnlyForDeploymentPostprocessing = 0;
6161
};
@@ -65,7 +65,7 @@
6565
28FB19379A2349AC9DE981D7 /* Frameworks */ = {
6666
isa = PBXGroup;
6767
children = (
68-
C44A19A748A1840F027BB796 /* Pods_Runner.framework */,
68+
9222D47AA509D70776A755B3 /* libPods-Runner.a */,
6969
);
7070
name = Frameworks;
7171
sourceTree = "<group>";
@@ -164,7 +164,7 @@
164164
97C146E61CF9000F007C117D /* Project object */ = {
165165
isa = PBXProject;
166166
attributes = {
167-
LastUpgradeCheck = 1130;
167+
LastUpgradeCheck = 1200;
168168
ORGANIZATIONNAME = "The Chromium Authors";
169169
TargetAttributes = {
170170
97C146ED1CF9000F007C117D = {
@@ -225,9 +225,16 @@
225225
files = (
226226
);
227227
inputPaths = (
228+
"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh",
229+
"${PODS_ROOT}/../Flutter/Flutter.framework",
230+
"${PODS_XCFRAMEWORKS_BUILD_DIR}/PSPDFKit/PSPDFKit.framework/PSPDFKit",
231+
"${PODS_XCFRAMEWORKS_BUILD_DIR}/PSPDFKitUI/PSPDFKitUI.framework/PSPDFKitUI",
228232
);
229233
name = "[CP] Embed Pods Frameworks";
230234
outputPaths = (
235+
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Flutter.framework",
236+
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/PSPDFKit.framework",
237+
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/PSPDFKitUI.framework",
231238
);
232239
runOnlyForDeploymentPostprocessing = 0;
233240
shellPath = /bin/sh;
@@ -303,7 +310,6 @@
303310
/* Begin XCBuildConfiguration section */
304311
97C147031CF9000F007C117D /* Debug */ = {
305312
isa = XCBuildConfiguration;
306-
baseConfigurationReference = 9740EEB21CF90195004384FC /* Debug.xcconfig */;
307313
buildSettings = {
308314
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
309315
ALWAYS_SEARCH_USER_PATHS = NO;
@@ -327,6 +333,7 @@
327333
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
328334
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
329335
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
336+
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
330337
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
331338
CLANG_WARN_STRICT_PROTOTYPES = YES;
332339
CLANG_WARN_SUSPICIOUS_MOVE = YES;
@@ -361,7 +368,6 @@
361368
};
362369
97C147041CF9000F007C117D /* Release */ = {
363370
isa = XCBuildConfiguration;
364-
baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */;
365371
buildSettings = {
366372
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
367373
ALWAYS_SEARCH_USER_PATHS = NO;
@@ -385,6 +391,7 @@
385391
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
386392
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
387393
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
394+
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
388395
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
389396
CLANG_WARN_STRICT_PROTOTYPES = YES;
390397
CLANG_WARN_SUSPICIOUS_MOVE = YES;

example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<Scheme
3-
LastUpgradeVersion = "1130"
3+
LastUpgradeVersion = "1200"
44
version = "1.3">
55
<BuildAction
66
parallelizeBuildables = "YES"

ios/pspdfkit_flutter.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,6 @@ PSPDFKit flutter plugin.
1717
s.dependency 'Flutter'
1818
s.dependency 'PSPDFKit'
1919
s.swift_version = '5.0'
20-
s.ios.deployment_target = '11.0'
20+
s.ios.deployment_target = '12.0'
2121
end
2222

0 commit comments

Comments
 (0)