4

We imported pure Swift XCFramework into Swift application. On setting the breaking point and trying the po command the following error is seen

    error: virtual filesystem overlay file '/Users/rakshitha/Library/Developer/Xcode/DerivedData/ABC-agkiherlqdmvaeakrqtfvsowceuq/Build/Intermediates.noindex/ArchiveIntermediates/ABCDE/IntermediateBuildFilesPath/ABC.build/Release-iphonesimulator/ABCDE.build/all-product-headers.yaml' not found
    error: virtual filesystem overlay file '/Users/rakshitha/Library/Developer/Xcode/DerivedData/ABC-agkiherlqdmvaeakrqtfvsowceuq/Build/Intermediates.noindex/ArchiveIntermediates/ABCDE/IntermediateBuildFilesPath/MoEngage.build/Release-iphonesimulator/ABCDE.build/all-product-headers.yaml' not found

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

Solutions Tried:

  1. XCFramework was created with dsym and BCSymbolMaps
  2. XCFramework created without dsym and BCSymbolMaps
  3. Set the Other Swift Flags to -Xfrontend -no-serialize-debugging-options

None of the above solutions worked

Note:

  1. The XCFramework was generated in Xcode 13.4.
  2. The Swift version for generated XCFramework is Swift 5.
  3. XCFramework contains support for iOS and tvOS.
  4. The Sample application was tested in the same Xcode and swift version.

Find the script below to generate XCFramework:

mkdir Framework
mkdir XCFramework

for a in  SampleFramework
do

#  create iOS Device framework
  xcodebuild archive -scheme $a -destination "generic/platform=iOS" -archivePath Framework/$a-iOS.xcarchive SKIP_INSTALL=NO BUILD_LIBRARY_FOR_DISTRIBUTION=YES

# create iOS simulator framework
 
  xcodebuild archive -scheme $a  -destination "generic/platform=iOS Simulator" -archivePath Framework/$a-Sim.xcarchive SKIP_INSTALL=NO BUILD_LIBRARY_FOR_DISTRIBUTION=YES

targetInTvOS=""

case "$a" in
   "SampleFramework")
   targetInTvOS="SampleFrameworkTvOS"
esac

  if [ ${#targetInTvOS} -ge 1 ]; 
  then

    # create tvOS framework
    xcodebuild archive -scheme $targetInTvOS -destination "generic/platform=tvOS" -archivePath Framework/$a-tvOS.xcarchive SKIP_INSTALL=NO BUILD_LIBRARY_FOR_DISTRIBUTION=YES

    # create tvOS simulator framework
    xcodebuild archive -scheme $targetInTvOS -destination "generic/platform=tvOS Simulator" -archivePath Framework/$a-tvOS-Sim.xcarchive SKIP_INSTALL=NO BUILD_LIBRARY_FOR_DISTRIBUTION=YES
  fi

  characterbase="_vers.c"
  FRAMEWORKNAME=$a
  FRAMEWORKNAME+=$characterbase
  BCSYMBOLFILEPATH=""
  BCSYMBOLFILEPATHTvOS=""
  
# Loop through BCSymbolMaps directory
  for fileName in `ls Framework/$a-iOS.xcarchive/BCSymbolMaps/`
  do
    #  give permission
     sudo chmod  777  $(pwd)/Framework/$a-iOS.xcarchive/BCSymbolMaps/$fileName      
      
      # search for framework name in file
      if  grep  $FRAMEWORKNAME $(pwd)/Framework/$a-iOS.xcarchive/BCSymbolMaps/$fileName
         then
          BCSYMBOLFILEPATH+=" -debug-symbols $(pwd)/Framework/$a-iOS.xcarchive/BCSymbolMaps/$fileName"

          if [[ ! -f "$(pwd)/Framework/$a-iOS.xcarchive/BCSymbolMaps/$fileName" ]] 
          then
            echo "INVALID BCSYMBOL FILE PATH"
            exit 0;
          fi
      fi
    
    done

  if [ ${#targetInTvOS} -ge 1 ]; 
  then
  for fileName in `ls Framework/$a-tvOS.xcarchive/BCSymbolMaps/`
  do
    #  give permission
     sudo chmod  777  $(pwd)/Framework/$a-tvOS.xcarchive/BCSymbolMaps/$fileName      
      
      # search for framework name in file
      if  grep  $FRAMEWORKNAME $(pwd)/Framework/$a-tvOS.xcarchive/BCSymbolMaps/$fileName
         then
          BCSYMBOLFILEPATHTvOS+=" -debug-symbols $(pwd)/Framework/$a-tvOS.xcarchive/BCSymbolMaps/$fileName"

          if [[ ! -f "$(pwd)/Framework/$a-tvOS.xcarchive/BCSymbolMaps/$fileName" ]] 
          then
            echo "INVALID BCSYMBOL FILE PATH"
            exit 0;
          fi
      fi
     
    done
    fi


     # dsym file path for simulator and device for iOS device
    DSYMFILEPATHDEVICE="$(pwd)/Framework/$a-iOS.xcarchive/dSYMs/$a.framework.dSYM"
    DSYMFILEPATHSIM="$(pwd)/Framework/$a-Sim.xcarchive/dSYMs/$a.framework.dSYM"


    if [[ ! -d "$DSYMFILEPATHDEVICE" ]] || [[ ! -d "$DSYMFILEPATHSIM" ]]
    then
         echo "INVALID DSYM FILE PATH"
         exit 0; 
    fi  

   # create xcframework
    if [ ${#targetInTvOS} -ge 1 ]; 
    then
    DSYMFILEPATHDEVICETVOS="$(pwd)/Framework/$a-tvOS.xcarchive/dSYMs/$a.framework.dSYM"
    DSYMFILEPATHSIMTVOS="$(pwd)/Framework/$a-tvOS-Sim.xcarchive/dSYMs/$a.framework.dSYM"

    xcodebuild -create-xcframework -framework  Framework/$a-iOS.xcarchive/Products/Library/Frameworks/$a.framework -debug-symbols  $DSYMFILEPATHDEVICE $BCSYMBOLFILEPATH -framework Framework/$a-Sim.xcarchive/Products/Library/Frameworks/$a.framework -debug-symbols $DSYMFILEPATHSIM -framework Framework/$a-tvOS.xcarchive/Products/Library/Frameworks/$a.framework -debug-symbols  $DSYMFILEPATHDEVICETVOS $BCSYMBOLFILEPATHTvOS -framework Framework/$a-tvOS-Sim.xcarchive/Products/Library/Frameworks/$a.framework -debug-symbols $DSYMFILEPATHSIMTVOS -output XCFramework/$a.xcframework 

    else

    xcodebuild -create-xcframework -framework Framework/$a-iOS.xcarchive/Products/Library/Frameworks/$a.framework -debug-symbols  $DSYMFILEPATHDEVICE $BCSYMBOLFILEPATH -framework Framework/$a-Sim.xcarchive/Products/Library/Frameworks/$a.framework -debug-symbols $DSYMFILEPATHSIM -output XCFramework/$a.xcframework 

    fi
 
done

#remove Framework directory
rm -r Framework
  • I faced same problem, I tried to create xcframework with different configuration with no luck, then I found this https://github.com/mstfy/spm-to-xcframework ,, when I used it to make the xcframework, then used it with zero problems and was able to do po normally – Majd Sabah Oct 05 '22 at 06:37
  • There's a workaround described [here](https://stackoverflow.com/a/61824142/4898050) if you're willing to make your project interop with a dummy ObjC file + bridging header. – AmitaiB Jan 06 '23 at 14:45

0 Answers0