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

How to manage dynamic NSString variable? #408

Closed
ersentekin opened this issue Jul 13, 2015 · 6 comments
Closed

How to manage dynamic NSString variable? #408

ersentekin opened this issue Jul 13, 2015 · 6 comments

Comments

@ersentekin
Copy link

Hey all faslaners,
How to manage dynamic NSString variable for different types of deliveries like Development, Stage & Production environments?

Is there any kind of lane action to use?

Thanks so much!

@KrauseFx
Copy link
Member

You can pass preprocessor macros when building, not sure how the majority of fastlane users solve this issue.

@milch
Copy link
Collaborator

milch commented Jul 13, 2015

You can pass additional arguments to be used as preprocessor macro when building your ipa like this:

server_url = '@\"http://beta.example.org\"'
ipa (
# ...
xcargs: "GCC_PREPROCESSOR_DEFINITIONS='$(inherited) X_SERVER_URL=#{url}'"
)

(it's important to have that $(inherited) in there so flags that are set by Xcode are set correctly)

And then in your code:

#ifdef X_SERVER_URL
    kServerBaseUrl = [NSURL URLWithString:X_SERVER_URL];
#else
    // Handle the case where no server URL is passed in from the build, e.g. on a developer machine
    // ... 
#endif

Of course, you can use as many preprocessor macros as you want.

@ersentekin
Copy link
Author

@KrauseFx & @milch
Thanks so much, macros probably the best choice 👍

@KrauseFx
Copy link
Member

Thanks again @milch for providing the solution 👍

@mortenholmgaard
Copy link

Use this in swift:
xcargs: "OTHER_SWIFT_FLAGS='$(inherited) -DVARNAME=1'"

@ersentekin
Copy link
Author

@mortenholmgaard thanks for Swift support ! 🐤

@fastlane fastlane locked and limited conversation to collaborators Sep 22, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants