古いXcodeに、新しいiOSがインストールされた実機を接続してインストール

依存しているライブラリの関係など、古いバージョンのXcodeでiOSアプリを開発しています。
ただ、iOSがアップデートされると実機へのインストール時に対応していないとエラーになります。
“iOS 12 not supported by Xcode 9.2 : Could not locate device support files”
のようなエラーです。

そんな時の対応方法です。

古いXcodeと最新のXcodeが共存している前提です。
Finderから最新のXcodeを右クリックして”パッケージの内容を表示”から下記ディレクトリに移動します。
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/DeviceSupport

同様に古いバージョンのXcodeから同じディレクトリを表示して、必要なiOSバージョンのディレクトリをコピーすれば、
新しいiOSの実機にもXcodeからインストールできます。

Android で versionName, versionCode を取得

Android で build.gradle に設定した versionName, versionCode をプログラムで取得する。

        PackageManager pm = context.getPackageManager();
        String versionName = "";
        Integer versionCode = null;
        try {
            PackageInfo packageInfo = pm.getPackageInfo(context.getPackageName(), 0);
            versionName = packageInfo.versionName;
            versionCode = packageInfo.versionCode;
        } catch (PackageManager.NameNotFoundException e) {
            //
        }

Android の ActionBar に画像を表示

ActionBar にオリジナルのレイアウトを適用し画像を表示する。

action_bar.xml

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="48dp">

    <ImageView
        android:id="@+id/logo_action_bar"
        android:layout_width="match_parent"
        android:layout_height="32dp"
        android:layout_alignParentStart="true"
        android:layout_centerVertical="true"
        android:layout_marginLeft="8dp"
        android:scaleType="fitStart"
        android:src="@drawable/logo_action_bar"/>

</RelativeLayout>

Activityで適用

public class XxxActivity extends AppCompatActivity {

    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        ・・・

        // 表示するlayoutファイルの取得
        LayoutInflater inflater = LayoutInflater.from(this);
        View actionBarView = inflater.inflate(R.layout.action_bar, null);

        // プログラムでオリジナル画像を設定するなら下記
        // ((ImageView)actionBarView.findViewById(R.id.logo_action_bar)).setImageDrawable(getDrawable(R.drawable.xxxx));

        ActionBar actionBar = getSupportActionBar();
        actionBar.setCustomView(actionBarView);
        actionBar.setDisplayShowCustomEnabled(true);