SeikoTheWiz
SeikoTheWiz

Reputation: 883

iOS Linking library in xcconfig

I'm building a library. And I want it to compile and contain another one (which is googleConversion) but I need to do it with xcconfig files (because for some build I want to not include the library for example)

Following: Link binary with static library in xcconfig

So what I did was add in my xcconfig file:

LIBRARY_SEARCH_PATHS = $(inherited) $(PROJECT_DIR)/../Vendors/Analytics/GoogleConversion/GoogleConversionTrackingSDK-iOS-3.2.0 
OTHER_LDFLAGS =$(inherited) -ObjC -L$(PROJECT_DIR)/../Vendors/Analytics/GoogleConversion/GoogleConversionTrackingSDK-iOS-3.2.0 -lGoogleConversionTracking

which let me compile without warning, but don't include the library in my .a

the only way I managed to do it is adding the library in the build phase in Link Binary With Library.

But it's not something I can do if I want to be able to automate my different type of builds

It sounds like it should be very simple ;(

Maybe some other configuration is preventing those lines to work?

I tried checking my logs and I can see in my "check dependencies" in Libtool export path I can see the resolved path of my OTHER_LDFLAGS (which disapear when I remove it from my xcconfig) but not the -lGoogleConversionTracking which exist when I put my lib in the build phase.

(I have more things happening, like nothing in libtool if I completly remove the panel from the build phases, but it could make sense in a way and it's not a big deal)

Thank you in advance!

Upvotes: 1

Views: 2198

Answers (2)

SeikoTheWiz
SeikoTheWiz

Reputation: 883

Finaly got it!!!!

It because of an old xcode bug that was solved in xcode 6.

https://tarunsharmaios.wordpress.com/2014/09/12/xcode6-static-library-linking-broken/

BlockquoteXcode will no longer pass options in the build setting OTHER_LDFLAGS to libtool when building static libraries, nor will it pass options in OTHER_LIBTOOLFLAGS to the Mach-O linker when building any other kind of product. Previously all options in both settings would be passed to both tools. Make sure that options are in the correct build setting for the product type, static library, or other component being built. (4285249)

Upvotes: 2

Serge Maslyakov
Serge Maslyakov

Reputation: 1410

In my case it looks like:

LIBRARY_SEARCH_PATHS = $(inherited) "${SRCROOT}/thirdparties/CardIO-5.1.0"
OTHER_LDFLAGS = $(inherited) -ObjC -lz -lc++ -lCardIO

But my libs placed inside source folder in a same level with the *.xcodeproj-file.

I think that paths with "\..\" won't work for xcode.

This issue can be resolved with a script phase in your scheme.

  • Open your scheme via Product->Scheme->Manage Schemes.
  • Add the New run script action in the Build->Pre-actions
  • Script should copy file libGoogleConversionTracking.a to the ${SRCROOT}
  • Set new path for a LIBRARY_SEARCH_PATHS in *.xcconfig file

Upvotes: 0

Related Questions