Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-23854] Hyperloop: iOS - Support creating of Run Script phases

GitHub Issuen/a
TypeNew Feature
PriorityCritical
StatusClosed
ResolutionFixed
Resolution Date2016-12-02T15:08:27.000+0000
Affected Version/shyperloop 1.2.7
Fix Version/sHyperloop 2.2.0
ComponentsHyperloop
Labelshyperloop, ios
ReporterRodolfo Perottoni
AssigneeJan Vennemann
Created2016-09-01T00:29:39.000+0000
Updated2017-10-19T18:16:31.000+0000

Description

Some native iOS libs / frameworks require the developer to call certain scripts during the build phase (see image attached). This could be done in the *appc.js* file:
hyperloop: {
  ios: {
    xcodebuild: {
      scripts: [{
        name: 'My script phase',
        shellScript: '${APPC_PROJECT_DIR}/src/script.sh'
      }]
    }
  }
}

Attachments

FileDateSize
Screen Shot 2016-09-01 at 10.23.37 AM.png2016-09-01T00:23:54.000+000019069

Comments

  1. Hans Knöchel 2016-09-01

    We can think about that. But you can actually do it today already using the Titanium plugin-hooks. Summarized, we have different hooks in our CLI that you can hook into (like we already do with our Hyperloop CLI that sits in plugins/hyperloop. So you could be notified when certain build phases are reached and inject your own scripts there (e.g. run shell-scripts using node-commands). Please check out how Hyperloop makes it and go from there for now. We schedule it anyway, might be a good appc.js addition. Thanks!
  2. Rodolfo Perottoni 2016-09-01

    Cool, I'll give it a go.
  3. Hans Knöchel 2016-09-02

    Here is how it's mapped in the .pbxproj file:
       3AC54DA81D7A4392007D9994 /* ShellScript */ = {
       	isa = PBXShellScriptBuildPhase;
       	buildActionMask = 2147483647;
       	files = (
       	);
       	inputPaths = (
       		"$(SRCROOT)/myfile",
       	);
       	outputPaths = (
       		"$(DERIVED_FILE_DIR)/myfile",
       	);
       	runOnlyForDeploymentPostprocessing = 0;
       	shellPath = /bin/sh;
       	shellScript = test;
       };
       
    as well as the reference of the ID in the buildPhases list.
  4. Hans Knöchel 2016-10-09

    [This page](http://www.monobjc.net/xcode-project-file-format.html) has a good summary, see the "PBXShellScriptBuildPhase" paragraph.
  5. Hans Knöchel 2016-10-27

    [~rdperottoni] Updated your proposal regarding the structure to have a more native data-structure. Where should we place scripts? Is src/scripts/ cool?
  6. Jan Vennemann 2016-11-29

    PR (master): https://github.com/appcelerator/hyperloop.next/pull/104 PR (2_0_X): https://github.com/appcelerator/hyperloop.next/pull/105 Usually I'm all in for convention over configuration but i felt the automatic mapping of a script name to a file in a folder we define is not quite fitting here. Instead, I introduced the env variable ${APPC_PROJECT_DIR} which points to the app's project directory. This is closer to the native behavior in Xcode where ${SRCROOT} is used by default, which points to the Xcode project directory. The minimum configuration to add a Run Script phase:
       hyperloop: {
         ios: {
           xcodebuild: {
             scripts: [{
               name: 'My script phase',
               shellScript: '${APPC_PROJECT_DIR}/src/script.sh'
             }]
           }
         }
       }
       
    All other options are optional and default to the following: * shellPath: '/bin/sh' * runOnlyWhenInstalling: false. I adopted the description from within Xcode for this field which is more clear than the runOnlyForDeploymentPostprocessing used inside the pbproj file * inputPaths: [] * outputPaths: [] * showEnvVarsInLog: false
  7. Hans Knöchel 2016-11-29

    Thanks for the input Jan. I get where you are coming from, but I'd really like to prevent the env-variable in there. First, because all Hyperloop-related assets should be stored in src/ (which I still don't really like, since we already have app/assets (Alloy) and /Resources (Classic), and second, because it adds another level of confusion, because using APPC_SRCROOT, I'd guess to be in /src already. So either we normalize the names of it to match more existing ones (see the ones in _build.js), or get rid of them in there completely.
  8. Eric Wieber 2017-10-19

    Verified. Able to run scripts and inline shell commands in the appc.js. Run script phases correctly execute and show in the logs.

JSON Source