IOS模块化 开发实践

直接入正题:

Screen Shot 2015-09-18 at 16.56.20.png

Mac上安装Jekins

jekins下载地址:http://jenkins-ci.org/ ,选择Mac 直接安装。安装成功后。访问http://localhost 是否可正常访问.

安装Jekins相关插件

证书管理插件
1.https://wiki.jenkins-ci.org/display/JENKINS/Keychains+and+Provisioning+Profiles+Plugin#KeychainsandProvisioningProfilesPlugin-Uploadkeychainandprovisioningprofilefilessection

xcode插件
2.https://wiki.jenkins-ci.org/display/JENKINS/XCode+Plugin#XcodePlugin-Installationguide

脚本执行插件
3.https://wiki.jenkins-ci.org/display/JENKINS/PostBuildScript+Plugin

git插件
4.https://wiki.jenkins-ci.org/display/JENKINS/Git+Plugin

IOS证书管理和修正

1.点击 Manage Jenkins-> [Keychains and Provisioning Profiles Management] 进入如下页面

Screen Shot 2015-09-18 at 15.49.30.png

2.点击choose File 并上传 当前登录用户的~/Library/Keychain/login.keychain文件.
上传成功后会出现:

Screen Shot 2015-09-18 at 15.55.05.png

点击Add Code Signing Identity添加对应的签名

3.上传Provisioning Profiles文件,xcode的profile存放在~/Library/MobileDevice/Provisioning Profiles/中,找到你要的profile,上传

Screen Shot 2015-09-18 at 16.04.46.png
这步很重要,如果证书出错请查看:http://www.cnblogs.com/qingjoin/p/3929493.html

新建项目

1.New Item -> 选择FreeStyle project
2.关联GIt

Screen Shot 2015-09-18 at 16.27.12.png

3.Xcode的相关配置

Screen Shot 2015-09-18 at 16.29.41.png
Screen Shot 2015-09-18 at 16.29.55.png
Screen Shot 2015-09-18 at 16.30.02.png

4.ipa上传到蒲公英和发送邮件

Screen Shot 2015-09-18 at 16.30.40.png

5.相关的python文件的地址为:
https://github.com/caiwenshu/CI_pgy/blob/master/pgy_upload_temp.py

该代码引用来自:http://www.cocoachina.com/ios/20150428/11698.html

最新补充 (2020/02/19)

因为jenkins里面xcode配置麻烦,现在已经把ios的打包移植到fastlane里面了。


source ~/.bash_profile
export LC_ALL=en_US.UTF-8
export LANG=en_US.UTF-8

echo $WORKSPACE
export output_dir=/Users/Shared/Jenkins/${BUILD_TAG}
export output_ipa_name=${BUILD_TAG}.ipa

echo $output_dir
echo $output_ipa_name

rm -rf release

ruby -v

bundle install


pwd

security unlock-keychain -p shenmajr /Users/macpro/Library/Keychains/login.keychain-db

fastlane release output_dir:$output_dir output_ipa_name:$output_ipa_name

对应的fastlane代码

# This file contains the fastlane.tools configuration
# You can find the documentation at https://docs.fastlane.tools
#
# For a list of all available actions, check out
#
#     https://docs.fastlane.tools/actions
#
# For a list of all available plugins, check out
#
#     https://docs.fastlane.tools/plugins/available-plugins
#

# Uncomment the line if you want fastlane to automatically update itself
# update_fastlane

default_platform(:ios)

platform :ios do 
  desc "Description of what the lane does"
  lane :release do |options|
    cocoapods
    gym(scheme: "ShenmaEV_iOS_SaaS",
    workspace:"ShenmaEV_iOS_SaaS.xcworkspace",
    configuration:"Release",
    clean: true,
    export_method:"enterprise",
    output_directory:options[:output_dir],
    buildlog_path:options[:output_dir],
    output_name:options[:output_ipa_name])
    # add actions here: https://docs.fastlane.tools/actions

  end


  lane :debug do |options|
    cocoapods
    gym(scheme: "ShenmaEV_iOS_SaaS",
    workspace:"ShenmaEV_iOS_SaaS.xcworkspace",
    configuration:"Debug",
    clean: true,
    export_method:"development",
    output_directory:options[:output_dir],
    buildlog_path:options[:output_dir],
    output_name:options[:output_ipa_name])
    # add actions here: https://docs.fastlane.tools/actions
  end
end

你可能感兴趣的:(IOS模块化 开发实践)