如何在 Xcode 中跳过开发版本的代码签名?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/31039513/
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-08 18:08:20  来源:igfitidea点击:

How can I skip code signing for development builds in Xcode?

xcodemacoscode-signingcodesignbuild-settings

提问by tbodt

Whenever I build my Xcode project, after compiling all my code, it takes foreverto finish "signing product." (I believe it's because the project includes about 200 MB of resources that need signing.) I would like to skip the code signing during development, so the build can finish faster. How can I do this?

每当我构建我的 Xcode 项目时,在编译我的所有代码之后,完成“签署产品”需要很长时间。(我相信这是因为该项目包含大约 200 MB 的需要签名的资源。)我想在开发过程中跳过代码签名,这样构建可以更快地完成。我怎样才能做到这一点?

回答by rob mayoff

As of Xcode 10, here is how to turn off code signing for a macOS app:

从 Xcode 10 开始,以下是关闭 macOS 应用程序代码签名的方法:

  1. Select your project in the project navigator.
  2. Select your app in the list of targets.
  3. Click “Build Settings”.
  4. Click “All”.
  5. Click “Levels”.
  6. Type “identity” into the search field.
  1. 在项目导航器中选择您的项目。
  2. 在目标列表中选择您的应用。
  3. 单击“构建设置”。
  4. 单击“全部”。
  5. 单击“级别”。
  6. 在搜索字段中输入“身份”。

first six steps

前六个步骤

  1. Click on the Code Signing Identity row, under the column for your app target (labeled “test” in my example). That cell of the table might appear empty.
  1. 单击应用程序目标列下的代码签名标识行(在我的示例中标记为“测试”)。表格的那个单元格可能显示为空。

where to click for step 7

在哪里点击第 7 步

  1. In the pop-up menu that appears, choose “Other…”.
  1. 在出现的弹出菜单中,选择“其他...”。

pop-up menu

弹出菜单

  1. In the popover text box that appears, delete all text so the box is empty.
  1. 在出现的弹出文本框中,删除所有文本,使该框为空。

empty popover

空弹出框

  1. Press return to dismiss the popover.
  1. 按回车关闭弹出窗口。

With this setting, Xcode will not sign your app target.

使用此设置,Xcode 将不会签署您的应用程序目标。

回答by Abcd Efg

To turn the code signing off, go to your project and target "Build Settings", search for "Code Signing Identity" change its value to "Don't Code Sign" in both of them.

要关闭代码签名,请转到您的项目并以“构建设置”为目标,搜索“代码签名标识”将其值更改为“不要代码签名”。

To make this effective you need to change this value in the Project and all of the Targets separately.

要使其有效,您需要分别在项目和所有目标中更改此值。

回答by Marek R

If someone uses CMake(for multi-platform projects) to disable code signing for specific target I used this:

如果有人使用CMake(对于多平台项目)禁用特定目标的代码签名,我使用了这个:

    set_target_properties(MyAppTarget PROPERTIES
        XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY ""
        OUTPUT_NAME "My nice application name"
        MACOSX_BUNDLE TRUE
        MACOSX_BUNDLE_BUNDLE_NAME "My nice application name"
        MACOSX_BUNDLE_INFO_PLIST path/to/Info.plist
        MACOSX_BUNDLE_BUNDLE_VERSION ${MY_APP_VERSION}
        MACOSX_BUNDLE_LONG_VERSION_STRING "My nice application name v${MY_APP_VERSION}"
        MACOSX_BUNDLE_SHORT_VERSION_STRING "${MY_APP_VERSION}"
        MACOSX_BUNDLE_GUI_IDENTIFIER "com.my.app"
        MACOSX_BUNDLE_COPYRIGHT "(C) 2019 My Company"
        MACOSX_RPATH TRUE
        MACOSX_FRAMEWORK_IDENTIFIER com.myapp.bundle.id
        XCODE_ATTRIBUTE_LD_RUNPATH_SEARCH_PATHS "@loader_path/Libraries"
        RESOURCE "${RESOURCE_FILES}"
        XCODE_ATTRIBUTE_ENABLE_HARDENED_RUNTIME TRUE
        XCODE_ATTRIBUTE_EXECUTABLE_NAME "exec_name"
    )

回答by Noah Witherspoon

You might try moving your resources to a separate bundle target, then adding the .bundle product of that target to your app's “copy bundle resources” build phase — ideally the app build should then be able to use the bundle's signature (which will only need to be regenerated when the bundle's contents change) instead of having to re-sign the resources individually.

您可以尝试将您的资源移动到一个单独的捆绑目标,然后将该目标的 .bundle 产品添加到您的应用程序的“复制捆绑资源”构建阶段——理想情况下,应用程序构建应该能够使用捆绑包的签名(这将只需要包的内容更改时重新生成),而不必单独重新签名资源。