socketio / socket.io-client-swift

Other
5.21k stars 841 forks source link

Build for distribution #1426

Closed hrabkin closed 1 year ago

hrabkin commented 1 year ago

Hello,

I would like to use SocketIO as a dynamic dependency of my xcframework

I have checked your project and see that you don't use option BUILD_LIBRARY_FOR_DISTRIBUTION:

189948772-d0117bcd-d267-46ac-aa2f-6f2ad0fdc5fb

why?

This option

Ensures that your libraries are built for distribution. For Swift, this enables support for library evolution and generation of a module interface file

https://xcodebuildsettings.com

Without forcing this option in Pods project there's the following error in runtime:

dyld[20229]: Symbol not found: _$s8SocketIO0A11ClientEventO5erroryA2CmFWC
  Referenced from: .../Frameworks/MyFramework.framework/MyFramework
  Expected in: .../MyApp.app/Frameworks/SocketIO.framework/SocketIO

I can confirm this error running project with the dependencies under Rosetta with some of these options used:

config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = ’x.0'
config.build_settings.delete 'IPHONEOS_DEPLOYMENT_TARGET'

P.S. Also these issues have relation to the ticket #1356 #1269

Current workaround is to add at the end of project's Podfile where Socket-IO integrated:

# Socket.IO-Client-Swift
post_install do |lib|
    lib.pods_project.targets.each do |target|
      if target.name == 'Socket.IO-Client-Swift'
          target.build_configurations.each do |config|
              config.build_settings['BUILD_LIBRARY_FOR_DISTRIBUTION'] = 'YES'
          end
      end
    end
end

and remove if used:

config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = ’x.0'
config.build_settings.delete 'IPHONEOS_DEPLOYMENT_TARGET'
hrabkin commented 1 year ago

Closing because of several other posts on the same topic