Repository: flutter
Issue: Cannot create a Flutter macOS app extension: 'FlutterEngineInitialize' returned 'kInvalidArguments'. The assets path in the Flutter project arguments was missing.
Labels: engine,platform-mac,P3,team-engine,triaged-engine

After https://github.com/flutter/engine/pull/41011/ started publishing artifacts I tried to make a macOS Share extension, but on launch the engine will not start:

```
Failed to find path for "flutter_assets"
embedder.cc (1601): 'FlutterEngineInitialize' returned 'kInvalidArguments'. The assets path in the Flutter project arguments was missing.
```

The App.framework bundle isn't found from the appex bundle.  Suspect macOS needs similar logic to this:
```objc
if ([mainBundle.bundleURL.pathExtension isEqualToString:@"appex"]) {
```
https://github.com/flutter/engine/pull/40332/files#diff-aff27bb72cc390eb03f0b733e1fa490102e311ffac10e8e09e8245e582484220R84

Here:
https://github.com/flutter/engine/blob/b50954c3f7d6dca6702ad843aa0fa7a51c774323/shell/platform/darwin/macos/framework/Source/FlutterDartProject.mm#L32

See also https://github.com/flutter/engine/pull/37421/files#diff-8646d867d6b502217ca15af1cfd042f7148929efb68e1f28d796351a80594832R38 which is changing this same spot.

### Steps to reproduce
1. Create Flutter project
```
$ flutter create test_create
$ cd test_create
$ flutter build macos --config-only
$ open macos/Runner.xcworkspace/
```

2. Add a new Share target and Activate it.
<img width="719" alt="Screenshot 2023-04-12 at 6 11 03 PM" src="https://user-images.githubusercontent.com/682784/231619906-9fd1d435-bde8-45a1-861e-46a37c298422.png">
<img width="726" alt="Screenshot 2023-04-12 at 6 11 26 PM" src="https://user-images.githubusercontent.com/682784/231619914-0033fdc1-857a-49d7-b292-e67bb8e5673b.png">

3. In `test_create/macos/FlutterShare/Info.plist` change `NSExtensionPrincipalClass` to `FlutterViewController`.
<img width="628" alt="Screenshot 2023-04-12 at 6 12 42 PM" src="https://user-images.githubusercontent.com/682784/231620036-02f5a7b1-ef94-45d7-aaae-f190f0eea351.png">

4. In Xcode set a signing Team and set the Signing Certificate to Development for **both** the Runner and new FlutterShare targets. These app extensions fail with codesign errors if they are ad-hoc signed.
<img width="586" alt="Screenshot 2023-04-12 at 6 09 24 PM" src="https://user-images.githubusercontent.com/682784/231619774-ca8b8466-ae4f-4218-a5a7-1cd96554c8ff.png">

5. In the FlutterShare target build settings add `-framework FlutterMacOS` to **Other Linker Flags**
<img width="1011" alt="Screenshot 2023-04-12 at 6 18 00 PM" src="https://user-images.githubusercontent.com/682784/231620748-3f16f13a-1c7a-4659-b998-fb5900e76a55.png">

6. Run the FlutterShare target in Safari
<img width="464" alt="Screenshot 2023-04-12 at 6 13 09 PM" src="https://user-images.githubusercontent.com/682784/231620076-bd122d60-2a26-44f5-b256-0f9f26846af8.png">

7. In the top right corner of Safari under the Share menu choose FlutterShare

![Screenshot 2023-04-12 at 6 15 21 PM](https://user-images.githubusercontent.com/682784/231620316-a50eb43b-af0b-4791-bb69-1caa30894d16.png)


## Results
In Xcode console:
```
2023-04-12 18:17:45.807583-0700 FlutterShare[28145:12591166] Failed to find path for "flutter_assets"
2023-04-12 18:17:45.808568-0700 FlutterShare[28145:12591166] Failed to find path for "flutter_assets"
embedder.cc (1601): 'FlutterEngineInitialize' returned 'kInvalidArguments'. The assets path in the Flutter project arguments was missing.
2023-04-12 18:17:45.808903-0700 FlutterShare[28145:12591166] Failed to initialize Flutter engine: error 2
```
and no UI launches.

cc @cyanglaz part of https://github.com/flutter/flutter/issues/124290