Always generate legal UTIs for project identifiers.
diff --git a/packages/flutter_tools/lib/src/commands/create.dart b/packages/flutter_tools/lib/src/commands/create.dart
index aa5408e..7abf6b4 100644
--- a/packages/flutter_tools/lib/src/commands/create.dart
+++ b/packages/flutter_tools/lib/src/commands/create.dart
@@ -98,6 +98,7 @@
void generateInto(Directory dir, String flutterPackagePath) {
String dirPath = path.normalize(dir.absolute.path);
String projectName = _normalizeProjectName(path.basename(dirPath));
+ String projectIdentifier = _createProjectIdentifier(path.basename(dirPath));
printStatus('Creating ${path.basename(projectName)}...');
dir.createSync(recursive: true);
@@ -108,6 +109,7 @@
String contents = files[filePath];
Map m = <String, String>{
'projectName': projectName,
+ 'projectIdentifier': projectIdentifier,
'description': description,
'flutterPackagePath': relativeFlutterPackagePath
};
@@ -150,6 +152,14 @@
return name;
}
+String _createProjectIdentifier(String name) {
+ // Create a UTI (https://en.wikipedia.org/wiki/Uniform_Type_Identifier) from a base name
+ RegExp disallowed = new RegExp(r"[^a-zA-Z0-9\-.\u0080-\uffff]+");
+ name = name.replaceAll(disallowed, '');
+ name = name.length == 0 ? 'untitled' : name;
+ return 'com.yourcompany.${name}';
+}
+
const String _analysis_options = r'''
analyzer:
exclude:
@@ -244,7 +254,7 @@
final String _apkManifest = '''
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
- package="com.example.{{projectName}}"
+ package="{{projectIdentifier}}"
android:versionCode="1"
android:versionName="0.0.1">
diff --git a/packages/flutter_tools/lib/src/ios/setup_xcodeproj.dart b/packages/flutter_tools/lib/src/ios/setup_xcodeproj.dart
index 7c98bbc..f91ab4e 100644
--- a/packages/flutter_tools/lib/src/ios/setup_xcodeproj.dart
+++ b/packages/flutter_tools/lib/src/ios/setup_xcodeproj.dart
@@ -173,7 +173,7 @@
<key>CFBundleExecutable</key>
<string>Runner</string>
<key>CFBundleIdentifier</key>
- <string>com.example.{{projectName}}</string>
+ <string>{{projectIdentifier}}</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>