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 iOS als Plattform.

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

  • Für die Product Name eintippen AppToPhone.

  • Wählen Sie oder fügen Sie den entsprechenden Wert für Team und Organisation Identifier. NB: Wenn Sie nicht über diese Informationen verfügen, wählen Sie None für Team und geben Sie com.test für Organisation Identifier.

  • Verwenden Sie Storyboard für Interface und Swift für Language.

  • Stellen Sie sicher, dass sowohl Use Core Data und Include Tests Optionen abgewählt sind. Klicken Sie auf Next.

  • Wählen Sie Ihren Projektordner, app-to-phone-swift als den Ort, an dem sich Ihr Xcode-Projekt befinden wird.

  • Sie haben jetzt ein brandneues Xcode-Projekt.

WICHTIG! 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 Xcode-Ordner innerhalb Ihres Projekts:
cd app-to-phone-swift/AppToPhone
  • 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 'AppToPhone' do
  # Comment the next line if you don't want to use dynamic frameworks
  use_frameworks!

  # Pods for AppToPhone
  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 `AppToPhone.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 `14.4` on target `AppToPhone` 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 AppToPhone.xcworkspace und nicht mehr das ursprüngliche Projekt. Um es zu öffnen, geben Sie Folgendes in das Terminal ein:

open AppToPhone.xcworkspace