Editor’s note: Thanks to @Amiamoy for contributing this article. If you also want to experience flow. Ci for iOS automation continuous integration, apply for internal testing in the flow. Ci Gitter group 🙂

First, I submitted one of my projects to Flow. ci, which implemented the basic iOS continuous integration function and made our programmer’s world a little bit better. This article is a long one, so if you don’t have time to read it, you can go directly to # Detailed Flow #, or you can go directly to flow.ci.

1. Why iOS Continuous Integration

Continuous integration is one of the important practice of agile development, imagine a scenario, you are considering how to write a regular expression to extract information from inside it, just as you wrote half, testers suddenly came to face you after you said: “on the backend interface, you make a line to the iPhone 7 let me a package”. Your half-thought suddenly disappears, and you have to interrupt your current work, switch git branches, and recompile the last version for testing. If the storyboard layout changes at this point… Then you’ll have to make eye contact with the testers until Xcode installs your application. However, if you use continuous integration in your project, you can gain the following advantages:

  • Iteration speeds up, and even runnable code is delivered with each commit, allowing testers to get into the testing phase sooner.
  • Less low-tech time is spent compiling, distributing, and more time is saved by increasing the success rate of packaging.
  • Test scripts can be plugged in to catch low-level errors, such as interface problems, compilation problems, and so on, before they are delivered to testers.

2.1 Why flow.ci

This is mainly because building your own server is very time consuming!

First of all, iOS projects need to compile on MacOS, and the closed-source nature of iOS greatly limits our choice of servers. At the same time, each team’s home-built server may differ to some degree. When an error occurs, your experience determines whether you can accurately locate the error. Is it a server problem? Pod problem? Certificate problem? Code problem?

Flow. ci configuration is very simple, and so far my experience with flow.ci has been mostly good. As for pricing, flow.ci is completely free during the private beta period as it is still in private beta.

2.2 Why did it start recently

Yeah, I know you hear Jenkins the most, Travis CI the second.

Jenkins needs you to have a CI server, and unless you want to contribute your Mac Pro, apply for a Mac Mini as a CI server. Jenkins+ Gitlab + FIR. im is already a mature continuous integration solution, and there are a lot of tutorials on the Internet, but the problem is that there are a lot of details to deal with, which I feel very troublesome, and some problems are not so easy to find solutions.

Travis CI currently only provides continuous integration services for projects on Github, and few commercial projects are considered directly on Github.

Since the iOS integration of Flow. ci began in private beta around November 4th, this feature has only recently been available. It is said that it is mainly because it is difficult to find a large number of Mac servers, which directly leads me to pay attention to flow.ci from the beginning of the emergence until now… It’s been a long time. And this function is the internal test in the internal test, now (November 17) need to apply to the official internal test, waiting for the official to provide the internal test qualification.

The newly launched function directly leads to incomplete documentation. If something goes wrong, there is no ready documentation to refer to. Fortunately, the official team provided a discussion group. Anyway, AFTER I obtained the internal test qualification, I conducted the experiment immediately, and immediately ran into a problem. After Google failed, I turned to the discussion group for help, and the official staff replied to my question the next day, which was perfectly solved.

3. Detailed process

3.1 Preparation

  1. Obtain mobileprovision files and P12. Yes, you need to issue certificates and signature files when you package the iOS internal beta version. For details, see here.

  2. Organize engineering projects and submit them to the corresponding code repository.

  3. Register the official address of flow. Ci account, and then apply for internal test qualification to the official, the address is in the Flow. Ci discussion group.

3.2 Creating a workflow

First open the Flow. ci action panel and click Create Project. You can start selecting code repositories. Currently, flow.ci has four repository types to choose from

GitHub(the world’s largest gay dating website) Gitlab(most companies will use Gitlab to build their own Git repository) Bitbucket(similar to China code cloud service, support private repository) Coding(Domestic code hosting service, support public and private repository, interface is very good, I think it is very fast)

3.3 license

Github and Coding ask you to provide authorization (Auth) in the event of an account login, or ask you to provide an RSA Key and repository address otherwise. If you don’t know, open a terminal and type CD ~/.ssh to feed the contents of the RSA file that you want to integrate with the platform to flow.ci.

3.4 Configuring workflow Content

After selecting the repository you want to integrate continuously, click Create first workflow to start the setup.

Go to the bottom and select the iOS template

Feel the Xcode version corresponding to your project Settings, then submit project matching certificates MobildProvision and P12 files. If you can’t find it, you can check it out here.

Set the build parameters below, which correspond directly to XcodeBuild if you have experience with automatic building with Xcode. You can use the xcodebuild-list command at the terminal in the project root directory to view the information to help you determine the following five input parameters.

FLOW_IOS_COMPILE_WORKSPACE If you integrate CocoaPods, this should be your project name. Xcworkspace! Note that if this is not empty then FLOW_IOS_COMPILE_PROJECT should be set to either.

FLOW_IOS_COMPILE_PROJECT If you are a small project and don’t have CocoaPods integrated, use.xcodeProj! Note that if this is not empty then FLOW_IOS_COMPILE_WORKSPACE should be set to empty or one of the two.

FLOW_IOS_COMPILE_SCHEME type under Targets. If there are more than one you need to specify the target you want to package

FLOW_IOS_COMPILE_SDK Use the default value

FLOW_IOS_COMPILE_CONFIGURATION Debug

Done! A simple workflow is added to your project. We continue to add other Settings.

3.5 Customize workflows based on requirements

  1. Triggers provide hooks that trigger packaging based on events, including Push, Pull, and Tag operations. You can also set up several scheduled tasks, such as packaging once a day after work.

  2. Initialization provides some of the information displayed at initialization, as well as some of the compile-time variables assigned, and a template for custom output is provided below.

  3. Git repository clone is the Git clone operation of the server

  4. Caching is a pod install dependency. If you choose to enable caching, flow.ci will only use the pod file that was packaged the first time after adding the dependency (pod install).

  5. The installation

  6. Compilation is a compilation of some variables, most of the errors are set here, in the automatic packaging will have the corresponding message.

  7. When you’re done, there are Email and Slack alerts, and you can choose to send an Email to a specific Email address in the event of success or failure.

3.6 Distribute to FIR.im

Fir. Im allows developers to test app launches at a rapid speed, and testers can scan the generated QR code to install the beta app. There is a + in the upper left corner of the workflow after completion. Click and select the fir. Im upload plugin. The other two parameters can be left blank.

3.7 Little details

  1. After scanning the QR code on FIR. im, the app was installed, but the phone reported that the app could not be installed — it may be that the phone was not added to the test list in MobileProvision.

  2. Code signing is required for product type ‘Application’ in SDK ‘iOS 10.1’ Select the MobileProvision certificate name manually in signing.

  3. You cannot specify both an Xcode project and a workspace. Compile the variables FLOW_IOS_COMPILE_WORKSPACE and FLOW_IOS_COMPILE_PROJECT.

  4. The workspace named “XXX” does not contain a scheme named “XXX”. Check that you have selected the right Scheme. If you are sure you have written correctly, then check whether Shared is enabled in Manage Scheme.

4. Next step

Integration unit testing and UI testing, to be continued

5. Related resources

Flow. The ci group discussion

Fir. Im application distribution

Official website of flow.ci

Welcome to send me email exchange: [email protected]

The above is the “Flow. Ci Best Practices” series of @Amiamoy usage share, I hope it is useful to you.

flow.ci