XcodeGen icon indicating copy to clipboard operation
XcodeGen copied to clipboard

codesigning executable embedded during buildPhase/copyFiles

Open alexandre-janniaux opened this issue 4 years ago • 7 comments

Hi,

I'm using XCodeGen to generate an XCode project using an autotool project.

It is currently made of the following spec file:

name: VLC
options:
  bundleIdPrefix: org.videolan.vlc
  deploymentTarget:
    iOS: 9.0
targets:
  VLCAutomake:
    type: ""
    platform: ${VLC_PLATFORM}
    legacy:
      toolPath: /usr/bin/make
      passSettings: true
      attributes: $(ACTIONS)
      workingDirectory: ${VLC_BUILD_DIR}
    sources:
      - path: "${VLC_SRC_DIR}/src"
        excludes: "**/Makefile.in"
      - path: "${VLC_SRC_DIR}/include"
        excludes: "**/Makefile.in"
      - path: "${VLC_SRC_DIR}/modules"
        excludes: "**/Makefile.in"
  vlccoreios:
    type: "application"
    platform: ${VLC_PLATFORM}
    dependencies:
      - target: VLCAutomake
    info:
      path: "vlccoreios/Info.plist"
    sources:
      - path: ${VLC_BUILD_DIR}/test/vlccoreios
        type: file
        optional: true
        buildPhase:
          copyFiles:
            destination: executables

I'm basically building most of the targets from the automake target, and then use XCode to package them into an iOS or tvOS application.

However, the executable used in the vlccoreios target is not code signed and it doesn't seem that there is a way to sign it within the buildPhase, so it must be checked within the project each time it is generated again.

Is it possible to add the sign: true like for dependencies here?

alexandre-janniaux avatar Feb 21 '21 14:02 alexandre-janniaux

For precision, this is where I need the code signing done in xcode automatically setup by xcodegen:

Screenshot 2021-02-22 at 13 46 03

alexandre-janniaux avatar Feb 22 '21 12:02 alexandre-janniaux

Hi,

I've workarounded using the CodeSignOnCopy attribute directly:

  vlccoreios:
    type: "application"
    platform: ${VLC_PLATFORM}
    dependencies:
      - target: VLCAutomake
    info:
      path: "vlccoreios/Info.plist"
    sources:
      - path: ${VLC_BUILD_DIR}/test/vlccoreios
        type: file
        optional: true
        attributes:
          - CodeSignOnCopy
        buildPhase:
          copyFiles:
            destination: executables

If that's the expected way to achieve this, maybe this should be documented and this ticket closed.

alexandre-janniaux avatar Mar 30 '21 14:03 alexandre-janniaux

We're supposed to have the codeSign option but it doesn't seem to work here neither. I'm on Xcode 12.5.1 btw

dependencies:
      - { bundle: XXX.bundle, implicit: true, codeSign: true }

mime29 avatar Jul 06 '21 03:07 mime29

I think this PR should solve this https://github.com/yonaskolb/XcodeGen/pull/1039

yonaskolb avatar Jul 06 '21 07:07 yonaskolb

I think this PR should solve this #1039

Sorry no, that's something else 👍

yonaskolb avatar Jul 06 '21 07:07 yonaskolb

This would require adding a codeSign boolean to the copyFiles in https://github.com/yonaskolb/XcodeGen/blob/master/Sources/ProjectSpec/BuildPhaseSpec.swift#L23

Happy to accept a PR for this. Otherwise the workaround posted above by @alexandre-janniaux about adding CodeSignOnCopy to attributes sounds like it works.

@mime29 in your case you have a dependency instead of something in sources. It looks like code signing a bundle isn't support yet, and would need some updates in PBXProjectGenerator.swift

yonaskolb avatar Jul 06 '21 08:07 yonaskolb

We're supposed to have the codeSign option but it doesn't seem to work here neither.

codeSign option is not working for bundle dependency because it doesn't pass codeSign parameter to PBXBuildFile initializer https://github.com/yonaskolb/XcodeGen/blob/270ef8b27963b9fbfae3d02a253cc32a82f04ab1/Sources/XcodeGenKit/PBXProjGenerator.swift#L938

I'm fixing it now.

kateinoigakukun avatar Jul 06 '21 08:07 kateinoigakukun