Giter Club home page Giter Club logo

autopacking-ios's Introduction

一、背景

在实际多业务迭代开发中,持续打包是必须的工作,自动化实现是必须实现的功能,编辑脚本实现自动化打包上传指定位置。

1.1、知识储备

需要了解打包命令 xcodebuild 的基本知识

二、预览效果图

2.1 执行脚本 和 选项配置

2.2 开始构建

2.3 构建成功并开始导出ipa 并上传到指定位置

二、脚本环境

基于 Xcode 10+ 设计,注意Xcode 8和9有所区别,请参考作者的另一篇:http://www.jianshu.com/p/ba179c731e3f , 如有问题,欢迎指正。

三、功能

  • 支持 xcworkspace 和 xcodeproj 两种类型的工程;
  • 可以自动化清理、编译、构建工程导出ipa;
  • 支持Debug 和 Release;
  • 支持导出app-store, ad-hoc, enterprise, development的包;
  • 支持自动上传到蒲公英或者Fir等内测网站

四、实现

4.1 更新RVM

curl -L get.rvm.io | bash -s stable

4.2 所需知识点

xcodebuild clean 			// 等同于Xcode下点击Product -> Clean
xcodebuild -xcworkspace  	// 等同于xcworkspace工程 command+B
xcodebuild -xcodeproj 		// 等同于xcworkspace工程 command+B
xcodebuild archive 			// 等同于Xcode下点击Product -> Archive
xcodebuild -exportArchive	// 等同于点击 export

五、脚本

配置完项目结构(可以根据自己喜好自由定义)

可以仿照Demo调整

测试体验Demo的话,

需要更换的地方:

    1. 你的Bundle identifier
  • 2.还有Plist里面的相应plist文件
  • 3、上传蒲公英或者Fir的相关APPID和Key,
  • 4.(可选) 如果是多个证书的话,需要指定证书,并打开下面的注释

六、注意事项

注意ExportOptions.plist配置,如下所示:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>compileBitcode</key>
    <false/>
    <key>method</key>
    <string>enterprise</string>
    <key>provisioningProfiles</key>
    <dict>
        <key>com.houmanager.enterprise.test</key>
        <string>com.houmanager.enterprise.test</string>
    </dict>
    <key>signingCertificate</key>
    <string>iPhone Distribution</string>
    <key>signingStyle</key>
    <string>manual</string>
    <key>stripSwiftSymbols</key>
    <true/>
    <key>teamID</key>
    <string>5XXXXXXXXXXXHM</string>
    <key>thinning</key>
    <string><none></string>
</dict>
</plist>

如果不知道怎么填写,手动用Xcode打包,导出文件中会有ExportOptions.plist

直接复制到指定路径或者手动copy即可。


FAQ

1.脚本支持多个target打包吗?

