Skip to content

Commit

Permalink
Create targets for Authenticator and tests
Browse files Browse the repository at this point in the history
  • Loading branch information
crazytonyli committed Jun 19, 2024
1 parent c910c4e commit 34c99c5
Show file tree
Hide file tree
Showing 24 changed files with 2,819 additions and 466 deletions.
27 changes: 18 additions & 9 deletions Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ end
def shared_test_pods
pod 'OHHTTPStubs/Swift', '~> 9.1.0'
pod 'OCMock', '~> 3.4.3'
pod 'Expecta', '1.0.6'
pod 'Specta', '1.0.7'
gutenberg_pod
end

Expand Down Expand Up @@ -304,25 +306,32 @@ end
# Make all pods that are not shared across multiple targets into static frameworks by overriding the static_framework? function to return true
# Linking the shared frameworks statically would lead to duplicate symbols
# A future version of CocoaPods may make this easier to do. See https://github.com/CocoaPods/CocoaPods/issues/7428
shared_targets = ['WordPressFlux']
shared_targets = %w[WordPressFlux]
dyanmic_framework_pods = %w[WordPressFlux WordPressShared WordPressKit WordPressUI SVProgressHUD Gridicons NSURL+IDN wpxmlrpc NSObject-SafeExpectations UIDeviceIdentifier]
# Statically linking Sentry results in a conflict with `NSDictionary.objectAtKeyPath`, but dynamically
# linking it resolves this.
dyanmic_framework_pods += %w[Sentry SentryPrivate]
pre_install do |installer|
static = []
dynamic = []
installer.pod_targets.each do |pod|
# Statically linking Sentry results in a conflict with `NSDictionary.objectAtKeyPath`, but dynamically
# linking it resolves this.
if %w[Sentry SentryPrivate].include? pod.name
dynamic << pod
next
use_dynamic_frameworks = false
if dyanmic_framework_pods.include? pod.name
use_dynamic_frameworks = true
end

# If this pod is a dependency of one of our shared targets, it must be linked dynamically
if pod.target_definitions.any? { |t| shared_targets.include? t.name }
use_dynamic_frameworks = true
end

if use_dynamic_frameworks
dynamic << pod
next
pod.instance_variable_set(:@build_type, Pod::BuildType.dynamic_framework)
else
static << pod
pod.instance_variable_set(:@build_type, Pod::BuildType.static_framework)
end
static << pod
pod.instance_variable_set(:@build_type, Pod::BuildType.static_framework)
end
puts "Installing #{static.count} pods as static frameworks"
puts "Installing #{dynamic.count} pods as dynamic frameworks"
Expand Down
10 changes: 9 additions & 1 deletion Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ PODS:
- CocoaLumberjack/Core
- CropViewController (2.5.3)
- Down (0.6.6)
- Expecta (1.0.6)
- FSInteractiveMap (0.1.0)
- Gifu (3.3.1)
- Gravatar (2.0.0)
Expand Down Expand Up @@ -61,6 +62,7 @@ PODS:
- SentryPrivate (= 8.21.0)
- SentryPrivate (8.21.0)
- Sodium (0.9.1)
- Specta (1.0.7)
- Starscream (4.0.8)
- SVProgressHUD (2.2.5)
- SwiftLint (0.54.0)
Expand Down Expand Up @@ -109,6 +111,7 @@ DEPENDENCIES:
- CocoaLumberjack/Swift (~> 3.0)
- CropViewController (= 2.5.3)
- Down (~> 0.6.6)
- Expecta (= 1.0.6)
- FSInteractiveMap (from `https://github.com/wordpress-mobile/FSInteractiveMap.git`, tag `0.2.0`)
- Gifu (= 3.3.1)
- Gravatar (= 2.0.0)
Expand All @@ -123,6 +126,7 @@ DEPENDENCIES:
- OCMock (~> 3.4.3)
- OHHTTPStubs/Swift (~> 9.1.0)
- Reachability (~> 3.7)
- Specta (= 1.0.7)
- Starscream (~> 4.0)
- SVProgressHUD (= 2.2.5)
- SwiftLint (= 0.54.0)
Expand All @@ -148,6 +152,7 @@ SPEC REPOS:
- CocoaLumberjack
- CropViewController
- Down
- Expecta
- Gifu
- Gravatar
- GravatarUI
Expand All @@ -163,6 +168,7 @@ SPEC REPOS:
- Sentry
- SentryPrivate
- Sodium
- Specta
- Starscream
- SVProgressHUD
- SwiftLint
Expand Down Expand Up @@ -201,6 +207,7 @@ SPEC CHECKSUMS:
CocoaLumberjack: 78abfb691154e2a9df8ded4350d504ee19d90732
CropViewController: a5c143548a0fabcd6cc25f2d26e40460cfb8c78c
Down: 71bf4af3c04fa093e65dffa25c4b64fa61287373
Expecta: 3b6bd90a64b9a1dcb0b70aa0e10a7f8f631667d5
FSInteractiveMap: a396f610f48b76cb540baa87139d056429abda86
Gifu: 416d4e38c4c2fed012f019e0a1d3ffcb58e5b842
Gravatar: 54fc63ea6298e9afca7329007815be25868f1dfe
Expand All @@ -218,6 +225,7 @@ SPEC CHECKSUMS:
Sentry: ebc12276bd17613a114ab359074096b6b3725203
SentryPrivate: d651efb234cf385ec9a1cdd3eff94b5e78a0e0fe
Sodium: 23d11554ecd556196d313cf6130d406dfe7ac6da
Specta: 3e1bd89c3517421982dc4d1c992503e48bd5fe66
Starscream: 19b5533ddb925208db698f0ac508a100b884a1b9
SVProgressHUD: 1428aafac632c1f86f62aa4243ec12008d7a51d6
SwiftLint: c1de071d9d08c8aba837545f6254315bc900e211
Expand All @@ -237,6 +245,6 @@ SPEC CHECKSUMS:
ZendeskSupportSDK: 3a8e508ab1d9dd22dc038df6c694466414e037ba
ZIPFoundation: d170fa8e270b2a32bef9dcdcabff5b8f1a5deced

