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

Crash when integrating the xcframework that contains mixpanel #474

Open
uzair opened this issue Aug 23, 2021 · 13 comments
Open

Crash when integrating the xcframework that contains mixpanel #474

uzair opened this issue Aug 23, 2021 · 13 comments

Comments

@uzair
Copy link

uzair commented Aug 23, 2021

I have create my custom framework and integrated mixpanel in it. When i create xcframework and integrate it in my sample project i'm getting the below crash:

dyld: lazy symbol binding failed: Symbol not found: _$s8MixpanelAAC10initialize5token13launchOptions13flushInterval12instanceName21automaticPushTracking06optOutL9ByDefaultAA0A8InstanceCSS_SDySo019UIApplicationLaunchE3KeyaypGSgSdSSS2btFZTj Referenced from: /Users/uzairshahzad/Library/Developer/CoreSimulator/Devices/F078F0D6-1469-430B-AB7B-35DDAECCC333/data/Containers/Bundle/Application/71E16C58-078E-4A8F-AF48-3ADAE35A210F/MixpanelExample.app/Frameworks/TGPaySDK.framework/TGPaySDK Expected in: /Users/uzairshahzad/Library/Developer/CoreSimulator/Devices/F078F0D6-1469-430B-AB7B-35DDAECCC333/data/Containers/Bundle/Application/71E16C58-078E-4A8F-AF48-3ADAE35A210F/MixpanelExample.app/Frameworks/Mixpanel.framework/Mixpanel

@zihejia
Copy link
Contributor

zihejia commented Sep 2, 2021

hi @uzair , could you share the integration code related to Mixpanel? Also, how do you integrate Mixpanel? For right now, we suggest using SPM.

@zihejia
Copy link
Contributor

zihejia commented Sep 27, 2021

hi @uzair , I will close this issue for now. Please feel free to reopen the issue anytime you get a chance to provide more information and the problem still exists.

@zihejia zihejia closed this as completed Sep 27, 2021
@jvigneshcs
Copy link

jvigneshcs commented Jun 15, 2023

Even myself facing the similar issue. We are using Cocoapods for integration
When I try integrating using SPM, I got the following error,

dyld: Library not loaded: @rpath/Mixpanel.framework/Mixpanel
Referenced from: /private/var/containers/Bundle/Application/DCD34A39-6E62-443B-813D-1402B648DB06/Mobile.app/Frameworks/MySDK.framework/MySDK
Reason: image not found

@zihejia
Copy link
Contributor

zihejia commented Jun 16, 2023

hi @jvigneshcs , which Mixpanel version are you using?

@jvigneshcs
Copy link

hi @jvigneshcs , which Mixpanel version are you using?

I tried with 4.1.2 (latest)

@jvigneshcs
Copy link

Hi @zihejia, I have created a bare minimum projects to reproduce this issue, you can find the repository here

@zihejia zihejia reopened this Jun 16, 2023
@jaredmixpanel
Copy link
Contributor

@jvigneshcs When I try to execute ./GenerateXCFramework.sh from the terminal, I get...

2023-07-19 10:31:33.525 xcodebuild[82369:13621943] DVTCoreDeviceEnabledState: DVTCoreDeviceEnabledState_Disabled set via user default (DVTEnableCoreDevice=disabled)
** ARCHIVE FAILED **

Have you experimented with using the :linkage option in your Podfiles?

use_frameworks! :linkage => :static and use_frameworks! :linkage => :dynamic

See:

https://medium.com/microsoft-mobile-engineering/mixing-static-and-dynamic-linking-in-cocoapods-83b6d4252c59

https://guides.cocoapods.org/syntax/podfile.html#use_frameworks_bang

@jvigneshcs
Copy link

@jaredmixpanel ,

Have you experimented with using the :linkage option in your Podfiles?

use_frameworks! :linkage => :static and use_frameworks! :linkage => :dynamic

I tried your suggestion with :linkage,
used use_frameworks! :linkage => :dynamic from MySDK framework project's pod file,
when I tried without :linkage => :static from MyApp application project's pod file, I got

missing symbol called

when I tried with :linkage => :static from MyApp application project's pod file, I got

Library not loaded: @rpath/Mixpanel.framework/Mixpanel

@jaredmixpanel
Copy link
Contributor

@jvigneshcs Can you please provide more detailed instructions for your bare minimum project to repro this issue?

I managed to get your build script to run, but the Mixpanel.xcworkspace says: There is no XCFramework found at '/Users/jaredmcfarland/Developer/MixpanelSwiftXCFIssue/MySDK/artifacts/Release/MySDK.xcframework'.

And No such module MySDK

image

@jaredmixpanel
Copy link
Contributor

Nevermind, got it to work. I had to remove -sdk flag from your xcodebuild archive commands in your build script to get the xcodebuild -create-xcframework step to work.

@jaredmixpanel
Copy link
Contributor

jaredmixpanel commented Jul 31, 2023

@jvigneshcs I've experimented with different build configurations. I'm able to get it building and running without crashing but I do see messages like this in the console:

objc[95678]: Class _TtC8Mixpanel15AutomaticEvents is implemented in both .../Xcode/DerivedData/MyApp-edscjgdqpchjdxfddizvrnvjpylm/Build/Products/Release-iphonesimulator/MySDK.framework/MySDK (0x103132a58) and .../CoreSimulator/Devices/89B0526D-C307-4DDA-8BF3-E794CAF74C03/data/Containers/Bundle/Application/60BD3F4D-0014-44F7-82EA-02ACCF9764E1/MyApp.app/MyApp (0x102f87848). One of the two will be used. Which one is undefined.

In MySDK - MyAPI.swift it seems like you will need to @_implementationOnly import Mixpanel. If I do that, then I can successfully run MyApp with the above warnings in the console if I use :linkage => :static in MySDK's Podifile. It also seems to work if I remove CocoaPods altogether and use SPM from both MySDK and MyApp (again with the implemented in both warnings).

So I do not think this is an issue with the Mixpanel SDK. I think this use case is running up against limitations in Swift/Xcode.

Some further reading:
https://forums.swift.org/t/exported-and-fixing-import-visibility/9415
https://forums.swift.org/t/update-on-implementation-only-imports/26996

Example usage in Firebase: https://github.com/firebase/firebase-ios-sdk/blob/master/FirebaseFunctions/Sources/Internal/FunctionsComponent.swift#L21-L22

@jaredmixpanel
Copy link
Contributor

@jvigneshcs One workaround I did find is to use the Mixpanel Objective-C SDK from MySDK instead of the Swift SDK. If however, MyApp also uses the Objective-C SDK then we're back to the implemented in both console warnings.

@jvigneshcs
Copy link

@jvigneshcs One workaround I did find is to use the Mixpanel Objective-C SDK from MySDK instead of the Swift SDK. If however, MyApp also uses the Objective-C SDK then we're back to the implemented in both console warnings.

@jaredmixpanel yeah we have already tried this approach and we didn't face the crash issue which is happening with mixpanel-swift pod.
Let me also try your other suggestions as well.

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

4 participants