SwiftKickMobile / SwiftMessages

A very flexible message bar for UIKit and SwiftUI.
MIT License
7.24k stars 742 forks source link

Xcode 12 error #420

Closed nkezhaya closed 3 years ago

nkezhaya commented 3 years ago

Sorry if this has been repeated a million times, but I'm getting this error with Xcode12 and Cocoapods:

'MessageView' has different definitions in different modules; first difference is definition in module 'SwiftMessages.Swift' found super class with type 'BaseView'

Issue is in SwiftMessages-Swift.h, line 284, SwiftMessages 8.0.2.

wtmoose commented 3 years ago

Where is the other definition of MessageView?

wtmoose commented 3 years ago

https://developer.apple.com/forums/thread/658012

nkezhaya commented 3 years ago

Yep, definitely seems to be an issue in Xcode 12. pod deintegrate and clearing of DerivedData didn't help.

nkezhaya commented 3 years ago

@wtmoose The other definition is here: https://github.com/GitHawkApp/MessageViewController/blob/master/MessageViewController/MessageView.swift

:(

nkezhaya commented 3 years ago

@wtmoose The solve was going through other libraries with conflicting class names and renaming it for the objc-bridge.

So in MessageViewController/MessageView.swift, the file before was:

public final class MessageView: UIView, MessageTextViewListener {

Adding one line above:

@objc(ABCMessageView)
public final class MessageView: UIView, MessageTextViewListener {

Seems to avoid the naming conflicts.

wtmoose commented 3 years ago

I worked around this problem in my own apps by configuring the build to not create an Objective-C compatibility header. I'm using CocoaPods, so I added the following post install script to my Podfile:

post_install do |installer|
    installer.pods_project.targets.each do |target|
        target.build_configurations.each do |config|
            config.build_settings['SWIFT_INSTALL_OBJC_HEADER'] = 'NO'
        end
    end
end

And then in each of my app's targets, I also set SWIFT_INSTALL_OBJC_HEADER to NO in the target's build settings.