How to populate Info.plist values dynamically in Xcode? - iphone

Can't figure out how to populate CFBundleVersion dynamically with ${BUNDLE_VERSION} which I would like to define as
BUNDLE_VERSION=`date "+%y%m%d"`

If you're doing command-line builds with xcodebuild, you can do something like
xcodebuild -target MyApp -configuration AppStore BUNDLE_VERSION=`date "+%y%m%d"`
However, I advise against doing this. An App Store app has three versions:
The iTunes Connect version number (this is the only one normally shown to the user)
CFBundleVersion
CFBundleShortVersionString
I think they're all supposed to be of the form [0-9]+.[0-9]+(.[0-9]+)?. To avoid confusion, I set them all to the same thing for App Store builds (we include CFBundleVersion/CFBundleShortVersionString in bug reports, and it's nice if they match CFBundleVersion). Non-App Store builds can include more info, since they don't need to be submitted.
I don't know if iTunes Connect lets you submit an app with CFBundleVersion that doesn't contain a ".", but I haven't extensively tested this.

You’ll need an Xcode configuration file and a configuration variable that you set at build time. This is described in some detail at Diego Massanti’s blog. You’ll need to modify the build phase he describes to set the variable to the current date instead of incrementing the existing value.

Related

How to include a CocoaPods framework only for certain schemes?

My app has three schemes, for each of my distribution channel:
Savings: App Store
Savings Setapp: Setapp
Savings Direct: Developer ID signed distribution
Of these three, I want to include the Sparkle framework (for updating app) only for Savings Direct.
My Podfile looks like this:
As you can see, "Sparkle" is added to the target GreenBooks. I only have a single target:
What I want to do is for schemes other than "Savings Direct", exclude the Sparkle framework; that is, don't include in the app at all.
How do I do that?
Found the answer. Just need to specify build configuration (configuration) when inputting the Pod entry:
https://guides.cocoapods.org/syntax/podfile.html#pod

How to publish 2 apps using 1 source code to Play store and App store?

I need to publish 2 clients to 1 source code. How do I do it?
I read this article.
How do I build different versions of my Flutter app for qa/dev/prod?
However I could not find the answer from this article.
Is it possible to publish 2 application in same source code and same Key file and same version code and same version name(com.eclipse.side)?
In order publish the same source code into 2 different applications, for example if you have a paid version and a free version of your application you need to use flutter flavors
Basically, it will create 2 different applications that can be uploaded to the stores with the same code, with slight changes in the application Id for example
So, Is it possible to publish 2 application in same source code
Yes. It is irrelevant how you create your app.
and same Key file
Yes, however it's not really recommended
and same version code
Yes, version code is just a version number of your specific app only.
and same version name(com.eclipse.side)
Yes, versionName string used as the version number shown to users. Not sure you meant that one really as noone puts package id there though.
So the only thing that matters globally is application id from your manifest and it must be unique across whole play store submitted apps.
EDIT
my question is, can to publish 2 application with same package name?**
Again, there's no such thing as package name. It's application id that matters only. All the other things are just labels. If you want to release two apps both can show "My App" label. But one mush have different application Id than other (i.e. com.company.app1 and com.company.app2). That's it - so ensure your flavours set different application id and you should be good.

Choosing the correct bundle ID in iTunes Connect.

I am preparing to submit an app to the App Store and have come across the following form. In the past when I have done this incorrectly it caused me a lot of grief which I would like to avoid this time around.
It is giving me a few options to choose from, but I'm not sure which one is correct. I would assume there is a way to check my Xcode project to be sure that the bundle IDs match. More specifically I would think that the form below would correspond to my bundle id name
where if my app is called AWESOMEAPP the correct bundle to choose should read EricBrotto.AWESOMEAPP or EricBrotto - *. In fact I don't have either as an option. What I do have is ericbrotto - *. That said could I just choose this one and change my Bundle identifier to ericbrotto.${PRODUCT_NAME:rfc1034identifier}?
Any clarification would be great!
I would get rid of the dollar signs, and enter explicitly com.ericbrotto.myawesomeapp into all of the provisioning portal, iTunes Connect and the Xcode Target Build settings. Or use a wildcard just for the provisioning profile.

How to share keychain data between iOS applications

I am describing a problem for which it took me quite some time to learn the answer.
The "GenericKeychain" example is a good start at providing a wrapper for sharing keychain data between applications when using the accessGroup in the init.
However, implementing this in my app yielded an obscure error code (which took forever to locate) -25243, which means: No access control.
I ran Apple's example app (GenericKeychain) on my iPad only to get the same error. Huh?
Does Apple's documentation fail to deliver on what is necessary to accomplish this?
After some (a lot of) digging throughout the web, I found the answer. The access Group that you use when constructing your KeychainItemWrapper class must ALSO be specified in each of your application's Entitlements.plist file in the "keychain-access-groups" section.
It seems almost obvious now that I see "keychain-access-groups". However, I had no idea to even look there. Hope this helps others.
Actually it's not hard to do. Please follow the steps.
App1:
Open your App's target Capabilities and enable KeyChain Sharing.
Add a identifier. (eg : com.example.sharedaccess)
Add "UICKeyChainStore" to your project.
Be sure you have a team id added to your App1 project.
Add Security.framework to your App1 project.
And add these codes to somewhere you need.
[UICKeyChainStore setString:#"someValue" forKey:#"someKey" service:#"someService"];
App2:
Open your App's target Capabilities and enable KeyChain Sharing.
Add a identifier. (eg : com.example.sharedaccess)
Add "UICKeyChainStore" to your project.
Be sure you have a team id added to your App2 project.
Add Security.framework to your App2 project.
And add these codes to somewhere you need.
NSString *string = [UICKeyChainStore stringForKey:#"someKey" service:#"someService"];
Your TeamIDs should be same for both projects.
I tried these steps on a real iPhone device.
I also tried these steps with Automatic and iOs Development provisioning profile.
My apps' bundle identifiers were like that : com.example.app1, com.example.app2.

How can I configure my iPhone project to use a seperate application icon for beta releases

What I am trying to achieve is for the application icon to be different in builds that I send out to my beta testers, to that of the application that will be submitted for approval. This will allow me and my beta testers to easily identify the app is a beta version.
I was not sure if I should be adding a build script to modify the info.plist and change the application icon specified there. For this I guess I would have to conditional check the build type (DEBUG/RELEASE/DISTRIBUTION etc) and write the appropriate value to the plist file.
Alternatively I thought I might need to create a separate target for beta releases and specify the new BETA application icon there.
If anyone has done this kind of procedure before, any tips and ideas about how best to do it would be very much appreciated.
Outdated: As of September 2017, my answer is probably outdated now. Please use latest Apple developer guides relating to Asset Catalogs. Asset Catalogs are the new way of specifying image/icon resources for your app.
Original answer:
Both ways you have mentioned can be used for this purpose (Through a separate Target or using Build settings). In my opinion, the more logical way would be to use a different build configuration and set the plist file to dynamically get the icon file name from the build configuration.
Here is how I would do it:
In project build settings, create a new user-defined variable called ICON_FILE (for "All Configurations")
Set the value of the variable to "Icon.png" (for "All Configurations")
Create a new build Configuration called "Beta".
Set the value of the ICON_FILE variable to "Icon-beta.png" for "Beta" configuration.
(this will make all the configurations have the value "Icon.png" except Beta config)
In the Info.plist set the value of "Icon file" attribute to ${ICON_FILE}. This will make the info.plist dynamically get the filename from the variable you defined earlier.
In your application resources, include the beta icon with the name "Icon-beta.png" in addition to "Icon.png" you already have.
If you build the app using "Beta" config, the app will have the beta icon as the app icon.
Hope this helps!
Asset catalogs can be used without creating another target.
Here are the steps I use:
1 - Create two (or more) app icon set in images.xcassets
2 - Create another configuration from project settings
3 - Go to Target -> Build Settings and search for app icon.
You will see Asset Catalog App Icon Set Name under Asset Catalog Compiler - Options. Change the asset catalog name that will be used in new configuration.
4 - Build for different configurations.
The accepted answer is not working for xcassets.
So, if you already started to use xcassets catalog here is the steps:
You need to create 2 different targets of your application.
To do this:
Right click on your target. -> Click Duplicate (or Cmd+D)
Set name of new target like MyApp-beta
Create separate icon:
Go to your xcasset catalog.
Right click on column with list of images -> click New App Icon
Name it like icon-beta, add place here your beta icons
Click on your beta-target
Go to tab General -> App Icons -> select your asset icon-beta
Here it is. Now you can build your beta application!
Another advantage of this method over that described in the accepted answer - is that you can install both versions at the same time of your Application. (you need to set different Bundle Identifier for this).