LoginSignup
1
3

More than 5 years have passed since last update.

SwiftでDropBox APIを使ってみる [準備編]

Posted at

DropBoxを使ってiosアプリからテキストファイルを書き換えができるまで頑張ってみた軌跡です。
ご指摘、改善できる箇所があればご教授いただけると幸いです。

下記のSwiftyDropboxリファレンスを参考に作成していきます。
http://dropbox.github.io/SwiftyDropbox/api-docs/latest/

環境

MacBookPro

Xcode : Version 10.1 (10B61)
swift : Version 4.2.1

#1 DropBoxにアプリ登録

*DropBoxアカウントが必要です。

1.DropBoxのホーム画面へ
https://www.dropbox.com/developers/apps

2.My apps画面右上の"Create app"ボタンをクリック
DropBoxメイン画面.png

3.Create a new app on the DBX Platform の設定

Choose an API : DropBox API
Choose the type of access you need : Full Dropbox
Name your app : 好きなアプリ名

DropBoxアプリ登録内容.png

4.App keyを保存(後ほど使います)
App key.png

#2 Xcodeプロジェクト作成

次のステップのcocoapodでライブラリをインストールするので作成、起動できるかテストを行う

#3 cocoapodでDropbox APIのライブラリのインストール

1.ターミナルで#2で作成したプロジェクトの階層まで移動
2.Podfileを生成

pod init

3.Podfile編集

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

    #追加
    pod 'SwiftyDropbox'

end

#4プロジェクトを設定

1.Info.plistファイルをテキスト編集ソフト(私の場合はvisual studio code)で開く
2.下記のコードを追加

<key>LSApplicationQueriesSchemes</key>
    <array>
        <string>dbapi-8-emm</string>
        <string>dbapi-2</string>
    </array>

3.CFBundleURLTypes内の配列にCFBundleURLSchemesを追加
db-########となるように記述

<key>CFBundleURLTypes</key>
    <array>
        <dict>
            <key>CFBundleTypeRole</key>
            <string>Editor</string>
=============================追加==================================
            <key>CFBundleURLSchemes</key>
            <array>
                <string>db-#1で作成したキー</string>
            </array>
=================================================================
        </dict>
    </array>

参考画像
info.lists.png

以上で下準備は完了です!
次の記事で実装を行なっていきたいと思います!

1
3
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
1
3