1

I have a problem sharing a static library to my xcode sub projects. Assuming the structure of my project is like this:

Main.xcodeproj
|
|_Cordova.xcodeproj
|
|_SubProject1.xcodeproj
|
|_SubProject2.xcodeproj

I have create the static library for:

  • SubProject1
  • SubProject2

These libraries needs to be linked with the Cordova Static Library.

I've done this by:

  • Open SubProject1
  • Add the Cordova static library in the "Link Binary With Libraries" section

then

  • Open SubProject2
  • Add the Cordova static library in the "Link Binary With Libraries" section

After that,

  • Opened the Main.xcodeproj
  • Add Target Depedendency for SubProject1
  • Add Target Depedendency for SubProject2
  • Add Link Binary With Libraries for SubProject1 static library
  • Add Link Binary With Libraries for SubProject2 static library

If i build i obtain the following errors:

duplicate symbol _OBJC_IVAR_$_CDVViewController._commandQueue in:
    /Users/xxx/Library/Developer/Xcode/DerivedData/appxxx/Build/Products/Debug-iphonesimulator/libSubProject1.a(CDVViewController.o)
    /Users/xxx/Library/Developer/Xcode/DerivedData/appxxx/Build/Products/Debug-iphonesimulator/libSubProject2.a(CDVViewController.o)

duplicate symbol _OBJC_IVAR_$_CDVViewController._commandDelegate in:
    /Users/xxx/Library/Developer/Xcode/DerivedData/appxxx/Build/Products/Debug-iphonesimulator/libSubProject1.a(CDVViewController.o)
    /Users/xxx/Library/Developer/Xcode/DerivedData/appxxx/Build/Products/Debug-iphonesimulator/libSubProject2.a(CDVViewController.o)

How can I share this library across these two sub projects?

Thank you so much

Fra8686
  • 11
  • 3

1 Answers1

1

There's no need to link both SubProjects with Cordova, you can just link the Main target to Cordova.

emix
  • 283
  • 1
  • 11
  • Hi emix thank you so much for your response. I've removed the reference to the cordova library in the both SubProject by removing the Cordovalib in the "Link Binary With Libraries" section and add the reference to the Cordovalib in the main in the "Link Binary With Libraries". If I remove the references in the sub projects, the import in the header files are not resolved and does not build also the subproject – Fra8686 Apr 29 '15 at 10:29
  • You should just remove Cordova from the "Link Binary" phase keeping everything else (i.e. the headers) in the subprojects. – emix Apr 29 '15 at 10:36