Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## [0.1.1] - 19/12/2021

- Keeping dependencies up-to-date
- More flexibility on hard-coded text messages
- Improving example code

## [0.1.0] - 16/05/2021
This is a major change as we are forcing an upgrade on the SDK.

Expand Down
76 changes: 15 additions & 61 deletions example/ios/Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,78 +10,32 @@ project 'Runner', {
'Release' => :release,
}

def parse_KV_file(file, separator='=')
file_abs_path = File.expand_path(file)
if !File.exists? file_abs_path
return [];
def flutter_root
generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'Generated.xcconfig'), __FILE__)
unless File.exist?(generated_xcode_build_settings_path)
raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure flutter pub get is executed first"
end
generated_key_values = {}
skip_line_start_symbols = ["#", "/"]
File.foreach(file_abs_path) do |line|
next if skip_line_start_symbols.any? { |symbol| line =~ /^\s*#{symbol}/ }
plugin = line.split(pattern=separator)
if plugin.length == 2
podname = plugin[0].strip()
path = plugin[1].strip()
podpath = File.expand_path("#{path}", file_abs_path)
generated_key_values[podname] = podpath
else
puts "Invalid plugin specification: #{line}"
end

File.foreach(generated_xcode_build_settings_path) do |line|
matches = line.match(/FLUTTER_ROOT\=(.*)/)
return matches[1].strip if matches
end
generated_key_values
raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Generated.xcconfig, then run flutter pub get"
end

require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root)

flutter_ios_podfile_setup

target 'Runner' do
use_frameworks!
use_modular_headers!

# Flutter Pod

copied_flutter_dir = File.join(__dir__, 'Flutter')
copied_framework_path = File.join(copied_flutter_dir, 'Flutter.framework')
copied_podspec_path = File.join(copied_flutter_dir, 'Flutter.podspec')
unless File.exist?(copied_framework_path) && File.exist?(copied_podspec_path)
# Copy Flutter.framework and Flutter.podspec to Flutter/ to have something to link against if the xcode backend script has not run yet.
# That script will copy the correct debug/profile/release version of the framework based on the currently selected Xcode configuration.
# CocoaPods will not embed the framework on pod install (before any build phases can generate) if the dylib does not exist.

generated_xcode_build_settings_path = File.join(copied_flutter_dir, 'Generated.xcconfig')
unless File.exist?(generated_xcode_build_settings_path)
raise "Generated.xcconfig must exist. If you're running pod install manually, make sure flutter pub get is executed first"
end
generated_xcode_build_settings = parse_KV_file(generated_xcode_build_settings_path)
cached_framework_dir = generated_xcode_build_settings['FLUTTER_FRAMEWORK_DIR'];

unless File.exist?(copied_framework_path)
FileUtils.cp_r(File.join(cached_framework_dir, 'Flutter.framework'), copied_flutter_dir)
end
unless File.exist?(copied_podspec_path)
FileUtils.cp(File.join(cached_framework_dir, 'Flutter.podspec'), copied_flutter_dir)
end
end

# Keep pod path relative so it can be checked into Podfile.lock.
pod 'Flutter', :path => 'Flutter'

# Plugin Pods

# Prepare symlinks folder. We use symlinks to avoid having Podfile.lock
# referring to absolute paths on developers' machines.
system('rm -rf .symlinks')
system('mkdir -p .symlinks/plugins')
plugin_pods = parse_KV_file('../.flutter-plugins')
plugin_pods.each do |name, path|
symlink = File.join('.symlinks', 'plugins', name)
File.symlink(path, symlink)
pod name, :path => File.join(symlink, 'ios')
end
flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__))
end

post_install do |installer|
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings['ENABLE_BITCODE'] = 'NO'
end
flutter_additional_ios_build_settings(target)
end
end
28 changes: 5 additions & 23 deletions example/ios/Podfile.lock
Original file line number Diff line number Diff line change
@@ -1,46 +1,28 @@
PODS:
- Flutter (1.0.0)
- in_app_update (0.0.1):
- Flutter
- package_info (0.0.1):
- Flutter
- url_launcher (0.0.1):
- Flutter
- url_launcher_macos (0.0.1):
- Flutter
- url_launcher_web (0.0.1):
- Flutter

DEPENDENCIES:
- Flutter (from `Flutter`)
- in_app_update (from `.symlinks/plugins/in_app_update/ios`)
- package_info (from `.symlinks/plugins/package_info/ios`)
- url_launcher (from `.symlinks/plugins/url_launcher/ios`)
- url_launcher_macos (from `.symlinks/plugins/url_launcher_macos/ios`)
- url_launcher_web (from `.symlinks/plugins/url_launcher_web/ios`)

