Skip to content

Commit fd670c6

Browse files
committed
ios compile sucessfull
1 parent a2b106e commit fd670c6

27 files changed

+2371
-28
lines changed

.packages

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Generated by pub on 2018-09-01 16:08:27.344997.
2+
collection:file:///Users/binxu/Documents/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/collection-1.14.11/lib/
3+
flutter:file:///Users/binxu/Documents/flutter/flutter/packages/flutter/lib/
4+
meta:file:///Users/binxu/Documents/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/meta-1.1.6/lib/
5+
sky_engine:file:///Users/binxu/Documents/flutter/flutter/bin/cache/pkg/sky_engine/lib/
6+
typed_data:file:///Users/binxu/Documents/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/typed_data-1.1.6/lib/
7+
vector_math:file:///Users/binxu/Documents/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/vector_math-2.0.8/lib/
8+
flutter_cpp_plugin:lib/

ios/Classes/CppPlugin.h

+1-3
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33

44
@interface FLTCppPlugin : NSObject
55

6-
+ (FLTCppPlugin *) getInstance;
7-
8-
- (void)initPlugin:(FlutterBinaryMessenger*) messenger;
6+
+ (void)initPlugin:(NSObject<FlutterBinaryMessenger>*) messenger;
97

108
@end

ios/Classes/CppPlugin.mm

+17-25
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,19 @@
11
#import "CppPlugin.h"
2-
#include "plugin_manager.h"
2+
#include <plugin_manager.h>
33
#include <stdio.h>
44

55
@implementation FLTCppPlugin
6-
{
7-
FlutterBinaryMessenger* messenger;
8-
}
9-
10-
static FLTCppPlugin* instance = nil;
116

12-
+(FLTCppPlugin *) getInstance{
13-
if (instance == nil) {
14-
instance = [[FLTCppPlugin alloc] init];
15-
}
16-
return instance;
17-
}
7+
static NSObject<FlutterBinaryMessenger> * sMessenger=nil;
8+
static FLTCppPlugin* sInstance = nil;
189

