XcodeGen icon indicating copy to clipboard operation
XcodeGen copied to clipboard

link a product of another xcproj?

Open pvinis opened this issue 6 years ago • 8 comments

i have a project and i want to link a .a that is the product of another xcproj. how can i do that?

so my proj is MyProj and a target MyApp. there is another one called SomeLib with a target Lib and a product lib.a. i want to link lib.a to MyApp.

pvinis avatar Apr 12 '18 11:04 pvinis

I believe you can use the implicit dependencies feature to achieve this.

From the project spec docs -

Implicit Framework options:

This only applies to framework dependencies. Implicit framework dependencies are useful in Xcode Workspaces which have multiple .xcodeproj that are not embedded within each other yet have a dependency on a framework built in an adjacent .xcodeproj. By having Find Implicit Dependencies checked within your scheme Build Options Xcode can link built frameworks in BUILT_PRODUCTS_DIR.

implicit: Bool - Whether the framework is an implicit dependency. Defaults to false .

rahul-malik avatar Apr 12 '18 11:04 rahul-malik

the problem is that my project is a project, not a workspace that contains these extra projects.

pvinis avatar Apr 12 '18 11:04 pvinis

How would you of done this in without XcodeGen? I assume just drag the framework in? In that case you can add a framework dependency

targets:
  MyTarget:
    dependencies:
      - framework: path/to/framework.a
        embed: true

You then may have to set OTHER_LDFLAGS and LIBRARY_SEARCH_PATHS as mentioned here: https://github.com/yonaskolb/XcodeGen/issues/271

yonaskolb avatar May 14 '18 00:05 yonaskolb

@yonaskolb i tried again today but i still think there is something missing.

my project is using a .a file that is a product of another project. that other project has a shared scheme, that builds this .a file, that i need for my project as a dependency.

using - framework: .. i can only add the path of the .a file, but that doesnt work because the .a will never be built, and it doesnt exist yet, or i can add the path of the other project, but that isnt going to build the .a file i need from it.

does that make sense?

pvinis avatar Oct 18 '18 13:10 pvinis

Should be able to use implicit: true to have it look in the built products directory.

brentleyjones avatar Oct 18 '18 14:10 brentleyjones

so i do

  - framework: some/path/Other.xcodeproj
    implicit: true

so far so good. now this Other project has a scheme called Wow that makes a product called libWow.a.

how do i link that .a, so its built before my code starts compiling?

pvinis avatar Oct 20 '18 05:10 pvinis

@pvinis any updates? did you find a way to make it work?

jakubkiermasz-zd avatar Jun 21 '21 14:06 jakubkiermasz-zd

I haven't tried that in a while, so I can't say it works or it doesn't work.

pvinis avatar Jun 21 '21 15:06 pvinis