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

TestFlight app crashes: DYLD error: x not loaded: @rpath/AnalyticsConnector.framework/AnalyticsConnector #238

Closed
bastianfischer-neotaste opened this issue Nov 4, 2024 · 9 comments
Labels
bug Something isn't working

Comments

@bastianfischer-neotaste
Copy link

Expected Behavior

TestFlight app should not crash.

Current Behavior

TestFlight app crashes on open: DYLD error: x not loaded: @rpath/AnalyticsConnector.framework/AnalyticsConnector
We also received a mail from Apple (for this build):

ITMS-90863: Macs with Apple silicon support issue - The app links with libraries that aren’t present in macOS:

@rpath/AnalyticsConnector.framework/AnalyticsConnector

Possible Solution

This issue appeared since bumping the SDK. I just had a quick look on the changes of the release this bug occurs since and I saw that you are now referencing to AnalyticsConnectorFramework instead of AnalyticsConnector. Might the issue described here be related to this change?

Steps to Reproduce

Issue occurred since upgrading to https://github.com/amplitude/Amplitude-Swift @ 1.10.0 / https://github.com/amplitude/analytics-connector-ios.git @ 1.2.3.

Environment

@bastianfischer-neotaste bastianfischer-neotaste added the bug Something isn't working label Nov 4, 2024
@izaaz
Copy link
Collaborator

izaaz commented Nov 4, 2024

@bastianfischer-neotaste can you please update to version 1.2.4 of the analytics connector?

@Gray-Wind
Copy link

@izaaz Hello, we have the same issue. The version of analytics connector in our case is 1.2.4.

@crleona
Copy link
Collaborator

crleona commented Nov 6, 2024