19-
- (void)initPlugin:(FlutterBinaryMessenger*) messenger{
20-
_messenger=messenger;
10+
+ (void)initPlugin:(NSObject<FlutterBinaryMessenger>*) messenger{
11+
sMessenger=messenger;
2112
plugin_main();
2213
}
2314

24-
- (FlutterBinaryMessenger*)getMessenger{
25-
return _messenger;
15+
+ (NSObject<FlutterBinaryMessenger>*)getMessenger{
16+
return sMessenger;
2617
}
2718
@end
2819

@@ -61,7 +52,7 @@ virtual void NotImplementedInternal()
6152

6253
void Reply(const uint8_t* data,size_t len)
6354
{
64-
NSData* nsdata=null;
55+
NSData* nsdata=NULL;
6556
if(data)
6657
{
6758
nsdata = [NSData dataWithBytes:data length:len];
@@ -71,12 +62,12 @@ void Reply(const uint8_t* data,size_t len)
7162

7263
private:
7364
Plugin* m_plugin;
74-
FlutterBinaryReply m_reply
65+
FlutterBinaryReply m_reply;
7566
};
7667

7768

7869

79-
PluginManagerIos* s_manager=NULL;
70+
class PluginManagerIos* s_manager=NULL;
8071

8172
class PluginManagerIos:public PluginManager
8273
{
@@ -90,7 +81,8 @@ virtual void RegisterPlugin(Plugin* plugin)
9081
{
9182
PluginManager::RegisterPlugin(plugin);
9283

93-
FlutterBinaryMessenger* messenger = [[FLTCppPlugin getInstance] getMessenger];
84+
NSObject<FlutterBinaryMessenger>* messenger = [FLTCppPlugin getMessenger];
85+
9486
if(!messenger)
9587
{
9688
printf("FLTCppPlugin not inited");
@@ -103,35 +95,35 @@ virtual void RegisterPlugin(Plugin* plugin)
10395
FlutterBinaryMessageHandler handler=^(NSData* _Nullable message, FlutterBinaryReply reply){
10496

10597
std::unique_ptr<MethodResult> method_result = std::make_unique<MethodResultIos>(plugin,reply);
106-
PluginManager::Instance()->HandleMethodCall(channel,[message bytes],message->length,std::move(method_result));
98+
PluginManager::Instance()->HandleMethodCall(channel,(const uint8_t*)message.bytes,message.length,std::move(method_result));
10799
};
108100
[messenger setMessageHandlerOnChannel:nschannel binaryMessageHandler:handler];
109101
}
110102

111103
virtual void UnRegisterPlugin(Plugin* plugin)
112104
{
113105
PluginManager::UnRegisterPlugin(plugin);
114-
FlutterBinaryMessenger* messenger = [[FLTCppPlugin getInstance] getMessenger];
106+
NSObject<FlutterBinaryMessenger>* messenger = [FLTCppPlugin getMessenger];
115107
if(!messenger)
116108
{
117109
printf("FLTCppPlugin not inited");
118110
return;
119111
}
120112
std::string channel = plugin->channel();
121113
NSString *nschannel= [NSString stringWithCString:channel.c_str() encoding:NSUTF8StringEncoding];
122-
[messenger setMessageHandlerOnChannel:nschannel binaryMessageHandler:null];
114+
[messenger setMessageHandlerOnChannel:nschannel binaryMessageHandler:NULL];
123115
}
124116

125117
virtual void InvokeMethodCall(const std::string &channel,const uint8_t* data,size_t len)
126118
{
127-
FlutterBinaryMessenger* messenger = [[FLTCppPlugin getInstance] getMessenger];
119+
NSObject<FlutterBinaryMessenger>* messenger = [FLTCppPlugin getMessenger];
128120
if(!messenger)
129121
{
130122
printf("FLTCppPlugin not inited");
131123
return;
132124
}
133125
NSString *nschannel= [NSString stringWithCString:channel.c_str() encoding:NSUTF8StringEncoding];
134-
NSData *nsdata = null;
126+
NSData *nsdata = NULL;
135127
if(data)
136128
nsdata = [NSData dataWithBytes:data length:len];
137129
[messenger sendOnChannel:nschannel message:nsdata];
+54
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
// Copyright 2016 The Chromium Authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style license that can be
3+
// found in the LICENSE file.
4+
5+
#ifndef FLUTTER_FLUTTER_H_
6+
#define FLUTTER_FLUTTER_H_
7+
8+
/**
9+
BREAKING CHANGES:
10+
11+
July 26, 2018: Marked -[FlutterDartProject
12+
initFromDefaultSourceForConfiguration] deprecated.
13+
14+
February 28, 2018: Removed "initWithFLXArchive" and
15+
"initWithFLXArchiveWithScriptSnapshot".
16+
17+
January 15, 2018: Marked "initWithFLXArchive" and
18+
"initWithFLXArchiveWithScriptSnapshot" as unavailable following the
19+
deprecation from December 11, 2017. Scheduled to be removed on February
20+
19, 2018.
21+
22+
January 09, 2018: Deprecated "FlutterStandardBigInteger" and its use in
23+
"FlutterStandardMessageCodec" and "FlutterStandardMethodCodec". Scheduled to
24+
be marked as unavailable once the deprecation has been available on the
25+
flutter/flutter alpha branch for four weeks. "FlutterStandardBigInteger" was
26+
needed because the Dart 1.0 int type had no size limit. With Dart 2.0, the
27+
int type is a fixed-size, 64-bit signed integer. If you need to communicate
28+
larger integers, use NSString encoding instead.
29+
30+
December 11, 2017: Deprecated "initWithFLXArchive" and
31+
"initWithFLXArchiveWithScriptSnapshot" and scheculed the same to be marked as
32+
unavailable on January 15, 2018. Instead, "initWithFlutterAssets" and
33+
"initWithFlutterAssetsWithScriptSnapshot" should be used. The reason for this
34+
change is that the FLX archive will be deprecated and replaced with a flutter
35+
assets directory containing the same files as the FLX did.
36+
37+
November 29, 2017: Added a BREAKING CHANGES section.
38+
*/
39+
40+
#include "FlutterAppDelegate.h"
41+
#include "FlutterBinaryMessenger.h"
42+
#include "FlutterCallbackCache.h"
43+
#include "FlutterChannels.h"
44+
#include "FlutterCodecs.h"
45+
#include "FlutterDartProject.h"
46+
#include "FlutterHeadlessDartRunner.h"
47+
#include "FlutterMacros.h"
48+
#include "FlutterNavigationController.h"
49+
#include "FlutterPlugin.h"
50+
#include "FlutterPluginAppLifeCycleDelegate.h"
51+
#include "FlutterTexture.h"
52+
#include "FlutterViewController.h"
53+
54+
#endif // FLUTTER_FLUTTER_H_
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
// Copyright 2016 The Chromium Authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style license that can be
3+
// found in the LICENSE file.
4+
5+
#ifndef FLUTTER_FLUTTERAPPDELEGATE_H_
6+
#define FLUTTER_FLUTTERAPPDELEGATE_H_
7+
8+
#import <UIKit/UIKit.h>
9+
10+
#include "FlutterMacros.h"
11+
#include "FlutterPlugin.h"
12+
13+
/**
14+
* UIApplicationDelegate subclass for simple apps that want default behavior.
15+
*
16+
* This class provides the following behaviors:
17+
* * Status bar touches are forwarded to the key window's root view
18+
* FlutterViewController, in order to trigger scroll to top.
19+
* * Keeps the Flutter connection open in debug mode when the phone screen
20+
* locks.
21+
*
22+
* App delegates for Flutter applications are *not* required to inherit from
23+
* this class. Developers of custom app delegate classes should copy and paste
24+
* code as necessary from FlutterAppDelegate.mm.
25+
*/
26+
FLUTTER_EXPORT
27+
@interface FlutterAppDelegate : UIResponder<UIApplicationDelegate, FlutterPluginRegistry, FlutterAppLifeCycleProvider>
28+
29+
@property(strong, nonatomic) UIWindow* window;
30+
31+
@end
32+
33+
#endif // FLUTTER_FLUTTERDARTPROJECT_H_
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
// Copyright 2017 The Chromium Authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style license that can be
3+
// found in the LICENSE file.
4+
5+
#ifndef FLUTTER_FLUTTERBINARYMESSENGER_H_
6+
#define FLUTTER_FLUTTERBINARYMESSENGER_H_
7+
8+
#import <Foundation/Foundation.h>
9+
10+
#include "FlutterMacros.h"
11+
12+
NS_ASSUME_NONNULL_BEGIN
13+
/**
14+
A message reply callback.
15+
16+
Used for submitting a binary reply back to a Flutter message sender. Also used
17+
in the dual capacity for handling a binary message reply received from Flutter.
18+
19+
- Parameters:
20+
- reply: The reply.
21+
*/
22+
typedef void (^FlutterBinaryReply)(NSData* _Nullable reply);
23+
24+
/**
25+
A strategy for handling incoming binary messages from Flutter and to send
26+
asynchronous replies back to Flutter.
27+
28+
- Parameters:
29+
- message: The message.
30+
- reply: A callback for submitting a reply to the sender.
31+
*/
32+
typedef void (^FlutterBinaryMessageHandler)(NSData* _Nullable message, FlutterBinaryReply reply);
33+
34+
/**
35+
A facility for communicating with the Flutter side using asynchronous message
36+
passing with binary messages.
37+
38+
- SeeAlso:
39+
- `FlutterBasicMessageChannel`, which supports communication using structured
40+
messages.
41+
- `FlutterMethodChannel`, which supports communication using asynchronous
42+
method calls.
43+
- `FlutterEventChannel`, which supports commuication using event streams.
44+
*/
45+
FLUTTER_EXPORT
46+
@protocol FlutterBinaryMessenger<NSObject>
47+
/**
48+
Sends a binary message to the Flutter side on the specified channel, expecting
49+
no reply.
50+
51+
- Parameters:
52+
- channel: The channel name.
53+
- message: The message.
54+
*/
55+
- (void)sendOnChannel:(NSString*)channel message:(NSData* _Nullable)message;
56+
57+
/**
58+
Sends a binary message to the Flutter side on the specified channel, expecting
59+
an asynchronous reply.
60+
61+
- Parameters:
62+
- channel: The channel name.
63+
- message: The message.
64+
- callback: A callback for receiving a reply.
65+
*/
66+
- (void)sendOnChannel:(NSString*)channel
67+
message:(NSData* _Nullable)message
68+
binaryReply:(FlutterBinaryReply _Nullable)callback;
69+
70+
/**
71+
Registers a message handler for incoming binary messages from the Flutter side
72+
on the specified channel.
73+
74+
Replaces any existing handler. Use a `nil` handler for unregistering the
75+
existing handler.
76+
77+
- Parameters:
78+
- channel: The channel name.
79+
- handler: The message handler.
80+
*/
81+
- (void)setMessageHandlerOnChannel:(NSString*)channel
82+
binaryMessageHandler:(FlutterBinaryMessageHandler _Nullable)handler;
83+
@end
84+
NS_ASSUME_NONNULL_END
85+
#endif // FLUTTER_FLUTTERBINARYMESSENGER_H_
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
// Copyright 2018 The Chromium Authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style license that can be
3+
// found in the LICENSE file.
4+
5+
#ifndef FLUTTER_FLUTTERCALLBACKCACHE_H_
6+
#define FLUTTER_FLUTTERCALLBACKCACHE_H_
7+
8+
#import <Foundation/Foundation.h>
9+
10+
#include "FlutterMacros.h"
11+
12+
FLUTTER_EXPORT
13+
@interface FlutterCallbackInformation : NSObject
14+
@property(retain) NSString* callbackName;
15+
@property(retain) NSString* callbackClassName;
16+
@property(retain) NSString* callbackLibraryPath;
17+
@end
18+
19+
FLUTTER_EXPORT
20+
@interface FlutterCallbackCache : NSObject
21+
/**
22+
Returns the callback information for the given callback handle.
23+
This callback information can be used when spawning a
24+
FlutterHeadlessDartRunner.
25+
26+
- Parameter handle: The handle for a callback, provided by the
27+
Dart method `PluginUtilities.getCallbackHandle`.
28+
- Returns: A FlutterCallbackInformation object which contains the name of the
29+
callback, the name of the class in which the callback is defined, and the
30+
path of the library which contains the callback. If the provided handle is
31+
invalid, nil is returned.
32+
*/
33+
+ (FlutterCallbackInformation*)lookupCallbackInformation:(int64_t)handle;
34+
35+
@end
36+
37+
#endif // FLUTTER_FLUTTERCALLBACKCACHE_H_

0 commit comments

Comments
 (0)