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

Today Extension example fails with EXC_BAD_ACCESS #929

Open
kspearrin opened this issue May 29, 2018 · 7 comments
Open

Today Extension example fails with EXC_BAD_ACCESS #929

kspearrin opened this issue May 29, 2018 · 7 comments
Assignees

Comments

@kspearrin
Copy link

kspearrin commented May 29, 2018

If there is no issue for your problem, tell us about it

I am trying to follow along with the Today extension example discussed here: https://www.nativescript.org/blog/making-a-today-widget-in-ios-with-nativescript-and-ui-for-nativescript

Which has example code from this repository here: https://github.com/NativeScript/ios-runtime/tree/master/examples/TodayExtension

Trying to to complete this example results in a runtime error when trying to launch the TodayWidget extension directly from Xcode:

at runtime = [[TNSRuntime alloc] initWithApplicationPath:[NSBundle mainBundle].bundlePath];

in platforms/ios/TodayWidget/main.m

EXC_BAD_ACCESS

I found this old issue of a user with the same problem: #503

An answer was posted in an old ios-runtime-docs repo which no longer exists so I cannot see what the fix for the problem was.

All in all, it seems like docs for iOS app extension support are not very complete or very outdated which is unfortunate since we need support for extensions to be able to switch to NativeScript from Xamarin. Perhaps some additional guidance or updated documentation could also be provided for using app extensions with NativeScript?

Please, provide the following version numbers that your issue occurs with:

  • CLI: 4.0.2
  • Cross-platform modules: 4.0.1
  • Runtime(s): 4.0.1
  • Plugin(s): n/a

Please, tell us how to recreate the issue in as much detail as possible.

Follow the tutorial at https://www.nativescript.org/blog/making-a-today-widget-in-ios-with-nativescript-and-ui-for-nativescript to add an app extension to the HelloWorld app. Then try to launch the extension from Xcode.

@kspearrin kspearrin mentioned this issue Jun 18, 2018
6 tasks
@fpaaske
Copy link

fpaaske commented Jun 18, 2018

I'm also looking for up-to-date documentation for how to add different types of app extensions to an iOS app.

@KevinBeckers
Copy link

Did anyone find some news? I am also looking for this.

@kspearrin
Copy link
Author

Nope. Still waiting for a response from the Nativescript team.

@tdermendjiev
Copy link
Contributor

tdermendjiev commented Aug 7, 2018

Hello @kspearrin

I just walked through the article and got the same error. After adding the ios runtime project to the widget's .xcodeproj so I can have the debug symbols, I saw the problem was missing metadata. So there are couple more things you need to do in order to run the widget:

  1. Add these flags to Settings->Other Linker Flags:
    -sectcreate __DATA __TNSMetadata "$(CONFIGURATION_BUILD_DIR)/metadata-$(CURRENT_ARCH).bin" $(inherited)

  2. Make the runtime aware of the metadata by adding the following two lines of code before allocating it

extern char startOfMetadataSection __asm("section$start$__DATA$__TNSMetadata");
[TNSRuntime initializeMetadata:&startOfMetadataSection];

so your main.m looks like this:

#import <NativeScript/NativeScript.h>

static TNSRuntime* runtime;

__attribute__((constructor))
void initialize() {
    
    extern char startOfMetadataSection __asm("section$start$__DATA$__TNSMetadata");
    [TNSRuntime initializeMetadata:&startOfMetadataSection];
    
    runtime = [[TNSRuntime alloc] initWithApplicationPath:[NSBundle mainBundle].bundlePath];
    TNSRuntimeInspector.logsToSystemConsole = YES;
    [runtime executeModule:@"./tiobe-widget"];
}

P.S. The article and docs will be updated.

@kspearrin
Copy link
Author

Thanks @tdermendjiev . That fixed it! Do the linker flags only need to be set for debug, or release too?

Also, it is not clear to me how these xcodeproj adjustments are suppose to be persisted since the nativescript /platforms directory is transient/generated and will be overwritten the next time the project is rebuilt.

@tdermendjiev
Copy link
Contributor

The linker flags need to be set for release as well. Currently these settings are not supported out of Xcode which means they will be overridden. I will research what is needed to implement Today extensions support meanwhile you can vote for this feature. Thank you!

@tdermendjiev tdermendjiev self-assigned this Aug 8, 2018
@mbektchiev
Copy link
Contributor

The current solution is far from perfect and requires quite a lot of manual changes. If you follow the updated steps in the tutorial, however, it does work.

That said, we've logged a new issue for app extensions support: NativeScript/nativescript-cli#3965. It is still not planned for implementation but at least can be voted for.

We would definitely welcome any contributions that can help us reach there!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants