5

私はアプリを持っており、それを異なる UI を持つ 3 つの異なるアプリとしてブランド化したいと考えています。

Xcodeを直接使用したくありません。

これまでのところ、さまざまなターゲットを作成し、そのように画像をドラッグアンドドロップするという非常に多くのソリューションを見つけました

しかし、私はこのブランディング作業を Xcode の外で行うつもりです



手伝ってください !

4

1 に答える 1

2

これで、Xcode を開かずにコードをビルドできます

ブランディング ( UI、ビルド設定、機能)

  • UI
    • アプリのアイコンとその他のアイコン
    • iTunes アートワーク
  • ビルド設定
    • アプリ名
    • バンドル識別子
    • プロビジョニング プロファイル
    • コード署名 ID
  • 機能的
    • ブランド固有の URL (ログイン、ログアウト、リソース取得など)

ターミナルの使用

Branding.sh

   #Author: Durai Amuthan(h.duraiamuthan@gmail.com)
#This is to achieve multiple branding of an iOS app by configuring the variables below

#************ Configuring the brand starts ************

#Directory path where .xcworkspace or .xcodeproj exists
PathOfProjectDirectory=/Users/Shared/Jenkins/Documents/JenkinsTestNuu/New/

#Path where info.plist exists
PathOfInfoPlist=$PathOfProjectDirectory/XxYyZz

#Path to icons where new iTunesArtwork and application icon exixts
#Note: Make sure proper naming conventions of file has been followed
PathOfNewIcons=/Users/Shared/Jenkins/Documents/icons-two

#Path to asset resource where you have kept your application icon.
PathOfAppIconSet=$PathOfProjectDirectory/XxYyZz/Icon.xcassets/AppIcon.appiconset

#Path where do you want the .app file has to be kept
PathToApp=/Users/Shared/Jenkins/Documents/JenkinsTestNuu/app

#Path where do you want the .ipa file has to kept
PathToIpa=/Users/Shared/Jenkins/Documents/JenkinsTestNuu/ipa

#Cocoapods project or project that involves more than one modules are scheme based
isWorkspaceBased=true

#Path of the Project (.xcodeproj) - applicable for workspace(.xcworkspace) based project
PathofProjectFile=$PathOfProjectDirectory/XxYyZz.xcodeproj

#Path of the Workspace (.xcworkspace)
PathofWorkspaceFile=$PathOfProjectDirectory/XxYyZz.xcworkspace

#Name of the target - applicable only for non-workspace(.xcodeproj)  based projects
Target=XxYyZz

#Scheme of the iOS app
Scheme=XxYyZz

#To ascertain Cocoapods has been used or not
isCocoaPodsBased=true

#Configuration of the app (Debug -(Development) or Release(Adhoc or Distribution))
Config=Release

#For giving access to signing idetity found in KeyChain
LoginKeychainPath=/Users/Shared/Jenkins/Library/Keychains/login.keychain
LoginKeyChainPassword=xxyyzz

#Name of the code signing identity.You can find the name in Keychain or xcode build setting
CodeSigningIdentity='iPhone Distribution: Xx Yy Zz Limited (3Z5MHUYJ2L)'

#Path of the provisioning profile
PathToMobileProvision=/Users/Shared/Jenkins/Desktop/BrandingTest.mobileprovision

#UUID value found inside Provisioning profile has to be given
#Do not forget to install provisiong profile in the system
ProvisioningProfileIdentity=6e6506e9-8233-4886-9084-zf21e8f8bbae

#Bundle identifier of the app
BundleIdentifier=com.xxyy.zz

#AppVersion of the app
AppVersion=2.2.2

#App Name
Appname=Two

#************ Configuring the brand ends ************

#** Creatting the build based on configuration starts **

cd $PathOfInfoPlist
echo "****************** Setting App Name ******************"
/usr/libexec/PlistBuddy -c "Set :CFBundleName $Appname" info.plist
/usr/libexec/PlistBuddy -c "Set :CFBundleDisplayName $Appname" info.plist
echo "app name has been set as $Appname"

