@@ -1898,12 +1898,19 @@ function addPreActionToScheme(
18981898 // attribute names (default /bin/sh), independent of a
18991899 // PBXShellScriptBuildPhase's own shellPath (see shellScriptPhase) — pin
19001900 // it to bash too. `>` can't appear unescaped inside either attribute
1901- // value, so it reliably closes the ActionContent open tag.
1901+ // value, so it reliably closes the ActionContent open tag. Search the
1902+ // whole open tag (not just after scriptText) and allow any spacing
1903+ // around `=`, since attribute order and formatting aren't guaranteed.
1904+ const contentOpenIdx = xmlWithScript . lastIndexOf (
1905+ '<ActionContent' ,
1906+ titleIdx ,
1907+ ) ;
19021908 const contentCloseIdx = xmlWithScript . indexOf ( '>' , stIdx ) ;
1903- const shellToInvokeMarker = 'shellToInvoke = "' ;
1904- const stiIdx = xmlWithScript . indexOf ( shellToInvokeMarker , valueStart ) ;
1905- if ( stiIdx >= 0 && stiIdx < contentCloseIdx ) {
1906- const stiValueStart = stiIdx + shellToInvokeMarker . length ;
1909+ const openTag = xmlWithScript . slice ( contentOpenIdx , contentCloseIdx ) ;
1910+ const stiMatch = openTag . match ( / s h e l l T o I n v o k e \s * = \s * " / ) ;
1911+ if ( stiMatch != null ) {
1912+ const stiValueStart =
1913+ contentOpenIdx + stiMatch . index + stiMatch [ 0 ] . length ;
19071914 const stiValueEnd = xmlWithScript . indexOf ( '"' , stiValueStart ) ;
19081915 xmlWithScript =
19091916 xmlWithScript . slice ( 0 , stiValueStart ) +
0 commit comments