Xcodegen: System dependencies

Created on 24 Jul 2017  Ā·  15Comments  Ā·  Source: yonaskolb/XcodeGen

This would allow to linking of system SDK frameworks

enhancement waiting input

Most helpful comment

@peymankh - You can achieve this by passing configuration settings for your target

i.e.

        "OTHER_LDFLAGS" : "$(inherited) -framework Foundation -weak_framework CoreML",

Use -framework for linking a framework
Use -weak_framework for weakly linking a framework
Use -l (example -lc++) to link a dylib

All 15 comments

Is this needed?

Would be useful for something like Google Maps where you have to specify a whole list of system SDK's.

Have a look at Google Maps Install Manually

This should be technically possible from your build settings @sbarow. What about adding an extra parameter in the target specification where you specify those frameworks, and generates the BUILD_SETTINGS necessary for doing the linking automatically?

Hey guys,

Is this still not possible? How do you exactly achieve adding SDK dependencies?

@peymankh - You can achieve this by passing configuration settings for your target

i.e.

        "OTHER_LDFLAGS" : "$(inherited) -framework Foundation -weak_framework CoreML",

Use -framework for linking a framework
Use -weak_framework for weakly linking a framework
Use -l (example -lc++) to link a dylib

@rahul-malik Thanks, that's great.

Thanks @rahul-malik.
Are there any other edges cases that would require explicit linking to something in the SDK directory? Otherwise I might close this

I think they are fairly uncommon but there are cases where you can specify additional sdk paths in xcconfig

In general, it’d be nice to have support for this out of the box. Maybe sdkDependencies attribute?

I think this is an interesting use case for a general design principle here.

Should the spec make it easier to express things that are configurable in xcconfig?

Hey all! I’d like to resurrect this topic, as I prefer to explicitly declare all dependencies but also want a single place for it that other engineers can edit. Without them having to know xcconfig syntax and linker flags 😃

I think adding another type of key to the regular dependencies array would be a good way to solve this. Doing so would also allow for declaring that the dependency is optional (for deployment to earlier OS versions). In my opinion it should be in the spec as opposed to an xcconfig file. Since that’s where all the other dependencies for a target are defined.

Something like:

targets:
  Foo:
    dependencies:
      - system: UserNotification
        optional: true # defaults to false

That should result in:

  • Adding a reference to UserNotification.framework from the SDK directory in the target’s ā€œFrameworksā€ group.
    screen shot 2018-09-19 at 2 26 14 pm
  • Adding the framework to the ā€œLink Binary With Librariesā€ build phase for the target.
  • If optional is set to true the ā€œstatusā€ is changed from Required to Optional.
    screen shot 2018-09-19 at 2 29 19 pm

What do you think @yonaskolb @rahul-malik


Update: The support for optional (uses weak as the key) was implemented by @alvarhansen in https://github.com/yonaskolb/XcodeGen/pull/411 šŸŽ‰

Hi @rastersize. Sorry for the late reply. I like that solution, though I would opt for the name sdk rather than system, as it will be using the sdk root path. What do you think?

I've opened an initial PR here https://github.com/yonaskolb/XcodeGen/pull/430
Can you guys have a look.

I decided to go with sdkFramework as you just pass in the framework name.
sdk could be reserved for other things in the sdk root path like libs, which could be referenced by the full path within the sdk root.

I'm still not sure why this is required, because if you're using something like the Contacts framework it should be automatically found when importing

@yonaskolb sdkFramework sounds good to me šŸ‘

I've finalized on sdk that handles frameworks and libs easily with a simple filename, and can handle anything else in the sdk with a full path (though this shouldn't be required)

targets:
  MyApp
    dependencies:
      - sdk: Contacts.framework
      - sdk: libc++.tbd
      - sdk: some/random/path/in/sdk/root/file.file
Was this page helpful?
0 / 5 - 0 ratings

Related issues

samedson picture samedson  Ā·  5Comments

lukewakeford picture lukewakeford  Ā·  6Comments

thecb4 picture thecb4  Ā·  3Comments

ismetanin picture ismetanin  Ā·  3Comments

brentleyjones picture brentleyjones  Ā·  6Comments