Commit 8d56fae5 authored by Adam Barth's avatar Adam Barth Committed by GitHub

Finish integrating HelloServices model on iOS (#4820)

This patch changes the default `flutter create` command to generate a
HelloServices-style app on iOS. As a consequence, the Atom integration now
fully works with HelloServices.
parent 5dae820c
......@@ -35,3 +35,4 @@ Icon?
/Flutter/app.zip
/Flutter/Flutter.framework
/Flutter/Generated.xcconfig
/ServiceDefinitions.json
......@@ -46,7 +46,7 @@
977505181CFDF23500BC28DA /* LocationProvider.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LocationProvider.m; sourceTree = "<group>"; };
97A38A331CFDEC680099F1B4 /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = "<group>"; };
97A38A341CFDEC880099F1B4 /* AppDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = "<group>"; };
97C146EE1CF9000F007C117D /* HelloServices.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = HelloServices.app; sourceTree = BUILT_PRODUCTS_DIR; };
97C146EE1CF9000F007C117D /* Runner.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Runner.app; sourceTree = BUILT_PRODUCTS_DIR; };
97C146F21CF9000F007C117D /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = "<group>"; };
97C146FB1CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = "<group>"; };
97C146FD1CF9000F007C117D /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
......@@ -82,7 +82,7 @@
isa = PBXGroup;
children = (
9740EEB11CF90186004384FC /* Flutter */,
97C146F01CF9000F007C117D /* HelloServices */,
97C146F01CF9000F007C117D /* Runner */,
97C146EF1CF9000F007C117D /* Products */,
);
sourceTree = "<group>";
......@@ -90,12 +90,12 @@
97C146EF1CF9000F007C117D /* Products */ = {
isa = PBXGroup;
children = (
97C146EE1CF9000F007C117D /* HelloServices.app */,
97C146EE1CF9000F007C117D /* Runner.app */,
);
name = Products;
sourceTree = "<group>";
};
97C146F01CF9000F007C117D /* HelloServices */ = {
97C146F01CF9000F007C117D /* Runner */ = {
isa = PBXGroup;
children = (
97C146FA1CF9000F007C117D /* Main.storyboard */,
......@@ -108,7 +108,7 @@
977505171CFDF21E00BC28DA /* LocationProvider.h */,
977505181CFDF23500BC28DA /* LocationProvider.m */,
);
path = HelloServices;
path = Runner;
sourceTree = "<group>";
};
97C146F11CF9000F007C117D /* Supporting Files */ = {
......@@ -122,9 +122,9 @@
/* End PBXGroup section */
/* Begin PBXNativeTarget section */
97C146ED1CF9000F007C117D /* HelloServices */ = {
97C146ED1CF9000F007C117D /* Runner */ = {
isa = PBXNativeTarget;
buildConfigurationList = 97C147051CF9000F007C117D /* Build configuration list for PBXNativeTarget "HelloServices" */;
buildConfigurationList = 97C147051CF9000F007C117D /* Build configuration list for PBXNativeTarget "Runner" */;
buildPhases = (
9740EEB61CF901F6004384FC /* ShellScript */,
97C146EA1CF9000F007C117D /* Sources */,
......@@ -136,9 +136,9 @@
);
dependencies = (
);
name = HelloServices;
productName = HelloServices;
productReference = 97C146EE1CF9000F007C117D /* HelloServices.app */;
name = Runner;
productName = Runner;
productReference = 97C146EE1CF9000F007C117D /* Runner.app */;
productType = "com.apple.product-type.application";
};
/* End PBXNativeTarget section */
......@@ -155,7 +155,7 @@
};
};
};
buildConfigurationList = 97C146E91CF9000F007C117D /* Build configuration list for PBXProject "HelloServices" */;
buildConfigurationList = 97C146E91CF9000F007C117D /* Build configuration list for PBXProject "Runner" */;
compatibilityVersion = "Xcode 3.2";
developmentRegion = English;
hasScannedForEncodings = 0;
......@@ -168,7 +168,7 @@
projectDirPath = "";
projectRoot = "";
targets = (
97C146ED1CF9000F007C117D /* HelloServices */,
97C146ED1CF9000F007C117D /* Runner */,
);
};
/* End PBXProject section */
......@@ -334,7 +334,7 @@
"$(inherited)",
"$(PROJECT_DIR)/Flutter",
);
INFOPLIST_FILE = HelloServices/Info.plist;
INFOPLIST_FILE = Runner/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
LIBRARY_SEARCH_PATHS = (
"$(inherited)",
......@@ -355,7 +355,7 @@
"$(inherited)",
"$(PROJECT_DIR)/Flutter",
);
INFOPLIST_FILE = HelloServices/Info.plist;
INFOPLIST_FILE = Runner/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
LIBRARY_SEARCH_PATHS = (
"$(inherited)",
......@@ -369,7 +369,7 @@
/* End XCBuildConfiguration section */
/* Begin XCConfigurationList section */
97C146E91CF9000F007C117D /* Build configuration list for PBXProject "HelloServices" */ = {
97C146E91CF9000F007C117D /* Build configuration list for PBXProject "Runner" */ = {
isa = XCConfigurationList;
buildConfigurations = (
97C147031CF9000F007C117D /* Debug */,
......@@ -378,7 +378,7 @@
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
97C147051CF9000F007C117D /* Build configuration list for PBXNativeTarget "HelloServices" */ = {
97C147051CF9000F007C117D /* Build configuration list for PBXNativeTarget "Runner" */ = {
isa = XCConfigurationList;
buildConfigurations = (
97C147061CF9000F007C117D /* Debug */,
......
......@@ -7,11 +7,11 @@
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<string>com.example.HelloServices</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>$(PRODUCT_NAME)</string>
<string>HelloServices</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
......
......@@ -96,13 +96,13 @@ class IOSApp extends ApplicationPackage {
if (getCurrentHostPlatform() != HostPlatform.darwin_x64)
return null;
String plistPath = path.join('ios', 'Info.plist');
String plistPath = path.join('ios', 'Runner', 'Info.plist');
String value = getValueFromFile(plistPath, kCFBundleIdentifierKey);
if (value == null)
return null;
return new IOSApp(
projectDir: path.join('ios', '.generated'),
projectDir: path.join('ios'),
projectBundleId: value
);
}
......
......@@ -105,16 +105,7 @@ Future<XcodeBuildResult> buildXcodeProject({
bool codesign: true
}) async {
String flutterProjectPath = Directory.current.path;
if (xcodeProjectRequiresUpdate(mode, target)) {
printTrace('Initializing the Xcode project.');
if ((await setupXcodeProjectHarness(flutterProjectPath, mode, target)) != 0) {
printError('Could not initialize the Xcode project.');
return new XcodeBuildResult(false);
}
} else {
updateXcodeGeneratedProperties(flutterProjectPath, mode, target);
}
updateXcodeGeneratedProperties(flutterProjectPath, mode, target);
if (!_checkXcodeVersion())
return new XcodeBuildResult(false);
......@@ -130,7 +121,6 @@ Future<XcodeBuildResult> buildXcodeProject({
'xcodebuild',
'clean',
'build',
'-target', 'Runner',
'-configuration', 'Release',
'ONLY_ACTIVE_ARCH=YES',
];
......
......@@ -2,16 +2,13 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'dart:async';
import 'dart:io';
import 'package:path/path.dart' as path;
import '../base/file_system.dart' show copyFolderSync;
import '../build_info.dart';
import '../cache.dart';
import '../globals.dart';
import '../version.dart';
void updateXcodeGeneratedProperties(String projectPath, BuildMode mode, String target) {
StringBuffer localsBuffer = new StringBuffer();
......@@ -37,54 +34,7 @@ void updateXcodeGeneratedProperties(String projectPath, BuildMode mode, String t
if (tools.isLocalEngine)
localsBuffer.writeln('LOCAL_ENGINE=${tools.engineBuildPath}');
File localsFile = new File(path.join(projectPath, 'ios', '.generated', 'Flutter', 'Generated.xcconfig'));
File localsFile = new File(path.join(projectPath, 'ios', 'Flutter', 'Generated.xcconfig'));
localsFile.createSync(recursive: true);
localsFile.writeAsStringSync(localsBuffer.toString());
}
bool xcodeProjectRequiresUpdate(BuildMode mode, String target) {
File revisionFile = new File(path.join(Directory.current.path, 'ios', '.generated', 'REVISION'));
// If the revision stamp does not exist, the Xcode project definitely requires
// an update
if (!revisionFile.existsSync()) {
printTrace("A revision stamp does not exist. The Xcode project has never been initialized.");
return true;
}
if (revisionFile.readAsStringSync() != _getCurrentXcodeRevisionString(mode, target)) {
printTrace("The revision stamp and the Flutter engine revision differ or the build mode has changed.");
printTrace("Project needs to be updated.");
return true;
}
printTrace("Xcode project is up to date.");
return false;
}
Future<int> setupXcodeProjectHarness(String flutterProjectPath, BuildMode mode, String target) async {
// Step 1: Copy templates into user project directory
String iosFilesPath = path.join(flutterProjectPath, 'ios');
String xcodeProjectPath = path.join(iosFilesPath, '.generated');
String templatesPath = path.join(Cache.flutterRoot, 'packages', 'flutter_tools', 'templates', 'build-ios');
copyFolderSync(templatesPath, xcodeProjectPath);
// Step 2: Populate the Generated.xcconfig with project specific paths
updateXcodeGeneratedProperties(flutterProjectPath, mode, target);
// Step 3: Write the REVISION file
File revisionFile = new File(path.join(xcodeProjectPath, 'REVISION'));
revisionFile.createSync();
revisionFile.writeAsStringSync(_getCurrentXcodeRevisionString(mode, target));
// Step 4: Tell the user the location of the generated project.
printStatus('Xcode project created in $iosFilesPath/.');
return 0;
}
String _getCurrentXcodeRevisionString(BuildMode mode, String target) => (new StringBuffer()
..write('${FlutterVersion.getVersion().frameworkRevision}')
..write('-${tools.isLocalEngine ? tools.engineBuildPath : getModeName(mode)}')
..write('::$target')
).toString();
......@@ -413,7 +413,7 @@ String getMissingPackageHintForPlatform(TargetPlatform platform) {
case TargetPlatform.android_x64:
return 'Is your project missing an android/AndroidManifest.xml?\nConsider running "flutter create ." to create one.';
case TargetPlatform.ios:
return 'Is your project missing an ios/Info.plist?\nConsider running "flutter create ." to create one.';
return 'Is your project missing an ios/Runner/Info.plist?\nConsider running "flutter create ." to create one.';
default:
return null;
}
......
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0720"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "9E07CF991BE8280A00BCD8DE"
BuildableName = "Runner.app"
BlueprintName = "Runner"
ReferencedContainer = "container:FlutterApplication.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
</Testables>
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "9E07CF991BE8280A00BCD8DE"
BuildableName = "Runner.app"
BlueprintName = "Runner"
ReferencedContainer = "container:FlutterApplication.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "9E07CF991BE8280A00BCD8DE"
BuildableName = "Runner.app"
BlueprintName = "Runner"
ReferencedContainer = "container:FlutterApplication.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
<CommandLineArguments>
<CommandLineArgument
argument = "--no-redirect-to-syslog"
isEnabled = "YES">
</CommandLineArgument>
<CommandLineArgument
argument = "--observatory-port=8181"
isEnabled = "YES">
</CommandLineArgument>
</CommandLineArguments>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "9E07CF991BE8280A00BCD8DE"
BuildableName = "Runner.app"
BlueprintName = "Runner"
ReferencedContainer = "container:FlutterApplication.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0720"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "9E07CF851BE7F4D200BCD8DE"
BuildableName = "FlutterApplication.framework"
BlueprintName = "FlutterApplication"
ReferencedContainer = "container:FlutterApplication.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
</Testables>
<AdditionalOptions>
</AdditionalOptions>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "9E07CF851BE7F4D200BCD8DE"
BuildableName = "FlutterApplication.framework"
BlueprintName = "FlutterApplication"
ReferencedContainer = "container:FlutterApplication.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "9E07CF851BE7F4D200BCD8DE"
BuildableName = "FlutterApplication.framework"
BlueprintName = "FlutterApplication"
ReferencedContainer = "container:FlutterApplication.xcodeproj">
</BuildableReference>
</MacroExpansion>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>
.idea/
.vagrant/
.sconsign.dblite
.svn/
.DS_Store
*.swp
*.lock
profile
DerivedData/
build/
*.pbxuser
*.mode1v3
*.mode2v3
*.perspectivev3
!default.pbxuser
!default.mode1v3
!default.mode2v3
!default.perspectivev3
xcuserdata
*.moved-aside
*.pyc
*sync/
Icon?
.tags*
/Flutter/app.flx
/Flutter/app.dylib
/Flutter/app.zip
/Flutter/Flutter.framework
/Flutter/Generated.xcconfig
/ServiceDefinitions.json
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="9531" systemVersion="15C50" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES" initialViewController="01J-lp-oVM">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="10117" systemVersion="15F34" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES" initialViewController="01J-lp-oVM">
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="9529"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="10085"/>
</dependencies>
<scenes>
<!--View Controller-->
......
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="6211" systemVersion="14A298i" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" initialViewController="BYZ-38-t0r">
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="6204"/>
</dependencies>
<scenes>
<!--View Controller-->
<scene sceneID="tne-QT-ifu">
<objects>
<viewController id="BYZ-38-t0r" customClass="ViewController" customModuleProvider="" sceneMemberID="viewController">
<layoutGuides>
<viewControllerLayoutGuide type="top" id="y3c-jy-aDJ"/>
<viewControllerLayoutGuide type="bottom" id="wfy-db-euE"/>
</layoutGuides>
<view key="view" contentMode="scaleToFill" id="8bC-Xf-vdC">
<rect key="frame" x="0.0" y="0.0" width="600" height="600"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
</view>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="dkx-z0-nzr" sceneMemberID="firstResponder"/>
</objects>
</scene>
</scenes>
</document>
......@@ -5,7 +5,7 @@
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleExecutable</key>
<string>Runner</string>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>{{iosIdentifier}}</string>
<key>CFBundleInfoDictionaryVersion</key>
......@@ -24,6 +24,8 @@
<true/>
<key>UILaunchStoryboardName</key>
<string>LaunchScreen</string>
<key>UIMainStoryboardFile</key>
<string>Main</string>
<key>UIRequiredDeviceCapabilities</key>
<array>
<string>arm64</string>
......@@ -41,7 +43,7 @@
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
<key>UIViewControllerBasedStatusBarAppearance</key>
<false/>
<key>UIViewControllerBasedStatusBarAppearance</key>
<false/>
</dict>
</plist>
......@@ -5,8 +5,10 @@
#import <UIKit/UIKit.h>
#import <Flutter/Flutter.h>
int main(int argc, const char* argv[]) {
FlutterInit(argc, argv);
return UIApplicationMain(argc, (char**)argv, nil,
NSStringFromClass([FlutterAppDelegate class]));
int main(int argc, char * argv[]) {
FlutterInit(argc, (const char**)argv);
@autoreleasepool {
return UIApplicationMain(argc, argv, nil,
NSStringFromClass([FlutterAppDelegate class]));
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment