adjust / cordova_sdk

This is the Cordova SDK of
http://www.adjust.com
Other
37 stars 43 forks source link

Error on Adjust.create() #151

Closed kerzmaximilian closed 2 years ago

kerzmaximilian commented 2 years ago

Error Message

+[NSString adjJoin:]: unrecognized selector sent to class 0x2094b1248 The app compiles without issues for Android and iOS, however fails on startup while Adjust is initialised in iOS only. No apparent changes have been made that led to this error being thrown recently.

--- Urgent support needed! ---

Adjust initialisation

(Using Adjust Cordova SDK wrapped in Capacitor plugin with Ionic) com.adjust.sdk@4.29.1 @awesome-cordova-plugins/adjust": "^5.37.3

index.tsx file:

import { Adjust, AdjustConfig, AdjustLogLevel, AdjustEnvironment } from "@awesome-cordova-plugins/adjust";
...
var adjustConfig = new AdjustConfig("6l3qlnnacmww", AdjustEnvironment.Production);
adjustConfig.setLogLevel(AdjustLogLevel.Verbose);
Adjust.create(adjustConfig);

Screenshot

Screenshot 2022-01-06 at 20 51 39

Verbose Logging:

022-01-06 20:47:56.357958-0700 App Name[3291:232472] [User Defaults] Couldn't read values in CFPrefsPlistSource<0x283056800> (Domain: group.health.cherry.app.onesignal, User: kCFPreferencesAnyUser, ByHost: Yes, Container: (null), Contents Need Refresh: Yes): Using kCFPreferencesAnyUser with a container is only allowed for System Containers, detaching from cfprefsd
2022-01-06 20:47:56.527012-0700 App Name[3291:232472] WARNING: appId set, but please call setLaunchOptions(launchOptions) to complete OneSignal init!
2022-01-06 20:47:56.884470-0700 App Name[3291:232707] 8.10.0 - [Firebase/Messaging][I-FCM001000] FIRMessaging Remote Notifications proxy enabled, will swizzle remote notification receiver handlers. If you'd prefer to manually integrate Firebase Messaging, add "FirebaseAppDelegateProxyEnabled" to your Info.plist, and set it to NO. Follow the instructions at:
https://firebase.google.com/docs/cloud-messaging/ios/client#method_swizzling_in_firebase_messaging
to ensure proper integration.
2022-01-06 20:47:57.095230-0700 App Name[3291:232472] KeyboardPlugin: resize mode - native
2022-01-06 20:47:57.392760-0700 App Name[3291:232703] 8.10.0 - [Firebase/Analytics][I-ACS023007] Analytics v.8.10.0 started
2022-01-06 20:47:57.393710-0700 App Name[3291:232703] 8.10.0 - [Firebase/Analytics][I-ACS023008] To enable debug logging set the following application argument: -FIRAnalyticsDebugEnabled (see http://goo.gl/RfcP7r)
⚡️  Loading app at capacitor://localhost...
2022-01-06 20:47:57.570736-0700 App Name[3291:232472] WF: === Starting WebFilter logging for process App Name
2022-01-06 20:47:57.570800-0700 App Name[3291:232472] WF: _userSettingsForUser mobile: {
    filterBlacklist =     (
    );
    filterWhitelist =     (
    );
    restrictWeb = 1;
    useContentFilter = 0;
    useContentFilterOverrides = 0;
    whitelistEnabled = 0;
}
2022-01-06 20:47:57.570860-0700 App Name[3291:232472] WF: _WebFilterIsActive returning: NO
2022-01-06 20:47:57.716236-0700 App Name[3291:232763] [Client] Updating selectors after delegate removal failed with: Error Domain=NSCocoaErrorDomain Code=4099 "The connection to service on pid 87 named com.apple.commcenter.coretelephony.xpc was invalidated from this process." UserInfo={NSDebugDescription=The connection to service on pid 87 named com.apple.commcenter.coretelephony.xpc was invalidated from this process.}
2022-01-06 20:47:57.716568-0700 App Name[3291:232763] [Client] Updating selectors after delegate addition failed with: Error Domain=NSCocoaErrorDomain Code=4099 "The connection to service on pid 87 named com.apple.commcenter.coretelephony.xpc was invalidated from this process." UserInfo={NSDebugDescription=The connection to service on pid 87 named com.apple.commcenter.coretelephony.xpc was invalidated from this process.}
⚡️  [log] - onscript loading complete
⚡️  [log] - CH_API Environment: prod
To Native Cordova ->  Adjust create Adjust1883951774 ["options": [[{"delayStart":0,"logLevel":"VERBOSE","defaultTracker":null,"urlStrategy":null,"externalDeviceId":null,"sendInBackground":null,"shouldLaunchDeeplink":null,"eventBufferingEnabled":null,"userAgent":null,"isDeviceKnown":null,"needsCost":null,"secretId":null,"info1":null,"info2":null,"info3":null,"info4":null,"processName":null,"preinstallTrackingEnabled":null,"preinstallFilePath":null,"oaidReadingEnabled":null,"allowiAdInfoReading":null,"allowIdfaReading":null,"allowAdServicesInfoReading":null,"attributionCallback":null,"eventTrackingSucceededCallback":null,"eventTrackingFailedCallback":null,"sessionTrackingSucceededCallback":null,"sessionTrackingFailedCallback":null,"deferredDeeplinkCallback":null,"conversionValueUpdatedCallback":null,"appToken":"6l3qlnnacmww","environment":"production","sdkPrefix":"cordova4.29.1"}]]]
2022-01-06 20:47:58.117150-0700 App Name[3291:232472]   [Adjust]w: PRODUCTION: Adjust is running in Production mode. Use this setting only for the build that you want to publish. Set the environment to `sandbox` if you want to test your app!
2022-01-06 20:47:58.118318-0700 App Name[3291:232472] +[NSString adjJoin:]: unrecognized selector sent to class 0x2094b1248
2022-01-06 20:47:58.119452-0700 App Name[3291:232472] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '+[NSString adjJoin:]: unrecognized selector sent to class 0x2094b1248'
*** First throw call stack:
(0x1a6db2dc0 0x1bb90f7a8 0x1a6cbae00 0x1a6db5918 0x1a6db7c10 0x10178e3b0 0x10178e23c 0x10178d368 0x101774490 0x101768940 0x101766148 0x101764a98 0x10175c4f8 0x10142da5c 0x10147707c 0x1014771ec 0x1b3456c40 0x1b36711b4 0x1b38e7ad4 0x1b3234268 0x1b35b356c 0x1b3215a5c 0x1b3215350 0x1b1175844 0x1b1176814 0x1a6d2d07c 0x1a6d2cf78 0x1a6d2c27c 0x1a6d2625c 0x1a6d259f4 0x1be3fb734 0x1a97a475c 0x1a97a9fcc 0x100f4a338 0x1a69e1cf8)
libc++abi: terminating with uncaught exception of type NSException
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '+[NSString adjJoin:]: unrecognized selector sent to class 0x2094b1248'
terminating with uncaught exception of type NSException
(lldb) 
IgorSavchenko90 commented 2 years ago

Same problem(

kerzmaximilian commented 2 years ago

Additional information provided in Sandbox Environment

Upon request by Adjust, the log output when run in Sandbox environment can be found below.

Error Message

+[NSString adjJoin:]: unrecognized selector sent to class 0x2094b1248 The app compiles without issues for Android and iOS, however fails on startup while Adjust is initialised in iOS only. No apparent changes have been made that led to this error being thrown recently.

--- Urgent support needed! ---

Adjust initialisation (Sandbox)

(Using Adjust Cordova SDK wrapped in Capacitor plugin with Ionic) com.adjust.sdk@4.29.1 @awesome-cordova-plugins/adjust": "^5.37.3

index.tsx file:

import { Adjust, AdjustConfig, AdjustLogLevel, AdjustEnvironment } from "@awesome-cordova-plugins/adjust";
...
var adjustConfig = new AdjustConfig("6l3qlnnacmww", AdjustEnvironment.Sandbox);
adjustConfig.setLogLevel(AdjustLogLevel.Verbose);
Adjust.create(adjustConfig);

Screenshot

Screenshot 2022-01-11 at 09 11 15

Verbose Log Output


2022-01-11 09:11:04.304181-0700 App Name[3050:524526] [User Defaults] Couldn't read values in CFPrefsPlistSource<0x2839de480> (Domain: group.health.cherry.app.onesignal, User: kCFPreferencesAnyUser, ByHost: Yes, Container: (null), Contents Need Refresh: Yes): Using kCFPreferencesAnyUser with a container is only allowed for System Containers, detaching from cfprefsd
2022-01-11 09:11:04.467028-0700 App Name[3050:524526] WARNING: appId set, but please call setLaunchOptions(launchOptions) to complete OneSignal init!
2022-01-11 09:11:05.069989-0700 App Name[3050:524748] 8.10.0 - [Firebase/Messaging][I-FCM001000] FIRMessaging Remote Notifications proxy enabled, will swizzle remote notification receiver handlers. If you'd prefer to manually integrate Firebase Messaging, add "FirebaseAppDelegateProxyEnabled" to your Info.plist, and set it to NO. Follow the instructions at:
https://firebase.google.com/docs/cloud-messaging/ios/client#method_swizzling_in_firebase_messaging
to ensure proper integration.
2022-01-11 09:11:05.070147-0700 App Name[3050:524748] 8.10.0 - [Firebase/Analytics][I-ACS023007] Analytics v.8.10.0 started
2022-01-11 09:11:05.070275-0700 App Name[3050:524748] 8.10.0 - [Firebase/Analytics][I-ACS023008] To enable debug logging set the following application argument: -FIRAnalyticsDebugEnabled (see http://goo.gl/RfcP7r)
2022-01-11 09:11:05.086504-0700 App Name[3050:524755] [connection] nw_endpoint_handler_set_adaptive_read_handler [C1.1 2606:4700::6812:e234.443 ready channel-flow (satisfied (Path is satisfied), viable, interface: en0, ipv4, ipv6, dns)] unregister notification for read_timeout failed
2022-01-11 09:11:05.086644-0700 App Name[3050:524755] [connection] nw_endpoint_handler_set_adaptive_write_handler [C1.1 2606:4700::6812:e234.443 ready channel-flow (satisfied (Path is satisfied), viable, interface: en0, ipv4, ipv6, dns)] unregister notification for write_timeout failed
2022-01-11 09:11:05.263864-0700 App Name[3050:524526] KeyboardPlugin: resize mode - native
⚡️  Loading app at capacitor://localhost...
2022-01-11 09:11:05.547228-0700 App Name[3050:524526] WF: === Starting WebFilter logging for process App Name
2022-01-11 09:11:05.547306-0700 App Name[3050:524526] WF: _userSettingsForUser mobile: {
    filterBlacklist =     (
    );
    filterWhitelist =     (
    );
    restrictWeb = 1;
    useContentFilter = 0;
    useContentFilterOverrides = 0;
    whitelistEnabled = 0;
}
2022-01-11 09:11:05.547366-0700 App Name[3050:524526] WF: _WebFilterIsActive returning: NO
2022-01-11 09:11:05.553808-0700 App Name[3050:524750] 8.10.0 - [Firebase/Analytics][I-ACS800023] No pending snapshot to activate. SDK name: app_measurement
2022-01-11 09:11:05.745245-0700 App Name[3050:524757] [Client] Updating selectors after delegate removal failed with: Error Domain=NSCocoaErrorDomain Code=4099 "The connection to service on pid 87 named com.apple.commcenter.coretelephony.xpc was invalidated from this process." UserInfo={NSDebugDescription=The connection to service on pid 87 named com.apple.commcenter.coretelephony.xpc was invalidated from this process.}
2022-01-11 09:11:05.745337-0700 App Name[3050:524757] [Client] Updating selectors after delegate addition failed with: Error Domain=NSCocoaErrorDomain Code=4099 "The connection to service on pid 87 named com.apple.commcenter.coretelephony.xpc was invalidated from this process." UserInfo={NSDebugDescription=The connection to service on pid 87 named com.apple.commcenter.coretelephony.xpc was invalidated from this process.}
2022-01-11 09:11:05.783363-0700 App Name[3050:524809] [connection] nw_endpoint_handler_set_adaptive_read_handler [C2.1 2607:f8b0:400a:805::200a.443 ready channel-flow (satisfied (Path is satisfied), viable, interface: en0, ipv4, ipv6, dns)] unregister notification for read_timeout failed
2022-01-11 09:11:05.783622-0700 App Name[3050:524809] [connection] nw_endpoint_handler_set_adaptive_write_handler [C2.1 2607:f8b0:400a:805::200a.443 ready channel-flow (satisfied (Path is satisfied), viable, interface: en0, ipv4, ipv6, dns)] unregister notification for write_timeout failed
2022-01-11 09:11:05.802310-0700 App Name[3050:524755] [connection] nw_endpoint_handler_set_adaptive_read_handler [C3.1 2606:4700::6812:e234.443 ready channel-flow (satisfied (Path is satisfied), viable, interface: en0, ipv4, ipv6, dns)] unregister notification for read_timeout failed
2022-01-11 09:11:05.802354-0700 App Name[3050:524755] [connection] nw_endpoint_handler_set_adaptive_write_handler [C3.1 2606:4700::6812:e234.443 ready channel-flow (satisfied (Path is satisfied), viable, interface: en0, ipv4, ipv6, dns)] unregister notification for write_timeout failed
2022-01-11 09:11:05.826139-0700 App Name[3050:524750] [connection] nw_endpoint_handler_set_adaptive_read_handler [C4.1 2607:f8b0:400a:803::200a.443 ready channel-flow (satisfied (Path is satisfied), viable, interface: en0, ipv4, ipv6, dns)] unregister notification for read_timeout failed
2022-01-11 09:11:05.826179-0700 App Name[3050:524750] [connection] nw_endpoint_handler_set_adaptive_write_handler [C4.1 2607:f8b0:400a:803::200a.443 ready channel-flow (satisfied (Path is satisfied), viable, interface: en0, ipv4, ipv6, dns)] unregister notification for write_timeout failed
⚡️  [log] - onscript loading complete
2022-01-11 09:11:05.943726-0700 App Name[3050:524750] Request <OSRequestRegisterUser: 0x2819740c0> success result {
    id = "0dc03d8a-700c-11ec-8401-26394d1eb8d6";
    success = 1;
}
⚡️  [log] - CH_API Environment: prod
2022-01-11 09:11:05.966656-0700 App Name[3050:524757] 8.10.0 - [Firebase/Analytics][I-ACS023012] Analytics collection enabled
2022-01-11 09:11:05.967752-0700 App Name[3050:524757] 8.10.0 - [Firebase/Analytics][I-ACS023220] Analytics screen reporting is enabled. Call +[FIRAnalytics logEventWithName:FIREventScreenView parameters:] to log a screen view event. To disable automatic screen reporting, set the flag FirebaseAutomaticScreenReportingEnabled to NO (boolean) in the Info.plist
To Native Cordova ->  Adjust create Adjust239842948 ["options": [[{"delayStart":0,"logLevel":"VERBOSE","defaultTracker":null,"urlStrategy":null,"externalDeviceId":null,"sendInBackground":null,"shouldLaunchDeeplink":null,"eventBufferingEnabled":null,"userAgent":null,"isDeviceKnown":null,"needsCost":null,"secretId":null,"info1":null,"info2":null,"info3":null,"info4":null,"processName":null,"preinstallTrackingEnabled":null,"preinstallFilePath":null,"oaidReadingEnabled":null,"allowiAdInfoReading":null,"allowIdfaReading":null,"allowAdServicesInfoReading":null,"attributionCallback":null,"eventTrackingSucceededCallback":null,"eventTrackingFailedCallback":null,"sessionTrackingSucceededCallback":null,"sessionTrackingFailedCallback":null,"deferredDeeplinkCallback":null,"conversionValueUpdatedCallback":null,"appToken":"6l3qlnnacmww","environment":"sandbox","sdkPrefix":"cordova4.29.1"}]]]
2022-01-11 09:11:05.998498-0700 App Name[3050:524526]   [Adjust]w: SANDBOX: Adjust is running in Sandbox mode. Use this setting for testing. Don't forget to set the environment to `production` before publishing
2022-01-11 09:11:05.999510-0700 App Name[3050:524526] +[NSString adjJoin:]: unrecognized selector sent to class 0x201685248
2022-01-11 09:11:05.999635-0700 App Name[3050:524526] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '+[NSString adjJoin:]: unrecognized selector sent to class 0x201685248'
*** First throw call stack:
(0x19ef86dc0 0x1b3ae37a8 0x19ee8ee00 0x19ef89918 0x19ef8bc10 0x102a9e3b0 0x102a9e23c 0x102a9d368 0x102a84490 0x102a78940 0x102a76148 0x102a74a98 0x102a6c4f8 0x102719a5c 0x10276307c 0x1027631ec 0x1ab62ac40 0x1ab8451b4 0x1ababbad4 0x1ab408268 0x1ab78756c 0x1ab3e9a5c 0x1ab3e9350 0x1a9349844 0x1a934a814 0x19ef0107c 0x19ef00f78 0x19ef0027c 0x19eefa25c 0x19eef99f4 0x1b65cf734 0x1a197875c 0x1a197dfcc 0x102282338 0x19ebb5cf8)
libc++abi: terminating with uncaught exception of type NSException
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '+[NSString adjJoin:]: unrecognized selector sent to class 0x201685248'
terminating with uncaught exception of type NSException
(lldb) 
uerceg commented 2 years ago

Hi @kerzmaximilian,

Hm, that's odd. adjJoin: method is custom made NSString extension method. Some past reports showed that whenever extension methods weren't recognized, lack of -ObjC flag in Other Linker Flags in Xcode project settings was responsible for that. Can you maybe check if you have this flag added to your Other Linker Flags section?

uerceg commented 2 years ago

I actually managed to reproduce this issue with new Capacitor project built from scratch. This is where I found solution for the issue.

In my new Capacitor project, Pods target had no -ObjC flag added, but adding it changed nothing pretty much. App target on the other hand had it, but issue was still there. But after following advice from link above and making it look like this:

import { CapacitorConfig } from '@capacitor/cli';

const config: CapacitorConfig = {
  appId: 'com.adjust.examples',
  appName: 'AdjustExample',
  webDir: 'www',
  bundledWebRuntime: false,
  "ios": {
    "cordovaLinkerFlags": ["-ObjC"]
  }
};

export default config;

error was gone and SDK initialized properly inside of Ionic Capacitor app.

Let us know if this solved your issue.

kerzmaximilian commented 2 years ago

Hi @uerceg,

Thanks a lot for your response and suggestion. Really appreciate it - the addition to the CapacitorConfig did the trick!

Interestingly, just setting Other Linker Flag to -ObjC in Xcode is not enough. CapacitorConfig to the rescue!

Thanks again - made my day!

selcuk-sahin commented 2 years ago

For Capacitor, we had to set this option all the time manually. To avoid that I have added this to our PodFile. Seems to be working

# add -ObjC flag to Pods
post_install do |installer|
  installer.pods_project.build_configurations.each do |config|
    puts "Setting OTHER_LDFLAGS as -ObjC in Config: #{config.name}"
    config.build_settings['OTHER_LDFLAGS'] = '-ObjC'
  end
end