twilio / conversations-ios

SPM releases

Home Page:https://www.twilio.com/docs/conversations/ios/changelog

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

v4.0.1 breaks LLDB in Xcode

andyyhope opened this issue · comments

We're using the latest version (4.0.1) via SPM and it has broken our ability to use LLDB. Upon further inspection, it appears that the included binary twilio-conversations-ios-4.0.1.xcframework is exporting absolute search paths for the SDKStatCaches.noindex directory. For example, when we try to po a variable, the following error is shown:

(lldb) po myString
error: expression failed to parse:
error: stat cache file '/Users/distiller/rtd-sdk-monorepo/sdk/ios/Local/temp/DerivedData/SDKStatCaches.noindex/iphonesimulator16.4-20E238-.sdkstatcache' not found
error: stat cache file '/Users/distiller/rtd-sdk-monorepo/sdk/ios/Local/temp/DerivedData/SDKStatCaches.noindex/iphonesimulator16.4-20E238-.sdkstatcache' not found

error: couldn't IRGen expression. Please check the above error messages for possible root causes.

Possible solutions:

Update the project to include the following flag so absolute search paths aren't used:

OTHER_SWIFT_FLAGS = "-Xfrontend -no-serialize-debugging-options"

Saw this as well. #36 also but don't think anything was ever done on it. @andyyhope Did that workaround work for you w/o side effects?

I've actually tried a bunch of things to get a workaround on this but without any success:

LLDB

Added an LLDBinit file to redirect the distiller path to a local one:

settings set target.source-map /Users/distiller/rtd-sdk-monorepo/sdk/ios/Local/temp/DerivedData/SDKStatCaches.noindex/iphonesimulator16.4-20E238-.sdkstatcache /Users/andyyhope/Library/Developer/Xcode/DerivedData/SDKStatCaches.noindex/iphonesimulator16.4-20E238-.sdkstatcache /Users/distiller/rtd-sdk-monorepo/sdk/ios/Local/temp/DerivedData/Build/Intermediates.noindex/ArchiveIntermediates/TwilioConversationsClient/IntermediateBuildFilesPath/TwilioConversationsClient.build/Release-iphonesimulator/TwilioConversationsClient.build/all-product-headers.yaml /Users/andyyhope/Downloads/TestTwilioLLDBWorkspace/TestTwilioLLDB/all-product-headers.yaml

VFS Overlays

Added a VFS overlay to the swift compile flags

-Xcc -ivfsoverlay -Xcc vfsoverlay.yaml
{
  'version': 0,
  'roots': [
    { 
      'name': '/Users/distiller/rtd-sdk-monorepo/sdk/ios/Local/temp/DerivedData/SDKStatCaches.noindex', 
      'type': 'directory',
      'contents': [
        { 
          'name': 'iphonesimulator16.4-20E238-.sdkstatcache', 
          'type': 'file',
          'external-contents': 'SDKStatCaches.noindex/iphonesimulator16.4-20E238-.sdkstatcache'
        },
      ]
    },
    { 
      'name': '/Users/distiller/rtd-sdk-monorepo/sdk/ios/Local/temp/DerivedData/Build/Intermediates.noindex/ArchiveIntermediates/TwilioConversationsClient/IntermediateBuildFilesPath/TwilioConversationsClient.build/Release-iphonesimulator/TwilioConversationsClient.build', 
      'type': 'directory',
      'contents': [
        { 
          'name': 'all-product-headers.yaml', 
          'type': 'file',
          'external-contents': 'all-product-headers.yaml'
        },
      ]
    },
  ]
}

Added compiler flags

To redirect distiller paths to my own

-fdebug-prefix-map=/Users/distiller/rtd-sdk-monorepo/sdk/ios/Local/temp/DerivedData/SDKStatCaches.noindex=/Users/andyyhope/Downloads/TestTwilioLLDBWorkspace/TestTwilioLLDB/SDKStatCaches.noindex

Modifying the twilio-conversations-ios-4.0.1 binary

  • Removed the references to dSYMs and dSYM files altogether
  • Modified the actual binary files to swap paths to distiller with my own

