Best way to determine if we're building an iOS app or iOS framework?

As the title suggest.

Since we’re creating some generic .yml files that will be used between multiple ways, I’m wondering which would be the best way to determine if the current build is a ‘iOS app’ or ‘iOS framework’.

Suggestions?

1 Like

Great question, although this might be a bit out of scope of Bitrise / to make this information automatically available.

If you do control the configurations then you could set an App Env Var which you can then utilize in the configs, something like PROJECT_TYPE=app/fw

If you store your bitrise.yml in your repo, you can still set env vars on bitrise.io and those will be available for your config. E.g. in a Script step you could simply:

if [ "${PROJECT_TYPE}" == "app" ] ; then
  # it's an app project
elif[ "${PROJECT_TYPE}" == "fw" ] ; then
  # it's a framework project
else
  # it's an "unknown" project type -> you most likely forgot to set the type as an app env var on bitrise.io ;)
fi

I hope this helps, if you have any questions just let us know! :slight_smile:

Sure, absolutley out if scope :slight_smile: But when/if you support more features that enable including of .yml files etc, it might be more people asking for things liket this :slight_smile:

Thanks for the answer! But my first attempt would be to try go get it without creating project-specific variables for each project.

Perhaps more in the line of:
grep BuildableName ${BITRISE_PROJECT_PATH}/xcshareddata/xcschemes/${BITRISE_SCHEME}.xcscheme | grep .framework
if [ $? -eq 0 ] ; then
export PROJECT_TYPE=FW
else
export PROJECT_TYPE=APP
fi

Sure, something like this might also work.

Just one note, if you want to expose the PROJECT_TYPE so that it will be accessible for other Steps too, you have to do that with envman - http://devcenter.bitrise.io/tips-and-tricks/expose-environment-variable/

E.g.

envman add --key PROJECT_TYPE --value "APP"

I tried that before for some other variable and couldnt get it to work… Perhaps it doesnt work in between different runs?

In one of our “wrapper”-workflows we do:
export TP_BITRISE_COMMON_YML="${COMMON_YML}" cd "$BITRISE_SOURCE_DIR" env bitrise run "${BITRISE_TRIGGERED_WORKFLOW_TITLE}-private" --config="${TP_BITRISE_COMMON_YML}"

It didnt work with envman add, only with export

Depends on how you run the other tools. If you run it from the same Script (it seems you do) then export is what you’re looking for.

If you want to expose an env var for other/subsequent steps of the same config / bitrise.yml, then you have to use envman.

Ok, yeah. Thanks!

1 Like