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

[native_assets] There's two errors thrown by Xcode 15.3 when submitting Flutter apps built with native_assets to the App Store. #148044

Closed
Tracked by #129757 ...
dcharkes opened this issue May 9, 2024 · 3 comments
Labels
r: fixed Issue is closed as already fixed in a newer version team-tool Owned by Flutter Tool team tool Affects the "flutter" command-line tool. See also t: labels.

Comments

@dcharkes
Copy link
Contributor

dcharkes commented May 9, 2024

There's two errors thrown by Xcode 15.3 when submitting Flutter apps built with native_assets to the App Store.

First is:

 This bundle is invalid. The bundle at path Payload/Runner.app/Frameworks/sherpa_onnx_dart.framework has an invalid CFBundleIdentifier 'io.flutter.flutter.native_assets.sherpa_onnx_dart' There are invalid characters(characters that are not dots, hyphen and alphanumerics) that have been replaced with their code point 'io.flutter.flutter.native\\u005fassets.sherpa\\u005fonnx\\u005fdart' CFBundleIdentifier must be present, must contain only alphanumerics, dots, hyphens and must not end with a dot.

Per the Apple reference, underscores can't be used in CFBundleIdentifier, so perhaps we could replace hyphens with underscores here, e.g.

<key>CFBundleIdentifier</key>
<string>io.flutter.flutter.native-assets.${name.replaceAll("_", "-")}</string>

The second issue is similar, the generated Info.plist does not contain an entry for MinimumOSVersion, so trying to publish via XCode will throw the following error:

Asset validation failed. Missing Info.plist value. A value for the key 'MinimumOSVersion' in bundle Runner.app/Frameworks/sherpa-onnx-dart.framework is required.

Workaround is to add the following to native_assets_host.dart

  <key>MinimumOSVersion</key>
  <string>13.0</string>

I haven't submitted a PR because I suspect there's a broader fix to the native_assets framework build process to consume some user-specified configuration (e.g. this may be contemplated by this issue here.

Originally posted by @nmfisher in #129757 (comment)

@dcharkes
Copy link
Contributor Author

dcharkes commented May 9, 2024

Thanks for the report @nmfisher!

There's two errors thrown by Xcode 15.3 when submitting Flutter apps built with native_assets to the App Store.

First is:

 This bundle is invalid. The bundle at path Payload/Runner.app/Frameworks/sherpa_onnx_dart.framework has an invalid CFBundleIdentifier 'io.flutter.flutter.native_assets.sherpa_onnx_dart' There are invalid characters(characters that are not dots, hyphen and alphanumerics) that have been replaced with their code point 'io.flutter.flutter.native\\u005fassets.sherpa\\u005fonnx\\u005fdart' CFBundleIdentifier must be present, must contain only alphanumerics, dots, hyphens and must not end with a dot.

Per the Apple reference, underscores can't be used in CFBundleIdentifier, so perhaps we could replace hyphens with underscores here, e.g.

<key>CFBundleIdentifier</key>
<string>io.flutter.flutter.native-assets.${name.replaceAll("_", "-")}</string>

I am not sure if the CFBundleIdentifier must be in some way identical to the framework name. If yes, then we should do the search-replace in the code modified in #144568. Also that PR shows where test cases can be added.

fileName = fileName.replaceAll(RegExp(r'[^A-Za-z0-9_-]'), '');

If the CFBundleIdentifier does not have to be equal to the framework name, we don't have to, but we should possibly still take care of when the rename happens that there are no duplicates.

The second issue is similar, the generated Info.plist does not contain an entry for MinimumOSVersion, so trying to publish via XCode will throw the following error:

Asset validation failed. Missing Info.plist value. A value for the key 'MinimumOSVersion' in bundle Runner.app/Frameworks/sherpa-onnx-dart.framework is required.

Workaround is to add the following to native_assets_host.dart

  <key>MinimumOSVersion</key>
  <string>13.0</string>

I haven't submitted a PR because I suspect there's a broader fix to the native_assets framework build process to consume some user-specified configuration (e.g. this may be contemplated by this issue here.

I think this value should come from Flutter, not from the build.dart hook output.

Reasoning: We have targetAndroidNdkApi as a parameter in BuildConfig, and the build.dart hook should fail if it cannot produce a dylib with that android NDK API version. I think we should have a similar pattern for the minimum iOS SDK version. The minimum iOS SDK version should be part of the BuildConfig and the build.dart should fail if it cannot produce a dylib for that version. Flutter Tools needs to pass the minimum iOS SDK version in a similar fashion to how it does it for Android:

final int targetAndroidNdkApi =
int.parse(environment.defines[kMinSdkVersion] ?? minSdkVersion);

For passing minimumIOSVersion in BuildConfig we'll need to do upstream changes in https://github.com/dart-lang/native.

Passing the minimumIOSVersion into the Info.plist can already be done in a PR.

Happy to receive PRs for this @nmfisher!

@knopp
Copy link
Member

knopp commented Jun 10, 2024

@dcharkes, this should be fixed via #148504. Though there is still a TODO for specifying deployment target in the hook, but it is possible to submit iOS app to appstore with native assets (we're already doing it). So perhaps this issue can be closed?

@dcharkes
Copy link
Contributor Author

Yes, the minimum deployment target is tracked in dart-lang/native#1133.

Thanks @knopp!

@danagbemava-nc danagbemava-nc added the r: fixed Issue is closed as already fixed in a newer version label Jun 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
r: fixed Issue is closed as already fixed in a newer version team-tool Owned by Flutter Tool team tool Affects the "flutter" command-line tool. See also t: labels.
Projects
None yet
Development

No branches or pull requests

3 participants