I'm also experiencing this issue and would very much appreciate a fix.

4.0.2 is cooking folks.

Fixed by 4.0.2.

@berkus Sadly, I'm still seeing the issue. What changes did you make to the binary?

@berkus Sadly, I'm still seeing the issue. What changes did you make to the binary?

Interesting, I've tested both 4.0.1 and 4.0.2 in xcode; with 4.0.1 the lldb debugging was failing with the error you've posted above. With 4.0.2 it actually worked.

Changes to the binary include setting SWIFT_SERIALIZE_DEBUGGING_OPTIONS = NO in user build flags. I've confirmed that build then uses -Xfrontend -no-serialize-debugging-options when building.

Do you have more details? Can you confirm that you're actually using 4.0.2? Xcode seems very stubborn on updating the deps properly.

Do we have to clear SPM cache locally to see the change possibly?

@berkus Sadly, I'm still seeing the issue. What changes did you make to the binary?

Interesting, I've tested both 4.0.1 and 4.0.2 in xcode; with 4.0.1 the lldb debugging was failing with the error you've posted above. With 4.0.2 it actually worked.

Changes to the binary include setting SWIFT_SERIALIZE_DEBUGGING_OPTIONS = NO in user build flags. I've confirmed that build then uses -Xfrontend -no-serialize-debugging-options when building.

Do you have more details? Can you confirm that you're actually using 4.0.2? Xcode seems very stubborn on updating the deps properly.

We have a test project that is able to reproduce the issue. I'll send it to you first thing Monday (Australia time)

@berkus We have a test project that is able to reproduce the issue. I'll send it to you first thing Monday (Australia time)

I'm also still seeing the problem. I've removed DerivedData, ~/Library/Caches/org.swift.swiftpm and ~/Library/Developer/swift-sh.cache and also confirmed the TwilioConversationsClient binary being used is the 4.0.2 one.

(Aside the Info.plist for the updated framework still has CFBundleShortVersionString set to 2.1.0 rather than 4.0.2...)

Here's the test project @andyyhope referred to TestTwilioLLDBWorkspace.zip - it's also in Support Ticket 12867609.

Update the TwilioDependencies/Package.swift to use 4.0.2, then build and run TestTwilioLLDB.xcworkspace's TestTwilioLLDB. Set a breakpoint in AppDelegate's didFinishLaunchingWithOptions and try to po application.

OK. So I'm able to repro this reliably with a test project on Xcode 14.3.1 but also noticed that Xcode 15b5 is able to resolve this issue (albeit with a bit of lag) but we can't really rely on that because there are a few things holding us back from adopting Xcode 15 at launch.

Check out @casr-anz's project above for repro or mine:
https://github.com/andyyhope/twilio-conversations-lldb

Aside the Info.plist for the updated framework still has CFBundleShortVersionString set to 2.1.0 rather than 4.0.2...)

ouch

@andyyhope @casr-anz thanks folks, I am checking it out now.

Hm. I've changed TwilioDependencies/Package.switft to depend on 4.0.2 before opening it with Xcode.
Opened in Xcode.
Built - po application failed with the issue we know.
THEN i've changed the dependency back to 4.0.1, rebuilt and this is the result:

image

quick sanity check. Does /Users/distiller/rtd-sdk-monorepo/sdk/ios/Local/temp/DerivedData/SDKStatCaches.noindex/iphonesimulator16.4-20E238-.sdkstatcache exist on your local machine?

ls /Users/distiller/rtd-sdk-monorepo/sdk/ios/Local/temp/DerivedData/SDKStatCaches.noindex/iphonesimulator16.4-20E238-.sdkstatcache
ls: /Users/distiller/rtd-sdk-monorepo/sdk/ios/Local/temp/DerivedData/SDKStatCaches.noindex/iphonesimulator16.4-20E238-.sdkstatcache: No such file or directory

This user exists only on CI boxes.