答:支持的,将您的所有target 写在 __SELECT_TARGET_OPTIONS=("1.AutoPackingDemo") 这个集合里面,比如:``__SELECT_TARGET_OPTIONS=("1.Tatget1" "2.Target2" "3.Target3")`, 同时修改下面的if else 判断。还有就是如果您是多个Target 对应多个Info.plist,请自行处理对应关系. so easy~

2. 编译报错,报 Print: Entry, "CFBundleVersion", Does Not Exist 类似错误怎么解决?

答:报这样的错误多半是Info.plist对应的路径不对 或者 Info.plist名称被修改,脚本 __CURRENT_INFO_PLIST_NAME="Info.plist" 处Info.plist 名称和你项目里的相对路径要对。如果是多个Targget对应多个Info.plist,请自行处理对应关系。

autopacking-ios's People

Contributors

hoaye avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

autopacking-ios's Issues

automatically signed problem

=== BUILD TARGET iforvert OF PROJECT iforvert WITH CONFIGURATION Debug ===

Check dependencies
Code Signing Error: iforvert has conflicting provisioning settings. iforvert is automatically signed, but code signing identity iPhone Developer: xuelin li (FH4LU34754) has been manually specified. Set the code signing identity value to "iPhone Developer" in the build settings editor, or switch to manual signing in the project editor.

大神, 能不能帮忙改下脚本, 在automatically signed状态下也能打包,万分感谢, 我对shell实在不熟

BUILD TARGETS OF PROJECT Pods WITH CONFIGURATION Release

=== BUILD TARGET AliyunOSSiOS OF PROJECT Pods WITH CONFIGURATION Release ===
Check dependencies
Code Signing Error: AliyunOSSiOS does not support provisioning profiles. AliyunOSSiOS does not support provisioning profiles, but provisioning profile NO_SIGNING/ has been manually specified. Set the provisioning profile value to "Automatic" in the build settings editor.

How to deal with these problems?

default info.plist file direction is not configurable

已经指定Target的Info.plist文件路径

__CURRENT_INFO_PLIST_NAME="${__SCHEME_NAME}-Info.plist"

获取 Info.plist 路径

__CURRENT_INFO_PLIST_PATH="${__PROJECT_NAME}/Configs/${__CURRENT_INFO_PLIST_NAME}"

the "Configs " path should be configurable, right?

打包成功导出失败

********* 项目构建成功 🚀 🚀 🚀 ***************

********* 开始导出ipa文件 ***************

2017-10-26 15:16:10.638 xcodebuild[8279:41963] [MT] IDEDistribution: -[IDEDistributionLogging _createLoggingBundleAtPath:]: Created bundle at path '/var/folders/q6/trbzk_6d0wj6kbtl_l3qwhnw0000gp/T/Leaf_2017-10-26_15-16-10.637.xcdistributionlogs'.
2017-10-26 15:16:12.550 xcodebuild[8279:41963] [MT] IDEDistribution: Step failed: <IDEDistributionOptionsStep: 0x7fd194bd24c0>: Error Domain=NSCocoaErrorDomain Code=3840 "No value." UserInfo={NSDebugDescription=No value., NSFilePath=/var/folders/q6/trbzk_6d0wj6kbtl_l3qwhnw0000gp/T/ipatool-json-filepath-Ve305u}
error: exportArchive: The data couldn’t be read because it isn’t in the correct format.

Error Domain=NSCocoaErrorDomain Code=3840 "No value." UserInfo={NSDebugDescription=No value., NSFilePath=/var/folders/q6/trbzk_6d0wj6kbtl_l3qwhnw0000gp/T/ipatool-json-filepath-Ve305u}

** EXPORT FAILED **

mv: rename ./build/Leaf.ipa to ./build/Leaf_V2.4.0.1_20171026_151142.ipa: No such file or directory

********* 导出 Leaf_V2.4.0.1_20171026_151142.ipa 包失败 😢 😢 😢 ***************

xcodebuild: error: Unknown build action 'Reading'.

image

********* 您选择了以 xcworkspace-Debug 模式打包 ***************

2018-05-07 15:01:49.292 xcodebuild[45175:4425633] [MT] PluginLoading: Required plug-in compatibility UUID B395D63E-9166-4CD6-9287-6889D507AD6A for plug-in at path '/Library/Application Support/Developer/Shared/Xcode/Plug-ins/ESJsonFormat.xcplugin' not present in DVTPlugInCompatibilityUUIDs
2018-05-07 15:01:49.292 xcodebuild[45175:4425633] [MT] PluginLoading: Required plug-in compatibility UUID B395D63E-9166-4CD6-9287-6889D507AD6A for plug-in at path '
/Library/Application Support/Developer/Shared/Xcode/Plug-ins/Alcatraz.xcplugin' not present in DVTPlugInCompatibilityUUIDs
xcodebuild: error: 'DeepCopyQuestion.xcworkspace' does not exist.
2018-05-07 15:01:49.772 xcodebuild[45176:4425669] [MT] PluginLoading: Required plug-in compatibility UUID B395D63E-9166-4CD6-9287-6889D507AD6A for plug-in at path '/Library/Application Support/Developer/Shared/Xcode/Plug-ins/ESJsonFormat.xcplugin' not present in DVTPlugInCompatibilityUUIDs
2018-05-07 15:01:49.772 xcodebuild[45176:4425669] [MT] PluginLoading: Required plug-in compatibility UUID B395D63E-9166-4CD6-9287-6889D507AD6A for plug-in at path '
/Library/Application Support/Developer/Shared/Xcode/Plug-ins/Alcatraz.xcplugin' not present in DVTPlugInCompatibilityUUIDs
User defaults from command line:
IDEArchivePathOverride = /Users/wyw/Git_reources/iOS/2018Year/04Month/DeepCopyQuestion/build/APPxxxxTest.xcarchive

Build settings from command line:
CFBundleVersion = Error
CODE_SIGN_IDENTITY = iPhone Developer:Xiamen henz wealth financial information services co., LTD

你好,请问下哪里配置错误了吗,文件位置和demo图片中的位置一致

xcode12 打包失败

xcode11 打包 OK,但是更新到 xcode12 后打包失败,失败原因如下:
image

求助** ARCHIVE FAILED **

** CLEAN SUCCEEDED **

User defaults from command line:
IDEArchivePathOverride = /Users/think/Documents/workspace/zznet/git/smart-class-iOS/smart-class/build/smart-class.xcarchive

Build settings from command line:
CFBundleVersion = 4
CODE_SIGN_IDENTITY = iPhone Developer: Gao Haitao (74E6NBPBCP)

2018-04-04 16:09:10.454 xcodebuild[4398:249345] DTDeviceKit: deviceType from 4a30868e4f6a429d542619dac38fed1684036b2b was NULL
=== BUILD TARGET DTFoundation OF PROJECT Pods WITH CONFIGURATION Release ===

Check dependencies
Code Signing Error: DTFoundation does not support provisioning profiles. DTFoundation does not support provisioning profiles, but provisioning profile NO_SIGNING/ has been manually specified. Set the provisioning profile value to "Automatic" in the build settings editor.

=== BUILD TARGET DACircularProgress OF PROJECT Pods WITH CONFIGURATION Release ===

Check dependencies
Code Signing Error: DACircularProgress does not support provisioning profiles. DACircularProgress does not support provisioning profiles, but provisioning profile NO_SIGNING/ has been manually specified. Set the provisioning profile value to "Automatic" in the build settings editor.

=== BUILD TARGET AFNetworking OF PROJECT Pods WITH CONFIGURATION Release ===

Check dependencies
Code Signing Error: AFNetworking does not support provisioning profiles. AFNetworking does not support provisioning profiles, but provisioning profile NO_SIGNING/ has been manually specified. Set the provisioning profile value to "Automatic" in the build settings editor.

=====
请问这是为什么,我的使用 pod 构建的工程,pod里的第三方库会报这个错误!!

Xcode9.4打包出现下面问题,scheme已设置无误

User defaults from command line:
IDEArchivePathOverride = /Users/zhonggaorong/ios/RedEnvelopes/build/xxxxx.xcarchive

Build settings from command line:
CFBundleVersion = File
CODE_SIGN_IDENTITY = iPhone Developer:xxxxxxxxxxxx(xxxxxx)

xcodebuild: error: Unknown build action 'Doesn't'.

********* 项目构建失败 😢 😢 😢 ***************

error: Multiple commands produce

大哥请教一下

`xcodebuild: error: You cannot specify both a scheme and -alltargets.
2018-10-29 14:06:38.593 xcodebuild[6695:113309] [MT] PluginLoading: Required plug-in compatibility UUID 8B9F56A7-4D8B-41AA-A65D-D4906CDF1539 for plug-in at path '~/Library/Application Support/Developer/Shared/Xcode/Plug-ins/ClangFormat.xcplugin' not present in DVTPlugInCompatibilityUUIDs
2018-10-29 14:06:38.594 xcodebuild[6695:113309] [MT] PluginLoading: Required plug-in compatibility UUID 8B9F56A7-4D8B-41AA-A65D-D4906CDF1539 for plug-in at path '~/Library/Application Support/Developer/Shared/Xcode/Plug-ins/Alcatraz.xcplugin' not present in DVTPlugInCompatibilityUUIDs
User defaults from command line:
    IDEArchivePathOverride = /Users/oswin/Downloads/auto_code/zzios_test/build/ios.xcarchive

