Kevin Machado
Kevin Machado

Reputation: 4187

duplicate symbols for architecture i386 - Error during adding custom framework

I'm trying to add a custom framework into 2 projects but an error occurred.

    duplicate symbol _OBJC_CLASS_$_ApiECV in:
    /Users/kevinmachado/Library/Developer/Xcode/DerivedData/EnvDevTestiPad-bvscnxvnzjltpxcxuoomuaqqsxpj/Build/Products/Debug-iphonesimulator/libAPI_ECV.a(ApiECV.o)
    /Users/kevinmachado/Library/Developer/Xcode/DerivedData/EnvDevTestiPad-bvscnxvnzjltpxcxuoomuaqqsxpj/Build/Products/Debug-iphonesimulator/libMKCalendar.a(ApiECV.o)
duplicate symbol _OBJC_METACLASS_$_ApiECV in:
    /Users/kevinmachado/Library/Developer/Xcode/DerivedData/EnvDevTestiPad-bvscnxvnzjltpxcxuoomuaqqsxpj/Build/Products/Debug-iphonesimulator/libAPI_ECV.a(ApiECV.o)
    /Users/kevinmachado/Library/Developer/Xcode/DerivedData/EnvDevTestiPad-bvscnxvnzjltpxcxuoomuaqqsxpj/Build/Products/Debug-iphonesimulator/libMKCalendar.a(ApiECV.o)
ld: 2 duplicate symbols for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)

I think this error is coming because I try to compile twice my custom framework.

I have 3 projects on my workspace. API_ECV and iPadTest are both calling MKCalendar as framework

You can take a look here : Projet tree

iPadTest build phase : iPadTest build Phase

API_ECV build phase : API_ECV build Phase

If I delete the link in API_ECV no error occurred but I can't use MKCalendar framework

Anyone have an idea ? Can I link my custom framework without compiling it twice ?

Thx ;)

Upvotes: 0

Views: 129

Answers (2)

ilya n.
ilya n.

Reputation: 18816

You have two choices:

  1. For a simple dependency like yours, just remove libMKCalendar.a from either iPadTest or API_ECV. Then it will be linked exactly once. (You would need to specify path to its headers were the compiler to have problems).

  2. If you have more complicated dependencies, just turn MKCalendar into a framework, then it can be intelligently reused by different targets. iOS frameworks are available if you use Xcode 6 beta.

Upvotes: 1

Vincent Guerci
Vincent Guerci

Reputation: 14419

From what you posted, I guess that:

  • API_ECV linked from MKCalendar
  • API_ECV linked from iPadTest
  • MKCalendar linked from iPadTest

So here is where your duplicate comes from, API_ECV twice from direct link and MKCalendar link. Two possible solutions:

  • Don't link it from iPadTest, relying on MKCalendar to provide it
  • Mark it as "Optional" in MKCalendar (Where is is mentioned "Required")

Upvotes: 1

Related Questions