turbo-ios
Hey Guys,
I spent yesterday figuring out the turbo-iOS Here is a quick demo
It is actually pretty straightforward enough but there are few gotchas in the readme that might have you scratching your head.
I'm going to assume you have an app with the turbo-rails gem installed. If that's setup, you can proceed to the next steps.
Also, make sure your app is running on port 5000.
First things, you have to have Xcode installed. It's pretty big and needs about 29.07 GB.
I wish I was joking when I said that. If you get an error that says you don't have enough space on your mac, you can download the Xcode.xip file from the apple developer website(which is a 13GB file) and then move it to an external hard drive and install from there.
Next thing is to launch Xcode
Click 'Create a new Xcode project'
I spent yesterday figuring out the turbo-iOS Here is a quick demo
It is actually pretty straightforward enough but there are few gotchas in the readme that might have you scratching your head.
I'm going to assume you have an app with the turbo-rails gem installed. If that's setup, you can proceed to the next steps.
Also, make sure your app is running on port 5000.
First things, you have to have Xcode installed. It's pretty big and needs about 29.07 GB.
I wish I was joking when I said that. If you get an error that says you don't have enough space on your mac, you can download the Xcode.xip file from the apple developer website(which is a 13GB file) and then move it to an external hard drive and install from there.
Next thing is to launch Xcode
Click 'Create a new Xcode project'
- Make sure to click iOS
- then click App.
- Click Next
On the next page, you enter the project name.
Make sure you select Storyboard and UiKit App Delegate. Here is a screenshot of my setup.
Now you can follow the turbo-ios quick start verbatim
From the docs
Select your app's main top-level project, go to the Swift Packages tab and add the Turbo iOS dependency by entering in https://github.com/hotwired/turbo-ios
.
This means you click File > Swift Packages > Add Package Dependency
The next step in the QuickStart:
Open the SceneDelegate
, and replace the entire file with this code:
import UIKit import Turbo class SceneDelegate: UIResponder, UIWindowSceneDelegate { var window: UIWindow? private lazy var navigationController = UINavigationController() func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) { guard let _ = (scene as? UIWindowScene) else { return } window!.rootViewController = navigationController visit(url: URL(string: "https://turbo-native-demo.glitch.me")!) } private func visit(url: URL) { let viewController = VisitableViewController(url: url) navigationController.pushViewController(viewController, animated: true) session.visit(viewController) } private lazy var session: Session = { let session = Session() session.delegate = self return session }() } extension SceneDelegate: SessionDelegate { func session(_ session: Session, didProposeVisit proposal: VisitProposal) { visit(url: proposal.url) } func session(_ session: Session, didFailRequestForVisitable visitable: Visitable, error: Error) { print("didFailRequestForVisitable: \(error)") } }
So now you should be able to press the Play button and target a device and the app should build.
The simulator will now build and you will be able to click around the example app.
However, we want to able to connect our Jumpstart apps. So let's do that.
Change the line
visit(url: URL(string: "https://turbo-native-demo.glitch.me")!)
to
visit(url: URL(string: "http://localhost:5000")!)
Now we have to change the
NSAppTransportSecurity settings in Info.plist.
This can be achieved by clicking Info.plist but honestly, I prefer using an editor. I've pasted my code below so you can see but I've also included a screenshot:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>
<key>CFBundleDisplayName</key>
<string></string>
<key>LSApplicationCategoryType</key>
<string></string>
<key>CFBundleDevelopmentRegion</key>
<string>$(DEVELOPMENT_LANGUAGE)</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>$(PRODUCT_NAME)</string>
<key>CFBundlePackageType</key>
<string>$(PRODUCT_BUNDLE_PACKAGE_TYPE)</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleVersion</key>
<string>1</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>UIApplicationSceneManifest</key>
<dict>
<key>UIApplicationSupportsMultipleScenes</key>
<false/>
<key>UISceneConfigurations</key>
<dict>
<key>UIWindowSceneSessionRoleApplication</key>
<array>
<dict>
<key>UISceneConfigurationName</key>
<string>Default Configuration</string>
<key>UISceneDelegateClassName</key>
<string>$(PRODUCT_MODULE_NAME).SceneDelegate</string>
<key>UISceneStoryboardFile</key>
<string>Main</string>
</dict>
</array>
</dict>
</dict>
<key>UIApplicationSupportsIndirectInputEvents</key>
<true/>
<key>UILaunchStoryboardName</key>
<string>LaunchScreen</string>
<key>UIMainStoryboardFile</key>
<string>Main</string>
<key>UIRequiredDeviceCapabilities</key>
<array>
<string>armv7</string>
</array>
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
<key>UISupportedInterfaceOrientations~ipad</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationPortraitUpsideDown</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
</dict>
</plist>
Once you have changed those settings, you can hit play again
Anyway, if there is anything I missed. Let me know.
Notifications
You’re not receiving notifications from this thread.