diff --git a/.github/workflows/ios-browserstack.yml b/.github/workflows/ios-browserstack.yml index 86f7cc945..457e1888e 100644 --- a/.github/workflows/ios-browserstack.yml +++ b/.github/workflows/ios-browserstack.yml @@ -12,9 +12,42 @@ jobs: ruby-version: "3.2.2" bundler-cache: true - run: brew install xcodesorg/made/xcodes + - name: Install the Apple certificate and provisioning profile + env: + BUILD_CERTIFICATE_BASE64: ${{ secrets.BUILD_CERTIFICATE_BASE64 }} + P12_PASSWORD: ${{ secrets.P12_PASSWORD }} + BUILD_PROVISION_PROFILE_BASE64: ${{ secrets.BUILD_PROVISION_PROFILE_BASE64 }} + KEYCHAIN_PASSWORD: ${{ secrets.KEYCHAIN_PASSWORD }} + EXPORT_OPTIONS_PLIST: ${{ secrets.EXPORT_OPTIONS_PLIST }} + run: | + # create variables + CERTIFICATE_PATH=$RUNNER_TEMP/build_certificate.p12 + PP_PATH=$RUNNER_TEMP/build_pp.mobileprovision + KEYCHAIN_PATH=$RUNNER_TEMP/app-signing.keychain-db + + # import certificate and provisioning profile from secrets + echo -n "$BUILD_CERTIFICATE_BASE64" | base64 --decode -o $CERTIFICATE_PATH + echo -n "$BUILD_PROVISION_PROFILE_BASE64" | base64 --decode -o $PP_PATH + + # create temporary keychain + security create-keychain -p "$KEYCHAIN_PASSWORD" $KEYCHAIN_PATH + security set-keychain-settings -lut 21600 $KEYCHAIN_PATH + security unlock-keychain -p "$KEYCHAIN_PASSWORD" $KEYCHAIN_PATH + + # import certificate to keychain + security import $CERTIFICATE_PATH -P "$P12_PASSWORD" -A -t cert -f pkcs12 -k $KEYCHAIN_PATH + security list-keychain -d user -s $KEYCHAIN_PATH + + # apply provisioning profile + mkdir -p ~/Library/MobileDevice/Provisioning\ Profiles + cp $PP_PATH ~/Library/MobileDevice/Provisioning\ Profiles + + # create plist + EXPORT_OPTS_PATH=$RUNNER_TEMP/ExportOptions.plist + echo -n "$EXPORT_OPTIONS_PLIST" | base64 --decode -o $EXPORT_OPTS_PATH - name: fastlane build swift-sample-app - run: bundle exec fastlane build_for_browserstack + run: bundle exec fastlane build_for_browserstack plist:$EXPORT_OPTS_PATH - name: upload swift-sample-app .ipa to browserstack id: upload_ipa diff --git a/fastlane/Fastfile b/fastlane/Fastfile index 8c4db630b..4bc59e4b7 100644 --- a/fastlane/Fastfile +++ b/fastlane/Fastfile @@ -2,16 +2,17 @@ default_platform(:ios) platform :ios do desc "build swift-sample-app .ipa and ui-test.zip for browserstack" - lane :build_for_browserstack do + lane :build_for_browserstack do |options| xcodes(version: "14.2", select_for_current_build_only: true) ensure_xcode_version(version: "14.2") setup_ci - build_swift_sample_app + build_swift_sample_app(plist:options[:plist]) build_ui_tests end desc "build swift-sample-app .ipa" - lane :build_swift_sample_app do + lane :build_swift_sample_app do |options| + export_option(options[:plist]) build_app( project: "sample-apps/swift-sample-app/swift-sample-app.xcodeproj", configuration: "Debug", @@ -23,15 +24,6 @@ platform :ios do output_name: "swift-sample-app.ipa", export_method: "development", export_team_id: "BP98Z28R86", - skip_profile_detection: true, - export_options: { - signingStyle: "manual", - compileBitcode: false, - provisioningProfiles: { - "iterable.swift-sample-app" => "ios-dev-swift-sample-app", - "iterable.swift-sample-app.swift-sample-app-notification-extension" => "ios-dev-swift-sample-app-notification-extension" - }, - } ) end diff --git a/sample-apps/swift-sample-app/swift-sample-app.xcodeproj/project.pbxproj b/sample-apps/swift-sample-app/swift-sample-app.xcodeproj/project.pbxproj index f95d5f25e..a9632e351 100644 --- a/sample-apps/swift-sample-app/swift-sample-app.xcodeproj/project.pbxproj +++ b/sample-apps/swift-sample-app/swift-sample-app.xcodeproj/project.pbxproj @@ -573,7 +573,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - PRODUCT_BUNDLE_IDENTIFIER = "com.iterable.swift-sample-app"; + PRODUCT_BUNDLE_IDENTIFIER = "iterable.swift-sample-app"; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_VERSION = 5.0; TARGETED_DEVICE_FAMILY = "1,2"; @@ -658,7 +658,7 @@ IPHONEOS_DEPLOYMENT_TARGET = 16.2; MARKETING_VERSION = 1.0; MTL_FAST_MATH = YES; - PRODUCT_BUNDLE_IDENTIFIER = com.iterable.sampleapp.swift.SwiftSampleAppUITest; + PRODUCT_BUNDLE_IDENTIFIER = "iterable.swift-sample-app.SwiftSampleAppUITest"; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_EMIT_LOC_STRINGS = NO; SWIFT_VERSION = 5.0;