Xcode 12 different definitions in different modules build error

In the Xcode 12 betas I'm seeing an issue with importing Swift modules with @objc annotations.

Given two Swift modules which expose classes of the same name:

Code Block
// FrameworkOne
@objc
public class Thing: NSObject {
public override init() {}
@objc
public func doSomething() {}
}


Code Block
// FrameworkTwo
@objc
public class Thing: NSObject {
public override init() {}
@objc
public func doSomethingElse() {}
}


And if I have imported both of the frameworks into an ObjC file and interact with the classes in either of them:

Code Block
#import <Foundation/Foundation.h>
@import FrameworkOneObjC;
@import FrameworkTwoObjC;
@interface Example : NSObject
@end
@implementation Example
- (void) example
{
Thing *thing = [[Thing alloc] init];
}
@end


Then I'm seeing this build error:
Code Block
'Thing' has different definitions in different modules; first difference is definition in module 'FrameworkOne.Swift' found method name 'doSomething'
But in 'FrameworkTwo.Swift' found method name 'doSomethingElse'


Is this expected behaviour? If so, is there any way to opt out?

In my case FrameworkOne & FrameworkTwo are external dependencies, and I'm unable to change the names of the classes.
still waiting for a solution . My Pods "Macaw" and "CometChatPro" has both a class named Group and other super classes so I get. an Compiler Error
We have exactly the same issue after upgrading to Xcode 12. Apple, is there a solution to this please?
Same here, I have to use Xcode 12.0.1 but I have these incompatibilities.

Having two classes with the same names from two independent librairies should definitely not be an issue, a fix would be appreciated.
same on xcode 12 (12.0.1 (12A7300))
nothing of these helps:
  • cleaning build/derived data/recycle bin/restarting mac

  • pod deintegrate && pod install

  • using legacy build system

To author and everyone complaining here, what behaviour do you expect if there was no error? There is a clear ambiguity, objc compiler doesn't know which class to choose. If there was no error previously, that means that compiler choses one of those classes via some internal, undocumented way, that can lead to faulty and unexpected behaviour.

To solve this issue you can either change objc names to have prefixes (which is a way to resolve namespacing in objc, and definitely should be done in good third party libs):
Code Block
// FrameworkOne
@objc(ABCThing)
public class Thing: NSObject { ... }
// FrameworkTwo
@objc(XYZThing)
public class Thing: NSObject { ... }

Or, if you don't have any way to affect this code, you have to avoid importing both frameworks at the same time when you referencing an ambiguous definitions.
Is there any solution to this? Please do it quickly! Please do it quickly ! Please do it quickly
We do not use any obj-c code in our project, so our solution was to set the
Code Block
SWIFT_INSTALL_OBJC_HEADER
build setting to 'NO' for all the pods in the post_install hook of cocoapods.
This is incredibly frustrating. To be honest most iOS development is incredibly frustrating but I don't understand why third party developers making silly mistakes should bite my project in the behind when upgrading to the latest version of XCode.

It sucks that Obj-C doesn't have namespacing and that third party devs didn't prefix, but how come this issue was avoided in previous XCode versions?

My build is completely broken now.
为什么不解决?为什么到现在还没解决?xcode 真的太差了,开发人员都干什么吃的?

Why not fix it? why not fix it now? Xcode is so bad, what do developers do for a living?
the same to me
please resolve quickly
Workaround
  • Both classes are in same workspace, rename one of the class name and it will resolve problem.

  • Both classes are in frameworks, fork one of the repos and rename class name and use fork repo instead of actual repo, it will resolve problem.

In general, you have to rename one of the class name in order to run your project. You just have to think about how to rename them based upon your project settings.
Why not fix it? why not fix it now
Is there any solution to this? Please do it quickly! Please do it quickly ! Please do it quickly
Has this issue been fixed?
I am still facing it in Xcode 12.3.
DELETED REPLY
check whether the header file name is repeated,remove the file which is not used. Doing this helped in my case.
Is there any update from Apple on this issue?

I am still facing it in Xcode 12.5.1 Is there any update from Apple on this issue?

If you are using Cocoapods, this previous post worked well for our project:

We do not use any obj-c code in our project, so our solution was to set the Code Block

SWIFT_INSTALL_OBJC_HEADER

build setting to 'NO' for all the pods in the post_install hook of cocoapods.

Here is an example – at the end of our Podfile:

# CocoaPods With conflicting symbol nameds 
PodsWithConflictingSymbolNames = [
  'CognoaUIKit',
  'Macaw',
]

## Pods settings.
post_install do |installer|
    installer.generated_projects.each do |project|
        project.targets.each do |target|
            if PodsWithConflictingSymbolNames.include? target.name
                target.build_configurations.each do |config|
                    config.build_settings['SWIFT_INSTALL_OBJC_HEADER'] = 'NO'
                end
            end
        end
    end
end
Xcode 12 different definitions in different modules build error
 
 
Q