Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

To step 12 > 2 #1288

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
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
1 change: 0 additions & 1 deletion pkgs/cupertino_http/darwin/Classes/CUPHTTPClientDelegate.m

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

1 change: 0 additions & 1 deletion pkgs/cupertino_http/darwin/Classes/dart_api_dl.c

This file was deleted.

8 changes: 2 additions & 6 deletions pkgs/cupertino_http/darwin/cupertino_http.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,9 @@ Pod::Spec.new do |s|
s.homepage = 'https://github.com/dart-lang/http/tree/master/pkgs/cupertino_http'
s.license = { :type => 'BSD', :file => '../LICENSE' }
s.author = { 'TODO' => 'use-valid-author' }
s.source = { :http => 'https://github.com/dart-lang/http/tree/master/pkgs/cupertino_http' }

# This will ensure the source files in Classes/ are included in the native
# builds of apps using this FFI plugin. Podspec does not support relative
# paths, so Classes contains a forwarder C file that relatively imports
# `../src/*` so that the C sources can be shared among all target platforms.
s.source = { :path => '.' }
s.source_files = 'Classes/**/*'
s.source_files = 'cupertino_http/Sources/cupertino_http/**/*'
s.ios.dependency 'Flutter'
s.osx.dependency 'FlutterMacOS'
s.ios.deployment_target = '12.0'
Expand Down
28 changes: 28 additions & 0 deletions pkgs/cupertino_http/darwin/cupertino_http/Package.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// swift-tools-version: 5.9
// The swift-tools-version declares the minimum version of Swift required to build this package.

import PackageDescription

let package = Package(
name: "cupertino_http",
platforms: [
.iOS("12.0"),
.macOS("10.4"),
],
products: [
.library(name: "cupertino-http", targets: ["cupertino_http"])
],
dependencies: [],
targets: [
.target(
name: "cupertino_http",
dependencies: [],
resources: [
],
cSettings: [
.headerSearchPath("include/cupertino_http"),
.unsafeFlags(["-fno-objc-arc"]),
]
)
]
)
2 changes: 2 additions & 0 deletions pkgs/cupertino_http/example/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@
*.swp
.DS_Store
.atom/
.build/
.buildlog/
.history
.svn/
.swiftpm/
migrate_working_dir/

# IntelliJ related
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package io.flutter.plugins;

import androidx.annotation.Keep;
import androidx.annotation.NonNull;
import io.flutter.Log;

import io.flutter.embedding.engine.FlutterEngine;

/**
* Generated file. Do not edit.
* This file is generated by the Flutter tool based on the
* plugins that support the Android platform.
*/
@Keep
public final class GeneratedPluginRegistrant {
private static final String TAG = "GeneratedPluginRegistrant";
public static void registerWith(@NonNull FlutterEngine flutterEngine) {
try {
flutterEngine.getPlugins().add(new dev.flutter.plugins.integration_test.IntegrationTestPlugin());
} catch (Exception e) {
Log.e(TAG, "Error registering plugin integration_test, dev.flutter.plugins.integration_test.IntegrationTestPlugin", e);
}
}
}
2 changes: 2 additions & 0 deletions pkgs/cupertino_http/example/android/local.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
sdk.dir=/Users/bquinlan/Library/Android/sdk
flutter.sdk=/Users/bquinlan/flutter
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
//
// Generated file. Do not edit.
//

// clang-format off

#include "generated_plugin_registrant.h"


void fl_register_plugins(FlPluginRegistry* registry) {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
//
// Generated file. Do not edit.
//

// clang-format off

#ifndef GENERATED_PLUGIN_REGISTRANT_
#define GENERATED_PLUGIN_REGISTRANT_

#include <flutter_linux/flutter_linux.h>

// Registers Flutter plugins.
void fl_register_plugins(FlPluginRegistry* registry);

#endif // GENERATED_PLUGIN_REGISTRANT_
23 changes: 23 additions & 0 deletions pkgs/cupertino_http/example/linux/flutter/generated_plugins.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#
# Generated file, do not edit.
#

list(APPEND FLUTTER_PLUGIN_LIST
)

list(APPEND FLUTTER_FFI_PLUGIN_LIST
)

set(PLUGIN_BUNDLED_LIBRARIES)

foreach(plugin ${FLUTTER_PLUGIN_LIST})
add_subdirectory(flutter/ephemeral/.plugin_symlinks/${plugin}/linux plugins/${plugin})
target_link_libraries(${BINARY_NAME} PRIVATE ${plugin}_plugin)
list(APPEND PLUGIN_BUNDLED_LIBRARIES $<TARGET_FILE:${plugin}_plugin>)
list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${plugin}_bundled_libraries})
endforeach(plugin)

foreach(ffi_plugin ${FLUTTER_FFI_PLUGIN_LIST})
add_subdirectory(flutter/ephemeral/.plugin_symlinks/${ffi_plugin}/linux plugins/${ffi_plugin})
list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${ffi_plugin}_bundled_libraries})
endforeach(ffi_plugin)
2 changes: 1 addition & 1 deletion pkgs/cupertino_http/example/macos/Podfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
platform :osx, '10.13'
platform :osx, '10.14'