To confirm, the change here is that we started to link to a precompiled xcframework version of analytics-connector. analytics-connector also now supports Mac-catalyst builds. 1.2.4 resolves some signing issues on MacOS due to invalid symlinks in the linked framework (see #236), but it seems like this is a different issue.

That said, I'm having some trouble reproducing this within a basic MacOS or MacOS Catalyst target just linked with the latest Amplitude-Swift SDK.
1/ Are you using our Experiment SDK or anything else that would continue to link to the older version of analytics-connector?
2/ Are these Mac or Mac Catalyst apps? Any other supported destinations?
3/ If possible, could you please include a screenshot of the "Link Binary with Libraries" section if you select your target -> Build Phases?

@Gray-Wind
Copy link

I've tried to reproduce the issue with a sample project but not successfully yet.

  1. We are using Amplitude-Swift library, we use Package.resolved file to use previously cached version. We observe the issue once we update the package dependency.
  2. It is a Mac app, no other destinations.
  3. We are using Amplitude-Swift not directly, but via an abstract package, so there is no direct linkage with either of amplitude libraries.

Interestingly enough I can see the framework copied to the application bundle
image

Now this line has caught my attention, not sure what can I do with it tho.

<…>AnalyticsConnector.framework/Versions/A/AnalyticsConnector' not valid for use in process: mapping process and mapped file (non-platform) have different Team IDs)
full dyld logs
dyld[45002]: Library not loaded: @rpath/AnalyticsConnector.framework/Versions/A/AnalyticsConnector
  Referenced from: <E96C2B42-790D-32F5-A0D3-7BF22202E531> /Users/USERNAME/Library/Developer/Xcode/DerivedData/AAAA-hssdflashdljahsdflkasjdhflaksjdh/Build/Products/Debug/APPNAME.app/Contents/MacOS/APPNAME.debug.dylib
  Reason: tried: '/Users/USERNAME/Library/Developer/Xcode/DerivedData/AAAA-hssdflashdljahsdflkasjdhflaksjdh/Build/Products/Debug/AnalyticsConnector.framework/Versions/A/AnalyticsConnector' (code signature in <DF550B17-73DE-3241-ACE9-49C8838077EB> '/Users/USERNAME/Library/Developer/Xcode/DerivedData/AAAA-hssdflashdljahsdflkasjdhflaksjdh/Build/Products/Debug/AnalyticsConnector.framework/Versions/A/AnalyticsConnector' not valid for use in process: mapping process and mapped file (non-platform) have different Team IDs), '/Users/USERNAME/Library/Developer/Xcode/DerivedData/AAAA-hssdflashdljahsdflkasjdhflaksjdh/Build/Products/Debug/PackageFrameworks/AnalyticsConnector.framework/Versions/A/AnalyticsConnector' (no such file), '/Users/USERNAME/Library/Developer/Xcode/DerivedData/AAAA-hssdflashdljahsdflkasjdhflaksjdh/Build/Products/Debug/PackageFrameworks/AnalyticsConnector.framework/Versions/A/AnalyticsConnector' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/Users/USERNAME/Library/Developer/Xcode/DerivedData/AAAA-hssdflashdljahsdflkasjdhflaksjdh/Build/Products/Debug/PackageFrameworks/AnalyticsConnector.framework/Versions/A/AnalyticsConnector' (no such file), '/Users/USERNAME/Library/Developer/Xcode/DerivedData/AAAA-hssdflashdljahsdflkasjdhflaksjdh/Build/Products/Debug/APPNAME.app/Contents/MacOS/AnalyticsConnector.framework/Versions/A/AnalyticsConnector' (no such file), '/Users/USERNAME/Library/Developer/Xcode/DerivedData/AAAA-hssdflashdljahsdflkasjdhflaksjdh/Build/Products/Debug/PackageFrameworks/AnalyticsConnector.framework/Versions/A/AnalyticsConnector' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/Users/USERNAME/Library/Developer/Xcode/DerivedData/AAAA-hssdflashdljahsdflkasjdhflaksjdh/Build/Products/Debug/PackageFrameworks/AnalyticsConnector.framework/Versions/A/AnalyticsConnector' (no such file), '/Users/USERNAME/Library/Developer/Xcode/DerivedData/AAAA-hssdflashdljahsdflkasjdhflaksjdh/Build/Products/Debug/APPNAME.app/Contents/MacOS/AnalyticsConnector.framework/Versions/A/AnalyticsConnector' (no such file), '/Users/USERNAME/Library/Developer/Xcode/DerivedData/AAAA-hssdflashdljahsdflkasjdhflaksjdh/Build/Products/Debug/PackageFrameworks/AnalyticsConnector.framework/Versions/A/AnalyticsConnector' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/Users/USERNAME/Library/Developer/Xcode/DerivedData/AAAA-hssdflashdljahsdflkasjdhflaksjdh/Build/Products/Debug/PackageFrameworks/AnalyticsConnector.framework/Versions/A/AnalyticsConnector' (no such file)

@bastianfischer-neotaste
Copy link
Author

bastianfischer-neotaste commented Nov 6, 2024

To confirm, the change here is that we started to link to a precompiled xcframework version of analytics-connector. analytics-connector also now supports Mac-catalyst builds. 1.2.4 resolves some signing issues on MacOS due to invalid symlinks in the linked framework (see #236), but it seems like this is a different issue.

That said, I'm having some trouble reproducing this within a basic MacOS or MacOS Catalyst target just linked with the latest Amplitude-Swift SDK. 1/ Are you using our Experiment SDK or anything else that would continue to link to the older version of analytics-connector? 2/ Are these Mac or Mac Catalyst apps? Any other supported destinations? 3/ If possible, could you please include a screenshot of the "Link Binary with Libraries" section if you select your target -> Build Phases?

  1. We are only using Amplitude-Swift - I cannot find any other references to analytics-connector in our workspace or package dependencies
  2. This actually is an iOS app, no other supported destinations than iPhone/iOS
  3. This unfortunately is not possible in this case, is there anything I should look out for though? Maybe it's relevant to add that we are including Amplitude-Swift via an abstract package as well.

Thanks for your help investigating this, much appreciated!

@crleona
Copy link
Collaborator

crleona commented Nov 7, 2024

From the logs @Gray-Wind provided it looks like this is a signing issue with the framework, as its unsigned from us and I'm doubtful you'd run into signing issues with different teams on the same project.

Xcode should be handling code signing, so I'm wondering if this is some cached SPM issue - Could you remove Amplitude-Swift as a dependency then add it back to see if that resolves the issue?

Otherwise, to confirm this is a code signing issue, could you add .package(url: "https://github.com/amplitude/analytics-connector-ios.git", from: "1.2.4") with .product(name: "AnalyticsConnectorFramework", package: "analytics-connector-ios") as a direct dependency? (perhaps setting "embed and sign" on the library in Xcode if needed).

Another option may be to distribute analytics-connector as a static (vs dynamic) framework, which should allow it to be linked directly into other libraries and wouldn't have to be signed as a standalone xcframework.

@Gray-Wind
Copy link

Thank you for your help!

I've identified the difference between the sample project and the main one. Basically the application was loading AnalyticsConnector.framework from outside of the application bundle and that framework was unsigned, unlike the one included into the bundle.

I was able to fix my issue with this addition to the build settings:

LD_RUNPATH_SEARCH_PATHS = @executable_path/Frameworks
LD_RUNPATH_SEARCH_PATHS[sdk=macosx*] = @executable_path/../Frameworks

@crleona
Copy link
Collaborator

crleona commented Nov 13, 2024

@Gray-Wind, @bastianfischer-neotaste - thank you for your help troubleshooting this issue. We've decided to restore SPM based builds to the prior built from source version in #241, which is released in 1.10.3. Carthage will still continue to use the precompiled frameworks, and we can continue to troubleshoot them if you still have issues.

@bastianfischer-neotaste
Copy link
Author

Thanks for the fix @crleona! Just tested, I can confirm that this issue is resolved with version 1.10.3. I will close this issue 🙂

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants