-
Notifications
You must be signed in to change notification settings - Fork 68
Cannot correctly build before COPY on release mode for macos #2145
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
Comments
Hi @australiaelon! Thanks for the report. Let me understand your use case.
What do you mean with wait time? The |
yes, we prebuilt all assets to directly implement the ability of It works when build on debug mode, but not work on release mode of BTW, the IOS not working when dealing with static pre-built assets (.a) due to |
Could you elaborate why it doesn't work in release mode?
What do you mean with wait time? Why is it different in debug and release? Why do you need a wait time?
Static linking is not yet supported. (It is not really defined what one would statically link against. E.g. on Android the main application is a JAR and run by the JVM, so there is no native executable to link against. On the other platforms the main application is the Dart VM, the Dart program is a dynamic library. Since the calls to native code will be in the Dart program, it would make more sense to statically link the Dart program and the native code, but this would still result in a dynamic library. For some more info see dart-lang/sdk#47718.)
This is not true. As long as dynamic libraries as packaged in a framework with the right metadata using dynamic libaries is fine. If you output a dynamic library from |
Okay, I fix it by add
yes, it works fine |
the main modifications is I replaced import 'dart:io';
import 'package:native_assets_cli/code_assets.dart';
LinkMode getLinkMode(LinkModePreference preference) {
if (preference == LinkModePreference.dynamic ||
preference == LinkModePreference.preferDynamic) {
return DynamicLoadingBundled();
}
assert(
preference == LinkModePreference.static ||
preference == LinkModePreference.preferStatic,
);
return StaticLinking();
}
void main(List<String> args) async {
await build(args, (input, output) async {
final os = input.config.code.targetOS;
final arch = input.config.code.targetArchitecture;
final linkMode = getLinkMode(input.config.code.linkModePreference);
final libraryFileName = os.libraryFileName(input.packageName, linkMode);
final libUri = input.outputDirectory.resolve(libraryFileName);
final prebuiltPath = 'native/$os/$arch/$libraryFileName';
final prebuiltLibUri = input.packageRoot.resolve(prebuiltPath);
await Directory.fromUri(input.outputDirectory).create(recursive: true);
await File.fromUri(prebuiltLibUri).copy(libUri.toFilePath());
print('$libraryFileName');
output.assets.code.add(
CodeAsset(
package: input.packageName,
name: 'ffi_bindings.dart',
file: libUri,
linkMode: linkMode,
os: input.config.code.targetOS,
architecture: input.config.code.targetArchitecture,
),
);
});
}```
And place the pre-build lib in 'native/$os/$arch/$libraryFileName' |
For more clear state, I just crafted a example repo which demonstrates the details for the modification after And it seems that simple copy the pre-built lib from final libraryFileName = os.libraryFileName(input.packageName, linkMode);
final libUri = input.outputDirectory.resolve(libraryFileName);
final prebuiltPath = 'native/$os/$arch/$libraryFileName';
final prebuiltLibUri = input.packageRoot.resolve(prebuiltPath);
await Directory.fromUri(input.outputDirectory).create(recursive: true);
await File.fromUri(prebuiltLibUri).copy(libUri.toFilePath()); |
okay, I found out that the path |
when run with
—debug
, everything worksHowever, when run with
—release
, it failed to copy, I guess it is due to it spend more time to createframework
on release, thus too small wait time before coping thus causing this issue.And for the lib, we have
with config file,
for the app, we have config file,
The text was updated successfully, but these errors were encountered: