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

iOS Crash on 5.4 - Podfile #1153

Closed
tsonevn opened this issue Jun 7, 2019 · 3 comments
Closed

iOS Crash on 5.4 - Podfile #1153

tsonevn opened this issue Jun 7, 2019 · 3 comments
Assignees
Labels
Milestone

Comments

@tsonevn
Copy link

tsonevn commented Jun 7, 2019

@gonniegijsen commented on Fri Jun 07 2019

Environment
Provide version numbers for the following components (information can be retrieved by running tns info in your project folder or by inspecting the package.json of the project):

  • CLI: 5.4.0
  • Cross-platform modules: 5.4.1
  • Android Runtime: 5.4.0
  • iOS Runtime: 5.4.1
  • Plugin(s): None

Describe the bug

The application is crashing on a real device on iOS (iPhone 7; iOS: 12.2) after including this podfile:

platform :ios, '10.0'
pod 'EstimoteProximitySDK'

Crash I am getting:

Unzipping LiveSync folder. This could take a while...
Unzipped 51 entries in 65.775990ms.
tns_modules folder not livesynced. Using tns_modules from the already deployed bundle...
***** Fatal JavaScript exception - application has been terminated. *****
Native stack trace:
1   0x104c8385c NativeScript::reportFatalErrorBeforeShutdown(JSC::ExecState*, JSC::Exception*, bool)
2   0x104cc2448 -[TNSRuntime executeModule:referredBy:]
3   0x1046705bc
4   0x1ac6a68e0 <redacted>
JavaScript stack trace:
1   stringWithString@file:///app/vendor.js:36015:49
2   @file:///app/vendor.js:36015:49
3   ../node_modules/tns-core-modules/utils/utils.js@file:///app/vendor.js:36064:3
4   __webpack_require__@file:///app/runtime.js:751:34
5   fn@file:///app/runtime.js:121:39
6   ../node_modules/tns-core-modules/file-system/file-system-access.js@file:///app/vendor.js:5348:34
7   __webpack_require__@file:///app/runtime.js:751:34
8   fn@file:///app/runtime.js:121:39
9   ../node_modules/tns-core-modules/file-system/file-system.js@file:///app/vendor.js:5686:47
10  __webpack_require__@file:///app/runtime.js:751:34
11  fn@file:///app/runtime.js:121:39
12  ../node_modules/tns-core-modules/utils/debug.js@file:///app/vendor.js:35496:40
13  __webpack_require__@file:///app/runtime.js:751:34
14  fn@file:///app/runtime.js:121:39
15  @file:///app/vendor.js:13156:34
16  ../node_modules/tns-core-modules/ui/builder/builder.js@file:///app/vendor.js:13767:34
17  __webpack_require__@file:///app/runtime.js:751:34
18  fn@file:///app/runt<\M-b\M^@\M-&>
JavaScript error:
file:///app/vendor.js:36015:49: JS ERROR Error: *** -[NSPlaceholderString initWithString:]: nil argument
*** JavaScript call stack:
(
)
*** Terminating app due to uncaught exception 'NativeScript encountered a fatal error: Error: *** -[NSPlaceholderString initWithString:]: nil argument
at
1   stringWithString@file:///app/vendor.js:36015:49
2   @file:///app/vendor.js:36015:49
3   ../node_modules/tns-core-modules/utils/utils.js@file:///app/vendor.js:36064:3
4   __webpack_require__@file:///app/runtime.js:751:34
5   fn@file:///app/runtime.js:121:39
6   ../node_modules/tns-core-modules/file-system/file-system-access.js@file:///app/vendor.js:5348:34
7   __webpack_require__@file:///app/runtime.js:751:34
8   fn@file:///app/runtime.js:121:39
9   ../node_modules/tns-core-modules/file-system/file-system.js@file:///app/vendor.js:5686:47
10  __webpack_require__@file:///app/runtime.js:751:34
11  fn@file:///app/runtime.js:121:39
12  ../node_modules/tns-core-modules/utils/debug.js@file:///app/vendor.js:35496:40
13  __webpack_require__@file:///app/runtime.js:751:34
14  fn@file:///app/runtime.js:121:39
15  @file:///app/vendor.js:13156:34
16  ../node<\M-b\M^@\M-&>
Successfully synced application org.nativescript.testestimote on device