EXTERNAL SOURCES:
Flutter:
:path: Flutter
in_app_update:
:path: ".symlinks/plugins/in_app_update/ios"
package_info:
:path: ".symlinks/plugins/package_info/ios"
url_launcher:
:path: ".symlinks/plugins/url_launcher/ios"
url_launcher_macos:
:path: ".symlinks/plugins/url_launcher_macos/ios"
url_launcher_web:
:path: ".symlinks/plugins/url_launcher_web/ios"

SPEC CHECKSUMS:
Flutter: 0e3d915762c693b495b44d77113d4970485de6ec
in_app_update: 16e877e205f4360264cb536e3a6481f0d90299e1
package_info: 48b108e75b8802c2d5e126f208ef540561c98aef
url_launcher: a1c0cc845906122c4784c542523d8cacbded5626
url_launcher_macos: fd7894421cd39320dce5f292fc99ea9270b2a313
url_launcher_web: e5527357f037c87560776e36436bf2b0288b965c
Flutter: 434fef37c0980e73bb6479ef766c45957d4b510c
package_info: 873975fc26034f0b863a300ad47e7f1ac6c7ec62
url_launcher: 6fef411d543ceb26efce54b05a0a40bfd74cbbef

PODFILE CHECKSUM: c34e2287a9ccaa606aeceab922830efb9a6ff69a
PODFILE CHECKSUM: aafe91acc616949ddb318b77800a7f51bffa2a4c

COCOAPODS: 1.9.1
COCOAPODS: 1.9.3
7 changes: 0 additions & 7 deletions example/ios/Runner.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -227,15 +227,11 @@
);
inputPaths = (
"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh",
"${PODS_ROOT}/../Flutter/Flutter.framework",
"${BUILT_PRODUCTS_DIR}/in_app_update/in_app_update.framework",
"${BUILT_PRODUCTS_DIR}/package_info/package_info.framework",
"${BUILT_PRODUCTS_DIR}/url_launcher/url_launcher.framework",
);
name = "[CP] Embed Pods Frameworks";
outputPaths = (
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Flutter.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/in_app_update.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/package_info.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/url_launcher.framework",
);
Expand Down Expand Up @@ -316,7 +312,6 @@
/* Begin XCBuildConfiguration section */
249021D3217E4FDB00AE95B9 /* Profile */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_NONNULL = YES;
Expand Down Expand Up @@ -393,7 +388,6 @@
};
97C147031CF9000F007C117D /* Debug */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = 9740EEB21CF90195004384FC /* Debug.xcconfig */;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_NONNULL = YES;
Expand Down Expand Up @@ -449,7 +443,6 @@
};
97C147041CF9000F007C117D /* Release */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_NONNULL = YES;
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 3 additions & 4 deletions example/lib/dio.dart
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,11 @@ class _HomeState extends State<Home> {
/// response of HTTP request.
/// Let's say the statusCode 412 requires you to force update
Future.delayed(Duration.zero, () {
if (statusCode == HttpStatus.unauthorized;) {
if (statusCode == HttpStatus.unauthorized) {
NativeUpdater.displayUpdateAlert(
context,
forceUpdate: true,
appStoreUrl: '<Your App Store URL>',
playStoreUrl: '<Your Play Store URL>',
iOSDescription: '<Your iOS description>',
iOSUpdateButtonLabel: 'Upgrade',
iOSCloseButtonLabel: 'Exit',
Expand All @@ -48,15 +47,15 @@ class _HomeState extends State<Home> {
title: Text('Your App'),
),
body: Center(
child: FlatButton(
child: TextButton(
onPressed: requestAPI,
child: Text('Request API')
),
),
);
}

requestAPI() {
requestAPI() async {
var dio = Dio(BaseOptions(
baseUrl: 'http://httpbin.org/',
));
Expand Down
5 changes: 3 additions & 2 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -43,17 +43,18 @@ class _HomeState extends State<Home> {
context,
forceUpdate: true,
appStoreUrl: '<Your App Store URL>',
playStoreUrl: '<Your Play Store URL>',
iOSDescription: '<Your iOS description>',
iOSUpdateButtonLabel: 'Upgrade',
iOSCloseButtonLabel: 'Exit',
errorText: "Error",
errorCloseButtonLabel: "Close",
errorSubtitle: "This version of the app isn't legit"
);
} else if (serverLatestVersion > localVersion) {
NativeUpdater.displayUpdateAlert(
context,
forceUpdate: false,
appStoreUrl: '<Your App Store URL>',
playStoreUrl: '<Your Play Store URL>',
iOSDescription: '<Your description>',
iOSUpdateButtonLabel: 'Upgrade',
iOSIgnoreButtonLabel: 'Next Time',
Expand Down
Loading