Build settings from command line:
    CFBundleVersion = 1
    CODE_SIGN_IDENTITY = iPhone Distribution:xxxxx(已经配置)

note: Using new build system
note: Planning build
note: Constructing build description
Build system information
warning: The Copy Bundle Resources build phase contains this target's Info.plist file '/Users/oswin/Downloads/auto_code/zzios_test/ios/Info.plist'. (in target 'ios')

Build system information
warning: duplicate output file '/Users/oswin/Library/Developer/Xcode/DerivedData/ios-afezxkudgwcbseamdzpppfeesusv/Build/Intermediates.noindex/ArchiveIntermediates/ios/InstallationBuildProductsLocation/Applications/ios.app/Info.plist' on task: ProcessInfoPlistFile /Users/oswin/Library/Developer/Xcode/DerivedData/ios-afezxkudgwcbseamdzpppfeesusv/Build/Intermediates.noindex/ArchiveIntermediates/ios/InstallationBuildProductsLocation/Applications/ios.app/Info.plist /Users/oswin/Downloads/auto_code/zzios_test/ios/Info.plist (in target 'ios')

Build system information
error: Multiple commands produce '/Users/oswin/Library/Developer/Xcode/DerivedData/ios-afezxkudgwcbseamdzpppfeesusv/Build/Intermediates.noindex/ArchiveIntermediates/ios/InstallationBuildProductsLocation/Applications/ios.app/Info.plist':
1) Target 'ios' (project 'ios') has copy command from '/Users/oswin/Downloads/auto_code/zzios_test/ios/Info.plist' to '/Users/oswin/Library/Developer/Xcode/DerivedData/ios-afezxkudgwcbseamdzpppfeesusv/Build/Intermediates.noindex/ArchiveIntermediates/ios/InstallationBuildProductsLocation/Applications/ios.app/Info.plist'
2) Target 'ios' (project 'ios') has process command with output '/Users/oswin/Library/Developer/Xcode/DerivedData/ios-afezxkudgwcbseamdzpppfeesusv/Build/Intermediates.noindex/ArchiveIntermediates/ios/InstallationBuildProductsLocation/Applications/ios.app/Info.plist'