This crash happens when the app is launching and wasn't doing so on Nativescript 5.3.1

To Reproduce
Create a new project with typescript or angular.
Add Podfile

platform :ios, '10.0'
pod 'EstimoteProximitySDK'

Enable ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES

Run the app on a real device

tns run ios

Expected behavior
No crash

Sample project

Additional context

  • This issue was not happening before 5.4.0
  • It doesn't crash on the simulator with the same specs; Only on real device

@tsonevn commented on Fri Jun 07 2019

Hi @gonniegijsen,
Can you send us the project, that you are using for testing and demonstrates, how you are calling the native API from the JavaScript?


@gonniegijsen commented on Fri Jun 07 2019

I can reproduce it with by creating a new project, adding the pod file and not writing any code :/


@gonniegijsen commented on Fri Jun 07 2019

test-ios-crash.zip


@tsonevn commented on Fri Jun 07 2019

Hi @gonniegijsen,
We were able to recreate the issue on our side and I will mark it as a bug. We will research it further, why this problem appears only on a device.

@mbektchiev
Copy link
Contributor

mbektchiev commented Jun 10, 2019

Hi @gonniegijsen,
We discovered the reason for the crash with Estimote Proximity SDK. It has appeared in the latest version of {N} due to two different unrelated factors:

  1. The tns-core-modules have stopped using the ios.getter function
  2. Until now it has hidden an issue with metadata generation connected with the way we call clang to parse all native frameworks and libraries.

We will further research alternatives and provide a fix for iOS runtime's metadata generator but in the meantime as a workaround you may need to either downgrade your tns-core-modules dependency to 5.3.x (if that's possible) or manually prepare a custom NPM package from the tag 5.4.1 tag with this commit reverted.

@NathanaelA

This comment was marked as abuse.

@mbektchiev
Copy link
Contributor

mbektchiev commented Jun 11, 2019

We plan to fix the metadata issue in a patch release (probably in 5.4.2 like you say). The ios.getter function was meant for a transition period and we don't want to revive its usage. If you are curious to know, this awkward behavior is caused by the definition of SWIFT_CLASS_EXTRA macro in the EstimoteProximitySDK-Swift.h header. All headers included in the umbrella-<arch>.h after this header start seeing this macro as defined, this leads to many changes in the metadata. The crash is caused by the fact that UIKit declares its internal macro UIKIT_DEFINE_AS_PROPERTIES as 0 like this:

#if (!defined(SWIFT_CLASS_EXTRA) || (defined(SWIFT_SDK_OVERLAY_UIKIT_EPOCH) && SWIFT_SDK_OVERLAY_UIKIT_EPOCH >= 1))
    #define UIKIT_DEFINE_AS_PROPERTIES 1
#else
    #define UIKIT_DEFINE_AS_PROPERTIES 0
#endif

Leading to declaring many properties as methods instead -- e.g. in UIDevice:

NS_CLASS_AVAILABLE_IOS(2_0) @interface UIDevice : NSObject 
#if UIKIT_DEFINE_AS_PROPERTIES
@property(class, nonatomic, readonly) UIDevice *currentDevice;
#else
+ (UIDevice *)currentDevice;
#endif

@mbektchiev mbektchiev added this to the 5.4.2 milestone Jun 11, 2019
mbektchiev added a commit to NativeScript/ios-metadata-generator that referenced this issue Jun 11, 2019
They define macros which may alter the way some iOS SDK methods
and properties are declared

refs NativeScript/ios-jsc#1153
mbektchiev added a commit that referenced this issue Jun 11, 2019
…rella header

They define macros which may alter the way some iOS SDK methods
and properties are declared

refs #1153
@mbektchiev mbektchiev self-assigned this Jun 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants