iPhone: determine distribution type programmatically for testing - iphone

At runtime in an iPhone app, is there a way to distinguish the distribution type programmatically between ad hoc and app store? Whenever I do an ad hoc distribution I want to target internal test servers for web service end points, then for the app store distribution target the production servers.

You can. Open the file embedded.mobileprovision file in your application bundle (you can do this programatically, of course) and check for <key>ProvisionedDevices</key>. It's only there in the Ad Hoc copy of your app, as long as you did sign the App Store version with an App Store provisioning profile.

I don't think that info is available to your app. But you could do this by using different preprocessor #defines for the different Build configs and then define your constants based on the values of these #defines.

I don't think there is a way to determine the distribution type as they would just be the same binary but supplied a different way. I would make a separate build for your ad hoc and change what you need to point it to your internal test servers.

Related

Manage iOS Enterprise Developer Program

We recently enrolled in the iOS Enterprise Developer Program to be able to use in-house distribution, which significantly simplifies the deployment of the apps inside our company which is fairly big. Before joining we have thoroughly read the program documentation and we were aware that the new account would live completely separated from the standard account we use for the AppStore submissions.
What I'm unsure about is now what would be the best way to organize the two accounts in the developer portals. I'm mostly concerned with the bundle identifier since I'll be dealing with two different bundle ids inside Xcode for each application. All of our apps use iCloud and Push notifications so wildcard is not an option.
How do you organize this inside Xcode? Do you create two different targets or are you able to manage this with a new Project Configuration? What about iCloud entitlements?
EDIT
Just as an update I wanted to make clear that we're looking for the best solution to build an app for both In-House distribution and for AppStore submission.
EDIT2
Given that the enterprise program does not grant you access to iTunesConnect, where test users and product ids can be setup, is there really no way to test InApp purchases?
I'm not entirely clear on what you need, but it sounds like you want to be able to build your app store apps for internal enterprise use. Is that correct?
If you want to be able to build your app with two different bundle IDs you can create a custom build setting, and give it different values for your different configurations.
So for example, you could create your Enterprise configuration:
Then go to your target's build settings and add a user-defined build setting:
Give it a name like BUNDLE_ID, and if you expand the triangle you can give it different values for each configuration:
Next, open your Info.plist file and enter ${BUNDLE_ID} for the bundle id value:
When you compile using the "Enterprise" configuration, which you can do using a custom scheme (or via the command line build process if that's what you use), the appropriate bundle id will be used.
You can also configure the code signing/provisiong profile setting in the same way:
Once you do this, the correct push notification/iCloud entitlements will be used depending on the configuration.
We've been doing this kind of thing for a long time now. Our build server will generate enterprise and app store versions of our apps for each build, using exactly this technique.
When it comes to the provisioning portal, you will need to configure both app IDs separately for push notifications, iCloud, etc.
This does mean that push notifications must be sent separately to the app store and enterprise versions since they will not share the same bundle ID or push notification certificate.
The iCloud storage by default will be totally separate for the two versions. They may be able to access the same iCloud store (if you need this) as long as the entitlements are set up with the same team ID. But this may be a problem if you have two separate developer accounts.

how to create binary which can be installed in all iphones without creating App Store or Ad Hoc?

i want to create an application which will not launch in AppStore but all my clients can install my application in their devices. the problem is that i do not have all my clients devices UDID. how they can insert my application because i can't create Ad Hoc since i do not have all my clients UDID and i do not want to create an App Store binary.
Please tell me this is possible or not.?
Use InHouse distribution, see
https://developer.apple.com/programs/ios/enterprise/
and
http://www.apple.com/iphone/business/apps/in-house/
In short, you'll need an Enterprise account. With it, you can create inhouse-distributions that work the same as ad-hoc (i.e. you can distribute them directly or via Over-the-air), except that you don't need to specify UDIDs.
However, since this is a major security "flaw" you have to make sure that everyone who downloads/gets this app is properly authenticated one way or another.
Important: If your clients are not members or subcompanies of your company, I'd check the legal status of using InHouse distribution for this. I'm not sure myself.
If you can turn your app into a web app, then yes you can do it.
But assuming you are talking about a native iOS app, and you don't want to require clients to jailbreak their phones, then no, Apple have a single distribution channel and that's the App Store.
If your clients are 'internal' clients, ie you want to distribute within your own organisation, then the enterprise program is an option for you;
https://developer.apple.com/programs/ios/enterprise/
If your clients are large, and want to buy in volume and then re-distribute internally, another option may be the custom B2B program;
http://www.apple.com/business/vpp/

Loading binary only onto Iphone for testing

Can you load a binary file onto an iPhone using xcode? We are an OEM that needs to QA test an application from a third party developer that owns the source code. They only provide us with the binary.
If your iPhone is Jailbroken, just create an .app folder, put the binary in, fill in the necessary Info.plist entries and throw it into /Applications.
You could create a dummy project, compile it, then find the generated .app bundle, replace the executable inside, then run the dummy app.
Or just ask the 3rd party dev to create an Ad Hoc distribution. Much better than the 2 methods above.
You can also send the 3rd party Dev the UDIDs from your iPod / iPhone units and they can create a provisioning profile for you so you can install the app on your test devices. No ad-hoc distribution needed.

iPhone Xcode Project Organization Question

I built a simple iPhone application for a customer
This will be distributed via iTunes using Ad Hoc Provisioning profile
I need to build two different executables
1) a test application and an 2) official application
the only differences between the two applications are:
. the Default.png startup screen
. some image icons in the application
. the application icon
how can I organize my xcode project so I can use a single project
for the two applications ?
- do I need to create multiple targets ?
- can I use the same Application name and Provisioning profiles for the two application
or I need different ones ?
- is it simpler to add a shell script at building start and just personalize the application
graphics depending on a SWITCH VARIABLE defined in the project ?
thank you for your help
You can use the same provisioning profile if you set it up as a "wildcard" profile. Do that by setting the application identifier to something along the lines of "com.companyname.*" (the * is the important part).
As for the image switching, you could do that with two targets, and each target having a specific shell script at the beginning of the build process which chooses which image to use.
Hope this helps.
yes, you should create multiple tatgets. That is the easiest way to include different Default.png files.
You sign both versions using a wildcard provisioning profile. Take a look at the Apple provisioning docs.

What's the point of App ID's and Provisioning Profiles?

As I understand it, an App ID is an code that's unique for an single application. Every time I start developing an new application, I have to create a new App ID.
But I don't get it what's up with that "provisioning profile". Do I need one for each single app? What's that for?
It's to protect the end users, by having a way to validate apps and their origin. It also serves as a centralized system to control development. On windows most apps use GUIDs for this, but they don't have any centralized info about them. Apple does, which is a pain at times, but it's a valid effort in the end.
The provisioning profile contains a list of devices that are allowed to run or debug your code. Everything is verified with a digital signature, which ultimately lets Apple control distribution. This is why you need to jailbreak in order to get apps from sources outside the App Store.