xcode xcodebuild 为目标依赖项构建不同的配置文件

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/27973011/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 06:29:42  来源:igfitidea点击:

xcodebuild different provisioning profile for target dependency

iosxcodexcodebuild

提问by Rey Gonzales

I'm trying to build my app with xcodebuild:

我正在尝试使用 xcodebuild 构建我的应用程序:

xcodebuild -workspace "RG.xcworkspace" -scheme "Production" -configuration "Release" build CONFIGURATION_BUILD_DIR="${TEMP_DIR}" PROVISIONING_PROFILE="1234-5678-9098-7654-3210"

My scheme has two targets. One target is the app, the other is the app extension (I built an extension for Safari). The app extension is a target dependency. Each target requires a separate provisioning profile. I don't know how to specify the PROVISIONING_PROFILE for the dependency. I'm getting this error, as expected:

我的计划有两个目标。一个目标是应用程序,另一个是应用程序扩展(我为 Safari 构建了一个扩展)。应用程序扩展是一个目标依赖项。每个目标都需要一个单独的配置文件。我不知道如何为依赖项指定 PROVISIONING_PROFILE。正如预期的那样,我收到此错误:

CodeSign error: code signing is required for product type 'App Extension' in SDK 'iOS 8.1'

StackOverflow and the man page for xcodebuild don't seem to come up with anything. Does anyone know how to build a project with xcodebuild that relies on two provisioning profiles?

StackOverflow 和 xcodebuild 的手册页似乎没有提出任何内容。有谁知道如何使用依赖于两个配置文件的 xcodebuild 构建项目?

回答by Max Chuquimia

I spent far too long working on this today. I was on my way to bed when the answer hit me:

我今天花了太长时间来研究这个。当答案打动我时,我正在睡觉的路上:

In each of your targets's Build Settingsyou should set a $VARIABLEfor the profile name. To do this, selected "Other" from the bottom of the list of profiles. Doing this will open a text field - choose a different $VARIABLEfor each target - for example I chose $APP_PROFILEfor the container app target and $EXTENSION_PROFILEfor my Today extension target

在每个目标的构建设置中,您应该$VARIABLE为配置文件名称设置一个。为此,请从配置文件列表的底部选择“其他”。这样做将打开一个文本字段 -$VARIABLE为每个目标选择一个不同的 - 例如我$APP_PROFILE为容器应用程序目标和$EXTENSION_PROFILE我的 Today 扩展目标选择

Adding a build variable variable...

添加构建变量变量...

This will result in something like the following:

这将导致类似以下内容:

Profiles

简介

Finally, when building with xcodebuild, specify the profile UUIDs as you did with PROVISIONING_PROFILE:

最后,在使用 构建时xcodebuild,像使用 一样指定配置文件 UUID PROVISIONING_PROFILE

xcodebuild ... APP_PROFILE="85b6f019-d5e5-43a7-9e8f-e3aaed64a7e4" EXTENSION_PROFILE="e50cf605-ab63-40ad-8329-2758359ea748"

Building from within XCode seems to be unaffected - as far as I could tell XCode is selecting the default profiles (as if in "Automatic" mode)

从 XCode 内部构建似乎不受影响 - 据我所知 XCode 正在选择默认配置文件(就像在“自动”模式下一样)

Theoretically this would support multiple extensions too.

理论上这也将支持多个扩展。

Works for me with XCode 6.3 :)

使用 XCode 6.3 对我有用 :)

回答by Sazzad Hissain Khan

Solution Without Variable

无变量解

There is an option, -exportSigningIdentitywhich can help you, because provisioning profiles of Application & Extension/Widget may be different, but signing identities of app & extension are supposed to be same.

有一个选项-exportSigningIdentity可以帮助您,因为应用程序和扩展程序/小部件的配置文件可能不同,但应用程序和扩展程序的签名身份应该是相同的。

For example, you will see that,

例如,你会看到,

  • TargetApp -> Build Settings -> "Code Signing Identity (id)" (Release)
  • TargetExtension -> Build Settings -> "Code Signing Identity (id)" (Release)
  • TargetApp -> 构建设置 -> “代码签名身份(id)”(发布)
  • TargetExtension -> 构建设置 -> “代码签名身份(id)”(发布)

