appsquickly / typhoon

Powerful dependency injection for Objective-C ✨✨ (https://PILGRIM.PH is the pure Swift successor to Typhoon!!)✨✨
https://pilgrim.ph
Apache License 2.0
2.7k stars 269 forks source link

Duplicate Interface definition for class Typhoon Method #565

Closed msalmanST closed 7 years ago

msalmanST commented 7 years ago

Hi,

I am facing a weird issue while using typhoon. If I delete the Derived Data folder and then try to compile the code then I get the some duplication error same as mentioned here and in below image , screen shot 2017-06-20 at 4 09 02 pm

Now if I clean the project and compile again then errors went away, it is fine till I am using the Xcode to run the project but not with command line, this is causing real problem for me when trying to run the unit tests from the command line, first command fails because of above errors and if I run the same command with clean then it run successfully.

Not sure what the issue is, below is the structure of my pod file,

screen shot 2017-06-20 at 4 22 53 pm

I am using below command to run the test,

xcodebuild test -workspace MyProject.xcworkspace -scheme MyProjectTests -destination 'platform=iOS Simulator,name=iPhone 7,OS=10.2'

And below is the error I received from command line

Testing failed:
    Duplicate interface definition for class 'TyphoonTypeConverterRegistry'
    Duplicate interface definition for class 'TyphoonTypeConversionUtils'
    Duplicate interface definition for class 'TyphoonComponentFactory'
    Property has a previous declaration
    Property has a previous declaration
    Property has a previous declaration
    Property has a previous declaration
    Duplicate interface definition for class 'TyphoonMethod'
    Property has a previous declaration
    Duplicate interface definition for class 'TyphoonDefinitionNamespace'
    Property has a previous declaration
    Redefinition of 'TyphoonScope'
    Redefinition of enumerator 'TyphoonScopeObjectGraph'
    Redefinition of enumerator 'TyphoonScopePrototype'
    Redefinition of enumerator 'TyphoonScopeSingleton'
    Redefinition of enumerator 'TyphoonScopeLazySingleton'
    Redefinition of enumerator 'TyphoonScopeWeakSingleton'
    Redefinition of 'TyphoonAutoInjectVisibility'
    Redefinition of enumerator 'TyphoonAutoInjectVisibilityNone'
    Redefinition of enumerator 'TyphoonAutoInjectVisibilityByClass'
    Redefinition of enumerator 'TyphoonAutoInjectVisibilityByProtocol'
    Redefinition of enumerator 'TyphoonAutoInjectVisibilityDefault'
    Duplicate interface definition for class 'TyphoonDefinition'
    Property has a previous declaration
    Property has a previous declaration
    Property has a previous declaration
    Property has a previous declaration
    Property has a previous declaration
    Property has a previous declaration
    Duplicate interface definition for class 'TyphoonOptionMatcher'
    Duplicate interface definition for class 'TyphoonAssembly'
    Duplicate interface definition for class 'TyphoonBlockDefinition'
    Duplicate interface definition for class 'TyphoonInject'
    Duplicate interface definition for class 'TyphoonConfigPostProcessor'
    Duplicate interface definition for class 'TyphoonPathResource'
    Duplicate interface definition for class 'TyphoonBundleResource'
    Duplicate interface definition for class 'TyphoonRuntimeArguments'
    Duplicate interface definition for class 'TyphoonBlockComponentFactory'
    Duplicate interface definition for class 'TyphoonFactoryDefinition'
    Property has a previous declaration
    Duplicate interface definition for class 'TyphoonIntrospectionUtils'
    Duplicate interface definition for class 'TyphoonCollaboratingAssemblyProxy'
    Duplicate interface definition for class 'TyphoonTestUtils'
    Duplicate interface definition for class 'TyphoonAbstractDetachableComponentFactoryPostProcessor'
    Duplicate interface definition for class 'TyphoonPatcher'
    Duplicate interface definition for class 'TyphoonInjectedObject'
    Duplicate interface definition for class 'TyphoonStoryboard'
    Property has a previous declaration
    Property has a previous declaration
    Duplicate interface definition for class 'TyphoonNibLoader'
    Property has a previous declaration
    Property has a previous declaration
    Duplicate interface definition for class 'TyphoonBundledImageTypeConverter'
    Duplicate interface definition for class 'TyphoonLoadedView'
Failed to import bridging header '/x/x/x/x/x/x/x/x/MyProject-Bridging-Header.h'
** TEST FAILED **

Please let me know if I am missing something. Thanks in advance.

jasperblues commented 7 years ago

If you declare your test target inside the main target, like this:

platform :ios, '8.0'
swift_version = "3.0"

target 'whatsbeef' do

  pod 'Cache'
  pod 'FieryCrucible'
  pod 'Hex'
  pod 'NanoFrame'
  pod "PromiseKit", "~> 4.0"
  pod 'R.swift'
  pod 'SwiftyJSON'

  target 'whatsbeefTests' do
    # Test Dependencies
  end

end

inhibit_all_warnings!
use_frameworks!

. . .then all should be well. Let us know.

msalmanST commented 7 years ago

@jasperblues Thanks for your reply, that didn't help me, let me simplify my problem, I believe that if I solve my below problem then unit test target will also starts working.

  1. I remove the unit test target from the pod file, keep in mind that I am not using "use_frameworks!".
  2. Now after pod install I delete my derived data folder, and open the project.
  3. Compile the code.
  4. Get swift compilation error about duplicate declaration.
  5. Clean the code.
  6. Run again and code compiles without any error.

As my project is a mix of objc+swift so I am importing Typhoon.h in my bridging header file, not sure if that is creating some issues.

msalmanST commented 7 years ago

@jasperblues So I have finally solved the issue, after searching for the possible reason of this issue I cam across this post comment and it gives me some idea of what I could have been doing wrong.

So in my bridging header file I was importing the typhoon as below.

#import "Typhoon.h"

I have change above to

#import <Typhoon/Typhoon.h>

I am not sure if this can be fixed at your side but I have solved this issue on my end :)

Thanks again :)

jasperblues commented 7 years ago

I'd forgotten about that. Thanks a lot for sharing your experience - noted.