PODFILE CHECKSUM: eb831d2230dd63c606ba18709a4ad74f04eb6dc8
PODFILE CHECKSUM: 34cac181bfa492c6308805218d23f0cb641ae64d

COCOAPODS: 1.15.2
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
${SRCROOT}/../Scripts/BuildPhases/Authenticator/CopyResources.sh
${PODS_ROOT}/Target Support Files/WordPressAuthenticator/WordPressAuthenticator-Unit-Tests-resources.sh
${SRCROOT}/../WordPressAuthenticator/Sources/Resources/WordPressAuthenticatorResources.bundle
${PODS_ROOT}/SVProgressHUD/SVProgressHUD/SVProgressHUD.bundle
${PODS_CONFIGURATION_BUILD_DIR}/Gridicons/GridiconsAssets.bundle
${PODS_CONFIGURATION_BUILD_DIR}/WordPressUI/WordPressUIResources.bundle
${PODS_CONFIGURATION_BUILD_DIR}/WordPressShared/WordPressShared.bundle
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/WordPressAuthenticatorResources.bundle
${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/SVProgressHUD.bundle
${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/GridiconsAssets.bundle
${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/WordPressUIResources.bundle
${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/WordPressShared.bundle
147 changes: 147 additions & 0 deletions Scripts/BuildPhases/Authenticator/CopyResources.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,147 @@
#!/bin/sh
set -e
set -u
set -o pipefail

function on_error {
echo "$(realpath -mq "${0}"):$1: error: Unexpected failure"
}
trap 'on_error $LINENO' ERR

if [ -z ${UNLOCALIZED_RESOURCES_FOLDER_PATH+x} ]; then
# If UNLOCALIZED_RESOURCES_FOLDER_PATH is not set, then there's nowhere for us to copy
# resources to, so exit 0 (signalling the script phase was successful).
exit 0
fi

mkdir -p "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}"

RESOURCES_TO_COPY=${PODS_ROOT}/resources-to-copy-${TARGETNAME}.txt
> "$RESOURCES_TO_COPY"

XCASSET_FILES=()

# This protects against multiple targets copying the same framework dependency at the same time. The solution
# was originally proposed here: https://lists.samba.org/archive/rsync/2008-February/020158.html
RSYNC_PROTECT_TMP_FILES=(--filter "P .*.??????")

case "${TARGETED_DEVICE_FAMILY:-}" in
1,2)
TARGET_DEVICE_ARGS="--target-device ipad --target-device iphone"
;;
1)
TARGET_DEVICE_ARGS="--target-device iphone"
;;
2)
TARGET_DEVICE_ARGS="--target-device ipad"
;;
3)
TARGET_DEVICE_ARGS="--target-device tv"
;;
4)
TARGET_DEVICE_ARGS="--target-device watch"
;;
*)
TARGET_DEVICE_ARGS="--target-device mac"
;;
esac