Additional info: if I open project as-is, with 4.0.1 as dependency, then debug fails the same way after build.

After further investigation:

  1. You need to delete the dSYMs from the framework bundle for it to work
  2. Until a patched xcode is released, -no-serialize-debugging-options option doesn't seem to have any effect.

Thanks @berkus
Could you clarify exactly which dSYMs you needed to delete for it to work? (Or were you saying that without an updated Xcode even deleting the dSYMs doesn't work?)

With our project I've just tried removing all the Twilio dSYMs to no avail:

  1. Quit Xcode
  2. Remove DerivedData
  3. Clear out ~/Library/Caches/org.swift.swiftpm and ~/Library/Developer/swift-sh.cache
  4. Configure our Package.swift to use 4.0.2
  5. Resolve packages from the command-line
  6. Remove all Twilio dSYMs find . -name "Twilio*.framework.dSYM" -exec rm -r \{\} \; from inside DerivedData
  7. Open Xcode, build and run, po still fails
  8. (Confirm there are no dSYMs still in DerivedData find . -name "Twilio*.framework.dSYM")

There are still lots of these kinds of references to the CI user's directory in these files in the Twilio framework bundles, which may be the culprits though:
"filePath": "\/Users\/distiller\/rtd-sdk-monorepo\/sdk\/ios\/convo\/TwilioConversationsClient\/Sources\/TCHParticipant+Extension.swift"
in files like TwilioConversationsClient.xcframework/ios-arm64_x86_64-simulator/TwilioConversationsClient.framework/Modules/TwilioConversationsClient.swiftmodule/x86_64-apple-ios-simulator.abi.json

@andyyhope which was the change to fix it?

This? OTHER_SWIFT_FLAGS = "-Xfrontend -no-serialize-debugging-options" or this SWIFT_SERIALIZE_DEBUGGING_OPTIONS = NO

@jesus-mg-ios if you just override using OTHER_SWIFT_FLAGS then the old setting of "-Xfrontend -serialize-debugging-options" remains active in the command line in addition to the other flags, so that doesn't work well. Setting SWIFT_SERIALIZE_DEBUGGING_OPTIONS = NO on the other hand cleans up the command line nicely.

So @berkus, with SWIFT_SERIALIZE_DEBUGGING_OPTIONS = NO the issue is solved, doesn't it?

@jesus-mg-ios Unless I'm missing something, still feels like this issue needs to be resolved inside Twilio with a new release of the SDK? This really just boils down to an incorrectly packaged/configured SPM package. Workarounds like this are appreciated but shouldn't be expected for a third party SDK.

@berkus are you sure that the -no-serialize-debugging-options setting you're inputting isn't being overwritten later in the stack or ? Have you tried compiling the Xcframework from the command line?

Try doing a grep search for:

grep -F -r . -e "OTHER_SWIFT_FLAGS"

and check to see it's being set everywhere

So @berkus, with SWIFT_SERIALIZE_DEBUGGING_OPTIONS = NO the issue is solved, doesn't it?

Not really. Even when sdk is compiled with the correct settings xcode manages to go crazy.

@berkus are you sure that the -no-serialize-debugging-options setting you're inputting isn't being overwritten later in the stack or ? Have you tried compiling the Xcframework from the command line?

Try doing a grep search for:

grep -F -r . -e "OTHER_SWIFT_FLAGS"

and check to see it's being set everywhere

Yeah i believe I’ve checked everything. I was grepping the logs from the CI cli build and it seems all options were propagated fully.

@andyyhope @mthormann-dhi @ryanwaggoner @casr-anz @jesus-mg-ios now that Xcode 15 is out, does it work for you with the regular conversations package to debug?

Tested in Xcode 15, seems to work fine.

Hi @berkus - yes, it does seem to work fine now. Both 4.0.1/4.0.2 with my test project and our production app seem to like LLDB again with Xcode 15.

Thanks for the reminder to re-check. (Can now get rid of various /Users/distiller sym-links that were working around the problem).

I am going to close this as fixed, since it clearly was a bug in Xcode 14.3.1.