Fix watchOS build when companion app is configured with xcode variable (#84519)
This commit is contained in:
parent
e57d97afd8
commit
bce1706f1c
1
AUTHORS
1
AUTHORS
@ -79,3 +79,4 @@ Seongyun Kim <helloworld@cau.ac.kr>
|
|||||||
Ludwik Trammer <ludwik@gmail.com>
|
Ludwik Trammer <ludwik@gmail.com>
|
||||||
Marian Triebe <m.triebe@live.de>
|
Marian Triebe <m.triebe@live.de>
|
||||||
Alexis Rouillard <contact@arouillard.fr>
|
Alexis Rouillard <contact@arouillard.fr>
|
||||||
|
Mirko Mucaria <skogsfrae@gmail.com>
|
||||||
|
@ -570,6 +570,7 @@
|
|||||||
isa = XCBuildConfiguration;
|
isa = XCBuildConfiguration;
|
||||||
buildSettings = {
|
buildSettings = {
|
||||||
ALWAYS_SEARCH_USER_PATHS = NO;
|
ALWAYS_SEARCH_USER_PATHS = NO;
|
||||||
|
APP_BUNDLE_IDENTIFIER = io.flutter.extensionTest;
|
||||||
CLANG_ANALYZER_NONNULL = YES;
|
CLANG_ANALYZER_NONNULL = YES;
|
||||||
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
|
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
|
||||||
CLANG_CXX_LIBRARY = "libc++";
|
CLANG_CXX_LIBRARY = "libc++";
|
||||||
@ -828,6 +829,7 @@
|
|||||||
isa = XCBuildConfiguration;
|
isa = XCBuildConfiguration;
|
||||||
buildSettings = {
|
buildSettings = {
|
||||||
ALWAYS_SEARCH_USER_PATHS = NO;
|
ALWAYS_SEARCH_USER_PATHS = NO;
|
||||||
|
APP_BUNDLE_IDENTIFIER = io.flutter.extensionTest;
|
||||||
CLANG_ANALYZER_NONNULL = YES;
|
CLANG_ANALYZER_NONNULL = YES;
|
||||||
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
|
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
|
||||||
CLANG_CXX_LIBRARY = "libc++";
|
CLANG_CXX_LIBRARY = "libc++";
|
||||||
@ -883,6 +885,7 @@
|
|||||||
isa = XCBuildConfiguration;
|
isa = XCBuildConfiguration;
|
||||||
buildSettings = {
|
buildSettings = {
|
||||||
ALWAYS_SEARCH_USER_PATHS = NO;
|
ALWAYS_SEARCH_USER_PATHS = NO;
|
||||||
|
APP_BUNDLE_IDENTIFIER = io.flutter.extensionTest;
|
||||||
CLANG_ANALYZER_NONNULL = YES;
|
CLANG_ANALYZER_NONNULL = YES;
|
||||||
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
|
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
|
||||||
CLANG_CXX_LIBRARY = "libc++";
|
CLANG_CXX_LIBRARY = "libc++";
|
||||||
|
@ -25,7 +25,7 @@
|
|||||||
<key>NSExtensionAttributes</key>
|
<key>NSExtensionAttributes</key>
|
||||||
<dict>
|
<dict>
|
||||||
<key>WKAppBundleIdentifier</key>
|
<key>WKAppBundleIdentifier</key>
|
||||||
<string>io.flutter.extensionTest.watchkitapp</string>
|
<string>$(APP_BUNDLE_IDENTIFIER).watchkitapp</string>
|
||||||
</dict>
|
</dict>
|
||||||
<key>NSExtensionPointIdentifier</key>
|
<key>NSExtensionPointIdentifier</key>
|
||||||
<string>com.apple.watchkit</string>
|
<string>com.apple.watchkit</string>
|
||||||
|
@ -26,7 +26,7 @@
|
|||||||
<string>UIInterfaceOrientationPortraitUpsideDown</string>
|
<string>UIInterfaceOrientationPortraitUpsideDown</string>
|
||||||
</array>
|
</array>
|
||||||
<key>WKCompanionAppBundleIdentifier</key>
|
<key>WKCompanionAppBundleIdentifier</key>
|
||||||
<string>io.flutter.extensionTest</string>
|
<string>$(APP_BUNDLE_IDENTIFIER)</string>
|
||||||
<key>WKWatchKitApp</key>
|
<key>WKWatchKitApp</key>
|
||||||
<true/>
|
<true/>
|
||||||
</dict>
|
</dict>
|
||||||
|
@ -689,8 +689,23 @@ class IosProject extends FlutterProjectPlatform implements XcodeBasedProject {
|
|||||||
final File infoFile = hostAppRoot.childDirectory(target).childFile('Info.plist');
|
final File infoFile = hostAppRoot.childDirectory(target).childFile('Info.plist');
|
||||||
// The Info.plist file of a target contains the key WKCompanionAppBundleIdentifier,
|
// The Info.plist file of a target contains the key WKCompanionAppBundleIdentifier,
|
||||||
// if it is a watchOS companion app.
|
// if it is a watchOS companion app.
|
||||||
if (infoFile.existsSync() && globals.plistParser.getValueFromFile(infoFile.path, 'WKCompanionAppBundleIdentifier') == bundleIdentifier) {
|
if (infoFile.existsSync()) {
|
||||||
return true;
|
final String? fromPlist = globals.plistParser.getValueFromFile(infoFile.path, 'WKCompanionAppBundleIdentifier');
|
||||||
|
if (bundleIdentifier == fromPlist) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// The key WKCompanionAppBundleIdentifier might contain an xcode variable
|
||||||
|
// that needs to be substituted before comparing it with bundle id
|
||||||
|
if (fromPlist != null && fromPlist.contains(r'$')) {
|
||||||
|
final Map<String, String>? allBuildSettings = await buildSettingsForBuildInfo(buildInfo);
|
||||||
|
if (allBuildSettings != null) {
|
||||||
|
final String substituedVariable = substituteXcodeVariables(fromPlist, allBuildSettings);
|
||||||
|
if (substituedVariable == bundleIdentifier) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
@ -697,6 +697,24 @@ apply plugin: 'kotlin-android'
|
|||||||
XcodeProjectInterpreter: () => mockXcodeProjectInterpreter,
|
XcodeProjectInterpreter: () => mockXcodeProjectInterpreter,
|
||||||
FlutterProjectFactory: () => flutterProjectFactory,
|
FlutterProjectFactory: () => flutterProjectFactory,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
testUsingContext('has watch companion with build settings', () async {
|
||||||
|
final FlutterProject project = await someProject();
|
||||||
|
project.ios.xcodeProject.createSync();
|
||||||
|
mockXcodeProjectInterpreter.buildSettings = <String, String>{
|
||||||
|
'PRODUCT_BUNDLE_IDENTIFIER': 'io.flutter.someProject',
|
||||||
|
};
|
||||||
|
project.ios.hostAppRoot.childDirectory('WatchTarget').childFile('Info.plist').createSync(recursive: true);
|
||||||
|
testPlistParser.setProperty('WKCompanionAppBundleIdentifier', r'$(PRODUCT_BUNDLE_IDENTIFIER)');
|
||||||
|
|
||||||
|
expect(await project.ios.containsWatchCompanion(<String>['WatchTarget'], null), isTrue);
|
||||||
|
}, overrides: <Type, Generator>{
|
||||||
|
FileSystem: () => fs,
|
||||||
|
ProcessManager: () => FakeProcessManager.any(),
|
||||||
|
PlistParser: () => testPlistParser,
|
||||||
|
XcodeProjectInterpreter: () => mockXcodeProjectInterpreter,
|
||||||
|
FlutterProjectFactory: () => flutterProjectFactory,
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user