Skip to content

Commit a4f8da8

Browse files
authored
Merge pull request #50 from PSPDFKit/rad/sample-project-fixes
Fix example project
2 parents 5c78994 + 29ad4b3 commit a4f8da8

File tree

5 files changed

+59
-55
lines changed

5 files changed

+59
-55
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,3 +87,5 @@ unlinked_spec.ds
8787
!**/ios/**/default.perspectivev3
8888
!/packages/flutter_tools/test/data/dart_dependencies_test/**/.packages
8989
/example/ios/Flutter/flutter_export_environment.sh
90+
/example/ios/Flutter/Flutter.podspec
91+
/example/.flutter-plugins-dependencies
File renamed without changes.

example/ios/Podfile

Lines changed: 52 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -16,53 +16,70 @@ def parse_KV_file(file, separator='=')
1616
if !File.exists? file_abs_path
1717
return [];
1818
end
19-
pods_ary = []
19+
generated_key_values = {}
2020
skip_line_start_symbols = ["#", "/"]
21-
File.foreach(file_abs_path) { |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-
pods_ary.push({:name => podname, :path => podpath});
29-
else
30-
puts "Invalid plugin specification: #{line}"
31-
end
32-
}
33-
return pods_ary
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
3434
end
3535

3636
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.
46+
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
60+
end
61+
62+
# Keep pod path relative so it can be checked into Podfile.lock.
63+
pod 'Flutter', :path => 'Flutter'
64+
65+
# Plugin Pods
3766
pod 'PSPDFKit', podspec:'https://customers.pspdfkit.com/cocoapods/YOUR_COCOAPODS_KEY_GOES_HERE/pspdfkit/latest.podspec'
38-
67+
3968
# Prepare symlinks folder. We use symlinks to avoid having Podfile.lock
4069
# referring to absolute paths on developers' machines.
4170
system('rm -rf .symlinks')
4271
system('mkdir -p .symlinks/plugins')
43-
44-
# Flutter Pods
45-
generated_xcode_build_settings = parse_KV_file('./Flutter/Generated.xcconfig')
46-
if generated_xcode_build_settings.empty?
47-
puts "Generated.xcconfig must exist. If you're running pod install manually, make sure flutter packages get is executed first."
48-
end
49-
generated_xcode_build_settings.map { |p|
50-
if p[:name] == 'FLUTTER_FRAMEWORK_DIR'
51-
symlink = File.join('.symlinks', 'flutter')
52-
File.symlink(File.dirname(p[:path]), symlink)
53-
pod 'Flutter', :path => File.join(symlink, File.basename(p[:path]))
54-
end
55-
}
56-
57-
# Plugin Pods
5872
plugin_pods = parse_KV_file('../.flutter-plugins')
59-
plugin_pods.map { |p|
60-
symlink = File.join('.symlinks', 'plugins', p[:name])
61-
File.symlink(p[:path], symlink)
62-
pod p[:name], :path => File.join(symlink, 'ios')
63-
}
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
6478
end
6579

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+
6683
post_install do |installer|
6784
installer.pods_project.targets.each do |target|
6885
target.build_configurations.each do |config|

example/ios/Runner.xcodeproj/project.pbxproj

Lines changed: 4 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
objects = {
88

99
/* Begin PBXBuildFile section */
10-
134B9D554906601BF25ED5F2 /* Pods_Runner.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1589BBAD9A55430A9716182C /* Pods_Runner.framework */; };
1110
1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */ = {isa = PBXBuildFile; fileRef = 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */; };
1211
3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */ = {isa = PBXBuildFile; fileRef = 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */; };
1312
3B80C3941E831B6300D905FE /* App.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3B80C3931E831B6300D905FE /* App.framework */; };
@@ -19,6 +18,7 @@
1918
97C146FC1CF9000F007C117D /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FA1CF9000F007C117D /* Main.storyboard */; };
2019
97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FD1CF9000F007C117D /* Assets.xcassets */; };
2120
97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */; };
21+
D58F315FF3A96F57CA38DB6C /* Pods_Runner.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C44A19A748A1840F027BB796 /* Pods_Runner.framework */; };
2222
/* End PBXBuildFile section */
2323

