# MPM SDKインストール

IMQA MPMをiOSプロジェクトに追加すると、Objective-CとSwiftで開発したアプリで発生するアプリケーションの性能問題を様々な視点から確認することができます。 \
最新アップデートガイドは、<https://github.com/onycom-imqa/IMQA-MPM-Release>にアップデートされます。

{% hint style="warning" %}
\[対応 OS] iOS 9.0以上 (WebView Crash コレクションの場合、iOS 11.0 以降) / Xcode最新バージョン
{% endhint %}

{% hint style="warning" %}
IMQAプロジェクトページでiOSプロジェクトを作成後、<mark style="color:red;">**プロジェクトキーを受け取った**</mark>らインストールを実行してください。
{% endhint %}

## 1. SDKインストール

IMQA MPM SDKは、2種類のSDKインストール方法をご提供しています。ご利用中の環境に適したインストール方法を選択して実行してください。

### XCFrameworks

1\. 以下のリンクから最新SDKファイルをダウンロードしてください。\
&#x20; \[<https://github.com/onycom-imqa/IMQA-MPM-Release/releases/download/v3.18.0/IMQAMPMAgent.zip>]

2\. 圧縮を解除したら、IMQAMpmAgent.frameworkファイルをTargets > \[Project Name] > General > Frameworks, Libraries, and Embedded Contentへ移してください。

3\. IMQAMpmAgentのEmbed OptionをEmbed & Signに変更してください。

4\. SDKインストールが完了しました。

### **CocoaPods**方式

1\. プロジェクトPodfileに以下のとおり入力してください。

```
use_frameworks!
pod 'IMQAMPMAgent', '3.24.1'
```

2\. ターミナルで当該プロジェクトの位置にpod installを実行してください。

3\. SDKインストールが完了しました。

## 2. プロジェクト設定

### Objective-C プロジェクト設定

Targets > \[Project Name] > Build Settings > Build OptionsでAlways Embed Swift Standard LibrariesをYESに変更してください。

## 3. Objective-C環境初期化コード

### AppDelegate.m Header設定

プロジェクトAppDelegate.mでIMQAMpmAgentヘッダを追加してください。

{% code title="AppDelegate.m" %}

```
#import <IMQAMPMAgent/IMQAMPMAgent.h>
```

{% endcode %}

### AppDelegate.m実行コード設定

プロジェクトAppDelegate.mでapplication: didFinishLaunchingWithOptions:に IMQAMpmAgentを初期化してください。PROJECT\_KEYは、IMQAサイトでプロジェクトを作成すると発行を受けることができます。

{% code title="AppDelegate.m " %}

```swift
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    // Override point for customization after application launch.
    
    NSString* PROJECT_KEY = @"<PROJECT_KEY>"; 
    IMQAConfig* mpmConfig = [[IMQAConfig alloc] init:PROJECT_KEY]; 
    [[IMQAMpm sharedInstance] runWithConfig:mpmConfig];
    
    return YES;
}
```

{% endcode %}

## 4. Swift環境初期化コード

### AppDelegate.swift Header設定

プロジェクトAppDelegate.swiftでIMQAMpmAgentヘッダを追加してください。

{% code title="AppDelegate.swift" %}

```swift
import IMQAMPMAgent
```

{% endcode %}

### AppDelegate.swift実行コード設定

プロジェクトAppDelegate.swiftでapplication: didFinishLaunchingWithOptions:に IMQAMpmAgentを初期化してください。PROJECT\_KEYは、IMQAサイトでプロジェクトを作成すると発行を受けることができます。

{% code title="AppDelegate.swift" %}

```swift
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
    // Override point for customization after application launch.
        
    let PROJECT_KEY = ""
    let mpmConfig = IMQAConfig(PROJECT_KEY) 
    IMQAMpm.sharedInstance.run(config: mpmConfig)
        
    return true
}
```

{% endcode %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.imqa.io/imqa-guide/jpn/installation/ios/mpm-sdk-install.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
