# How to setup CI to add generated code to project

**URL:** <https://discuss.bitrise.io/t/how-to-setup-ci-to-add-generated-code-to-project/4672>\
**Category:** Question & Answer\
**Tags:** ios\
**Created:** [March 30, 2018, 8:53pm UTC](https://discuss.bitrise.io/t/how-to-setup-ci-to-add-generated-code-to-project/4672 "2018-03-30T20:53:28Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![bbpiepho](https://sea2.discourse-cdn.com/flex016/user_avatar/discuss.bitrise.io/bbpiepho/32/1377_2.png) [@bbpiepho](https://discuss.bitrise.io/u/bbpiepho)\
**Post date:** [March 30, 2018, 8:53pm UTC](https://discuss.bitrise.io/t/how-to-setup-ci-to-add-generated-code-to-project/4672/1 "2018-03-30T20:53:28Z")

</div>

Hello! I’m trying to get my app to build on CI without having to commit my “AppSecrets.swift” file similar to this thread:

> [@How to add a file that is needed to compile a project, but which is in the gitingore?](http://discuss.bitrise.io/t/how-to-add-a-file-that-is-needed-to-compile-a-project-but-which-is-in-the-gitingore/1611):
>
> Hello! Firstly, I’m sorry for my English. Problem: I have an Android project on GitHub. This project uses Crashlytics library from Fabric. Project contains file named fabric.properties, that contains API-keys, and Fabric recommends to add this file to .gitignore. And without this file project can not be compiled. How to add this file to bitrise or API-keys in project so that was not visible in GitHub? Regards.

I’m using Bitrise “Secrets” to store credentials and app keys then using Sourcery for code gen and build phase run scripts to generate AppSecrets.swift. I got the idea from this thread:

> [@Secret Environment Variables not used in Xcode Archive & Export](http://discuss.bitrise.io/t/secret-environment-variables-not-used-in-xcode-archive-export/3994):
>
> I’m successfully building and running tests for our iOS app that uses environment variables to set things like API secrets/keys. Some of these tests access these secrets, so it seems like at test time, they exist. However when added the “Deploy to iTunes” step, the app is flagged as crashing. In our crash logs, I can see that our [asserts](https://github.com/rnystrom/GitHawk/blob/master/Classes/Systems/Secrets.swift) are firing b/c environment variables are missing. I’m not at all sure why the environment variables appear to be used during testing, but are not included dur…

The problem is that I can’t figure out how to automate adding the generated file to the project!

 ![19%20PM](https://us1.discourse-cdn.com/flex016/uploads/bitrise/original/2X/9/942b617aba65af88fa5cc3bab04df23f8388bbd9.png)

Any help would be appreciated! Thank you!

---

<div class="post-metadata">

**Author:** ![viktorbenei](https://sea2.discourse-cdn.com/flex016/user_avatar/discuss.bitrise.io/viktorbenei/32/18_2.png) [@viktorbenei](https://discuss.bitrise.io/u/viktorbenei)\
**Post date:** [April 3, 2018, 3:57pm UTC](https://discuss.bitrise.io/t/how-to-setup-ci-to-add-generated-code-to-project/4672/2 "2018-04-03T15:57:05Z")

</div>

> [@bbpiepho](#):
>
> The problem is that I can’t figure out how to automate adding the generated file to the project!

How do you do it on your own Mac @bbpiepho? Do you add it manually every time after the file is generated?

---

<div class="post-metadata">

**Author:** ![bbpiepho](https://sea2.discourse-cdn.com/flex016/user_avatar/discuss.bitrise.io/bbpiepho/32/1377_2.png) [@bbpiepho](https://discuss.bitrise.io/u/bbpiepho)\
**Post date:** [April 5, 2018, 3:51am UTC](https://discuss.bitrise.io/t/how-to-setup-ci-to-add-generated-code-to-project/4672/3 "2018-04-05T03:51:53Z")

</div>

Hi Viktor,

I figured it out, I just needed to change the order of my build phase scripts. Specifically, moving the code gen script to run before the source code was compiled.

---

<div class="post-metadata">

**Author:** ![viktorbenei](https://sea2.discourse-cdn.com/flex016/user_avatar/discuss.bitrise.io/viktorbenei/32/18_2.png) [@viktorbenei](https://discuss.bitrise.io/u/viktorbenei)\
**Post date:** [April 5, 2018, 4:06pm UTC](https://discuss.bitrise.io/t/how-to-setup-ci-to-add-generated-code-to-project/4672/4 "2018-04-05T16:06:08Z")

</div>

Glad to hear you managed to solve it @bbpiepho, and thanks for reporting! 😉

If you’d have any questions just let us know, any time!  
Happy Building! 🙂

---

<div class="post-metadata">

**Author:** ![viktorbenei](https://sea2.discourse-cdn.com/flex016/user_avatar/discuss.bitrise.io/viktorbenei/32/18_2.png) [@viktorbenei](https://discuss.bitrise.io/u/viktorbenei)\
**Post date:** [April 19, 2018, 4:00pm UTC](https://discuss.bitrise.io/t/how-to-setup-ci-to-add-generated-code-to-project/4672/5 "2018-04-19T16:00:21Z")

</div>

This topic was automatically closed after 13 days. New replies are no longer allowed.
