Skip to content

Commit

Permalink
Added support for the new iOS naming convention in Cordova 7 (#56)
Browse files Browse the repository at this point in the history
* Inseting breakpoints for debugging

* Directory does not exist

* Wrongly inserted else

* Log ios output directory

* Logged parameters

* Added support for Cordova 7 ios

* Removed breakpoints

* Minor tweaks

* Cleanups

---------

Co-authored-by: Olivér Falvai <ofalvai@gmail.com>
  • Loading branch information
atanas-bitrise and ofalvai committed Sep 20, 2023
1 parent de0126c commit b7df552
Show file tree
Hide file tree
Showing 3 changed files with 76 additions and 9 deletions.
15 changes: 7 additions & 8 deletions bitrise.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
format_version: 6
format_version: "12"
default_step_lib_source: https://github.com/bitrise-io/bitrise-steplib.git

app:
Expand All @@ -14,10 +14,10 @@ workflows:
before_run:
- audit-this-step
steps:
- go-list:
- golint:
- errcheck:
- go-test:
- go-list: {}
- golint: {}
- errcheck: {}
- go-test: {}
after_run:
- test-with-npm
- test-with-yarn
Expand Down Expand Up @@ -61,7 +61,7 @@ workflows:
rm -rf ./_tmp
- change-workdir:
title: Switch working dir to ./_tmp dir
run_if: true
run_if: "true"
inputs:
- path: ./_tmp
- is_create_path: true
Expand Down Expand Up @@ -93,8 +93,7 @@ workflows:
- cordova-prepare:
title: Cordova prepare
run_if: '{{enveq "RUN_PREPARE_STEP" "true"}}'
inputs:
# - cordova_version: latest
inputs: []
- path::./:
title: Cordova archive
inputs:
Expand Down
22 changes: 21 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"fmt"
"os"
"path/filepath"
"strconv"
"strings"
"time"

Expand Down Expand Up @@ -172,6 +173,25 @@ func fail(format string, v ...interface{}) {
os.Exit(1)
}

func findIosTargetPathComponent(target string, configuration string, cordovaVersion string) string {
if cordovaVersion == "" {
return target
}

majorVersion, err := strconv.Atoi(cordovaVersion[0:1])
if err != nil || majorVersion < 7 {
// Pre-Cordova-7 behavior: path segment is just "device" or "emulator"
return target
}

targetPlatform := "iphonesimulator"
if target == "device" {
targetPlatform = "iphoneos"
}

return strings.Title(configuration) + "-" + targetPlatform
}

func main() {
var configs config
if err := stepconf.Parse(&configs); err != nil {
Expand Down Expand Up @@ -302,7 +322,7 @@ func main() {
// collect outputs
var ipas, apps []string
iosOutputDirExist := false
iosOutputDir := filepath.Join(workDir, "platforms", "ios", "build", configs.Target)
iosOutputDir := filepath.Join(workDir, "platforms", "ios", "build", findIosTargetPathComponent(configs.Target, configs.Configuration, configs.CordovaVersion))
if exist, err := pathutil.IsDirExists(iosOutputDir); err != nil {
fail("Failed to check if dir (%s) exist, error: %s", iosOutputDir, err)
} else if exist {
Expand Down
48 changes: 48 additions & 0 deletions main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,3 +157,51 @@ func Test_checkBuildProducts(t *testing.T) {
})
}
}

func Test_findIosTargetPathComponentEmulatorOld(t *testing.T) {
got := findIosTargetPathComponent("emulator", "debug", "6.3.0")
want := "emulator"
if got != want {
t.Errorf("got %q, wanted %q", got, want)
}
}

func Test_findIosTargetPathComponentDeviceOld(t *testing.T) {
got := findIosTargetPathComponent("device", "debug", "6.3.0")
want := "device"
if got != want {
t.Errorf("got %q, wanted %q", got, want)
}
}

func Test_findIosTargetPathComponentEmulatorDebug7(t *testing.T) {
got := findIosTargetPathComponent("emulator", "debug", "7.0.0")
want := "Debug-iphonesimulator"
if got != want {
t.Errorf("got %q, wanted %q", got, want)
}
}

func Test_findIosTargetPathComponentEmulatorRelease7(t *testing.T) {
got := findIosTargetPathComponent("emulator", "release", "7.0.0")
want := "Release-iphonesimulator"
if got != want {
t.Errorf("got %q, wanted %q", got, want)
}
}

func Test_findIosTargetPathComponentDeviceRelease7(t *testing.T) {
got := findIosTargetPathComponent("device", "release", "7.0.0")
want := "Release-iphoneos"
if got != want {
t.Errorf("got %q, wanted %q", got, want)
}
}

func Test_findIosTargetPathComponentDeviceDebug7(t *testing.T) {
got := findIosTargetPathComponent("device", "debug", "7.0.0")
want := "Debug-iphoneos"
if got != want {
t.Errorf("got %q, wanted %q", got, want)
}
}

0 comments on commit b7df552

Please sign in to comment.