cd $PathOfProjectDirectory
echo "****************** Setting AppVersion ******************"
/usr/bin/agvtool new-marketing-AppVersion $AppVersion
/usr/bin/agvtool new-AppVersion -all $AppVersion

echo "****************** Changing app icons & iTunes Artwork ******************"
cp -R $PathOfNewIcons/*.png $PathOfAppIconSet
echo "App icons has been changed at $PathOfNewIcons"
cp -R $PathOfNewIcons/iTunesArtwork@2x $PathOfProjectDirectory/XxYyZz
cp -R $PathOfNewIcons/iTunesArtwork $PathOfProjectDirectory/XxYyZz
echo "iTunesArtwork has been changed at $PathOfProjectDirectory"

#Unlock login keychain
security unlock-keychain -p $LoginKeyChainPassword $LoginKeychainPath
if $isCocoaPodsBased == 'true'
then
echo "****************** Installing Cocoapods **********************"
/usr/local/bin/pod install
echo "Cocoapods has been installed"
fi

echo "****************** Creating .app ******************"
if $isWorkspaceBased == 'true'
then
/usr/bin/xcodebuild -scheme $Scheme -workspace $PathofWorkspaceFile -configuration $Config clean build CONFIGURATION_BUILD_DIR=$PathToApp "CODE_SIGN_IDENTITY=$CodeSigningIdentity" "PRODUCT_BUNDLE_IDENTIFIER=$BundleIdentifier" "PROVISIONING_PROFILE=$ProvisioningProfileIdentity"
else
/usr/bin/xcodebuild -target $Target -project $PathofProjectFile -configuration $Config clean build CONFIGURATION_BUILD_DIR=$PathToApp "CODE_SIGN_IDENTITY=$CodeSigningIdentity" "PRODUCT_BUNDLE_IDENTIFIER=$BundleIdentifier" "PROVISIONING_PROFILE=$ProvisioningProfileIdentity"
fi
echo ".app has been generated at $PathToApp"

echo "****************** Creating .ipa *******************"
/usr/bin/xcrun -sdk iphoneos PackageApplication -v $PathToApp/XxYyZz.app -o $PathToIpa/$Appname.ipa --embed $PathToMobileProvision --sign "$CodeSigningIdentity"
echo "$Appname.ipa has been generated at $PathToIpa"

#** Creatting the build based on configuration ends **

ファイルは自己記述的で、簡単に理解できます。ファイル内の変数の値を構成し、以下のように呼び出すだけです

sh Branding.sh

ご参考までに:

App Icon と iTunesArtwork 以外の他のアイコンも変更したい場合は、cpコマンドを使用します。

cp path/to/source path/to/destination

詳細情報を知るにはcp man

上記のファイルを使用すると、UI とビルド設定のブランディングを行うことができます。

機能的なブランディングのために、あなたは維持しなければなりません

  • ブランド固有の URL

  • ブランドに関連するその他のインプット

別の plist ファイルで、アプリのビルド中にそれぞれのブランドに応じて変更できるようにします

plistファイル

コーディング側では、このように plist から値を読み取るようにアプリケーションをカスタマイズできます

関数定義:

func getPlistFile()->Dictionary<String,AnyObject>? {
        var dictPlistFile:Dictionary<String,AnyObject>?
        if let path = NSBundle.mainBundle().pathForResource("plistfile", ofType: "plist") {
            if let dictValue = NSDictionary(contentsOfFile: path) as? Dictionary<String, AnyObject> {
                dictPlistFile=dictValue
            }
        }
        return dictPlistFile
    }

関数呼び出し:

var Value=getPlistFile()?["Key"]

アプリの構築中にPlistBuddyを使用して、ブランドに応じてキーの値を変更できます

ここに構文があります

/usr/libexec/PlistBuddy -c "Set :Key Value" plistfile.plist

ジェンキンスの使用

ここでジェンキンスでシェルスクリプトを効果的に再利用できます

1.パラメータの追加を使用して、jenkinsのシェルスクリプトのすべての変数をパラメータ化する必要があります...下のスクリーンショットのように、1つの変数に対して行ったように、他のすべての変数に対して行う必要があります

パラメータ化

2.ビルドステップでシェルの実行を選択します

ビルドステップ

3.Creating the build based on configuration startsとMaking the build based on configuration fails の間にあるスクリプトをコピーし、 Execute Shellに貼り付けます。 シェルを実行

ノート:

  • リソース ルール

    一部のバージョンでは、Xcode 以外のインターフェイスを介してアプリをビルドおよびパッケージ化する際に、Xcode のResourceRulesに関する既知のバグがあります。

    そのため、 xcodeでリソース ルールパスの検証を無効にするには、一度実行する必要があります。リソース ルール パスは非推奨の機能であり、Apple はリソース ルールに付属するアプリを受け入れませんが、Xcode を使用せずにアプリをビルドすると、検証エラーが表示されます。リソース ルールが見つかりませんでした。これは、スクリプトを 1 回だけ実行する必要があることに対抗するために発生します。

xcode_fix_PackageApplicationResourceRules.sh

#!/bin/sh
# A script to patch xcrun PackageInstallation so that it doesn't use the deprecated --resource-rules
# See "Do not use the --resource-rules flag or ResourceRules.plist. They have been obsoleted and will be rejected."
#   under https://developer.apple.com/library/mac/technotes/tn2206/_index.html#//apple_ref/doc/uid/DTS40007919-CH1-TNTAG205
# Reported as Apple bug #19384243
# 
# should be run as a user who can modify the PackageApplication file

xcodedir=$1

function usage {
        # FIXME we cannot parse args properly because 2 are optional...
        echo "USAGE: $0 xcodedir"
        echo "  xcodedir: an install dir like /Application/Xcode6.1.1.app"
}

if [[ $# -ne 1 ]]; then
        echo "ERROR: invalid number of arguments"
        usage
        exit -1 
fi

pi="$xcodedir/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/PackageApplication"
piorig="$piOrig"

if [[ ! -f "$pi" ]]; then
    echo "$pi file not found. Invalid argument ?"
    usage
    exit -1
fi

grep resource-rules "$pi" 
if [[ $? -ne 0 ]]; then
    echo "PackageApplication doesn't use resource-rules. Skipping"
    exit 0
fi

if [[ -f "$piorig" ]]; then
    echo "Backup file $piorig already exist. Aborting"
    exit -1
fi

perl  -p -i'Orig' -e 'BEGIN{undef $/;} s/,resource-rules(.*sign}).*ResourceRules.plist"/$1/smg' "$pi" 
echo $?
  • キーチェーンのロックを解除

    ターミナルで Branding.sh を実行すると、システム キーチェーンにアクセスするためのユーザー名とパスワードが要求されます。

    ジェンキンスでジョブを実行するたびに、「User Interaction Is Not Allowed」というエラーが表示されます

    これに取り組むには、以下の手順に従う必要があります

    • キーチェーンアクセスを開く
    • 秘密鍵を右クリック
    • 「情報を見る」を選択
    • 「アクセス制御」タブを選択
    • 「すべてのアプリケーションにこのアイテムへのアクセスを許可する」をクリック
    • 「変更を保存」をクリック
    • パスワードを入力してください
  • プロビジョニング プロファイル

    No Matching Provisioning Profile Found」が表示された場合は、ダブルクリックしてXcode経由でインストールしたことを確認してください。

    インストールすると、~/Library/MobileDevice/Provisioning Profiles/にUUID.mobileprovisionが表示されます。

    この UUID は、プロビジョニング プロファイルがインストールされていることを意味するモバイル プロビジョニング内の値です。

これがお役に立てば幸いです

于 2016-07-14T11:52:24.433 に答える