LoginSignup
0
2

More than 3 years have passed since last update.

iOSでAzure Storageを利用する方法

Posted at

何の記事?

iOSでAzure Storageとデータをやり取りするための紐付け方法です。
操作がやや煩雑なので、次するときのための備忘録です。

開発環境

XCode 12.5

方法

Azureの公式ドキュメントに従ってやります。
https://github.com/Azure/azure-storage-ios

Cocoa Podsのインストール

ターミナルを起動して以下を入力していきます。

1 ruby gemを最新にする

sudo gem update --system

2 Cocoapodsのインストール
Cocoapodsは、swiftからObjectCのライブラリを使用するためのツールだそうです。

sudo gem install cocoapods

3 Cocoapodsのセットアップ

pod setup

これで準備ができました!

Pod fileの作成

1 Xcodeのプロジェクトファイルがあるフォルダのパスをコピー
スクリーンショット 2021-05-17 18.47.59.png

2 ターミナル上で該当するフォルダに移動

cd /Users/***/Xcode/CorneaApp3

3 ポッドファイルを作成

pod init

4 ファイルの中身を確認

vi Podfile

こんな感じで表示されます。
iを押すと編集モードになります。(後にXCode上で編集しても可)

# Uncomment the next line to define a global platform for your project
# platform :ios, '9.0'

target 'CorneaApp3' do
  # Comment the next line if you're not using Swift and don't want to use dynamic frameworks
  use_frameworks!

  # Pods for CorneaAppp3
end

5 公式ドキュメントに従ってpodfileを書き換える

# Uncomment the next line to define a global platform for your project
# platform :ios, '9.0'

target 'CorneaApp3' do
  # Comment the next line if you're not using Swift and don't want to use dynamic frameworks
  use_frameworks!

  # Pods for CorneaApp3
  pod 'AZSClient'

end

入力が終わったら「esc」で編集モード終了。
「:wq」で保存。

7 ライブラリのインストール

pod install

8 念の為アップデート

pod update

Bridging-Header.hファイルの作成

プロジェクトファイルの直下で、New File> Header Fileとして、ヘッダーファイルを作成。Bridging-Header.hと名前を付けます。

Bridging-Header.hに、以下の内容を書き込みます。

// Include the following import statement to use blob APIs.
#import <AZSClient/AZSClient.h>

プロジェクトファイルのBuild Settingsから、Swift Compiler-Generalの項目を探します。上のタブをAllにしないと出てこないので注意。
"Objective-C Bridging Header"という項目の横をクリックして、Bridging-Header.hと書き込みます。

スクリーンショット 2021-05-17 19.44.12.png

最後に

これで設定は終わりです。読み書きのサンプルコードは公式のドキュメントをご参照下さい。

0
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
2