@@ -56,6 +56,11 @@ extern NSString* const FlutterDefaultInitialRoute;
5656 * A newly initialized FlutterEngine will not actually run a Dart Isolate until
5757 * either `-runWithEntrypoint:` or `-runWithEntrypoint:libraryURI` is invoked.
5858 * One of these methods must be invoked before calling `-setViewController:`.
59+ *
60+ * `FlutterEngine` instances must be created and run on the main thread. The engine adopts the
61+ * thread that runs it as its platform thread, which is also used for executing application UI code
62+ * written in Dart. Running an engine on a background queue is not supported, apps and app
63+ * extensions must dispatch to the main queue.
5964 */
6065FLUTTER_DARWIN_EXPORT
6166@interface FlutterEngine : NSObject <FlutterPluginRegistry>
@@ -76,7 +81,7 @@ FLUTTER_DARWIN_EXPORT
7681 * This means that the engine will continue to run regardless of whether a `FlutterViewController`
7782 * is attached to it or not, until `-destroyContext:` is called or the process finishes.
7883 */
79- - (instancetype )init ;
84+ - (instancetype )init NS_SWIFT_UI_ACTOR ;
8085
8186/* *
8287 * Initialize this FlutterEngine.
@@ -95,7 +100,7 @@ FLUTTER_DARWIN_EXPORT
95100 * be unique across FlutterEngine instances, and is used in instrumentation to label
96101 * the threads used by this FlutterEngine.
97102 */
98- - (instancetype )initWithName : (NSString *)labelPrefix ;
103+ - (instancetype )initWithName : (NSString *)labelPrefix NS_SWIFT_UI_ACTOR ;
99104
100105/* *
101106 * Initialize this FlutterEngine with a `FlutterDartProject`.
@@ -116,7 +121,8 @@ FLUTTER_DARWIN_EXPORT
116121 * the threads used by this FlutterEngine.
117122 * @param project The `FlutterDartProject` to run.
118123 */
119- - (instancetype )initWithName : (NSString *)labelPrefix project : (nullable FlutterDartProject*)project ;
124+ - (instancetype )initWithName : (NSString *)labelPrefix
125+ project : (nullable FlutterDartProject*)project NS_SWIFT_UI_ACTOR;
120126
121127/* *
122128 * Initialize this FlutterEngine with a `FlutterDartProject`.
@@ -137,7 +143,7 @@ FLUTTER_DARWIN_EXPORT
137143 */
138144- (instancetype )initWithName : (NSString *)labelPrefix
139145 project : (nullable FlutterDartProject*)project
140- allowHeadlessExecution : (BOOL )allowHeadlessExecution ;
146+ allowHeadlessExecution : (BOOL )allowHeadlessExecution NS_SWIFT_UI_ACTOR ;
141147
142148/* *
143149 * Initialize this FlutterEngine with a `FlutterDartProject`.
@@ -161,7 +167,7 @@ FLUTTER_DARWIN_EXPORT
161167- (instancetype )initWithName : (NSString *)labelPrefix
162168 project : (nullable FlutterDartProject*)project
163169 allowHeadlessExecution : (BOOL )allowHeadlessExecution
164- restorationEnabled : (BOOL )restorationEnabled NS_DESIGNATED_INITIALIZER;
170+ restorationEnabled : (BOOL )restorationEnabled NS_DESIGNATED_INITIALIZER NS_SWIFT_UI_ACTOR ;
165171
166172/* *
167173 * Runs a Dart program on an Isolate from the main Dart library (i.e. the library that
@@ -171,9 +177,11 @@ FLUTTER_DARWIN_EXPORT
171177 * The first call to this method will create a new Isolate. Subsequent calls will return
172178 * immediately and have no effect.
173179 *
180+ * This method must be called on the main thread. See the `FlutterEngine` class documentation.
181+ *
174182 * @return YES if the call succeeds in creating and running a Flutter Engine instance; NO otherwise.
175183 */
176- - (BOOL )run ;
184+ - (BOOL )run NS_SWIFT_UI_ACTOR ;
177185
178186/* *
179187 * Runs a Dart program on an Isolate from the main Dart library (i.e. the library that
@@ -182,14 +190,16 @@ FLUTTER_DARWIN_EXPORT
182190 * The first call to this method will create a new Isolate. Subsequent calls will return
183191 * immediately and have no effect.
184192 *
193+ * This method must be called on the main thread. See the `FlutterEngine` class documentation.
194+ *
185195 * @param entrypoint The name of a top-level function from the same Dart
186196 * library that contains the app's main() function. If this is FlutterDefaultDartEntrypoint (or
187197 * nil) it will default to `main()`. If it is not the app's main() function, that function must
188198 * be decorated with `@pragma(vm:entry-point)` to ensure the method is not tree-shaken by the Dart
189199 * compiler.
190200 * @return YES if the call succeeds in creating and running a Flutter Engine instance; NO otherwise.
191201 */
192- - (BOOL )runWithEntrypoint : (nullable NSString *)entrypoint ;
202+ - (BOOL )runWithEntrypoint : (nullable NSString *)entrypoint NS_SWIFT_UI_ACTOR ;
193203
194204/* *
195205 * Runs a Dart program on an Isolate from the main Dart library (i.e. the library that
@@ -198,6 +208,8 @@ FLUTTER_DARWIN_EXPORT
198208 * The first call to this method will create a new Isolate. Subsequent calls will return
199209 * immediately and have no effect.
200210 *
211+ * This method must be called on the main thread. See the `FlutterEngine` class documentation.
212+ *
201213 * @param entrypoint The name of a top-level function from the same Dart
202214 * library that contains the app's main() function. If this is FlutterDefaultDartEntrypoint (or
203215 * nil), it will default to `main()`. If it is not the app's main() function, that function must
@@ -208,7 +220,7 @@ FLUTTER_DARWIN_EXPORT
208220 * @return YES if the call succeeds in creating and running a Flutter Engine instance; NO otherwise.
209221 */
210222- (BOOL )runWithEntrypoint : (nullable NSString *)entrypoint
211- initialRoute : (nullable NSString *)initialRoute ;
223+ initialRoute : (nullable NSString *)initialRoute NS_SWIFT_UI_ACTOR ;
212224
213225/* *
214226 * Runs a Dart program on an Isolate using the specified entrypoint and Dart library,
@@ -217,6 +229,8 @@ FLUTTER_DARWIN_EXPORT
217229 * The first call to this method will create a new Isolate. Subsequent calls will return
218230 * immediately and have no effect.
219231 *
232+ * This method must be called on the main thread. See the `FlutterEngine` class documentation.
233+ *
220234 * @param entrypoint The name of a top-level function from a Dart library. If this is
221235 * FlutterDefaultDartEntrypoint (or nil); this will default to `main()`. If it is not the app's
222236 * main() function, that function must be decorated with `@pragma(vm:entry-point)` to ensure the
@@ -226,7 +240,8 @@ FLUTTER_DARWIN_EXPORT
226240 * the same library as the `main()` function in the Dart program.
227241 * @return YES if the call succeeds in creating and running a Flutter Engine instance; NO otherwise.
228242 */
229- - (BOOL )runWithEntrypoint : (nullable NSString *)entrypoint libraryURI : (nullable NSString *)uri ;
243+ - (BOOL )runWithEntrypoint : (nullable NSString *)entrypoint
244+ libraryURI : (nullable NSString *)uri NS_SWIFT_UI_ACTOR;
230245
231246/* *
232247 * Runs a Dart program on an Isolate using the specified entrypoint and Dart library,
@@ -235,6 +250,8 @@ FLUTTER_DARWIN_EXPORT
235250 * The first call to this method will create a new Isolate. Subsequent calls will return
236251 * immediately and have no effect.
237252 *
253+ * This method must be called on the main thread. See the `FlutterEngine` class documentation.
254+ *
238255 * @param entrypoint The name of a top-level function from a Dart library. If this is
239256 * FlutterDefaultDartEntrypoint (or nil); this will default to `main()`. If it is not the app's
240257 * main() function, that function must be decorated with `@pragma(vm:entry-point)` to ensure the
@@ -248,7 +265,7 @@ FLUTTER_DARWIN_EXPORT
248265 */
249266- (BOOL )runWithEntrypoint : (nullable NSString *)entrypoint
250267 libraryURI : (nullable NSString *)libraryURI
251- initialRoute : (nullable NSString *)initialRoute ;
268+ initialRoute : (nullable NSString *)initialRoute NS_SWIFT_UI_ACTOR ;
252269
253270/* *
254271 * Runs a Dart program on an Isolate using the specified entrypoint and Dart library,
@@ -257,6 +274,8 @@ FLUTTER_DARWIN_EXPORT
257274 * The first call to this method will create a new Isolate. Subsequent calls will return
258275 * immediately and have no effect.
259276 *
277+ * This method must be called on the main thread. See the `FlutterEngine` class documentation.
278+ *
260279 * @param entrypoint The name of a top-level function from a Dart library. If this is
261280 * FlutterDefaultDartEntrypoint (or nil); this will default to `main()`. If it is not the app's
262281 * main() function, that function must be decorated with `@pragma(vm:entry-point)` to ensure the
@@ -272,7 +291,7 @@ FLUTTER_DARWIN_EXPORT
272291- (BOOL )runWithEntrypoint : (nullable NSString *)entrypoint
273292 libraryURI : (nullable NSString *)libraryURI
274293 initialRoute : (nullable NSString *)initialRoute
275- entrypointArgs : (nullable NSArray <NSString*>*)entrypointArgs ;
294+ entrypointArgs : (nullable NSArray <NSString*>*)entrypointArgs NS_SWIFT_UI_ACTOR ;
276295
277296/* *
278297 * Destroy running context for an engine.
0 commit comments