yonaskolb / XcodeGen

A Swift command line tool for generating your Xcode project
MIT License
6.99k stars 816 forks source link

codesigning executable embedded during buildPhase/copyFiles #1022

Open alexandre-janniaux opened 3 years ago

alexandre-janniaux commented 3 years ago

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 commented 3 years ago

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 commented 3 years ago

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.

mime29 commented 3 years ago

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 }
yonaskolb commented 3 years ago

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

yonaskolb commented 3 years ago

I think this PR should solve this #1039

Sorry no, that's something else 👍

yonaskolb commented 3 years ago

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

kateinoigakukun commented 3 years ago

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.