Open the required project and go to the dependency settings: “Project -> Package dependency”
1.1 Click the “+” (Add package dependency) button.
You will see the “Apple swift packages” window.
Paste the link https://github.com/onboarding-online/swift-onboarding-sdk in the “Search or Enter Package URL” field.
Xcode will show the settings for adding SDK. Make sure the settings look like this “Dependency rule -> branch : main” and click the “Add package” button.
You will see the library verification window. Wait till the verification ends and click “Add package.”
The package integration has been completed. Only a few code lines remain to be added to your project!
If you use Interface -> SwiftUI (Point 6) for the project initializing:
12.1. Open the ContentView file (or wherever you want to add an onboarding launcher: ScreenService).
12.2 Add to the file header the following:
import OnboardingiOSSDK
12.3 Find the structure:
struct ContentView: View {}
12.4 Add the piece of code to it:
func startOnboarding() {OnboardingService.shared.startOnboarding(projectId: "",
localJSONFileName: "",
useLocalJSONAfterTimeout: 1.0)
{ onboardingResults in
print(onboardingResults)
}
}
12.5 Add a call to the screen constructor:
var body: some View {VStack {
Image(systemName: "globe")
.imageScale(.large)
.foregroundColor(.accentColor)
Text("Hello, world!")
}
.onAppear(perform: startOnboarding)
.padding()
}
If you have already obtained an onboarding.online service project, download the json file of your onboarding Onboarding.online-> project -> onboarding -> json
Drag the file into your Xcode project. After that, a settings window for adding a file will appear.
Select "Copy if needed," "Create groups" and click "Finish."
Add the file name to the onboarding launch function:
16.1 Open the "ContentView" file (or wherever you want to add an onboarding launcher: ScreenService);
16.2 Add the name of the json file you have downloaded.
Click the run button, wait for the simulator to launch, and enjoy your first onboarding!
В
Автор: Валерия Зимницкая
Обновлено больше недели назад