diff --git a/.circleci/config.yml b/.circleci/config.yml index 4b334941d..ced310f9c 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -138,22 +138,6 @@ commands: popd - build-libs: platform: ios - carthage-bootstrap: - steps: - - run: - name: Determine XCode version - command: echo "$(xcodebuild -version)" >| xcode_version - - restore_cache: - name: Restore Carthage/ cache - key: carthage-dir-cache-{{ arch }}-{{ checksum "xcode_version" }}-{{ checksum "Cartfile.resolved" }} - - run: - name: Bootstrap Carthage dependencies - command: XCODE_XCCONFIG_FILE=`pwd`/xcconfig/xcode-12-fix-carthage-lipo.xcconfig carthage bootstrap --platform iOS --cache-builds - - save_cache: - name: Save Carthage/ cache - key: carthage-dir-cache-{{ arch }}-{{ checksum "xcode_version" }}-{{ checksum "Cartfile.resolved" }} - paths: - - Carthage test-setup: steps: - build-desktop-libs @@ -224,7 +208,6 @@ commands: rm /usr/local/lib/python3.9/site-packages/six.py brew install swift-protobuf --force - - carthage-bootstrap - run: name: Verify the build environment command: ./libs/verify-ios-ci-environment.sh @@ -237,8 +220,8 @@ executors: - image: cimg/rust:1.53.0 macos: macos: - xcode: 13.1.0 - resource_class: m2.medium + xcode: 13.2.1 + resource_class: macos.x86.medium.gen2 jobs: Check Swift formatting: @@ -330,56 +313,7 @@ jobs: - run: rustup override set beta - run-tests - save-sccache-cache - iOS build carthage: - executor: macos - steps: - - full-checkout - - restore-sccache-cache - - install-rust - - setup-rust-target-version - - setup-sccache - - setup-ios-environment - - run: - name: Build Carthage archive - no_output_timeout: 20m - command: | - if [ -z "${CIRCLE_TAG}" ]; then - # XCode tests build in Debug configuration, save us a full - # Rust rebuild in Release mode by forcing Debug mode on - # non-release builds. - bash build-carthage.sh --out MozillaAppServices.framework.zip --configuration Debug - else - bash build-carthage.sh --out MozillaAppServices.framework.zip - fi - - store_artifacts: - path: raw_xcodebuild.log - destination: logs/raw_xcodebuild.log - - run: - name: "Create Carthage bin-only project specification" - command: | - ZIP_URL=https://circleci.com/api/v1.1/project/github/mozilla/application-services/$CIRCLE_BUILD_NUM/artifacts/0/dist/MozillaAppServices.framework.zip - echo "{\"0.0.1\":\"$ZIP_URL\"}" > mozilla.app-services.json - - save-sccache-cache: - path: "~/Library/Caches/Mozilla.sccache" - - store_artifacts: - name: Store Carthage framework in workspace - path: MozillaAppServices.framework.zip - destination: dist/MozillaAppServices.framework.zip - - store_artifacts: - name: Store Carthage bin-only project specification in workspace - path: mozilla.app-services.json - destination: dist/mozilla.app-services.json - - run: - name: "Carthage binary snapshot URL" - command: | - JSON_URL=https://circleci.com/api/v1.1/project/github/mozilla/application-services/$CIRCLE_BUILD_NUM/artifacts/0/dist/mozilla.app-services.json - echo "Add the following line to your Cartfile:" - echo "binary \"$JSON_URL\" ~> 0.0.1-snapshot # mozilla/application-services@$CIRCLE_SHA1" - - persist_to_workspace: - root: . - paths: - - MozillaAppServices.framework.zip - + iOS build xcframework: executor: macos steps: @@ -433,17 +367,6 @@ jobs: fi - save-sccache-cache: path: "~/Library/Caches/Mozilla.sccache" - Carthage release: - executor: macos - steps: - - full-checkout - - attach_workspace: - at: . - - install-ghr - - run: - name: Release Carthage archive on GitHub - command: | - ghr -replace "${CIRCLE_TAG}" MozillaAppServices.framework.zip XCFramework release: executor: macos steps: @@ -535,22 +458,10 @@ workflows: ios-test-and-artifacts: jobs: - iOS test - - iOS build carthage: - filters: # required since `Carthage Release` has tag filters AND requires this job - tags: - only: /.*/ - iOS build xcframework: filters: # required since `XCFramework release` has tag filters AND requires this job tags: only: /.*/ - - Carthage release: - requires: - - iOS build carthage - filters: - branches: - ignore: /.*/ - tags: - only: /^v.*/ - XCFramework release: requires: - iOS build xcframework diff --git a/CHANGES_UNRELEASED.md b/CHANGES_UNRELEASED.md index c9083066f..1cf7aa6a5 100644 --- a/CHANGES_UNRELEASED.md +++ b/CHANGES_UNRELEASED.md @@ -28,3 +28,7 @@ Use the template below to make assigning a version number during the release cut - JEXL is now available for evaluation from application code in Swift and Android ([#4813](https://github.com/mozilla/application-services/pull/4813)). This is the next piece of the puzzle for supporting Messaging Experiments. + +## Xcode + +- Bumped Xcode version from 13.1.0 -> 13.2.1 \ No newline at end of file diff --git a/Cartfile b/Cartfile deleted file mode 100644 index 45514a039..000000000 --- a/Cartfile +++ /dev/null @@ -1,2 +0,0 @@ -github "apple/swift-protobuf" ~> 1.0 -github "jrendel/SwiftKeychainWrapper" ~> 4.0 diff --git a/Cartfile.resolved b/Cartfile.resolved deleted file mode 100644 index a72976c1c..000000000 --- a/Cartfile.resolved +++ /dev/null @@ -1,2 +0,0 @@ -github "apple/swift-protobuf" "1.18.0" -github "jrendel/SwiftKeychainWrapper" "4.0.1" diff --git a/automation/run_ios_tests.sh b/automation/run_ios_tests.sh index f981a0566..61576f390 100755 --- a/automation/run_ios_tests.sh +++ b/automation/run_ios_tests.sh @@ -2,8 +2,7 @@ set -euvx -carthage bootstrap --platform iOS --cache-builds - +./megazords/ios-rust/build-xcframework.sh --build-profile release set -o pipefail && \ xcodebuild \ -workspace ./megazords/ios/MozillaAppServices.xcodeproj/project.xcworkspace \ diff --git a/automation/smoke-test-firefox-ios.py b/automation/smoke-test-firefox-ios.py index 3b02e59ee..cdf90a615 100755 --- a/automation/smoke-test-firefox-ios.py +++ b/automation/smoke-test-firefox-ios.py @@ -47,8 +47,6 @@ elif firefox_ios_branch is not None: if not Path(repo_path, "Carthage").exists(): step_msg("Carthage folder not present. Running the firefox-ios bootstrap script") run_cmd_checked(["./bootstrap.sh"], cwd=repo_path) -step_msg("Running carthage substitution script") -run_cmd_checked(["./appservices_local_dev.sh", "enable", find_app_services_root()], cwd=repo_path) if action == "do-nothing": exit(0) diff --git a/build-carthage.sh b/build-carthage.sh deleted file mode 100755 index 2d7d66c6d..000000000 --- a/build-carthage.sh +++ /dev/null @@ -1,34 +0,0 @@ -#!/usr/bin/env bash - -set -eu - -CONFIGURATION="Release" -FRAMEWORK_NAME="MozillaAppServices.framework.zip" -ARCHIVE=true - -while [[ "$#" -gt 0 ]]; do case $1 in - --configuration) CONFIGURATION="$2"; shift;shift;; - --out) FRAMEWORK_NAME="$2"; shift;shift;; - --no-archive) ARCHIVE=false; shift;; - *) echo "Unknown parameter: $1"; exit 1; -esac; done - -set -vx - -XCODE_XCCONFIG_FILE=$(pwd)/xcconfig/xcode-12-fix-carthage-lipo.xcconfig -export XCODE_XCCONFIG_FILE - -carthage bootstrap --platform iOS --cache-builds - -set -o pipefail && \ -carthage build --no-skip-current --platform iOS --verbose --configuration "${CONFIGURATION}" --cache-builds | \ -tee raw_xcodebuild.log | \ -xcpretty - -if [ "$ARCHIVE" = true ]; then - ## When https://github.com/Carthage/Carthage/issues/2623 is fixed, - ## carthage build --archive should work to produce a zip - - # Exclude SwiftProtobuf. - zip -r "${FRAMEWORK_NAME}" Carthage/Build/iOS megazords/ios/DEPENDENCIES.md -x '*SwiftProtobuf.framework*/*' -fi diff --git a/build-scripts/xc-universal-binary.sh b/build-scripts/xc-universal-binary.sh deleted file mode 100644 index c8734e8c7..000000000 --- a/build-scripts/xc-universal-binary.sh +++ /dev/null @@ -1,90 +0,0 @@ -#!/usr/bin/env bash -set -eEuvx - -function error_help() -{ - ERROR_MSG="It looks like something went wrong building the Application Services framework." - ERROR_MSG="${ERROR_MSG} This is most likely related to some missing system dependencies." - ERROR_MSG="${ERROR_MSG} See https://github.com/mozilla/application-services/blob/main/docs/building.md#ios-development for instructions." - echo "error: ${ERROR_MSG}" -} -trap error_help ERR - -# XCode tries to be helpful and overwrites the PATH. Reset that. -PATH="$(bash -l -c 'echo $PATH')" - -# This should be invoked from inside xcode, not manually -if [[ "${#}" -ne 4 ]] -then - echo "Usage (note: only call inside xcode!):" - echo "path/to/build-scripts/xc-universal-binary.sh " - exit 1 -fi -# e.g. liblogins_ffi.a -STATIC_LIB_NAME=${1} -# what to pass to cargo build -p, e.g. logins_ffi -FFI_TARGET=${2} -# path to app services root -APPSVC_ROOT=${3} -# buildvariant from our xcconfigs -BUILDVARIANT=${4} - -RELFLAG= -RELDIR="debug" -if [[ "${BUILDVARIANT}" != "debug" ]]; then - RELFLAG=--release - RELDIR=release -fi - -LIBSDIR=${APPSVC_ROOT}/libs -TARGETDIR=${APPSVC_ROOT}/target - -# If the libs don't exist, or it's modification time is older than the last commit in ${LIBSDIR}/ios, wipe it out. -if [[ ! -d "${LIBSDIR}/ios" ]] || [[ "$(stat -f "%m" "${LIBSDIR}/ios")" -lt "$(git log -n 1 --pretty=format:%at -- "${LIBSDIR}")" ]]; then - echo "No iOS libs present, or they are stale" - pushd "${LIBSDIR}" - rm -rf ios - env -i PATH="${PATH}" HOME="${HOME}" ./build-all.sh ios - popd -else - echo "iOS libs already present, not rebuilding" -fi - -# We can't use cargo lipo because we can't link to universal libraries :( -# https://github.com/rust-lang/rust/issues/55235 -LIBS_ARCHS=("x86_64" "arm64") -IOS_TRIPLES=("x86_64-apple-ios" "aarch64-apple-ios") -for i in "${!LIBS_ARCHS[@]}"; do - LIB_ARCH=${LIBS_ARCHS[${i}]} - env -i \ - PATH="${PATH}" \ - NSS_STATIC=1 \ - NSS_DIR="${LIBSDIR}/ios/${LIB_ARCH}/nss" \ - SQLCIPHER_LIB_DIR="${LIBSDIR}/ios/${LIB_ARCH}/sqlcipher/lib" \ - SQLCIPHER_INCLUDE_DIR="${LIBSDIR}/ios/${LIB_ARCH}/sqlcipher/include" \ - RUSTC_WRAPPER="${RUSTC_WRAPPER:-}" \ - SCCACHE_IDLE_TIMEOUT="${SCCACHE_IDLE_TIMEOUT:-}" \ - SCCACHE_CACHE_SIZE="${SCCACHE_CACHE_SIZE:-}" \ - SCCACHE_ERROR_LOG="${SCCACHE_ERROR_LOG:-}" \ - RUST_LOG="${RUST_LOG:-}" \ - "${HOME}"/.cargo/bin/cargo build --locked -p "${FFI_TARGET}" --lib ${RELFLAG} --target "${IOS_TRIPLES[${i}]}" -done - -UNIVERSAL_BINARY=${TARGETDIR}/universal/${RELDIR}/${STATIC_LIB_NAME} -NEED_LIPO= - -# if the universal binary doesnt exist, or if it's older than the static libs, -# we need to run `lipo` again. -if [[ ! -f "${UNIVERSAL_BINARY}" ]]; then - NEED_LIPO=1 -elif [[ "$(stat -f "%m" "${TARGETDIR}/x86_64-apple-ios/${RELDIR}/${STATIC_LIB_NAME}")" -gt "$(stat -f "%m" "${UNIVERSAL_BINARY}")" ]]; then - NEED_LIPO=1 -elif [[ "$(stat -f "%m" "${TARGETDIR}/aarch64-apple-ios/${RELDIR}/${STATIC_LIB_NAME}")" -gt "$(stat -f "%m" "${UNIVERSAL_BINARY}")" ]]; then - NEED_LIPO=1 -fi -if [[ "${NEED_LIPO}" = "1" ]]; then - mkdir -p "${TARGETDIR}/universal/${RELDIR}" - lipo -create -output "${UNIVERSAL_BINARY}" \ - "${TARGETDIR}/x86_64-apple-ios/${RELDIR}/${STATIC_LIB_NAME}" \ - "${TARGETDIR}/aarch64-apple-ios/${RELDIR}/${STATIC_LIB_NAME}" -fi diff --git a/components/fxa-client/ios/FxAClient/MZKeychain/KeychainItemAccessibility.swift b/components/fxa-client/ios/FxAClient/MZKeychain/KeychainItemAccessibility.swift index a295a38aa..f35903909 100644 --- a/components/fxa-client/ios/FxAClient/MZKeychain/KeychainItemAccessibility.swift +++ b/components/fxa-client/ios/FxAClient/MZKeychain/KeychainItemAccessibility.swift @@ -100,7 +100,6 @@ public enum MZKeychainItemAccessibility { return key } } - return nil } } diff --git a/components/fxa-client/ios/FxAClient/MZKeychain/KeychainWrapper.swift b/components/fxa-client/ios/FxAClient/MZKeychain/KeychainWrapper.swift index fbad27f8c..cc1b00b8b 100644 --- a/components/fxa-client/ios/FxAClient/MZKeychain/KeychainWrapper.swift +++ b/components/fxa-client/ios/FxAClient/MZKeychain/KeychainWrapper.swift @@ -95,7 +95,6 @@ open class MZKeychainWrapper { // Remove accessibility attribute keychainQueryDictionary.removeValue(forKey: SecAttrAccessible) - // Limit search results to one keychainQueryDictionary[SecMatchLimit] = kSecMatchLimitOne @@ -375,7 +374,6 @@ open class MZKeychainWrapper { return false } } - /// Remove all keychain data, including data not added through keychain wrapper. /// /// - Warning: This may remove custom keychain entries you did not add via SwiftKeychainWrapper. @@ -396,7 +394,6 @@ open class MZKeychainWrapper { @discardableResult private class func deleteKeychainSecClass(_ secClass: AnyObject) -> Bool { let query = [SecClass: secClass] let status: OSStatus = SecItemDelete(query as CFDictionary) - if status == errSecSuccess { return true } else { @@ -413,7 +410,6 @@ open class MZKeychainWrapper { if let accessibility = accessibility { keychainQueryDictionary[SecAttrAccessible] = accessibility.keychainAttrValue } - // Update let status: OSStatus = SecItemUpdate(keychainQueryDictionary as CFDictionary, updateDictionary as CFDictionary) @@ -441,7 +437,6 @@ open class MZKeychainWrapper { if let accessibility = accessibility { keychainQueryDictionary[SecAttrAccessible] = accessibility.keychainAttrValue } - // Set the keychain access group if defined if let accessGroup = self.accessGroup { keychainQueryDictionary[SecAttrAccessGroup] = accessGroup diff --git a/components/fxa-client/ios/FxAClient/MZKeychain/KeychainWrapperSubscript.swift b/components/fxa-client/ios/FxAClient/MZKeychain/KeychainWrapperSubscript.swift index c167eca88..a661f6e62 100644 --- a/components/fxa-client/ios/FxAClient/MZKeychain/KeychainWrapperSubscript.swift +++ b/components/fxa-client/ios/FxAClient/MZKeychain/KeychainWrapperSubscript.swift @@ -93,7 +93,6 @@ public extension MZKeychainWrapper { if let value = bool(forKey: key.rawValue) { return value } - return nil } @@ -101,7 +100,6 @@ public extension MZKeychainWrapper { if let value = integer(forKey: key.rawValue) { return value } - return nil } @@ -109,7 +107,6 @@ public extension MZKeychainWrapper { if let value = float(forKey: key.rawValue) { return value } - return nil } @@ -127,7 +124,6 @@ public extension MZKeychainWrapper { if let value = double(forKey: key.rawValue) { return value } - return nil } diff --git a/docs/build-and-publish-pipeline.md b/docs/build-and-publish-pipeline.md index 10e65b9f3..1bd805d5d 100644 --- a/docs/build-and-publish-pipeline.md +++ b/docs/build-and-publish-pipeline.md @@ -14,7 +14,7 @@ The key points: * We use [Cargo](https://github.com/rust-lang/cargo) for building and testing the core Rust code in isolation, [Gradle](https://gradle.org/) with [rust-android-gradle](https://github.com/mozilla/rust-android-gradle) for combining Rust and Kotlin code into Android components and running tests against them, - and [Carthage](https://github.com/Carthage/Carthage) driving [XCode](../xconfig) + and [XCframeworks](https://developer.apple.com/documentation/swift_packages/distributing_binary_frameworks_as_swift_packages) driving [XCode](../xconfig) for combining Rust and Swift code into iOS components. * [TaskCluster](../automation/taskcluster/README.md) runs on every pull-request, release, and push to main, to ensure Android artifacts build correctly and to execute their @@ -75,18 +75,13 @@ For iOS consumers the corresponding steps are: * TODO: could this step check for signed tags as an additional integrity measure? * TODO: can we prevent these steps from being able to see the tokens used for publishing in subsequent steps? -4. CircleCI builds two binary artifacts: - * A Carthage framework containing both Rust and Swift code compiled together, as a zipfile. +4. CircleCI builds a binary artifact: * An XCFramework containing just Rust code and header files, as a zipfile, for use by Swift Packags. * TODO: could a malicious dev dependency from step (3) influence the build environment here? 5. CircleCI uses [dpl](https://github.com/travis-ci/dpl) to publish to GitHub as a release artifact. * CircleCI config contains a github token (owned by the @appsvc-moz GitHub account) with appropriate permissions to add release artifacts. -6. Consumers fetch the published artifacts from GitHub during their build process, - using Carthage. +6. Consumers add Application services as a dependency from the [Rust Components Swift](https://github.com/mozilla/rust-components-swift/) repo using Apple's Swift Package Manager. -It's worth noting that Carthage will *prefer* to use the built binary artifacts, -but will happily check out the tag and compile from source itself if such artifacts -are not available. This is a diagram of the pipeline as it exists (and is planned) for the Nimbus SDK, one of the libraries in Application Services: diff --git a/docs/building.md b/docs/building.md index 1e98cf519..249213bb5 100644 --- a/docs/building.md +++ b/docs/building.md @@ -105,7 +105,6 @@ Configure maven to use the native windows maven repository - then, when doing `. ## Building for Firefox iOS -1. Install Carthage: `brew install carthage` 1. Install [xcpretty](https://github.com/xcpretty/xcpretty#installation): `gem install xcpretty` 1. Run `./libs/verify-ios-environment.sh` to check your setup and environment variables. diff --git a/docs/howtos/consuming-rust-components-on-ios.md b/docs/howtos/consuming-rust-components-on-ios.md deleted file mode 100644 index 9b5ff5b97..000000000 --- a/docs/howtos/consuming-rust-components-on-ios.md +++ /dev/null @@ -1,47 +0,0 @@ -# Guide to Consuming Rust Components on iOS - -The application services libraries are published as a zip file containing a single composite (megazord) framework called *MozillaAppServices.framework*, -which contains the compiled code for all components. - -The package is published as a release on github: https://github.com/mozilla/application-services/releases - -## Carthage - -- Add the dependency line to the Cartfile, for instance: `github "mozilla/application-services" ~> "v0.16.1"` -- `carthage` will download MozillaAppServices.frameworks.zip, and add all the available frameworks to the 'Carthage/' dir. -- Link against the provided MozillaAppServices.framework (in the *Link Binary with Libraries* step in your Xcode target). -- Add additional dependencies, see [below](#additional-dependencies). - -### Adding a carthage provided framework to Xcode -- In general, to do this, add *XXX.framework* from *Carthage/Build/iOS* to *Link binary with Libraries* for the Xcode target. -- Update the list of additional dependencies below, so that consumers know to include the framework in their final build. - -### Using a Circle-CI built framework - -Rather than using a tagged release version, one can grab the build from Circle-CI, like so: - -`binary "https://circleci.com/api/v1.1/project/github/mozilla/application-services/2862/artifacts/0/dist/mozilla.app-services.json" ~> 0.0.1-snapshot` - -## Additional dependencies - -The project has additional 3rd-party dependencies that a client must link against. - -### NSS - -- In your project, add all the .dylibs in the `../Carthage/Build/iOS/MozillaAppServices.framework` directory to both the "Embedded Binaries" and the "Linked Frameworks and Libraries" panels. - -### Protobuf - -- *SwiftProtoBuf.framework* should be automatically downloaded by carthage while pulling in the application-services dependency. -- [Add that framework to Xcode.](#adding-a-carthage-provided-framework-to-xcode) - -## Third-party licenses - -This project incorporates code from a number of third-party dependencies, -under a variety of open-source licenses. You should review the license info -in the file `DEPENDENCIES.md` and decide on an appropriate way to include -license and attribution notices into your product. - - - - diff --git a/docs/howtos/cut-a-new-release.md b/docs/howtos/cut-a-new-release.md index 8f7889fbc..759179793 100644 --- a/docs/howtos/cut-a-new-release.md +++ b/docs/howtos/cut-a-new-release.md @@ -35,8 +35,8 @@ **Note:** If you need to manually produce the iOS build for some reason (for example, if CircleCI cannot), someone with a mac needs to do the following steps: 1. If necessary, set up for performing iOS builds using `./libs/verify-ios-environment.sh`. - 2. Run `./build-carthage.sh` in the root of the repository. - 3. Upload the resulting `MozillaAppServices.framework.zip` as an attachment on the github release. + 2. Run `./megazords/ios-rust/build-xcframework.sh` + 3. Upload the resulting `MozillaRustComponents.xcframework.zip` as an attachment on the github release. --- ## Make a new point-release from an existing release that is behind latest main. diff --git a/docs/howtos/locally-published-components-in-ios.md b/docs/howtos/locally-published-components-in-ios.md deleted file mode 100644 index 2921ee09c..000000000 --- a/docs/howtos/locally-published-components-in-ios.md +++ /dev/null @@ -1,24 +0,0 @@ -# Using locally-published components in Firefox for iOS - -It's often important to test work-in-progress changes to this repo against a real-world -consumer project. Here are our current best-practices for approaching this on iOS: - -1. Make a local build of the application-services framework using `./build-carthage.sh`. -1. Checkout and `carthage bootstrap` the consuming app (for example using [these instructions with Firefox for - iOS](https://github.com/mozilla-mobile/firefox-ios#building-the-code)). -1. In the consuming app, replace the application-services framework with a copy of your local build. For example: - - ``` - rm -rf Carthage/Build/iOS/MozillaAppServices.framework - rsync -ad path/to/application-services/Carthage/Build/iOS/MozillaAppServices.framework/ Carthage/Build/iOS/MozillaAppServices.framework/ - ``` -1. Open the consuming app project in Xcode and build it from there. - -After making changes to application-services code, you will need to re-run these steps in order to -copy the latest changes over into the consuming app. - -Firefox for iOS also has a helper script that automates these steps: -[`appservices_local_dev.sh`](https://github.com/mozilla-mobile/firefox-ios/blob/main/appservices_local_dev.sh). - -Note that for firefox-ios specifically, you may also need to copy the Glean `sdk_generator.sh` script -from the appservices build into the root of the firefox-ios repository. diff --git a/libs/verify-ios-ci-environment.sh b/libs/verify-ios-ci-environment.sh index 22729616b..bc8d21832 100755 --- a/libs/verify-ios-ci-environment.sh +++ b/libs/verify-ios-ci-environment.sh @@ -22,11 +22,6 @@ rustup target add "${RUST_TARGETS[@]}" # If you add a dependency below, mention it in building.md in the iOS section! -if ! [[ -x "$(command -v carthage)" ]]; then - echo 'Error: Carthage needs to be installed. See https://github.com/Carthage/Carthage#installing-carthage for install instructions.' >&2 - exit 1 -fi - if ! [[ -x "$(command -v protoc-gen-swift)" ]]; then echo 'Error: swift-protobuf needs to be installed. See https://github.com/apple/swift-protobuf#alternatively-install-via-homebrew for install instructions.' >&2 exit 1 @@ -37,14 +32,6 @@ if ! [[ -x "$(command -v xcpretty)" ]]; then exit 1 fi -# For Xcode 12 make sure EXCLUDED_ARCHS is set to arm architectures otherwise -# the build will fail on lipo due to duplicate architectures. -XCODE_XCCONFIG_FILE=$(pwd)/xcconfig/xcode-12-fix-carthage-lipo.xcconfig -export XCODE_XCCONFIG_FILE - -echo "Running carthage boostrap..." -carthage bootstrap --platform iOS --cache-builds - if [[ ! -d "${PWD}/libs/ios/universal/nss" ]] || [[ ! -d "${PWD}/libs/ios/universal/sqlcipher" ]]; then pushd libs || exit 1 ./build-all.sh ios diff --git a/libs/verify-ios-environment.sh b/libs/verify-ios-environment.sh index 63d207f32..402081d4b 100755 --- a/libs/verify-ios-environment.sh +++ b/libs/verify-ios-environment.sh @@ -19,9 +19,7 @@ fi echo "" echo "Looks good! You can do the following:" -echo "- Build the project:" -echo " ./build-carthage.sh --no-archive" -echo "- Open the Xcode project:" +echo "- Open the XCode project:" echo " open megazords/ios/MozillaAppServices.xcodeproj" echo "- Run the iOS tests:" echo " ./automation/run_ios_tests.sh" diff --git a/megazords/ios-rust/build-xcframework.sh b/megazords/ios-rust/build-xcframework.sh index 1c74e4f45..c0fc37f69 100755 --- a/megazords/ios-rust/build-xcframework.sh +++ b/megazords/ios-rust/build-xcframework.sh @@ -61,10 +61,6 @@ cargo_build () { case $TARGET in x86_64*) LIBS_DIR="$REPO_ROOT/libs/ios/x86_64";; - # TODO: when we want to include crates that depend on SQLCipher or NSS, - # we'll need to distinguish between hardware and simulator builds here - # and link the later against separately-compiled libraries. - # Ref https://github.com/mozilla/application-services/issues/4352. aarch64*) LIBS_DIR="$REPO_ROOT/libs/ios/arm64";; *) diff --git a/megazords/ios/MozillaAppServices.xcodeproj/project.pbxproj b/megazords/ios/MozillaAppServices.xcodeproj/project.pbxproj index f83f12a48..a04e2d813 100644 --- a/megazords/ios/MozillaAppServices.xcodeproj/project.pbxproj +++ b/megazords/ios/MozillaAppServices.xcodeproj/project.pbxproj @@ -69,11 +69,7 @@ BF1A87D025064AC000FED88E /* Sysctl.swift in Sources */ = {isa = PBXBuildFile; fileRef = BF1A87CC25064AC000FED88E /* Sysctl.swift */; }; BF1A87D125064AC000FED88E /* Unreachable.swift in Sources */ = {isa = PBXBuildFile; fileRef = BF1A87CD25064AC000FED88E /* Unreachable.swift */; }; BF1A87D325064B1100FED88E /* sdk_generator.sh in Resources */ = {isa = PBXBuildFile; fileRef = BF1A87D225064B1100FED88E /* sdk_generator.sh */; }; - C852EE9E220A283200A6E79A /* libsqlcipher.a in Frameworks */ = {isa = PBXBuildFile; fileRef = C852EE9D220A283200A6E79A /* libsqlcipher.a */; }; C852EED6220A29FE00A6E79A /* LoginsStorage.swift in Sources */ = {isa = PBXBuildFile; fileRef = C852EECD220A29FE00A6E79A /* LoginsStorage.swift */; }; - C852EEEF220A2E9400A6E79A /* libmegazord_ios.a in Frameworks */ = {isa = PBXBuildFile; fileRef = C852EEEE220A2E9400A6E79A /* libmegazord_ios.a */; }; - CD440A422238A08E003F004B /* SwiftProtobuf.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = EB7DE84C2214D30B00E7CF17 /* SwiftProtobuf.framework */; }; - CD440A452238A703003F004B /* SwiftProtobuf.framework in CopyFiles */ = {isa = PBXBuildFile; fileRef = EB7DE84C2214D30B00E7CF17 /* SwiftProtobuf.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; CD4CFDD3221DFA5100EB3B33 /* LogTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = CD4CFDD2221DFA5100EB3B33 /* LogTest.swift */; }; CD5ECD192716FB88009D10CC /* QuantityMetric.swift in Sources */ = {isa = PBXBuildFile; fileRef = CD5ECD182716FB88009D10CC /* QuantityMetric.swift */; }; CD5ECD1B2716FB99009D10CC /* UrlMetric.swift in Sources */ = {isa = PBXBuildFile; fileRef = CD5ECD1A2716FB99009D10CC /* UrlMetric.swift */; }; @@ -92,14 +88,12 @@ CE3A2F38225BDE5300EA569C /* PlacesTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = CE3A2F37225BDE5300EA569C /* PlacesTests.swift */; }; CE58B2F8242D54340089F091 /* RustViaductFFI.h in Headers */ = {isa = PBXBuildFile; fileRef = CE58B2F7242D54340089F091 /* RustViaductFFI.h */; settings = {ATTRIBUTES = (Public, ); }; }; CE90D1BB23D7570A00FD9A5F /* FxAccountManagerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = CE34DB3C23D0C9640027AD63 /* FxAccountManagerTests.swift */; }; - CE96459C23D7A7D500B662F8 /* SwiftKeychainWrapper.framework in CopyFiles */ = {isa = PBXBuildFile; fileRef = CE96459823D7A77500B662F8 /* SwiftKeychainWrapper.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; CE9FFA13242D4E7B0011029E /* Viaduct.swift in Sources */ = {isa = PBXBuildFile; fileRef = CE9FFA12242D4E7B0011029E /* Viaduct.swift */; }; CEB1A06823D8A42D005BD4DD /* FxAccountMocks.swift in Sources */ = {isa = PBXBuildFile; fileRef = CEB1A06723D8A42D005BD4DD /* FxAccountMocks.swift */; }; CED443CD23CD13E5007E5FA6 /* FxAccountDeviceConstellation.swift in Sources */ = {isa = PBXBuildFile; fileRef = CED443CC23CD13E5007E5FA6 /* FxAccountDeviceConstellation.swift */; }; CEDDBC8E23DB4CD600CFF5AA /* PersistedFirefoxAccount.swift in Sources */ = {isa = PBXBuildFile; fileRef = CEDDBC8D23DB4CD600CFF5AA /* PersistedFirefoxAccount.swift */; }; CEFB1EB022EF708B0001E20F /* ResultError.swift in Sources */ = {isa = PBXBuildFile; fileRef = CEFB1EAF22EF708B0001E20F /* ResultError.swift */; }; D05434A1225680D900FDE4EF /* MozillaAppServices.h in Headers */ = {isa = PBXBuildFile; fileRef = C852EEF2220A3C6800A6E79A /* MozillaAppServices.h */; settings = {ATTRIBUTES = (Public, ); }; }; - EB879D7F221234EB00753DC9 /* MozillaAppServices.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = CE9D202020914D0D00F1C8FA /* MozillaAppServices.framework */; }; EB879D8B22123FD900753DC9 /* LoginsTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = EB879D8A22123FD900753DC9 /* LoginsTests.swift */; }; /* End PBXBuildFile section */ @@ -150,14 +144,13 @@ dstPath = ""; dstSubfolderSpec = 10; files = ( - CE96459C23D7A7D500B662F8 /* SwiftKeychainWrapper.framework in CopyFiles */, - CD440A452238A703003F004B /* SwiftProtobuf.framework in CopyFiles */, ); runOnlyForDeploymentPostprocessing = 0; }; /* End PBXCopyFilesBuildPhase section */ /* Begin PBXFileReference section */ + 1B6FD2C0272B533D00858E16 /* MozillaRustComponents.xcframework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcframework; name = MozillaRustComponents.xcframework; path = "../ios-rust/MozillaRustComponents.xcframework"; sourceTree = ""; }; 1B9B8EFE267439CC00C8A918 /* places.udl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = places.udl; path = ../../src/places.udl; sourceTree = ""; }; 1B9B8F0726743B8800C8A918 /* places.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = places.swift; path = ../../Generated/places.swift; sourceTree = ""; }; 1B9B8F0826743B8800C8A918 /* placesFFI.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = placesFFI.h; path = ../../Generated/placesFFI.h; sourceTree = ""; }; @@ -224,9 +217,7 @@ BF1A87D225064B1100FED88E /* sdk_generator.sh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.sh; name = sdk_generator.sh; path = ../sdk_generator.sh; sourceTree = ""; }; BF1A87D625064B4C00FED88E /* Metrics.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Metrics.swift; sourceTree = ""; }; C852EE9A220A26E600A6E79A /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; - C852EE9D220A283200A6E79A /* libsqlcipher.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libsqlcipher.a; path = ../../libs/ios/universal/sqlcipher/lib/libsqlcipher.a; sourceTree = ""; }; C852EECD220A29FE00A6E79A /* LoginsStorage.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = LoginsStorage.swift; sourceTree = ""; }; - C852EEEE220A2E9400A6E79A /* libmegazord_ios.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libmegazord_ios.a; path = ../../target/universal/release/libmegazord_ios.a; sourceTree = ""; }; C852EEF2220A3C6800A6E79A /* MozillaAppServices.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MozillaAppServices.h; sourceTree = ""; }; CD4CFDD2221DFA5100EB3B33 /* LogTest.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LogTest.swift; sourceTree = ""; }; CD5ECD182716FB88009D10CC /* QuantityMetric.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = QuantityMetric.swift; sourceTree = ""; }; @@ -246,7 +237,6 @@ CE34DB3C23D0C9640027AD63 /* FxAccountManagerTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FxAccountManagerTests.swift; sourceTree = ""; }; CE3A2F37225BDE5300EA569C /* PlacesTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PlacesTests.swift; sourceTree = ""; }; CE58B2F7242D54340089F091 /* RustViaductFFI.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RustViaductFFI.h; sourceTree = ""; }; - CE96459823D7A77500B662F8 /* SwiftKeychainWrapper.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SwiftKeychainWrapper.framework; path = ../../Carthage/Build/iOS/SwiftKeychainWrapper.framework; sourceTree = ""; }; CE9D202020914D0D00F1C8FA /* MozillaAppServices.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = MozillaAppServices.framework; sourceTree = BUILT_PRODUCTS_DIR; }; CE9FFA12242D4E7B0011029E /* Viaduct.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Viaduct.swift; sourceTree = ""; }; CEB1A06723D8A42D005BD4DD /* FxAccountMocks.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FxAccountMocks.swift; sourceTree = ""; }; @@ -254,7 +244,6 @@ CEDDBC8D23DB4CD600CFF5AA /* PersistedFirefoxAccount.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PersistedFirefoxAccount.swift; sourceTree = ""; }; CEFB1EAF22EF708B0001E20F /* ResultError.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ResultError.swift; sourceTree = ""; }; D9FA8C532644A170008344BF /* HistoryMetadata.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HistoryMetadata.swift; sourceTree = ""; }; - EB7DE84C2214D30B00E7CF17 /* SwiftProtobuf.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SwiftProtobuf.framework; path = ../../Carthage/Build/iOS/SwiftProtobuf.framework; sourceTree = ""; }; EB879D7A221234EB00753DC9 /* MozillaAppServicesTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = MozillaAppServicesTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; EB879D7E221234EB00753DC9 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; EB879D8A22123FD900753DC9 /* LoginsTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LoginsTests.swift; sourceTree = ""; }; @@ -268,8 +257,6 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( - C852EEEF220A2E9400A6E79A /* libmegazord_ios.a in Frameworks */, - C852EE9E220A283200A6E79A /* libsqlcipher.a in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -277,8 +264,6 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( - CD440A422238A08E003F004B /* SwiftProtobuf.framework in Frameworks */, - EB879D7F221234EB00753DC9 /* MozillaAppServices.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -588,10 +573,7 @@ CE9D203720914D4800F1C8FA /* Frameworks */ = { isa = PBXGroup; children = ( - CE96459823D7A77500B662F8 /* SwiftKeychainWrapper.framework */, - EB7DE84C2214D30B00E7CF17 /* SwiftProtobuf.framework */, - C852EE9D220A283200A6E79A /* libsqlcipher.a */, - C852EEEE220A2E9400A6E79A /* libmegazord_ios.a */, + 1B6FD2C0272B533D00858E16 /* MozillaRustComponents.xcframework */, ); name = Frameworks; sourceTree = ""; @@ -652,8 +634,8 @@ CEEA12EF20AA1D630018998A /* Build Rust libraries */, BF1A87712506468F00FED88E /* Generate Glean metrics */, CE9D201B20914D0D00F1C8FA /* Sources */, - CE9D201C20914D0D00F1C8FA /* Frameworks */, CE9D201D20914D0D00F1C8FA /* Headers */, + CE9D201C20914D0D00F1C8FA /* Frameworks */, CE9D201E20914D0D00F1C8FA /* Resources */, ); buildRules = ( @@ -663,6 +645,8 @@ dependencies = ( ); name = MozillaAppServices; + packageProductDependencies = ( + ); productName = Logins; productReference = CE9D202020914D0D00F1C8FA /* MozillaAppServices.framework */; productType = "com.apple.product-type.framework"; @@ -693,7 +677,7 @@ isa = PBXProject; attributes = { LastSwiftUpdateCheck = 1010; - LastUpgradeCheck = 1300; + LastUpgradeCheck = 1320; ORGANIZATIONNAME = Mozilla; TargetAttributes = { CE9D201F20914D0D00F1C8FA = { @@ -714,6 +698,8 @@ Base, ); mainGroup = CE9D201620914D0D00F1C8FA; + packageReferences = ( + ); productRefGroup = CE9D202120914D0D00F1C8FA /* Products */; projectDirPath = ""; projectRoot = ""; @@ -778,7 +764,7 @@ ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "bash $PWD/../../build-scripts/xc-universal-binary.sh libmegazord_ios.a megazord_ios $PWD/../.. $buildvariant\n\n\n"; + shellScript = "bash $PWD/../../megazords/ios-rust/build-xcframework.sh\n\n\n"; }; /* End PBXShellScriptBuildPhase section */ @@ -795,6 +781,7 @@ BF1A87B625064A8100FED88E /* UuidMetric.swift in Sources */, BF1A87AE25064A8100FED88E /* BooleanMetric.swift in Sources */, CEFB1EB022EF708B0001E20F /* ResultError.swift in Sources */, + CE1B09A3231863D7006226E1 /* KeychainWrapper+.swift in Sources */, CE1B09A5231865BC006226E1 /* FxAccountStorage.swift in Sources */, 1BD3484C27A0DF8900AA1422 /* KeychainWrapperSubscript.swift in Sources */, BF1A87B525064A8100FED88E /* CounterMetric.swift in Sources */, @@ -902,7 +889,6 @@ buildSettings = { CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; IPHONEOS_DEPLOYMENT_TARGET = 12.0; - SWIFT_COMPILATION_MODE = wholemodule; VALIDATE_WORKSPACE = NO; }; name = Release; @@ -910,20 +896,29 @@ CE9D202920914D0D00F1C8FA /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { + "EXCLUDED_ARCHS[sdk=iphonesimulator*]" = arm64; + FRAMEWORK_SEARCH_PATHS = ( + "$(PROJECT_DIR)-rust/MozillaRustComponents.xcframework/ios-arm64_x86_64-simulator", + "$(PROJECT_DIR)-rust/MozillaRustComponents.xcframework/ios-arm64", + ); MACH_O_TYPE = mh_dylib; OTHER_LDFLAGS = "-lc++"; PRODUCT_BUNDLE_IDENTIFIER = org.mozilla.MozillaAppServices; - VALIDATE_WORKSPACE = NO; + VALIDATE_WORKSPACE = YES; }; name = Debug; }; CE9D202A20914D0D00F1C8FA /* Release */ = { isa = XCBuildConfiguration; buildSettings = { + FRAMEWORK_SEARCH_PATHS = ( + "$(PROJECT_DIR)-rust/MozillaRustComponents.xcframework/ios-arm64_x86_64-simulator", + "$(PROJECT_DIR)-rust/MozillaRustComponents.xcframework/ios-arm64", + ); MACH_O_TYPE = mh_dylib; OTHER_LDFLAGS = "-lc++"; PRODUCT_BUNDLE_IDENTIFIER = org.mozilla.MozillaAppServices; - VALIDATE_WORKSPACE = NO; + VALIDATE_WORKSPACE = YES; }; name = Release; }; @@ -939,7 +934,7 @@ OTHER_LDFLAGS = "-lc++"; PRODUCT_BUNDLE_IDENTIFIER = mozilla.org.MozillaAppServicesTests; PRODUCT_NAME = "$(TARGET_NAME)"; - VALIDATE_WORKSPACE = NO; + VALIDATE_WORKSPACE = YES; }; name = Debug; }; @@ -955,7 +950,7 @@ OTHER_LDFLAGS = "-lc++"; PRODUCT_BUNDLE_IDENTIFIER = mozilla.org.MozillaAppServicesTests; PRODUCT_NAME = "$(TARGET_NAME)"; - VALIDATE_WORKSPACE = NO; + VALIDATE_WORKSPACE = YES; }; name = Release; }; diff --git a/megazords/ios/MozillaAppServices.xcodeproj/xcshareddata/xcschemes/MozillaAppServices.xcscheme b/megazords/ios/MozillaAppServices.xcodeproj/xcshareddata/xcschemes/MozillaAppServices.xcscheme index d34a16f92..b8ac3c6d0 100644 --- a/megazords/ios/MozillaAppServices.xcodeproj/xcshareddata/xcschemes/MozillaAppServices.xcscheme +++ b/megazords/ios/MozillaAppServices.xcodeproj/xcshareddata/xcschemes/MozillaAppServices.xcscheme @@ -1,6 +1,6 @@