Skip to content
This repository was archived by the owner on Jan 20, 2023. It is now read-only.

Commit 46d90c5

Browse files
committed
fixes #39 and #42
1 parent 5829370 commit 46d90c5

File tree

9 files changed

+45
-104
lines changed

9 files changed

+45
-104
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
/Users/koenzwikstra/Source/flutter_sodium
1+
/Users/koenzwikstra/Source/flutter_sodium/

example/ios/Flutter/flutter_export_environment.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@
22
# This is a generated file; do not edit or check into version control.
33
export "FLUTTER_ROOT=/Users/koenzwikstra/Source/flutter"
44
export "FLUTTER_APPLICATION_PATH=/Users/koenzwikstra/Source/flutter_sodium/example"
5-
export "FLUTTER_TARGET=lib/main.dart"
5+
export "FLUTTER_TARGET=/Users/koenzwikstra/Source/flutter_sodium/example/lib/main.dart"
66
export "FLUTTER_BUILD_DIR=build"
77
export "SYMROOT=${SOURCE_ROOT}/../build/ios"
88
export "OTHER_LDFLAGS=$(inherited) -framework Flutter"
9-
export "FLUTTER_FRAMEWORK_DIR=/Users/koenzwikstra/Source/flutter/bin/cache/artifacts/engine/ios"
9+
export "FLUTTER_FRAMEWORK_DIR=/Users/koenzwikstra/Source/flutter/bin/cache/artifacts/engine/ios-release"
1010
export "FLUTTER_BUILD_NAME=1.0.0"
1111
export "FLUTTER_BUILD_NUMBER=1"
1212
export "DART_OBFUSCATION=false"
13-
export "TRACK_WIDGET_CREATION=false"
13+
export "TRACK_WIDGET_CREATION=true"
1414
export "TREE_SHAKE_ICONS=false"
1515
export "PACKAGE_CONFIG=.packages"

example/ios/Podfile

Lines changed: 15 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -10,81 +10,32 @@ project 'Runner', {
1010
'Release' => :release,
1111
}
1212

13-
def parse_KV_file(file, separator='=')
14-
file_abs_path = File.expand_path(file)
15-
if !File.exists? file_abs_path
16-
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"
1717
end
18-
generated_key_values = {}
19-
skip_line_start_symbols = ["#", "/"]
20-
File.foreach(file_abs_path) do |line|
21-
next if skip_line_start_symbols.any? { |symbol| line =~ /^\s*#{symbol}/ }
22-
plugin = line.split(pattern=separator)
23-
if plugin.length == 2
24-
podname = plugin[0].strip()
25-
path = plugin[1].strip()
26-
podpath = File.expand_path("#{path}", file_abs_path)
27-
generated_key_values[podname] = podpath
28-
else
29-
puts "Invalid plugin specification: #{line}"
30-
end
18+
19+
File.foreach(generated_xcode_build_settings_path) do |line|
20+
matches = line.match(/FLUTTER_ROOT\=(.*)/)
21+
return matches[1].strip if matches
3122
end
32-
generated_key_values
23+
raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Generated.xcconfig, then run flutter pub get"
3324
end
3425

26+
require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root)
27+
28+
flutter_ios_podfile_setup
29+
3530
target 'Runner' do
3631
use_frameworks!
3732
use_modular_headers!
38-
39-
# Flutter Pod
4033

41-
copied_flutter_dir = File.join(__dir__, 'Flutter')
42-
copied_framework_path = File.join(copied_flutter_dir, 'Flutter.framework')
43-
copied_podspec_path = File.join(copied_flutter_dir, 'Flutter.podspec')
44-
unless File.exist?(copied_framework_path) && File.exist?(copied_podspec_path)
45-
# Copy Flutter.framework and Flutter.podspec to Flutter/ to have something to link against if the xcode backend script has not run yet.
46-
# That script will copy the correct debug/profile/release version of the framework based on the currently selected Xcode configuration.
47-
# CocoaPods will not embed the framework on pod install (before any build phases can generate) if the dylib does not exist.
48-
49-
generated_xcode_build_settings_path = File.join(copied_flutter_dir, 'Generated.xcconfig')
50-
unless File.exist?(generated_xcode_build_settings_path)
51-
raise "Generated.xcconfig must exist. If you're running pod install manually, make sure flutter pub get is executed first"
52-
end
53-
generated_xcode_build_settings = parse_KV_file(generated_xcode_build_settings_path)
54-
cached_framework_dir = generated_xcode_build_settings['FLUTTER_FRAMEWORK_DIR'];
55-
56-
unless File.exist?(copied_framework_path)
57-
FileUtils.cp_r(File.join(cached_framework_dir, 'Flutter.framework'), copied_flutter_dir)
58-
end
59-
unless File.exist?(copied_podspec_path)
60-
FileUtils.cp(File.join(cached_framework_dir, 'Flutter.podspec'), copied_flutter_dir)
61-
end
62-
end
63-
64-
# Keep pod path relative so it can be checked into Podfile.lock.
65-
pod 'Flutter', :path => 'Flutter'
66-
67-
# Plugin Pods
68-
69-
# Prepare symlinks folder. We use symlinks to avoid having Podfile.lock
70-
# referring to absolute paths on developers' machines.
71-
system('rm -rf .symlinks')
72-
system('mkdir -p .symlinks/plugins')
73-
plugin_pods = parse_KV_file('../.flutter-plugins')
74-
plugin_pods.each do |name, path|
75-
symlink = File.join('.symlinks', 'plugins', name)
76-
File.symlink(path, symlink)
77-
pod name, :path => File.join(symlink, 'ios')
78-
end
34+
flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__))
7935
end
8036

81-
# Prevent Cocoapods from embedding a second Flutter framework and causing an error with the new Xcode build system.
82-
install! 'cocoapods', :disable_input_output_paths => true
83-
8437
post_install do |installer|
8538
installer.pods_project.targets.each do |target|
86-
target.build_configurations.each do |config|
87-
config.build_settings['ENABLE_BITCODE'] = 'NO'
88-
end
39+
flutter_additional_ios_build_settings(target)
8940
end
9041
end

example/ios/Podfile.lock

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,11 @@ PODS:
44
- Flutter
55
- url_launcher (0.0.1):
66
- Flutter
7-
- url_launcher_macos (0.0.1):
8-
- Flutter
9-
- url_launcher_web (0.0.1):
10-
- Flutter
117

128
DEPENDENCIES:
139
- Flutter (from `Flutter`)
1410
- flutter_sodium (from `.symlinks/plugins/flutter_sodium/ios`)
1511
- url_launcher (from `.symlinks/plugins/url_launcher/ios`)
16-
- url_launcher_macos (from `.symlinks/plugins/url_launcher_macos/ios`)
17-
- url_launcher_web (from `.symlinks/plugins/url_launcher_web/ios`)
1812

1913
EXTERNAL SOURCES:
2014
Flutter:
@@ -23,18 +17,12 @@ EXTERNAL SOURCES:
2317
:path: ".symlinks/plugins/flutter_sodium/ios"
2418
url_launcher:
2519
:path: ".symlinks/plugins/url_launcher/ios"
26-
url_launcher_macos:
27-
:path: ".symlinks/plugins/url_launcher_macos/ios"
28-
url_launcher_web:
29-
:path: ".symlinks/plugins/url_launcher_web/ios"
3020

3121
SPEC CHECKSUMS:
3222
Flutter: 0e3d915762c693b495b44d77113d4970485de6ec
33-
flutter_sodium: c84426b4de738514b5b66cfdeb8a06634e72fe0b
23+
flutter_sodium: cb936f3dfb79fcccd1f48831701b4e3f23e0e3d4
3424
url_launcher: 6fef411d543ceb26efce54b05a0a40bfd74cbbef
35-
url_launcher_macos: fd7894421cd39320dce5f292fc99ea9270b2a313
36-
url_launcher_web: e5527357f037c87560776e36436bf2b0288b965c
3725

38-
PODFILE CHECKSUM: 1b66dae606f75376c5f2135a8290850eeb09ae83
26+
PODFILE CHECKSUM: aafe91acc616949ddb318b77800a7f51bffa2a4c
3927

4028
COCOAPODS: 1.8.4

example/ios/Runner.xcodeproj/project.pbxproj

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,9 +226,16 @@
226226
files = (
227227
);
228228
inputPaths = (
229+
"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh",
230+
"${PODS_ROOT}/../Flutter/Flutter.framework",
231+
"${BUILT_PRODUCTS_DIR}/flutter_sodium/flutter_sodium.framework",
232+
"${BUILT_PRODUCTS_DIR}/url_launcher/url_launcher.framework",
229233
);
230234
name = "[CP] Embed Pods Frameworks";
231235
outputPaths = (
236+
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Flutter.framework",
237+
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/flutter_sodium.framework",
238+
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/url_launcher.framework",
232239
);
233240
runOnlyForDeploymentPostprocessing = 0;
234241
shellPath = /bin/sh;

ios/Classes/FlutterSodiumPlugin.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,4 @@
1-
int sodium_init(void);
1+
#import <Flutter/Flutter.h>
2+
3+
@interface FlutterSodiumPlugin : NSObject<FlutterPlugin>
4+
@end

ios/Classes/FlutterSodiumPlugin.m

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#import "FlutterSodiumPlugin.h"
2+
3+
@implementation FlutterSodiumPlugin
4+
+ (void)registerWithRegistrar:(NSObject<FlutterPluginRegistrar>*)registrar {
5+
}
6+
@end

ios/Classes/FlutterSodiumPlugin.swift

Lines changed: 0 additions & 18 deletions
This file was deleted.

pubspec.yaml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ dev_dependencies:
1818
sdk: flutter
1919

2020
flutter:
21-
plugin:
22-
android:
23-
ios:
21+
plugin:
22+
platforms:
23+
android:
24+
package: com.firstfloorsoftware.flutter_sodium
25+
pluginClass: FlutterSodiumPlugin
26+
ios:
27+
pluginClass: FlutterSodiumPlugin

0 commit comments

Comments
 (0)