preface

Learning is like rowing upstream; not to advance is to drop back. Mutual encouragement!!

Recently, I have studied the automatic compilation of iOS. The purpose is to simplify The Times of communication and coordination among students of testing and development, so that students can compile the latest source code of SVN from web page operation at any time and package ipA for testing. The specific idea is to read the configuration list of the project to be compiled from the configuration file and display it on the web page, test students to select the project to be compiled, and then pass the parameters of the selected project into the shell script to run. After compiling, the page will automatically jump to the download page. The original | address

The main processes include:

  1. Shell script writing. Automatic compilation and packaging via XcodeBuild and XCRun.
  2. PHP invokes the script. Start the Apache server of OS X and write PHP to call the shell.

Writing shell scripts

Automatic compilation is basically using xcodeBuild commands for compilation and xcRun to package the APP into ipA. The official documentation for XcodeBuild can be found here.

Key commands used

  • Compile the workspace
xcodebuild -workspace workspacename -scheme schemename -configuration [-configuration configurationname] clean build SYMROOT=(SYMROOT)
Copy the code
  • Compile the project
xcodebuild -target targetname -configuration [-configuration configurationname] clean build SYMROOT=(SYMROOT)
Copy the code
  • Viewing Configuration Information
xcodebuild -list
Copy the code
  • Xcrun packaging of ipa
xcrun -sdk iphoneos PackageApplication -v projectName.app -o ipaName.ipa
Copy the code

The full shell script, a bit longer, is at the end of the article, adapted from the BashShell.

Note that it is best to use absolute paths in scripts.

Configure Apache and PHP

Start the Apache

Start: sudo apachectl start

Stop: sudo apachectl stop

Restart: sudo apachectl restart

File root Directory Indicates the root directory of the system

http://localhosts/

The corresponding file directory is:

/Library/WebServer/Documents/

The directory list is not enabled for the system-level root directory by default. To enable the directory list, run the /etc/apache2/httpd.conf file

Search to find < Directory “/ Library/WebServer/Documents” > the Options Multiviews is modified to the Options Indexes Multiviews

User-level root directory

The other Web root directory defaults to ~/Sites, which you will need to create manually in 10.9.

Check whether username. Conf file /etc/apache2/users/ exists in the directory

If not, you need to create a new file, username should be your account name, it is recommended to create this file using terminal:

cd /etc/apache2/users

sudo vi username.conf

Change username to your account name

<Directory "/Users/username/Sites/"> 
Options Indexes MultiViews FollowSymLinksAllowOverride AllOrder allow,denyAllow from allRequire all granted </Directory>
Copy the code

The permissions for this file should be:

-rw-r--r-- 1 root wheel 298 Jun 28 16:47 
username.conf
Copy the code

If not, modify it

sudo chmod 644 username.conf\

Edit the /etc/apache2/httpd.conf file and remove the following comments: #

Include /private/etc/apache2/extra/httpd-userdir.conf LoadModule authz_core_module libexec/apache2/mod_authz_core.soLoadModule authz_host_module libexec/apache2/mod_authz_host.soLoadModule userdir_module  libexec/apache2/mod_userdir.soCopy the code

Edit the /etc/apache2/extra/httpd-userdir.conf file to remove the following comment symbols: #

Include/private/etc/apache2 / users / *. Conf restart Apache sudo apachectl restart at this time, the site should have can be used: http://localhost/~username/

PHP invokes the shell script

The PHP system command is used: System ($CMD) PHP has low permission to call shell, so the shell will need permission to create files and folders. The solution is to upgrade the permissions of the PHP file directory and all files under the directory through the command line, otherwise the script will report permission errors. The specific steps are as follows:

  1. Open the directory /private/etc/apache2

  2. Open the file httpd.conf to find

    User _www 
    Group _www
    Copy the code

Change _ WWW to your login username

User < login User name >Copy the code
  1. Restart Apache from the command line
sudo apachectl restart
Copy the code
  1. Example Upgrade the directory permission of the website. Since my site root directory is the user Sites file mentioned above, execute the following command
sudo chmod 775 ~/Sites
sudo chmod 775 ~/Sites/*
Copy the code

All right, we’ve got the clearance problem solved. Confident when seen from the web site, call the script output information reported results and unable to find a certificate error, OMG, but call the script from the terminal can be successful, initially thought permissions not enough lead to can not call, full circle and found that the problem is just because the key string of certificate of general installation under the login, only need to move to the system.

I won’t write the part about getting the source code from the SVN repository. Now that you can call the script, this part is easy. This process is still a bit of a struggle, I hope this article can save your time 😃

The iOS data | address

Recommended reading: Preliminary to Swift Concurrency

Recommended reading: Some recent experiences as an architect developing apps