ios-jsc
ios-jsc copied to clipboard
Using TextField will crash in iOS embedded app
From @bergeragoston on April 21, 2018 9:36
Dear friend, we, the rest of the NativeScript community really appreciate your feedback! While we are doing all we can to take care of every issue, sometimes we get overwhelmed. Because of that, we will consider issues that are not constructive or problems that cannot be reproduced "dead". Additionally, we will treat feature requests or bug reports with unanswered questions regarding the behavior/reproduction for more than 20 days "dead". All "dead" issues will get closed.
Please, provide the details below:
Did you verify this is a real problem by searching the NativeScript Forum and the other open issues in this repo? yes
Tell us about the problem
I am building a Nativescript angular app that is used both as a standalone app and embedded into a native app on both platforms. On Android and on iOS standalone it works as expected, but embedded into a native iOS app it crashes with EXC_BAD_ACCESS the first time I load a page that has a TextField in it. I am using nativescript-angular w/ 3.3.0 but the issue is reproducible in PAN w/ 3.4 as well.
I am using the methods described here and here to embed my app.
Which platform(s) does your issue occur on?
iOS
Please provide the following version numbers that your issue occurs with:
- CLI: 3.3.0
- Cross-platform modules: 3.3.0, able to reproduce in 3.4.0
- Runtime(s): 3.3.0, able to reproduce in 3.4.0
- Plugin(s): not needed
- Environment: XCode 9.3, iOS simulator for iPhone 8
Please tell us how to recreate the issue in as much detail as possible.
- Checkout this repo: link
- Prepare app as instructed in the readme.
- Add this line to any page in the embedded app:
<TextField hint="Some text"> </TextField> - Build and run, it will crash when loading the page the textfield is in.
- If the line above is not present, it will run without issues.
Is there code involved? If so, please share the minimal amount of code needed to recreate the problem.
Copied from original issue: NativeScript/NativeScript#5716
@bergeragoston thank you for reporting this issue - I can confirm that indeed introducing a TextField is causing an embedded app to fail with
Thread 1: EXC_BAD_ACCESS (code=1, address=0x18)
in this return statement
#import <UIKit/UIKit.h>
#import "AppDelegate.h"
int main(int argc, char * argv[]) {
@autoreleasepool {
return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
}
}
The feature for embedding is still experimental
@NickIliev I tried to create a workaround using TextView, with slightly different behavior. The control renders properly, then crashes the moment I try to input/edit text in it.
Can you give me an update on this? I understand if the embedded mode is not a priority for you, in this case can you suggest a workaround? Thanks
For anyone else experiencing this issue, I have found a workaround:
The crash only occurs if a control overrides textRectForBounds, removing this from TextField (or a custom control) prevents the crash.