Creating an iOS Base Project

Joel Márquez
9 min readJan 3, 2017

--

The idea of this project is to serve as a template when starting a new project. It will contain 3 build configurations: Debug, AdHoc and Release. We’ll integrate CocoaPods using Fabric for distributing the app, and then we’ll use FBTweaks, and awesome library from facebook.

We’ll start by creating an App ID. In Member Center

Go to Certificates, Identifiers & Profiles:

And then to Identifiers inside iOS Apps section:

Then click on the Plus (+) sign on the right of the screen,

And enter an App ID Description. Use a properly description for your App ID. You can change it later though. Then, enter an App ID Suffix:

This one would be permanent, so think it well, because you can’t change it later.

Then, once all the capabilities have been selected, click on Submit.

Now we’ll create three provisioning profiles: one for Development, another for AdHoc distribution of our app (like distributing the app internally with the QA team and to our client for weekly builds), and the last one for Release.

Go to the Provisioning Profiles section, and then click on the Plus (+) sign.

Then, select iOS App Development option and click Continue.

Then, select the previously created App ID and click Continue.

Then, select the certificates you want to include in the Provisioning Profile and click Continue.

Then, select the devices you want to include in the Provisioning Profile and click Continue.

Finally, pick a name for the Provisioning Profile and click Generate.

We are going to do the same for the AdHoc and the Release provisioning profiles.

Click again on the Plus (+) sign.

Now select the Ad Hoc option and click Continue.

Again, select the previously created App ID and click Continue.

Now select a valid Distribution certificate and click Continue.

Then, select the devices you want to include in the Provisioning Profile and click Continue.

Finally, pick a name for the Provisioning Profile and click Generate.

The last Provisioning Profile that we are going to create will be the Release Provisioning Profile.

You’ll notice that for this profile we didn’t have to choose the devices we want to include. That’s because this profile is used to sign the App and release it to the AppStore, so in that way it can be installed in every single iOS Device.

Once all the Provisioning Profiles had been generated, we’ll go to the iTunes Connect home page and login.

Then, access to My Apps section and click on the Plus (+) sign and select the New App option.

Fill the App details, selecting the Bundle ID with the App ID previously created. The SKU is a product identifier of your organization, it can be anything. Then click Create.

Then, open the XCode and click on Create a new XCode project.

And select the template of your choice and click Next.

Then fill your company details and click Next and in the next screen select the project destination and click Create.

Then we will close the XCode and open a terminal and enter pod install. Previously, create a Podfile and include the dependencies you want for the project. I've installed Tweaks, among others, which we'll include it later in our project.

At this moment, our project should look similar to this.

Then we will have to go to XCode -> Preferences and enter the Accounts Section. Then click on View Details… and

Click on Download All. This will download all of our certificates. We will need them to configure our build settings.

Go to the project settings

And click the Plus (+) sign in the Configurations section, and select Duplicate “Release” Configuration, and name it AdHoc or the one of your choice. That will be the configuration we will use to distribute internally our app.

Then, select the Target settings, and check that the Code Signing section looks like the picture from above, we will change that

For this ones. Check that in the the Debug Provisioning Profile has the Automatic option selected, whereas the AdHoc and the Release Provisioning Profiles have a the ones created before. This is because if we select Automatic for both ones, XCode will use the last one generated, and we don’t want that. Also check that in the Code Signing Identity section we are using the same Distribution Certificate for both AdHoc and Release, and in Debug we are not code signing the app.

Then, in the Preprocessing section, we will add a RELEASE=1 macro in the Release configuration, and the same for the AdHoc configuration. With this macros, we can distinguish then if we have to create the Tweaks window or not.

Then, in the App Delegate, we will import this

#import "FBTweakShakeWindow.h"

and in the - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions method, and add the following code:

CGRect screenBounds = [[UIScreen mainScreen] bounds]; #ifndef RELEASE self.window = [[FBTweakShakeWindow alloc] initWithFrame:screenBounds]; #else self.window = [[UIWindow alloc] initWithFrame:screenBounds]; #endif self.window.backgroundColor = [UIColor whiteColor]; UIViewController *rootVC = [UIViewController new]; rootVC.view.backgroundColor = [UIColor redColor]; UINavigationController *navVC = [[UINavigationController alloc] initWithRootViewController:rootVC]; self.window.rootViewController = navVC; [self.window makeKeyAndVisible]; [Fabric with:@[[Crashlytics class]]]; return YES;

This code will check if we are not in the RELEASE build, and if that’s the case, will create an FBTweakShakeWindow, for debugging purposes, being able to add tweaks to our project, like changing the API URL, or another useful stuff.

Now we’ll add Fabric for distributing internally our app or to our clients. First of all download it from here, and create an account or login into yours. Then, open it and click on + New App.

Then, select your project and click Next.

Then, select your organization and click Next.

Then, select a Kit to install and click Next. In this case we will install Crashlytics.

Agree to this

Select Install via CocoaPods and follow the instructions:

Then, go back to the XCode and click on Edit Scheme, and in the Archive section, change the Build Configuration and select AdHoc. We will have to change back to Release if we want to make a release build.

Then, click on Product -> Archive and wait until the archive it’s done (hopefully, if the XCode doesn’t complains with the Provisioning Profiles).

Fabric will popup a notification asking us if we want to distribute the recently generated archive. Click on Distribute and then

Enter the emails of the testers you want to test the app. Enter the release notes and click Next and wait until the archive is uploaded.

We will receive a Fabric invitation to test our app. Click on Let Me In and accept the message (you’ll have to open in Safari browser).

Finally, click on Install and accept the popup

And that’s all. You’ve learned how to create an iOS App from scratch, create the required Provisioning Profiles to develop and distribute your app, and then how to distribute via Fabric.

Hope you enjoyed this tutorial, and good bye!

Originally published at gist.github.com.

--

--

Joel Márquez

📱Software Manager @mercadolibre.arg 🏉 Co-Founder of @todorugby.app 📍Haedo, Bs.As., Argentina