diff --git a/maven/codenameone-maven-plugin/src/main/java/com/codename1/builders/IPhoneBuilder.java b/maven/codenameone-maven-plugin/src/main/java/com/codename1/builders/IPhoneBuilder.java index 12411a9c75..3251cd43ae 100644 --- a/maven/codenameone-maven-plugin/src/main/java/com/codename1/builders/IPhoneBuilder.java +++ b/maven/codenameone-maven-plugin/src/main/java/com/codename1/builders/IPhoneBuilder.java @@ -305,10 +305,12 @@ public boolean build(File sourceZip, BuildRequest request) throws BuildException iosPods += (((iosPods.length() > 0) ? ",":"") + "FBSDKCoreKit "+fbPodsVersion+",FBSDKLoginKit "+fbPodsVersion+",FBSDKShareKit "+fbPodsVersion); } - runPods = true; - - String googleAdUnitId = request.getArg("ios.googleAdUnitId", request.getArg("google.adUnitId", null)); + runPods = (iosPods.length() > 0) || + (googleAdUnitId != null && googleAdUnitId.length() > 0) || + "true".equals(request.getArg("ios.useCocoapods", "false")) || + "true".equals(request.getArg("ios.pods.alwaysRun", "false")); + boolean usePodsForGoogleAds = runPods && googleAdUnitId != null && googleAdUnitId.length() > 0; if (usePodsForGoogleAds) { iosPods += (((iosPods.length() > 0) ? ",":"") + "Firebase/Core,Firebase/AdMob"); @@ -1527,7 +1529,7 @@ public void usesClassMethod(String cls, String method) { debug("Building using addLibs="+addLibs); try { - if (!exec(userDir, env, 420000, "java", "-DsaveUnitTests=" + isUnitTestMode(), "-DfieldNullChecks=" + fieldNullChecks, "-DINCLUDE_NPE_CHECKS=" + includeNullChecks, "-DbundleVersionNumber=" + bundleVersionNumber, "-Xmx384m", + if (!exec(userDir, env, 420000, "java", "-DsaveUnitTests=" + isUnitTestMode(), "-DfieldNullChecks=" + fieldNullChecks, "-DINCLUDE_NPE_CHECKS=" + includeNullChecks, "-DbundleVersionNumber=" + bundleVersionNumber, "-Xmx2048m", "-jar", parparVMCompilerJar, "ios", classesDir.getAbsolutePath() + ";" + resDir.getAbsolutePath() + ";" + buildinRes.getAbsolutePath(), @@ -1810,9 +1812,12 @@ public void usesClassMethod(String cls, String method) { return false; } - if (!exec(new File(tmpFile, "dist"), podTimeout, pod, "init")) { - log("Failed to run "+pod+" init. Make sure you have Cocoapods installed."); - return false; + boolean skipPodInstall = "true".equals(request.getArg("ios.pods.skipInstall", "false")); + if (!skipPodInstall) { + if (!exec(new File(tmpFile, "dist"), podTimeout, pod, "init")) { + log("Failed to run "+pod+" init. Make sure you have Cocoapods installed."); + return false; + } } File podFile = new File(new File(tmpFile, "dist"), "Podfile"); if (!podFile.exists()) { @@ -1909,23 +1914,25 @@ public void usesClassMethod(String cls, String method) { Map podEnv = new HashMap(); podEnv.put("LANG", "en_US.UTF-8"); - if (!exec(new File(tmpFile, "dist"), (File)null, podTimeout, podEnv, pod, "install")) { - // Perhaps we need to update the master repo - log("Failed to exec cocoapods. Trying to update master repo..."); - if (!exec(new File(tmpFile, "dist"), podTimeout * 3, pod, "repo", "update")) { - log("Failed to update cocoapods master repo. Trying to clean up spec repos"); + if (!skipPodInstall) { + if (!exec(new File(tmpFile, "dist"), (File)null, podTimeout, podEnv,pod, "install")) { + // Perhaps we need to update the master repo + log("Failed to exec cocoapods. Trying to update master repo..."); if (!exec(new File(tmpFile, "dist"), podTimeout * 3, pod, "repo", "update")) { - log("Failed to update cocoapods master repo event after cleaning spec repos."); - return false; + log("Failed to update cocoapods master repo. Trying to clean up spec repos"); + if (!exec(new File(tmpFile, "dist"), podTimeout * 3, pod, "repo", "update")) { + log("Failed to update cocoapods master repo event after cleaning spec repos."); + return false; + } } - } - if (!exec(new File(tmpFile, "dist"), (File)null, podTimeout, podEnv,pod, "install")) { - log("Cocoapods failed even after updating master repo"); - log("Trying to cleanup spec repos"); if (!exec(new File(tmpFile, "dist"), (File)null, podTimeout, podEnv,pod, "install")) { - log("Cocoapods failed even after cleaning up spec repos."); - return false; + log("Cocoapods failed even after updating master repo"); + log("Trying to cleanup spec repos"); + if (!exec(new File(tmpFile, "dist"), (File)null, podTimeout, podEnv,pod, "install")) { + log("Cocoapods failed even after cleaning up spec repos."); + return false; + } } } } diff --git a/scripts/build-ios-app.sh b/scripts/build-ios-app.sh index e88710f21b..82ecf879ae 100755 --- a/scripts/build-ios-app.sh +++ b/scripts/build-ios-app.sh @@ -120,27 +120,44 @@ for candidate in "$PROJECT_DIR"/*.xcworkspace; do break fi done -if [ -z "$WORKSPACE" ]; then - bia_log "Failed to locate xcworkspace in $PROJECT_DIR" >&2 - ls "$PROJECT_DIR" >&2 || true - exit 1 + +if [ -n "$WORKSPACE" ]; then + bia_log "Found xcworkspace: $WORKSPACE" + BUILD_TYPE_FLAG="-workspace" + OUTPUT_PATH="$WORKSPACE" +else + bia_log "No xcworkspace found; looking for xcodeproj" + PROJECT="" + for candidate in "$PROJECT_DIR"/*.xcodeproj; do + if [ -d "$candidate" ]; then + PROJECT="$candidate" + break + fi + done + if [ -z "$PROJECT" ]; then + bia_log "Failed to locate xcworkspace or xcodeproj in $PROJECT_DIR" >&2 + ls "$PROJECT_DIR" >&2 || true + exit 1 + fi + bia_log "Found xcodeproj: $PROJECT" + BUILD_TYPE_FLAG="-project" + OUTPUT_PATH="$PROJECT" fi -bia_log "Found xcworkspace: $WORKSPACE" # Make these visible to the next GH Actions step if [ -n "${GITHUB_OUTPUT:-}" ]; then { - echo "workspace=$WORKSPACE" + echo "workspace=$OUTPUT_PATH" echo "scheme=HelloCodenameOne" } >> "$GITHUB_OUTPUT" fi -bia_log "Emitted outputs -> workspace=$WORKSPACE, scheme=HelloCodenameOne" +bia_log "Emitted outputs -> workspace=$OUTPUT_PATH, scheme=HelloCodenameOne" # (Optional) dump xcodebuild -list for debugging ARTIFACTS_DIR="${ARTIFACTS_DIR:-$REPO_ROOT/artifacts}" mkdir -p "$ARTIFACTS_DIR" -xcodebuild -workspace "$WORKSPACE" -list > "$ARTIFACTS_DIR/xcodebuild-list.txt" 2>&1 || true +xcodebuild "$BUILD_TYPE_FLAG" "$OUTPUT_PATH" -list > "$ARTIFACTS_DIR/xcodebuild-list.txt" 2>&1 || true exit 0 \ No newline at end of file diff --git a/scripts/run-ios-ui-tests.sh b/scripts/run-ios-ui-tests.sh index 2b319798a4..85336956e3 100755 --- a/scripts/run-ios-ui-tests.sh +++ b/scripts/run-ios-ui-tests.sh @@ -82,7 +82,7 @@ if [ -z "$REQUESTED_SCHEME" ]; then if [[ "$WORKSPACE_PATH" == *.xcworkspace ]]; then REQUESTED_SCHEME="$(basename "$WORKSPACE_PATH" .xcworkspace)" else - REQUESTED_SCHEME="$(basename "$WORKSPACE_PATH")" + REQUESTED_SCHEME="$(basename "$WORKSPACE_PATH" .xcodeproj)" fi fi SCHEME="$REQUESTED_SCHEME" @@ -97,8 +97,17 @@ mkdir -p "$SCREENSHOT_RAW_DIR" "$SCREENSHOT_PREVIEW_DIR" export CN1SS_OUTPUT_DIR="$SCREENSHOT_RAW_DIR" export CN1SS_PREVIEW_DIR="$SCREENSHOT_PREVIEW_DIR" +# Determine build argument (workspace vs project) +if [[ "$WORKSPACE_PATH" == *.xcodeproj ]]; then + BUILD_TYPE_FLAG="-project" + # For project files, shared schemes are inside the .xcodeproj directory + SCHEME_FILE="$WORKSPACE_PATH/xcshareddata/xcschemes/$SCHEME.xcscheme" +else + BUILD_TYPE_FLAG="-workspace" + SCHEME_FILE="$WORKSPACE_PATH/xcshareddata/xcschemes/$SCHEME.xcscheme" +fi + # Patch scheme env vars to point to our runtime dirs -SCHEME_FILE="$WORKSPACE_PATH/xcshareddata/xcschemes/$SCHEME.xcscheme" if [ -f "$SCHEME_FILE" ]; then if sed --version >/dev/null 2>&1; then # GNU sed @@ -163,7 +172,7 @@ normalize_destination() { auto_select_destination() { local show_dest rc=0 best_line="" best_key="" line payload platform id name os priority key part value set +e - show_dest="$(xcodebuild -workspace "$WORKSPACE_PATH" -scheme "$SCHEME" -sdk iphonesimulator -showdestinations 2>/dev/null)" + show_dest="$(xcodebuild "$BUILD_TYPE_FLAG" "$WORKSPACE_PATH" -scheme "$SCHEME" -sdk iphonesimulator -showdestinations 2>/dev/null)" rc=$? set -e @@ -348,7 +357,7 @@ BUILD_LOG="$ARTIFACTS_DIR/xcodebuild-build.log" ri_log "Building simulator app with xcodebuild" COMPILE_START=$(date +%s) if ! xcodebuild \ - -workspace "$WORKSPACE_PATH" \ + "$BUILD_TYPE_FLAG" "$WORKSPACE_PATH" \ -scheme "$SCHEME" \ -sdk iphonesimulator \ -configuration Debug \ @@ -363,7 +372,7 @@ COMPILE_END=$(date +%s) COMPILATION_TIME=$((COMPILE_END - COMPILE_START)) ri_log "Compilation time: ${COMPILATION_TIME}s" -BUILD_SETTINGS="$(xcodebuild -workspace "$WORKSPACE_PATH" -scheme "$SCHEME" -sdk iphonesimulator -configuration Debug -showBuildSettings 2>/dev/null || true)" +BUILD_SETTINGS="$(xcodebuild "$BUILD_TYPE_FLAG" "$WORKSPACE_PATH" -scheme "$SCHEME" -sdk iphonesimulator -configuration Debug -showBuildSettings 2>/dev/null || true)" TARGET_BUILD_DIR="$(printf '%s\n' "$BUILD_SETTINGS" | awk -F' = ' '/ TARGET_BUILD_DIR /{print $2; exit}')" WRAPPER_NAME="$(printf '%s\n' "$BUILD_SETTINGS" | awk -F' = ' '/ WRAPPER_NAME /{print $2; exit}')" if [ -z "$WRAPPER_NAME" ]; then