install_resource()
{
if [[ "$1" = /* ]] ; then
RESOURCE_PATH="$1"
else
RESOURCE_PATH="${PODS_ROOT}/$1"
fi
if [[ ! -e "$RESOURCE_PATH" ]] ; then
cat << EOM
error: Resource "$RESOURCE_PATH" not found. Run 'pod install' to update the copy resources script.
EOM
exit 1
fi
case $RESOURCE_PATH in
*.storyboard)
echo "ibtool --reference-external-strings-file --errors --warnings --notices --minimum-deployment-target ${!DEPLOYMENT_TARGET_SETTING_NAME} --output-format human-readable-text --compile ${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename \"$RESOURCE_PATH\" .storyboard`.storyboardc $RESOURCE_PATH --sdk ${SDKROOT} ${TARGET_DEVICE_ARGS}" || true
ibtool --reference-external-strings-file --errors --warnings --notices --minimum-deployment-target ${!DEPLOYMENT_TARGET_SETTING_NAME} --output-format human-readable-text --compile "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename \"$RESOURCE_PATH\" .storyboard`.storyboardc" "$RESOURCE_PATH" --sdk "${SDKROOT}" ${TARGET_DEVICE_ARGS}
;;
*.xib)
echo "ibtool --reference-external-strings-file --errors --warnings --notices --minimum-deployment-target ${!DEPLOYMENT_TARGET_SETTING_NAME} --output-format human-readable-text --compile ${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename \"$RESOURCE_PATH\" .xib`.nib $RESOURCE_PATH --sdk ${SDKROOT} ${TARGET_DEVICE_ARGS}" || true
ibtool --reference-external-strings-file --errors --warnings --notices --minimum-deployment-target ${!DEPLOYMENT_TARGET_SETTING_NAME} --output-format human-readable-text --compile "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename \"$RESOURCE_PATH\" .xib`.nib" "$RESOURCE_PATH" --sdk "${SDKROOT}" ${TARGET_DEVICE_ARGS}
;;
*.framework)
echo "mkdir -p ${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" || true
mkdir -p "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}"
echo "rsync --delete -av "${RSYNC_PROTECT_TMP_FILES[@]}" $RESOURCE_PATH ${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" || true
rsync --delete -av "${RSYNC_PROTECT_TMP_FILES[@]}" "$RESOURCE_PATH" "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}"
;;
*.xcdatamodel)
echo "xcrun momc \"$RESOURCE_PATH\" \"${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$RESOURCE_PATH"`.mom\"" || true
xcrun momc "$RESOURCE_PATH" "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$RESOURCE_PATH" .xcdatamodel`.mom"
;;
*.xcdatamodeld)
echo "xcrun momc \"$RESOURCE_PATH\" \"${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$RESOURCE_PATH" .xcdatamodeld`.momd\"" || true
xcrun momc "$RESOURCE_PATH" "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$RESOURCE_PATH" .xcdatamodeld`.momd"
;;
*.xcmappingmodel)
echo "xcrun mapc \"$RESOURCE_PATH\" \"${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$RESOURCE_PATH" .xcmappingmodel`.cdm\"" || true
xcrun mapc "$RESOURCE_PATH" "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$RESOURCE_PATH" .xcmappingmodel`.cdm"
;;
*.xcassets)
ABSOLUTE_XCASSET_FILE="$RESOURCE_PATH"
XCASSET_FILES+=("$ABSOLUTE_XCASSET_FILE")
;;
*)
echo "$RESOURCE_PATH" || true
echo "$RESOURCE_PATH" >> "$RESOURCES_TO_COPY"
;;
esac
}
if [[ "$CONFIGURATION" == "Debug" ]]; then
install_resource "${PODS_ROOT}/SVProgressHUD/SVProgressHUD/SVProgressHUD.bundle"
install_resource "${PODS_CONFIGURATION_BUILD_DIR}/Gridicons/GridiconsAssets.bundle"
install_resource "${PODS_CONFIGURATION_BUILD_DIR}/WordPressUI/WordPressUIResources.bundle"
install_resource "${PODS_CONFIGURATION_BUILD_DIR}/WordPressShared/WordPressShared.bundle"
fi
if [[ "$CONFIGURATION" == "Release" ]]; then
install_resource "${PODS_ROOT}/SVProgressHUD/SVProgressHUD/SVProgressHUD.bundle"
install_resource "${PODS_CONFIGURATION_BUILD_DIR}/Gridicons/GridiconsAssets.bundle"
install_resource "${PODS_CONFIGURATION_BUILD_DIR}/WordPressUI/WordPressUIResources.bundle"
install_resource "${PODS_CONFIGURATION_BUILD_DIR}/WordPressShared/WordPressShared.bundle"
fi
if [[ "$CONFIGURATION" == "Release-Internal" ]]; then
install_resource "${PODS_ROOT}/SVProgressHUD/SVProgressHUD/SVProgressHUD.bundle"
install_resource "${PODS_CONFIGURATION_BUILD_DIR}/Gridicons/GridiconsAssets.bundle"
install_resource "${PODS_CONFIGURATION_BUILD_DIR}/WordPressUI/WordPressUIResources.bundle"
install_resource "${PODS_CONFIGURATION_BUILD_DIR}/WordPressShared/WordPressShared.bundle"
fi
if [[ "$CONFIGURATION" == "Release-Alpha" ]]; then
install_resource "${PODS_ROOT}/SVProgressHUD/SVProgressHUD/SVProgressHUD.bundle"
install_resource "${PODS_CONFIGURATION_BUILD_DIR}/Gridicons/GridiconsAssets.bundle"
install_resource "${PODS_CONFIGURATION_BUILD_DIR}/WordPressUI/WordPressUIResources.bundle"
install_resource "${PODS_CONFIGURATION_BUILD_DIR}/WordPressShared/WordPressShared.bundle"
fi

mkdir -p "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}"
rsync -avr --copy-links --no-relative --exclude '*/.svn/*' --files-from="$RESOURCES_TO_COPY" / "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}"
if [[ "${ACTION}" == "install" ]] && [[ "${SKIP_INSTALL}" == "NO" ]]; then
mkdir -p "${INSTALL_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}"
rsync -avr --copy-links --no-relative --exclude '*/.svn/*' --files-from="$RESOURCES_TO_COPY" / "${INSTALL_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}"
fi
rm -f "$RESOURCES_TO_COPY"

if [[ -n "${WRAPPER_EXTENSION}" ]] && [ "`xcrun --find actool`" ] && [ -n "${XCASSET_FILES:-}" ]
then
# Find all other xcassets (this unfortunately includes those of path pods and other targets).
OTHER_XCASSETS=$(find -L "$PWD" -iname "*.xcassets" -type d)
while read line; do
if [[ $line != "${PODS_ROOT}*" ]]; then
XCASSET_FILES+=("$line")
fi
done <<<"$OTHER_XCASSETS"

if [ -z ${ASSETCATALOG_COMPILER_APPICON_NAME+x} ]; then
printf "%s\0" "${XCASSET_FILES[@]}" | xargs -0 xcrun actool --output-format human-readable-text --notices --warnings --platform "${PLATFORM_NAME}" --minimum-deployment-target "${!DEPLOYMENT_TARGET_SETTING_NAME}" ${TARGET_DEVICE_ARGS} --compress-pngs --compile "${BUILT_PRODUCTS_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}"
else
printf "%s\0" "${XCASSET_FILES[@]}" | xargs -0 xcrun actool --output-format human-readable-text --notices --warnings --platform "${PLATFORM_NAME}" --minimum-deployment-target "${!DEPLOYMENT_TARGET_SETTING_NAME}" ${TARGET_DEVICE_ARGS} --compress-pngs --compile "${BUILT_PRODUCTS_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" --app-icon "${ASSETCATALOG_COMPILER_APPICON_NAME}" --output-partial-info-plist "${TARGET_TEMP_DIR}/assetcatalog_generated_info_cocoapods.plist"
fi
fi
12 changes: 12 additions & 0 deletions Scripts/BuildPhases/Authenticator/EmbedFrameworks-input.xcfilelist
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
${SRCROOT}/../Scripts/BuildPhases/Authenticator/EmbedFrameworks.sh
${BUILT_PRODUCTS_DIR}/Gridicons/Gridicons.framework
${BUILT_PRODUCTS_DIR}/NSObject-SafeExpectations/NSObject_SafeExpectations.framework
${BUILT_PRODUCTS_DIR}/NSURL+IDN/NSURL_IDN.framework
${BUILT_PRODUCTS_DIR}/SVProgressHUD/SVProgressHUD.framework
${BUILT_PRODUCTS_DIR}/Sentry/Sentry.framework
${BUILT_PRODUCTS_DIR}/SentryPrivate/SentryPrivate.framework
${BUILT_PRODUCTS_DIR}/UIDeviceIdentifier/UIDeviceIdentifier.framework
${BUILT_PRODUCTS_DIR}/WordPressKit/WordPressKit.framework
${BUILT_PRODUCTS_DIR}/WordPressShared/WordPressShared.framework
${BUILT_PRODUCTS_DIR}/WordPressUI/WordPressUI.framework
${BUILT_PRODUCTS_DIR}/wpxmlrpc/wpxmlrpc.framework
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Gridicons.framework
${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/NSObject_SafeExpectations.framework
${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/NSURL_IDN.framework
${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/SVProgressHUD.framework
${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Sentry.framework
${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/SentryPrivate.framework
${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/UIDeviceIdentifier.framework
${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/WordPressKit.framework
${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/WordPressShared.framework
${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/WordPressUI.framework
${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/wpxmlrpc.framework
Loading

0 comments on commit 34c99c5

Please sign in to comment.