منظمة النكهات في Flutter

ما هي النكهات؟


تخيل الموقف: هناك تطبيق يحتوي على تحليلات. هناك فريق تطوير واختبار ومستخدمين نهائيين. يستخدم هؤلاء وهؤلاء إصدارًا واحدًا من التطبيق. لنفترض أننا نريد تحليل مدى أهمية الميزة أ للمستخدمين ، فماذا نفعل في هذه الحالة؟ نذهب إلى التحليلات ونرى عدد استخدامات هذه الميزة (على سبيل المثال ، الانتقالات إلى الشاشة). لكن ماذا نرى: عدد باهظ من التحولات ، وهو أمر مستحيل بأي حال من الأحوال مع الجمهور الحالي ، وكانت جميع هذه التحولات في فترة زمنية معينة. نذهب أبعد من ذلك ونفهم أنه في هذا الوقت تم إجراء اختبارات لهذه الميزة. وقبل ذلك بقليل تطورها. في نفس الوقت ، تم إرسال التحليلات أيضًا. خلاصة القول: التحليلات قذرة ودون المستوى.


هنا يمكنك استبدال كلمة تحليلات بأي كلمة أخرى: إشعارات الدفع ، وتقارير الأعطال ، وما إلى ذلك.


وفي هذه الحالة ، يتم حفظنا بتقسيم التطبيق إلى نسختين تختلف بشكل طفيف ، على سبيل المثال ، Bundle ID (اسم الحزمة). يستخدم المطورون والمختبرون إصدار مطورًا خاصًا فقط ، ويستخدم المستخدمون إصدار مبيعات.


هذه مجرد واحدة من مهام النكهات. هنا سيتم استخدام النكهة ، لأن هذا هو الاسم الذي يستخدمه Flutter. الأشخاص الذين هم على دراية بتطوير Android ، أعتقد أنهم تعرفوا على الفور على هذه الآلية.



المنكهة رفرفة؟


حسنًا ، لقد توصلنا إلى المهمة. ولكن كيف يتم تنفيذه؟ هل كل شيء بسيط كما يقولون؟
دعنا نقرر على الفور: تنظيم النكهات مهمة أصلية بحتة. لن تكون المعلومات الخاصة بهم متاحة من كود السهام. لذلك ، بالنسبة لأساليب التنظيم ، سنذهب إلى تطوير الهاتف المحمول الأصلي.


ذكري المظهر


. android. : « buildType?», .


, , :


flavorDimensions "release-type"

    productFlavors {
        dev {
            dimension "release-type"
            applicationIdSuffix  ".dev"
            versionNameSuffix "-dev"
        }

        prod {
            dimension "release-type"
        }
    }

, :


flutter run --flavor dev

android .


: « buildType?» : Flutter buildType . , .


.
, builtTypes. IOS.
:


AndroidIOS
build typesbuild configurations
flavorstargets

— , ( ). flavor’ target’ — .


, , «»...


Runner — .


, target flavors iOS . , Flutter . , . . .


IOS


: (dev, prod, ).


:


  1. .
  2. .
  3. !

.



: dev, prod. :


    #include "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug-dev.xcconfig"
    #include "Generated.xcconfig"
    #include "common.xcconfig"

    bundle_suffix=.dev
    IDENTIFIER=$(identifier)$(bundle_suffix)

, bundle_suffix.


, Flutter Release Debug. bundle_suffix. , IDE.


IDENTIFIER — .


, :


ios/Flutter/dev.xcconfig
ios/Flutter/prod.xcconfig

XCode ( , ). Runner → New File → Configuration Settings File → .


Build Configurations. .


. Runner.xcworkspace Xcode Project.


«+» Configurations : Release Debug, .


:



, , IOS .


Scheme


, .



. : — Runner.
Edit Scheme .


Info.plist


(: ) — Bundle Identifier Info.plist


$(PRODUCT_BUNDLE_IDENTIFIER)$(bundle_suffix)

...


, , Android , fastlane gym iOS — . , IOS - … .


No Provisioning Profile


— . , .


, Info.plist , gym PRODUCT_BUNDLE_IDENTIFIER, .
common.xcconfig IDENTIFIER? .


, , , PRODUCT_BUNDLE_IDENTIFIER.


:


identifier=your.bundle.identifier

include User Defined
IDENTIFIER:


#include "common.xcconfig"

IDENTIFIER=$(identifier)$(bundle_suffix)

Xcode. Build Settings:



Product Bundle Identifier ( Packaging):



:


$(IDENTIFIER)


Info.plist bundle suffix, :


$(PRODUCT_BUNFLE_IDENTIFIER)

. .


bundle id


. Firebase, ( ).


— google-services.json(Google-Services.Info.plist). Android : flavor’ .


IOS - .



, . :



: XCode. . XCode — IDE, Add to target.
.



, . - , .


Run Script (setup firebase ):



, !


, :


# Name of the resource we're selectively copying
GOOGLESERVICE_INFO_PLIST=GoogleService-Info.plist

# Get references to dev and prod versions of the GoogleService-Info.plist
# NOTE: These should only live on the file system and should NOT be part of the target (since we'll be adding them to the target manually)
GOOGLESERVICE_INFO_DEV=${PROJECT_DIR}/${TARGET_NAME}/Firebase/dev/${GOOGLESERVICE_INFO_PLIST}
GOOGLESERVICE_INFO_PROD=${PROJECT_DIR}/${TARGET_NAME}/Firebase/prod/${GOOGLESERVICE_INFO_PLIST}

# Make sure the dev version of GoogleService-Info.plist exists
echo "Looking for ${GOOGLESERVICE_INFO_PLIST} in ${GOOGLESERVICE_INFO_DEV}"
if [ ! -f $GOOGLESERVICE_INFO_DEV ]
then
echo "No Development GoogleService-Info.plist found. Please ensure it's in the proper directory."
exit 1 # 1
fi

# Make sure the prod version of GoogleService-Info.plist exists
echo "Looking for ${GOOGLESERVICE_INFO_PLIST} in ${GOOGLESERVICE_INFO_PROD}"
if [ ! -f $GOOGLESERVICE_INFO_PROD ]
then
echo "No Production GoogleService-Info.plist found. Please ensure it's in the proper directory."
exit 1 # 1
fi

# Get a reference to the destination location for the GoogleService-Info.plist
PLIST_DESTINATION=${BUILT_PRODUCTS_DIR}/${PRODUCT_NAME}.app
echo "Will copy ${GOOGLESERVICE_INFO_PLIST} to final destination: ${PLIST_DESTINATION}"

# Copy over the prod GoogleService-Info.plist for Release builds
if [[ "${CONFIGURATION}" == *-prod ]]
then
echo "Using ${GOOGLESERVICE_INFO_PROD}"
cp "${GOOGLESERVICE_INFO_PROD}" "${PLIST_DESTINATION}"
else
echo "Using ${GOOGLESERVICE_INFO_DEV}"
cp "${GOOGLESERVICE_INFO_DEV}" "${PLIST_DESTINATION}"
fi


. , , Flutter ( ). , . .


All Articles