are essentially same string, lets say this identity is "Code Signing Identity (id)". So to build & export archive, what you can run, are simply,

本质上是相同的字符串,可以说这个身份是"Code Signing Identity (id)"。因此,要构建和导出存档,您可以运行的内容很简单,

Cleaning

打扫

xcodebuild clean -workspace HelloWorld.xcworkspace -scheme HelloWorld

xcodebuild clean -workspace HelloWorld.xcworkspace -scheme HelloWorld

Building

建筑

xcodebuild -workspace HelloWorld.xcworkspace -scheme HelloWorld archive -archivePath ~/output/HelloWorld.xcarchive

xcodebuild -workspace HelloWorld.xcworkspace -scheme HelloWorld archive -archivePath ~/output/HelloWorld.xcarchive

Exporting

出口

xcodebuild -exportArchive -exportFormat ipa -archivePath ~/output/HelloWorld.xcarchive -exportPath "HelloWorld.ipa" -exportSigningIdentity "Code Signing Identity (id)"

xcodebuild -exportArchive -exportFormat ipa -archivePath ~/output/HelloWorld.xcarchive -exportPath "HelloWorld.ipa" -exportSigningIdentity "Code Signing Identity (id)"

Reference: xcodebuild documentation

参考:xcodebuild 文档

回答by Max Chuquimia

Months later... Found a solution that doesn't involve settings values within Xcode: Within sighthere is a scriptthat is capable of resigning an ipa file with given profiles. The following works for me:

几个月后... 找到了一个不涉及 Xcode 中设置值的解决方案:其中sigh有一个脚本可以使用给定的配置文件重新签名 ipa 文件。以下对我有用:

bash resign.sh Experiments-AdHocProd.ipa "iPhone Distribution: Company Pty Ltd" output.ipa -p com.company.experiments.AudioPlugin=Experiments-AdHocProd_com.company.experiments.AudioPlugin.mobileprovision -p com.company.experiments=Experiments-AdHocProd.mobileprovision --verbose

where:

在哪里:

  • Experiments-AdHocProd.ipais the existing ipa
  • com.company.experiments.AudioPluginis the extension bundle ID
  • Experiments-AdHocProd_com.company.experiments.AudioPlugin.mobileprovisionis the extension profile
  • com.company.experimentsis the main app bundle identifier
  • Experiments-AdHocProd.mobileprovisionis the main app profile
  • Experiments-AdHocProd.ipa是现有的ipa
  • com.company.experiments.AudioPlugin是扩展包 ID
  • Experiments-AdHocProd_com.company.experiments.AudioPlugin.mobileprovision是扩展配置文件
  • com.company.experiments是主要的应用程序包标识符
  • Experiments-AdHocProd.mobileprovision是主要的应用程序配置文件

Each profile's bundle identifier must match that of the app it will be signed with.

每个配置文件的包标识符必须与将用于签名的应用程序的标识符相匹配。

Something I found that is important to noteis that if a bundle identifier has a wildcard (in my case Experiments-AdHocProd.mobileprovisiondoes) then the profiles with explicit IDs must be passed into -pfirst.

我发现需要注意的重要一点是,如果包标识符有一个通配符(在我的例子中Experiments-AdHocProd.mobileprovision是这样),那么必须首先传入具有显式 ID 的配置文件-p



Alternatively, you could use sighto perform the resign. Unfortunately, sigh --helpdoesn't say anything about resigning binaries with extensions, however sigh resign --helpdoes.

或者,您可以使用sigh来执行辞职。不幸的是,sigh --help没有说任何关于使用扩展退出二进制文件的内容,但是sigh resign --help确实如此。

回答by PradeepKN

In Swift, Pod files framework will be packaged separately. Following steps solved the problem.

在 Swift 中,Pod 文件框架会被单独打包。以下步骤解决了问题。

 1. Select pods 
 2. Targets
 3. General
 4. Edit bundle id
 5. Build Settings
 6. Code Signing
 7. Provisioning profile -> select the valid profile
 8. Code Signing Identity -> Select the respective identity from
    profile.

Repeat the same for all targets.

对所有目标重复相同的操作。

I am able to generate build.

我能够生成构建。