Swift

Xcode-Projekt und Arbeitsbereich

Sie werden die iOS Client SDK-Bibliothek in einem Xcode-Projekt verwenden, das Sie als Nächstes erstellen werden.

Ein Xcode-Projekt erstellen

  • Öffnen Sie Xcode und wählen Sie im Menü File > New > Project....

  • Wählen Sie eine Single View App für den Anwendungstyp und klicken Sie auf Next.

  • Für die Product Name eintippen AppToAppChatwählen Sie die entsprechende Team und Organisation Identifier.

  • Benutzer Swift für Language und Storyboard für User Interface. Klicken Sie auf Next.

  • Wählen Sie die Desktop als den Ort, an dem sich Ihr Projektordner befinden wird. Sie können auch einen anderen Speicherort wählen, aber merken Sie sich diesen, da Sie ihn bald von der Website aus ansteuern müssen. Terminal.

  • Sie haben jetzt ein brandneues Xcode-Projekt.

Bevor Sie fortfahren, schließen Sie bitte das neue Projekt, das Sie erstellt haben.

Sie fügen die iOS Client SDK Bibliothek zu Ihrem Projekt über CocoaPods.

CocoaPods installieren

  • Öffnen Sie die Terminal App und navigieren Sie zum Projektordner, indem Sie eingeben:
cd ~/Desktop/AppToAppChat
  • Installieren Sie CocoaPods in Ihrem System, wenn Sie es nicht bereits haben:
sudo gem install cocoapods

Hinweis: CocoaPods wird mit Ruby erstellt, das standardmäßig unter macOS verfügbar ist.

  • Erstellen Sie eine Poddatei für Ihr Projekt:
pod init

Hinzufügen des iOS Client SDK

  • Fügen Sie das Vonage iOS Client SDK zum Podfile hinzu. Um dies zu tun, öffnen wir es in Xcode:
open -a Xcode Podfile
  • Aktualisieren Sie das Podfile wie unten gezeigt:
# Uncomment the next line to define a global platform for your project
# platform :ios, '9.0'

target 'AppToAppChat' do
  # Comment the next line if you don't want to use dynamic frameworks
  use_frameworks!

  # Pods for AppToAppChat
  pod 'NexmoClient'
  
end
  • Installieren Sie die Bibliothek:
pod install

Die neueste Version der Bibliothek wird zu Ihrem Projekt hinzugefügt:

Analyzing dependencies
Downloading dependencies
Installing NexmoClient (3.0.0)
Generating Pods project
Integrating client project

[!] Please close any current Xcode sessions and use `AppToAppChat.xcworkspace` for this project from now on.
Pod installation complete! There is 1 dependency from the Podfile and 1 total pod installed.

[!] Automatically assigning platform `iOS` with version `13.5` on target `AppToAppChat` because no platform was specified. Please specify a platform for this target in your Podfile. See `https://guides.cocoapods.org/syntax/podfile.html#platform`.

Öffnen Sie den Arbeitsbereich

Wie in der obigen Ausgabe beschrieben, verwenden Sie bitte AppToAppChat.xcworkspace und nicht mehr das ursprüngliche Projekt. Um es zu öffnen, geben Sie Folgendes in das Terminal ein:

open AppToAppChat.xcworkspace