Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

platform_view_swift rebuild script #1374

Closed
wants to merge 10 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 22 additions & 2 deletions platform_view_swift/.metadata
Original file line number Diff line number Diff line change
@@ -1,10 +1,30 @@
# This file tracks properties of this Flutter project.
# Used by Flutter tool to assess capabilities and perform upgrades etc.
#
# This file should be version controlled and should not be manually edited.
# This file should be version controlled.

version:
revision: 2d2a1ffec95cc70a3218872a2cd3f8de4933c42f
revision: f1875d570e39de09040c8f79aa13cc56baab8db1
channel: stable

project_type: app

# Tracks metadata for the flutter migrate command
migration:
platforms:
- platform: root
create_revision: f1875d570e39de09040c8f79aa13cc56baab8db1
base_revision: f1875d570e39de09040c8f79aa13cc56baab8db1
- platform: ios
create_revision: f1875d570e39de09040c8f79aa13cc56baab8db1
base_revision: f1875d570e39de09040c8f79aa13cc56baab8db1

# User provided section

# List of Local paths (relative to this file) that should be
# ignored by the migrate tool.
#
# Files that are not part of the templates will be ignored by default.
unmanaged_files:
- 'lib/main.dart'
- 'ios/Runner.xcodeproj/project.pbxproj'
169 changes: 169 additions & 0 deletions platform_view_swift/codelab_rebuild.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,169 @@
# Run with tooling from https://github.com/flutter/codelabs/tree/main/tooling/codelab_rebuild
name: Platform Design rebuild script
steps:
- name: Remove runner
rmdirs:
- ios
- name: Flutter recreate runner
flutter: create --platform ios --org dev.flutter .
- name: Replace ios/Runner/AppDelegate.swift
path: ios/Runner/AppDelegate.swift
replace-contents: |
// Copyright 2018, the Flutter project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

import UIKit
import Flutter

@UIApplicationMain
@objc class AppDelegate: FlutterAppDelegate, PlatformViewControllerDelegate {
var flutterResult: FlutterResult?

override func application(
_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
) -> Bool {
GeneratedPluginRegistrant.register(with: self)
let controller: FlutterViewController = window?.rootViewController as! FlutterViewController
let channel = FlutterMethodChannel.init(name: "dev.flutter.sample/platform_view_swift", binaryMessenger: controller.binaryMessenger)

channel.setMethodCallHandler({
(call: FlutterMethodCall, result: @escaping FlutterResult) -> Void in
if ("switchView" == call.method) {
self.flutterResult = result

let platformViewController = PlatformViewController(nibName: "PlatformViewController", bundle: nil)
platformViewController.counter = call.arguments as! Int
platformViewController.delegate = self

let navigationController = UINavigationController(rootViewController: platformViewController)
navigationController.navigationBar.topItem?.title = "Platform View"
controller.present(navigationController, animated: true, completion: nil)
} else {
result(FlutterMethodNotImplemented)
}
});

return super.application(application, didFinishLaunchingWithOptions: launchOptions)
}

func didUpdateCounter(counter: Int) {
flutterResult?(counter)
}
}
- name: Replace ios/Runner/PlatformViewController.swift
path: ios/Runner/PlatformViewController.swift
replace-contents: |
// Copyright 2018, the Flutter project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

import UIKit
import Foundation

protocol PlatformViewControllerDelegate {
func didUpdateCounter(counter: Int)
}

class PlatformViewController : UIViewController {
var delegate: PlatformViewControllerDelegate? = nil
var counter: Int = 0

@IBOutlet weak var incrementLabel: UILabel!

override func viewDidLoad() {
super.viewDidLoad()
setIncrementLabelText()
}

@IBAction func handleIncrement(_ sender: Any) {
self.counter += 1
self.setIncrementLabelText()
}

@IBAction func switchToFlutterView(_ sender: Any) {
self.delegate?.didUpdateCounter(counter: self.counter)
dismiss(animated:false, completion:nil)
}

func setIncrementLabelText() {
let text = String(format: "Button tapped %d %@", self.counter, (self.counter == 1) ? "time" : "times")
self.incrementLabel.text = text;
}
}

