Fixing your iOS build scripts PackageApplication ERROR

针对Apple不再允许提交包含ResourceRules.plist文件的归档问题,本文介绍了一种通过修改Xcode捆绑的PackageApplication脚本来解决iOS应用构建过程中的错误的方法。

If you, like myself, tend to be a part of projects where we’re delivering several builds of an iOS app, this blogpost might concern you. Up until now, Apple has allowed you to specify which parts of your archive should be signed, but this has changed a while ago.

This blogpost aims to bring you knowledge of what you can do to get your build process working again.

TL;DR

If you build and upload using Xcode’s UI, this blogpost is not intended for you, since you’re not affected
Apple will reject apps and updates hereof if the submitted archive contains a ResourceRules.plist file (they’ll either tell you directly, or you’ll get notified regarding signature issues regarding your submitted archive)
You can change the perl script PackageApplication bundled with Xcode to remove the usage of the deprecated –resource-rules option for the codesign command (do this with great care and remember to backup the original script)
If you use 3rd party applications to build and upload your app to either TestFlight or App Store, you might also be affected by this issue.
Explanation

In Yosemite, the –resource-rules option is deprecated (obsoleted in Mavericks), and it’s one of the scripts Apple include in the Xcode bundle. In our use case, we do a codesign after the app has been archived, and the thing to note is the PackageApplication script which amongst other things signs the app.

The PackageApplication script will fail with an error and warning:

Script output

Shell

Warning: –resource-rules has been deprecated in Mac OS X >= 10.10!
error: /usr/bin/codesign –force –preserve-metadata=identifier,entitlements,resource-rules –sign foo —resource-rules=/path/to/foo/bar.app failed with error 1
If you getting this error, then you’re missing the Code Signing Resource Rules Path build setting for the target you’re building. If you try to ask e.g StackOverflow about this error, you’ll most likely end up with a solution that tells you to set the missing setting to something like $(SDKROOT)/ResourceRules.plist .

This will get rid of the error, since the resource-rules parameter now points to an actual ResourceRules.plist file, but will however result in your app getting rejected, since Apple won’t allow the ResourceRules.plist to be included anymore.

Solution

My suggestion for a solution is not a great one, nor is it a permanent one – I’ll explain in the end.

First, locate and backup the script PackageApplication , e.g with the command

Locate PackageApplication script

Shell

xcrun -sdk iphoneos -f PackageApplication
The resulting path will mostly yield the following path

PackageApplication location

Shell

/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/PackageApplication
Now, find the lines including the following code in the script

Perl


my @codesign_args = (“/usr/bin/codesign”, “–force”, “–preserve-metadata=identifier,entitlements,resource-rules”,
“–sign”, optsign,resourcerules= destApp/ResourceRules.plist”);
Here you can see the –resource-rules option which is deprecated. For the sake of backwards compatibility, and development of OS X apps, I’ll recommend a solution that excludes the –resource-rules option if nothing is specified in the Code Signing Resource Rules Path path for your target.

Replace this code with the following:

Perl


my @codesign_args;
if (-e ‘destApp/ResourceRules.plist’) {  # If ResourceRules.plist exists, include it in codesign arguments, for backwards compatability  
        @codesign_args = (“/usr/bin/codesign”, “–force”, “–preserve-metadata=identifier,entitlements,resource-rules”,  
                         “–sign”,
opt{sign},
“–resource-rules=destApp/ResourceRules.plist”);  
    } else { # If ResourceRules.plist isn’t found, don’t include it in the codesign arguments  
        @codesign_args = (“/usr/bin/codesign”, “–force”, “–preserve-metadata=identifier,entitlements”,  
                         “–sign”,
opt{sign});
}
This change to the script requires your Code Signing Resource Rules Path
parameter to be blank in Xcode to have the desired effect. When you try to run your script again, you will now see that neither the warning nor the error will occur, and you’re now one step closer to submitting you app or update.

Thoughts

I generally won’t recommend editing scripts bundled with Xcode, and my opinion towards this is that Apple should fix it, not us the developers. But until then, this is one approach to getting the job done. Or, since one could get the assumption that Apple doesn’t really care about us developers in these kinda projects, you could change your entire building process.

If you adopt this hack, please be aware that you have to do the script change every time you update Xcode, since the script will be overwritten then.

If you don’t want to handle both scenarios, (where the ResourceRules.plist exists and where it doesn’t) you could simply modify the script to not include resource-rules and –resource-rules=$destApp/ResourceRules.plist in the @codesign_args . Simply delete those, and the script will work as well.

My final advice is that you retain a copy of both the original script and the modified one – how is up to you.

http://www.jayway.com/2015/05/21/fixing-your-ios-build-scripts/

内容概要:本文系统阐述了嵌入式功能安全领域的两大核心标准——IEC 61508与ISO 26262的完整体系,涵盖其定位、关系、技术要求及认证流程。IEC 61508作为通用工业功能安全基础标准,适用于PLC、机器人、轨道交通等系统,采用SIL等级划分;ISO 26262则是其在汽车行业的衍生标准,专用于车载电控单元(如BMS、ESP、自动驾驶控制器),采用ASIL等级评估。文章详细解析了两个标准在风险评估方法(如HARA与风险图法)、软硬件设计规范、失效分析、安全机制实现(如看门狗、CRC校验、冗余设计)等方面的异同,并提供了从需求分析到认证落地的全流程实施路径,包括安全生命周期管理、文档证据链构建及第三方认证机构介绍。; 适合人群:从事工业自动化或汽车电子领域嵌入式系统设计、功能安全开发与认证工作的工程师、项目经理及安全分析师,具备一定电子电气或软件开发背景的专业人员; 使用场景及目标:①指导企业开展符合IEC 61508或ISO 26262的功能安全产品设计与认证;②帮助研发团队理解SIL/ASIL等级判定逻辑与软硬件安全机制实现方式;③支持撰写安全需求文档、FMEDA报告及准备第三方审核材料; 阅读建议:此资源兼具理论体系与工程实践,建议结合具体项目场景对照标准条款进行研读,并重点关注安全生命周期各阶段的交付物要求与典型安全防护设计示例,以提升实际应用能力。
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值