# CocoaPods analytics sends network stats synchronously affecting flutter build latency.
ENV['COCOAPODS_DISABLE_STATS'] = 'true'
Expand Down
13 changes: 7 additions & 6 deletions pkgs/cupertino_http/example/macos/Podfile.lock
Original file line number Diff line number Diff line change
@@ -1,22 +1,23 @@
PODS:
- cupertino_http (0.0.1):
- Flutter
- FlutterMacOS
- FlutterMacOS (1.0.0)

DEPENDENCIES:
- cupertino_http (from `Flutter/ephemeral/.symlinks/plugins/cupertino_http/macos`)
- cupertino_http (from `Flutter/ephemeral/.symlinks/plugins/cupertino_http/darwin`)
- FlutterMacOS (from `Flutter/ephemeral`)

EXTERNAL SOURCES:
cupertino_http:
:path: Flutter/ephemeral/.symlinks/plugins/cupertino_http/macos
:path: Flutter/ephemeral/.symlinks/plugins/cupertino_http/darwin
FlutterMacOS:
:path: Flutter/ephemeral

SPEC CHECKSUMS:
cupertino_http: afa11b9e2786b62da2671e4ddd32caf792503748
FlutterMacOS: 85f90bfb3f1703249cf1539e4dfbff31e8584698
cupertino_http: 1c08a57f2f5de1fb61844cf904b226be50f2bee1
FlutterMacOS: 8f6f14fa908a6fb3fba0cd85dbd81ec4b251fb24

PODFILE CHECKSUM: a884f6dd3f7494f3892ee6c81feea3a3abbf9153
PODFILE CHECKSUM: 353c8bcc5d5b0994e508d035b5431cfe18c1dea7

COCOAPODS: 1.11.2
COCOAPODS: 1.15.2
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@
isa = PBXProject;
attributes = {
LastSwiftUpdateCheck = 0920;
LastUpgradeCheck = 1300;
LastUpgradeCheck = 1510;
ORGANIZATIONNAME = "";
TargetAttributes = {
33CC10EC2044A3C60003C045 = {
Expand Down Expand Up @@ -405,7 +405,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
MACOSX_DEPLOYMENT_TARGET = 10.13;
MACOSX_DEPLOYMENT_TARGET = 10.14;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = macosx;
SWIFT_COMPILATION_MODE = wholemodule;
Expand Down Expand Up @@ -484,7 +484,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
MACOSX_DEPLOYMENT_TARGET = 10.13;
MACOSX_DEPLOYMENT_TARGET = 10.14;
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = macosx;
Expand Down Expand Up @@ -531,7 +531,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
MACOSX_DEPLOYMENT_TARGET = 10.13;
MACOSX_DEPLOYMENT_TARGET = 10.14;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = macosx;
SWIFT_COMPILATION_MODE = wholemodule;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1300"
LastUpgradeVersion = "1510"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
6 changes: 5 additions & 1 deletion pkgs/cupertino_http/example/macos/Runner/AppDelegate.swift
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
import Cocoa
import FlutterMacOS

@NSApplicationMain
@main
class AppDelegate: FlutterAppDelegate {
override func applicationShouldTerminateAfterLastWindowClosed(_ sender: NSApplication) -> Bool {
return true
}

override func applicationSupportsSecureRestorableState(_ app: NSApplication) -> Bool {
return true
}
}
35 changes: 23 additions & 12 deletions pkgs/cupertino_http/lib/src/utils.dart
Original file line number Diff line number Diff line change
Expand Up @@ -27,21 +27,32 @@ final ncb.NativeCupertinoHttp linkedLibs = () {
/// library.
final ncb.NativeCupertinoHttp helperLibs = _loadHelperLibrary();

DynamicLibrary _loadHelperDynamicLibrary() {
if (Platform.isMacOS || Platform.isIOS) {
return DynamicLibrary.open('$_libName.framework/$_libName');
ncb.NativeCupertinoHttp _loadHelperLibrary() {
if (!Platform.isMacOS && !Platform.isIOS) {
throw UnsupportedError(
'Platform ${Platform.operatingSystem} is not supported');
}

throw UnsupportedError(
'Platform ${Platform.operatingSystem} is not supported');
}

ncb.NativeCupertinoHttp _loadHelperLibrary() {
final lib = _loadHelperDynamicLibrary();
late DynamicLibrary lib;
late int Function(Pointer<Void>) initializeApi;
late int initializeResult;

lib = DynamicLibrary.process();
try {
initializeApi = lib.lookupFunction<IntPtr Function(Pointer<Void>),
int Function(Pointer<Void>)>('Dart_InitializeApiDL');
// ignore: avoid_catching_errors
} on ArgumentError {
// Dart_InitializeApiDL is not available in the current process. Assume
// that is was build as a dynamic library.
// TODO: remove this when package:cupertino_http no longer supports
// CocoaPods (which uses dynamic linking).
lib = DynamicLibrary.open('$_libName.framework/$_libName');
initializeApi = lib.lookupFunction<IntPtr Function(Pointer<Void>),
int Function(Pointer<Void>)>('Dart_InitializeApiDL');
}

final initializeApi = lib.lookupFunction<IntPtr Function(Pointer<Void>),
int Function(Pointer<Void>)>('Dart_InitializeApiDL');
final initializeResult = initializeApi(NativeApi.initializeApiDLData);
initializeResult = initializeApi(NativeApi.initializeApiDLData);
if (initializeResult != 0) {
throw StateError('failed to init API.');
}
Expand Down
Loading