- name: Replace ios/Runner/PlatformViewController.xib
path: ios/Runner/PlatformViewController.xib
replace-contents: |
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="14490.70" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
<device id="retina6_1" orientation="portrait">
<adaptation id="fullscreen"/>
</device>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14490.49"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<objects>
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner" customClass="PlatformViewController" customModule="Runner" customModuleProvider="target">
<connections>
<outlet property="incrementLabel" destination="Fwz-pb-Vxw" id="LtN-bK-cIm"/>
<outlet property="view" destination="i5M-Pr-FkT" id="sfx-zR-JGt"/>
</connections>
</placeholder>
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
<view clearsContextBeforeDrawing="NO" contentMode="scaleToFill" id="i5M-Pr-FkT">
<rect key="frame" x="0.0" y="0.0" width="414" height="896"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Button tapped 0 times." textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Fwz-pb-Vxw">
<rect key="frame" x="114.5" y="379.5" width="185" height="21.5"/>
<fontDescription key="fontDescription" type="system" pointSize="18"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="0Q4-1m-vDk">
<rect key="frame" x="144" y="433" width="126" height="30"/>
<fontDescription key="fontDescription" type="system" pointSize="15"/>
<state key="normal" title="Increment counter"/>
<connections>
<action selector="handleIncrement:" destination="-1" eventType="touchUpInside" id="6jY-7M-lj4"/>
</connections>
</button>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="1Vb-F2-qFl">
<rect key="frame" x="125" y="495" width="164" height="30"/>
<fontDescription key="fontDescription" type="system" pointSize="15"/>
<state key="normal" title="Continue in Flutter View"/>
<connections>
<action selector="switchToFlutterView:" destination="-1" eventType="touchUpInside" id="tzA-cQ-gl6"/>
</connections>
</button>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="iOS" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="QgT-DT-gSd">
<rect key="frame" x="16" y="828" width="47" height="36"/>
<fontDescription key="fontDescription" type="system" pointSize="30"/>
<color key="textColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<nil key="highlightedColor"/>
</label>
</subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<constraints>
<constraint firstItem="1Vb-F2-qFl" firstAttribute="top" secondItem="0Q4-1m-vDk" secondAttribute="bottom" constant="32" id="2Fr-G0-fL1"/>
<constraint firstItem="0Q4-1m-vDk" firstAttribute="centerX" secondItem="i5M-Pr-FkT" secondAttribute="centerX" id="6R3-W6-Dle"/>
<constraint firstItem="1Vb-F2-qFl" firstAttribute="centerX" secondItem="i5M-Pr-FkT" secondAttribute="centerX" id="8sv-fF-vKQ"/>
<constraint firstItem="QgT-DT-gSd" firstAttribute="leading" secondItem="i5M-Pr-FkT" secondAttribute="leading" constant="16" id="8yF-bR-Te3"/>
<constraint firstItem="0Q4-1m-vDk" firstAttribute="top" secondItem="Fwz-pb-Vxw" secondAttribute="bottom" constant="32" id="QNR-n2-WAr"/>
<constraint firstItem="0Q4-1m-vDk" firstAttribute="centerY" secondItem="i5M-Pr-FkT" secondAttribute="centerY" id="YWH-R0-Md3"/>
<constraint firstItem="QgT-DT-gSd" firstAttribute="bottom" secondItem="i5M-Pr-FkT" secondAttribute="bottom" constant="-32" id="bIY-Nb-J3I"/>
<constraint firstItem="Fwz-pb-Vxw" firstAttribute="centerX" secondItem="i5M-Pr-FkT" secondAttribute="centerX" id="jcd-no-9jg"/>
</constraints>
<point key="canvasLocation" x="144.92753623188406" y="64.955357142857139"/>
</view>
</objects>
</document>
# TODO(DomesticMouse): Figure out a way to patch ios/Runner.xcodeproj/project.pbxproj
- name: Flutter doctor
flutter: doctor
- name: Build for iOS
flutter: build ios --simulator
2 changes: 2 additions & 0 deletions platform_view_swift/ios/.gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
**/dgph
*.mode1v3
*.mode2v3
*.moved-aside
Expand All @@ -18,6 +19,7 @@ Flutter/App.framework
Flutter/Flutter.framework
Flutter/Flutter.podspec
Flutter/Generated.xcconfig
Flutter/ephemeral/
Flutter/app.flx
Flutter/app.zip
Flutter/flutter_assets/
Expand Down
4 changes: 2 additions & 2 deletions platform_view_swift/ios/Flutter/AppFrameworkInfo.plist
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>$(DEVELOPMENT_LANGUAGE)</string>
<string>en</string>
<key>CFBundleExecutable</key>
<string>App</string>
<key>CFBundleIdentifier</key>
Expand All @@ -21,6 +21,6 @@
<key>CFBundleVersion</key>
<string>1.0</string>
<key>MinimumOSVersion</key>
<string>8.0</string>
<string>9.0</string>
</dict>
</plist>

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?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>IDEDidComputeMac32BitWarning</key>
<true/>
</dict>
</plist>
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?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>PreviewsEnabled</key>
<false/>
</dict>
</plist>
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1020"
LastUpgradeVersion = "1300"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand All @@ -27,8 +27,6 @@
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
</Testables>
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
Expand All @@ -38,8 +36,8 @@
ReferencedContainer = "container:Runner.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
<Testables>
</Testables>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
Expand All @@ -61,8 +59,6 @@
ReferencedContainer = "container:Runner.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
buildConfiguration = "Profile"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?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>PreviewsEnabled</key>
<false/>
</dict>
</plist>
4 changes: 4 additions & 0 deletions platform_view_swift/ios/Runner/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>$(DEVELOPMENT_LANGUAGE)</string>
<key>CFBundleDisplayName</key>
<string>Platform View Swift</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
Expand Down Expand Up @@ -41,5 +43,7 @@
</array>
<key>UIViewControllerBasedStatusBarAppearance</key>
<false/>
<key>CADisableMinimumFrameDurationOnPhone</key>
<true/>
</dict>
</plist>