2424
/* Begin PBXCopyFilesBuildPhase section */
@@ -39,7 +39,6 @@
3939
/* Begin PBXFileReference section */
4040
1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GeneratedPluginRegistrant.h; sourceTree = "<group>"; };
4141
1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GeneratedPluginRegistrant.m; sourceTree = "<group>"; };
42-
1589BBAD9A55430A9716182C /* Pods_Runner.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Runner.framework; sourceTree = BUILT_PRODUCTS_DIR; };
4342
3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = AppFrameworkInfo.plist; path = Flutter/AppFrameworkInfo.plist; sourceTree = "<group>"; };
4443
3B80C3931E831B6300D905FE /* App.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = App.framework; path = Flutter/App.framework; sourceTree = "<group>"; };
4544
7680CF0EE621C4C588CA8319 /* Pods-Runner.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.debug.xcconfig"; path = "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"; sourceTree = "<group>"; };
@@ -55,6 +54,7 @@
5554
97C146FD1CF9000F007C117D /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
5655
97C147001CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
5756
97C147021CF9000F007C117D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
57+
C44A19A748A1840F027BB796 /* Pods_Runner.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Runner.framework; sourceTree = BUILT_PRODUCTS_DIR; };
5858
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>"; };
5959
/* End PBXFileReference section */
6060

@@ -65,7 +65,7 @@
6565
files = (
6666
9705A1C61CF904A100538489 /* Flutter.framework in Frameworks */,
6767
3B80C3941E831B6300D905FE /* App.framework in Frameworks */,
68-
134B9D554906601BF25ED5F2 /* Pods_Runner.framework in Frameworks */,
68+
D58F315FF3A96F57CA38DB6C /* Pods_Runner.framework in Frameworks */,
6969
);
7070
runOnlyForDeploymentPostprocessing = 0;
7171
};
@@ -75,7 +75,7 @@
7575
28FB19379A2349AC9DE981D7 /* Frameworks */ = {
7676
isa = PBXGroup;
7777
children = (
78-
1589BBAD9A55430A9716182C /* Pods_Runner.framework */,
78+
C44A19A748A1840F027BB796 /* Pods_Runner.framework */,
7979
);
8080
name = Frameworks;
8181
sourceTree = "<group>";
@@ -238,24 +238,9 @@
238238
files = (
239239
);
240240
inputPaths = (
241-
"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh",
242-
"${PODS_ROOT}/../.symlinks/flutter/ios/Flutter.framework",
243-
"${PODS_ROOT}/PSPDFKit/PSPDFKit.framework",
244-
"${PODS_ROOT}/PSPDFKit/PSPDFKit.framework.dSYM",
245-
"${PODS_ROOT}/PSPDFKit/PSPDFKitUI.framework",
246-
"${PODS_ROOT}/PSPDFKit/PSPDFKitUI.framework.dSYM",
247-
"${BUILT_PRODUCTS_DIR}/path_provider/path_provider.framework",
248-
"${BUILT_PRODUCTS_DIR}/pspdfkit_flutter/pspdfkit_flutter.framework",
249241
);
250242
name = "[CP] Embed Pods Frameworks";
251243
outputPaths = (
252-
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Flutter.framework",
253-
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/PSPDFKit.framework",
254-
"${DWARF_DSYM_FOLDER_PATH}/PSPDFKit.framework.dSYM",
255-
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/PSPDFKitUI.framework",
256-
"${DWARF_DSYM_FOLDER_PATH}/PSPDFKitUI.framework.dSYM",
257-
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/path_provider.framework",
258-
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/pspdfkit_flutter.framework",
259244
);
260245
runOnlyForDeploymentPostprocessing = 0;
261246
shellPath = /bin/sh;

example/lib/main.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import 'package:pspdfkit_flutter/pspdfkit.dart';
1818

1919
const String _documentPath = 'PDFs/PSPDFKit.pdf';
2020
const String _lockedDocumentPath = 'PDFs/protected.pdf';
21-
const String _imagePath = 'PDFs/PSPDFKit Image Example.jpg';
21+
const String _imagePath = 'PDFs/PSPDFKit_Image_Example.jpg';
2222
const String _formPath = 'PDFs/Form_example.pdf';
2323
const String _instantDocumentJsonPath = 'PDFs/Instant/instant-document.json';
2424
const String _pspdfkitFlutterPluginTitle = 'PSPDFKit Flutter Plugin example app';

0 commit comments

Comments
 (0)