** ARCHIVE FAILED **`

build fail for unknown error. May cocoadpods be blamed.

=== BUILD TARGET SnapKit OF PROJECT Pods WITH CONFIGURATION Release ===

Check dependencies
Code Signing Error: SnapKit does not support provisioning profiles. SnapKit does not support provisioning profiles, but provisioning profile NO_SIGNING/ has been manually specified. Set the provisioning profile value to "Automatic" in the build settings editor.

** ARCHIVE FAILED **

The following build commands failed:
Check dependencies
Check dependencies
Check dependencies
Check dependencies
Check dependencies
Check dependencies
Check dependencies
Check dependencies
(8 failures)

********* 项目构建失败 😢 😢 😢 ***************

the pod --version is 1.3.1 and the build settings is "Don't code sign"

.xcworkspace 打包报错

** ARCHIVE FAILED **

The following build commands failed:
Ld /Users/edaobao/Library/Developer/Xcode/DerivedData/AutoPackingDemo-ggclroqhawoqkrbfupxglfycilxo/Build/Intermediates.noindex/ArchiveIntermediates/AutoPackingDemo/IntermediateBuildFilesPath/AutoPackingDemo.build/Debug-iphoneos/AutoPackingDemo.build/Objects-normal/arm64/AutoPackingDemo normal arm64
(1 failure)

********* 项目构建失败 😢 😢 😢 ***************

Unknown build action 'Doesn't'

Build settings from command line:
CFBundleVersion = File
CODE_SIGN_IDENTITY = iPhone Distribution: Chongqing xxxxxxxxxx xxxxxxx Co., Ltd.

xcodebuild: error: Unknown build action 'Doesn't'.

项目构建失败

已开始打包

autopacking.sh: line 166: 104: command not found
Print: Entry, "CFBundleVersion", Does Not Exist
autopacking.sh: line 168: 1.4#File: command not found
2019-05-17 13:35:22.053 xcodebuild[60630:936461] [MT] PluginLoading: Required plug-in compatibility UUID 72F7D751-F810-43B8-A53F-1F1DFD74FC54 for plug-in at path '~/Library/Application Support/Developer/Shared/Xcode/Plug-ins/xTransCodelation.xcplugin' not present in DVTPlugInCompatibilityUUIDs
2019-05-17 13:35:22.053 xcodebuild[60630:936461] [MT] PluginLoading: Required plug-in compatibility UUID 72F7D751-F810-43B8-A53F-1F1DFD74FC54 for plug-in at path '~/Library/Application Support/Developer/Shared/Xcode/Plug-ins/ESTranslate.xcplugin' not present in DVTPlugInCompatibilityUUIDs
2019-05-17 13:35:22.054 xcodebuild[60630:936461] [MT] PluginLoading: Required plug-in compatibility UUID 72F7D751-F810-43B8-A53F-1F1DFD74FC54 for plug-in at path '~/Library/Application Support/Developer/Shared/Xcode/Plug-ins/Alcatraz.xcplugin' not present in DVTPlugInCompatibilityUUIDs
xcodebuild: error: Unknown build action 'Release'.
2019-05-17 13:35:22.882 xcodebuild[60631:936505] [MT] PluginLoading: Required plug-in compatibility UUID 72F7D751-F810-43B8-A53F-1F1DFD74FC54 for plug-in at path '~/Library/Application Support/Developer/Shared/Xcode/Plug-ins/xTransCodelation.xcplugin' not present in DVTPlugInCompatibilityUUIDs
2019-05-17 13:35:22.882 xcodebuild[60631:936505] [MT] PluginLoading: Required plug-in compatibility UUID 72F7D751-F810-43B8-A53F-1F1DFD74FC54 for plug-in at path '~/Library/Application Support/Developer/Shared/Xcode/Plug-ins/ESTranslate.xcplugin' not present in DVTPlugInCompatibilityUUIDs
2019-05-17 13:35:22.883 xcodebuild[60631:936505] [MT] PluginLoading: Required plug-in compatibility UUID 72F7D751-F810-43B8-A53F-1F1DFD74FC54 for plug-in at path '~/Library/Application Support/Developer/Shared/Xcode/Plug-ins/Alcatraz.xcplugin' not present in DVTPlugInCompatibilityUUIDs
User defaults from command line:
    IDEArchivePathOverride = /Users/nathan/Documents/workspace/YY/LuckyBet/build/.xcarchive

Build settings from command line:
    CFBundleVersion = 

xcodebuild: error: Unknown build action 'Release'.
项目构建失败 😢 😢 😢


我直接指定版本号貌似也不行,求解。
image

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.