Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Including target from existing external Xcode project #806

Open
mobileben opened this issue Mar 16, 2020 · 1 comment
Open

Including target from existing external Xcode project #806

mobileben opened this issue Mar 16, 2020 · 1 comment

Comments

@mobileben
Copy link

I'm currently working on a build system that uses prebuilts for dependency frameworks/libraries. We want the ability to use the project file instead of the prebuilt library for debug. I have a model working which I manually built a workspace, but am aiming to build this workspace dynamically with xcodegen. This is because the blend of prebuilts to projects is dependent upon the scenario. The main application project always exists in the workspace.

The key to how this works is creating a "bootstrap" project. This bootstrap contains an aggregate target which is really just a dummy target for the scheme. The scheme does all the work to make this work. The scheme contains a preaction script. This preaction script copies over necessary configurations (in particular, anxcconfig file). The scheme also has the application's target as a build target.

There are really 2 issues here I've encountered when trying to get xcodegen to generate the bootstrap project file.

  • ExecutionAction does not support defining the shell to use for the script (BuildScript does)
  • My application's target is in an existing external project. It isn't not clear how or if external targets are supported.

So the two questions are:

  • Can we define the shell to use in the ExecutionAction?
  • Can we and if we can, what is the correct syntax to reference external targets? In particular, this external target is to be added to a scheme's target list.

Note I generate the workspace with XcodeProj. The code seems relatively difficult for creating the project and adding custom schemes (based on looking at some of the XcodeGen code). Thus why I'm looking at this. Right now the plan is to call do this via the command line, but ideally I'd like to do this via using XcodeGen as a library, but it also isn't clear in this latter case if I lose the niceties done by the generate command.

@mobileben
Copy link
Author

I've made some progress in this, but also some setbacks.

  • Ideally I want to use an aggregate, but seem forced to use a type == tool, as trying to use aggregateTargets is not overly documented and doesn't seem to work in my case
  • When adding a pre-action script, if one uses multi-lines, it seems newlines are not honored.

For example the start of the script in the YAML looks like

      preActions:
        - name: Bootstrap Script
          script: |+
            #!/bin/bash
            # Update xcconfig and yaml or remove if doesn't exist
            # yaml probably should go elsewhere but for making this easier right now, this is where they all go
            XCCONFIG="Custom.xcconfig"\n
            FRAMEWORKS_YAML="frameworks.yml"
            RESOURCES_YAML="resources.yml"

I'm not an YAML expert, but from my understanding |+ should keep newlines. Instead this gets inserted as one full line, which, because there is a she bang and comments up front ... means this script does nothing.

Some other issues I've run in.

The trick seems to use projectReferences, however I'd like to have a projectReference where in the end, the project is not inserted in the project. I really only need to scheme to hold the path to the project. But otherwise, this is not needed in my case.

  • I've noticed an issue where it seems that all pathing is relative to the spec file. It would be nice to be able to make it relative to the project directory. This is important because pathing get get out of sync if the spec file is in a different directory structure. This is particularly important is relative addressing is being created.

  • In a scheme, if you have a multiple targets, the order is not honored. This is actually important if you turn off parallel builds.

Some of the items listed above still hold (like not being able to define the shell for the preaction).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant