Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abdullh.alsoleman
Front-End
Commits
e1337218
Unverified
Commit
e1337218
authored
Oct 25, 2022
by
Victoria Ashworth
Committed by
GitHub
Oct 25, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Check for watch companion in build settings (#113956)
parent
ae143ad8
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
291 additions
and
29 deletions
+291
-29
project.pbxproj
..._app_with_extensions/ios/Runner.xcodeproj/project.pbxproj
+3
-0
Info.plist
...ration_tests/ios_app_with_extensions/ios/watch/Info.plist
+0
-2
mac.dart
packages/flutter_tools/lib/src/ios/mac.dart
+4
-3
xcodeproj.dart
packages/flutter_tools/lib/src/ios/xcodeproj.dart
+9
-2
xcode_project.dart
packages/flutter_tools/lib/src/xcode_project.dart
+43
-5
xcodeproj_test.dart
.../flutter_tools/test/general.shard/ios/xcodeproj_test.dart
+70
-0
project_test.dart
packages/flutter_tools/test/general.shard/project_test.dart
+162
-17
No files found.
dev/integration_tests/ios_app_with_extensions/ios/Runner.xcodeproj/project.pbxproj
View file @
e1337218
...
@@ -727,6 +727,7 @@
...
@@ -727,6 +727,7 @@
GCC_C_LANGUAGE_STANDARD
=
gnu11
;
GCC_C_LANGUAGE_STANDARD
=
gnu11
;
IBSC_MODULE
=
watch_Extension
;
IBSC_MODULE
=
watch_Extension
;
INFOPLIST_FILE
=
watch/Info.plist
;
INFOPLIST_FILE
=
watch/Info.plist
;
INFOPLIST_KEY_WKCompanionAppBundleIdentifier
=
io.flutter.extensionTest
;
MARKETING_VERSION
=
1.0.0
;
MARKETING_VERSION
=
1.0.0
;
MTL_ENABLE_DEBUG_INFO
=
INCLUDE_SOURCE
;
MTL_ENABLE_DEBUG_INFO
=
INCLUDE_SOURCE
;
MTL_FAST_MATH
=
YES
;
MTL_FAST_MATH
=
YES
;
...
@@ -757,6 +758,7 @@
...
@@ -757,6 +758,7 @@
GCC_C_LANGUAGE_STANDARD
=
gnu11
;
GCC_C_LANGUAGE_STANDARD
=
gnu11
;
IBSC_MODULE
=
watch_Extension
;
IBSC_MODULE
=
watch_Extension
;
INFOPLIST_FILE
=
watch/Info.plist
;
INFOPLIST_FILE
=
watch/Info.plist
;
INFOPLIST_KEY_WKCompanionAppBundleIdentifier
=
io.flutter.extensionTest
;
MARKETING_VERSION
=
1.0.0
;
MARKETING_VERSION
=
1.0.0
;
MTL_FAST_MATH
=
YES
;
MTL_FAST_MATH
=
YES
;
OTHER_LDFLAGS
=
""
;
OTHER_LDFLAGS
=
""
;
...
@@ -785,6 +787,7 @@
...
@@ -785,6 +787,7 @@
GCC_C_LANGUAGE_STANDARD
=
gnu11
;
GCC_C_LANGUAGE_STANDARD
=
gnu11
;
IBSC_MODULE
=
watch_Extension
;
IBSC_MODULE
=
watch_Extension
;
INFOPLIST_FILE
=
watch/Info.plist
;
INFOPLIST_FILE
=
watch/Info.plist
;
INFOPLIST_KEY_WKCompanionAppBundleIdentifier
=
io.flutter.extensionTest
;
MARKETING_VERSION
=
1.0.0
;
MARKETING_VERSION
=
1.0.0
;
MTL_FAST_MATH
=
YES
;
MTL_FAST_MATH
=
YES
;
OTHER_LDFLAGS
=
""
;
OTHER_LDFLAGS
=
""
;
...
...
dev/integration_tests/ios_app_with_extensions/ios/watch/Info.plist
View file @
e1337218
...
@@ -25,8 +25,6 @@
...
@@ -25,8 +25,6 @@
<
string
>
UIInterfaceOrientationPortrait
<
/string
>
<
string
>
UIInterfaceOrientationPortrait
<
/string
>
<
string
>
UIInterfaceOrientationPortraitUpsideDown
<
/string
>
<
string
>
UIInterfaceOrientationPortraitUpsideDown
<
/string
>
<
/
a
rr
a
y
>
<
/
a
rr
a
y
>
<
k
e
y
>
WKCompanionAppBundleIdentifier
<
/k
e
y
>
<
string
>
$
(
APP_BUNDLE_IDENTIFIER
)<
/string
>
<
k
e
y
>
WKWatchKitApp
<
/k
e
y
>
<
k
e
y
>
WKWatchKitApp
<
/k
e
y
>
<
tru
e
/
>
<
tru
e
/
>
<
/
d
i
c
t
>
<
/
d
i
c
t
>
...
...
packages/flutter_tools/lib/src/ios/mac.dart
View file @
e1337218
...
@@ -265,9 +265,10 @@ Future<XcodeBuildResult> buildXcodeProject({
...
@@ -265,9 +265,10 @@ Future<XcodeBuildResult> buildXcodeProject({
// Check if the project contains a watchOS companion app.
// Check if the project contains a watchOS companion app.
final
bool
hasWatchCompanion
=
await
app
.
project
.
containsWatchCompanion
(
final
bool
hasWatchCompanion
=
await
app
.
project
.
containsWatchCompanion
(
projectInfo
.
targets
,
targets:
projectInfo
.
targets
,
buildInfo
,
schemes:
projectInfo
.
schemes
,
deviceID
,
buildInfo:
buildInfo
,
deviceId:
deviceID
,
);
);
if
(
hasWatchCompanion
)
{
if
(
hasWatchCompanion
)
{
// The -sdk argument has to be omitted if a watchOS companion app exists.
// The -sdk argument has to be omitted if a watchOS companion app exists.
...
...
packages/flutter_tools/lib/src/ios/xcodeproj.dart
View file @
e1337218
...
@@ -198,7 +198,11 @@ class XcodeProjectInterpreter {
...
@@ -198,7 +198,11 @@ class XcodeProjectInterpreter {
if
(
buildContext
.
environmentType
==
EnvironmentType
.
simulator
)
if
(
buildContext
.
environmentType
==
EnvironmentType
.
simulator
)
...<
String
>[
'-sdk'
,
'iphonesimulator'
],
...<
String
>[
'-sdk'
,
'iphonesimulator'
],
'-destination'
,
'-destination'
,
if
(
deviceId
!=
null
)
if
(
buildContext
.
isWatch
==
true
&&
buildContext
.
environmentType
==
EnvironmentType
.
physical
)
'generic/platform=watchOS'
else
if
(
buildContext
.
isWatch
==
true
)
'generic/platform=watchOS Simulator'
else
if
(
deviceId
!=
null
)
'id=
$deviceId
'
'id=
$deviceId
'
else
if
(
buildContext
.
environmentType
==
EnvironmentType
.
physical
)
else
if
(
buildContext
.
environmentType
==
EnvironmentType
.
physical
)
'generic/platform=iOS'
'generic/platform=iOS'
...
@@ -376,12 +380,14 @@ class XcodeProjectBuildContext {
...
@@ -376,12 +380,14 @@ class XcodeProjectBuildContext {
this
.
configuration
,
this
.
configuration
,
this
.
environmentType
=
EnvironmentType
.
physical
,
this
.
environmentType
=
EnvironmentType
.
physical
,
this
.
deviceId
,
this
.
deviceId
,
this
.
isWatch
=
false
,
});
});
final
String
?
scheme
;
final
String
?
scheme
;
final
String
?
configuration
;
final
String
?
configuration
;
final
EnvironmentType
environmentType
;
final
EnvironmentType
environmentType
;
final
String
?
deviceId
;
final
String
?
deviceId
;
final
bool
isWatch
;
@override
@override
int
get
hashCode
=>
Object
.
hash
(
scheme
,
configuration
,
environmentType
,
deviceId
);
int
get
hashCode
=>
Object
.
hash
(
scheme
,
configuration
,
environmentType
,
deviceId
);
...
@@ -395,7 +401,8 @@ class XcodeProjectBuildContext {
...
@@ -395,7 +401,8 @@ class XcodeProjectBuildContext {
other
.
scheme
==
scheme
&&
other
.
scheme
==
scheme
&&
other
.
configuration
==
configuration
&&
other
.
configuration
==
configuration
&&
other
.
deviceId
==
deviceId
&&
other
.
deviceId
==
deviceId
&&
other
.
environmentType
==
environmentType
;
other
.
environmentType
==
environmentType
&&
other
.
isWatch
==
isWatch
;
}
}
}
}
...
...
packages/flutter_tools/lib/src/xcode_project.dart
View file @
e1337218
...
@@ -256,6 +256,8 @@ class IosProject extends XcodeBasedProject {
...
@@ -256,6 +256,8 @@ class IosProject extends XcodeBasedProject {
BuildInfo
?
buildInfo
,
{
BuildInfo
?
buildInfo
,
{
EnvironmentType
environmentType
=
EnvironmentType
.
physical
,
EnvironmentType
environmentType
=
EnvironmentType
.
physical
,
String
?
deviceId
,
String
?
deviceId
,
String
?
scheme
,
bool
isWatch
=
false
,
})
async
{
})
async
{
if
(!
existsSync
())
{
if
(!
existsSync
())
{
return
null
;
return
null
;
...
@@ -265,10 +267,12 @@ class IosProject extends XcodeBasedProject {
...
@@ -265,10 +267,12 @@ class IosProject extends XcodeBasedProject {
return
null
;
return
null
;
}
}
final
String
?
scheme
=
info
.
schemeFor
(
buildInfo
);
if
(
scheme
==
null
)
{
scheme
=
info
.
schemeFor
(
buildInfo
);
if
(
scheme
==
null
)
{
if
(
scheme
==
null
)
{
info
.
reportFlavorNotFoundAndExit
();
info
.
reportFlavorNotFoundAndExit
();
}
}
}
final
String
?
configuration
=
(
await
projectInfo
())?.
buildConfigurationFor
(
final
String
?
configuration
=
(
await
projectInfo
())?.
buildConfigurationFor
(
buildInfo
,
buildInfo
,
...
@@ -279,6 +283,7 @@ class IosProject extends XcodeBasedProject {
...
@@ -279,6 +283,7 @@ class IosProject extends XcodeBasedProject {
scheme:
scheme
,
scheme:
scheme
,
configuration:
configuration
,
configuration:
configuration
,
deviceId:
deviceId
,
deviceId:
deviceId
,
isWatch:
isWatch
,
);
);
final
Map
<
String
,
String
>?
currentBuildSettings
=
_buildSettingsByBuildContext
[
buildContext
];
final
Map
<
String
,
String
>?
currentBuildSettings
=
_buildSettingsByBuildContext
[
buildContext
];
if
(
currentBuildSettings
==
null
)
{
if
(
currentBuildSettings
==
null
)
{
...
@@ -327,7 +332,12 @@ class IosProject extends XcodeBasedProject {
...
@@ -327,7 +332,12 @@ class IosProject extends XcodeBasedProject {
}
}
/// Check if one the [targets] of the project is a watchOS companion app target.
/// Check if one the [targets] of the project is a watchOS companion app target.
Future
<
bool
>
containsWatchCompanion
(
List
<
String
>
targets
,
BuildInfo
buildInfo
,
String
?
deviceId
)
async
{
Future
<
bool
>
containsWatchCompanion
({
required
List
<
String
>
targets
,
required
List
<
String
>
schemes
,
required
BuildInfo
buildInfo
,
String
?
deviceId
,
})
async
{
final
String
?
bundleIdentifier
=
await
productBundleIdentifier
(
buildInfo
);
final
String
?
bundleIdentifier
=
await
productBundleIdentifier
(
buildInfo
);
// A bundle identifier is required for a companion app.
// A bundle identifier is required for a companion app.
if
(
bundleIdentifier
==
null
)
{
if
(
bundleIdentifier
==
null
)
{
...
@@ -336,8 +346,8 @@ class IosProject extends XcodeBasedProject {
...
@@ -336,8 +346,8 @@ class IosProject extends XcodeBasedProject {
for
(
final
String
target
in
targets
)
{
for
(
final
String
target
in
targets
)
{
// Create Info.plist file of the target.
// Create Info.plist file of the target.
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
,
//
In older versions of Xcode, if the target was a watchOS companion app
,
//
if it is a watchOS companion app
.
//
the Info.plist file of the target contained the key WKCompanionAppBundleIdentifier
.
if
(
infoFile
.
existsSync
())
{
if
(
infoFile
.
existsSync
())
{
final
String
?
fromPlist
=
globals
.
plistParser
.
getStringValueFromFile
(
infoFile
.
path
,
'WKCompanionAppBundleIdentifier'
);
final
String
?
fromPlist
=
globals
.
plistParser
.
getStringValueFromFile
(
infoFile
.
path
,
'WKCompanionAppBundleIdentifier'
);
if
(
bundleIdentifier
==
fromPlist
)
{
if
(
bundleIdentifier
==
fromPlist
)
{
...
@@ -357,6 +367,34 @@ class IosProject extends XcodeBasedProject {
...
@@ -357,6 +367,34 @@ class IosProject extends XcodeBasedProject {
}
}
}
}
}
}
// If key not found in Info.plist above, do more expensive check of build settings.
// In newer versions of Xcode, the build settings of the watchOS companion
// app's scheme should contain the key INFOPLIST_KEY_WKCompanionAppBundleIdentifier.
final
bool
watchIdentifierFound
=
xcodeProjectInfoFile
.
readAsStringSync
().
contains
(
'WKCompanionAppBundleIdentifier'
);
if
(
watchIdentifierFound
==
false
)
{
return
false
;
}
for
(
final
String
scheme
in
schemes
)
{
final
Map
<
String
,
String
>?
allBuildSettings
=
await
buildSettingsForBuildInfo
(
buildInfo
,
deviceId:
deviceId
,
scheme:
scheme
,
isWatch:
true
,
);
if
(
allBuildSettings
!=
null
)
{
final
String
?
fromBuild
=
allBuildSettings
[
'INFOPLIST_KEY_WKCompanionAppBundleIdentifier'
];
if
(
bundleIdentifier
==
fromBuild
)
{
return
true
;
}
if
(
fromBuild
!=
null
&&
fromBuild
.
contains
(
r'$'
))
{
final
String
substitutedVariable
=
substituteXcodeVariables
(
fromBuild
,
allBuildSettings
);
if
(
substitutedVariable
==
bundleIdentifier
)
{
return
true
;
}
}
}
}
return
false
;
return
false
;
}
}
...
...
packages/flutter_tools/test/general.shard/ios/xcodeproj_test.dart
View file @
e1337218
...
@@ -395,6 +395,76 @@ void main() {
...
@@ -395,6 +395,76 @@ void main() {
ProcessManager:
()
=>
FakeProcessManager
.
any
(),
ProcessManager:
()
=>
FakeProcessManager
.
any
(),
});
});
testUsingContext
(
'build settings uses watch destination if isWatch is true'
,
()
async
{
platform
.
environment
=
const
<
String
,
String
>{};
fakeProcessManager
.
addCommands
(<
FakeCommand
>[
kWhichSysctlCommand
,
kx64CheckCommand
,
FakeCommand
(
command:
<
String
>[
'xcrun'
,
'xcodebuild'
,
'-project'
,
'/'
,
'-destination'
,
'generic/platform=watchOS'
,
'-showBuildSettings'
,
'BUILD_DIR=
${fileSystem.path.absolute('build', 'ios')}
'
,
],
exitCode:
1
,
),
]);
expect
(
await
xcodeProjectInterpreter
.
getBuildSettings
(
''
,
buildContext:
const
XcodeProjectBuildContext
(
isWatch:
true
),
),
const
<
String
,
String
>{},
);
expect
(
fakeProcessManager
,
hasNoRemainingExpectations
);
},
overrides:
<
Type
,
Generator
>{
FileSystem:
()
=>
fileSystem
,
ProcessManager:
()
=>
FakeProcessManager
.
any
(),
});
testUsingContext
(
'build settings uses watch simulator destination if isWatch is true and environment type is simulator'
,
()
async
{
platform
.
environment
=
const
<
String
,
String
>{};
fakeProcessManager
.
addCommands
(<
FakeCommand
>[
kWhichSysctlCommand
,
kx64CheckCommand
,
FakeCommand
(
command:
<
String
>[
'xcrun'
,
'xcodebuild'
,
'-project'
,
'/'
,
'-sdk'
,
'iphonesimulator'
,
'-destination'
,
'generic/platform=watchOS Simulator'
,
'-showBuildSettings'
,
'BUILD_DIR=
${fileSystem.path.absolute('build', 'ios')}
'
,
],
exitCode:
1
,
),
]);
expect
(
await
xcodeProjectInterpreter
.
getBuildSettings
(
''
,
buildContext:
const
XcodeProjectBuildContext
(
environmentType:
EnvironmentType
.
simulator
,
isWatch:
true
),
),
const
<
String
,
String
>{},
);
expect
(
fakeProcessManager
,
hasNoRemainingExpectations
);
},
overrides:
<
Type
,
Generator
>{
FileSystem:
()
=>
fileSystem
,
ProcessManager:
()
=>
FakeProcessManager
.
any
(),
});
testWithoutContext
(
'xcodebuild clean contains Flutter Xcode environment variables'
,
()
async
{
testWithoutContext
(
'xcodebuild clean contains Flutter Xcode environment variables'
,
()
async
{
platform
.
environment
=
const
<
String
,
String
>{
platform
.
environment
=
const
<
String
,
String
>{
'FLUTTER_XCODE_CODE_SIGN_STYLE'
:
'Manual'
,
'FLUTTER_XCODE_CODE_SIGN_STYLE'
:
'Manual'
,
...
...
packages/flutter_tools/test/general.shard/project_test.dart
View file @
e1337218
...
@@ -458,7 +458,8 @@ apply plugin: 'kotlin-android'
...
@@ -458,7 +458,8 @@ apply plugin: 'kotlin-android'
testWithMocks
(
'from build settings, if no plist'
,
()
async
{
testWithMocks
(
'from build settings, if no plist'
,
()
async
{
final
FlutterProject
project
=
await
someProject
();
final
FlutterProject
project
=
await
someProject
();
project
.
ios
.
xcodeProject
.
createSync
();
project
.
ios
.
xcodeProject
.
createSync
();
xcodeProjectInterpreter
.
buildSettings
=
<
String
,
String
>{
const
XcodeProjectBuildContext
buildContext
=
XcodeProjectBuildContext
(
scheme:
'Runner'
);
xcodeProjectInterpreter
.
buildSettingsByBuildContext
[
buildContext
]
=
<
String
,
String
>{
'PRODUCT_BUNDLE_IDENTIFIER'
:
'io.flutter.someProject'
,
'PRODUCT_BUNDLE_IDENTIFIER'
:
'io.flutter.someProject'
,
};
};
xcodeProjectInterpreter
.
xcodeProjectInfo
=
XcodeProjectInfo
(<
String
>[],
<
String
>[],
<
String
>[
'Runner'
],
logger
);
xcodeProjectInterpreter
.
xcodeProjectInfo
=
XcodeProjectInfo
(<
String
>[],
<
String
>[],
<
String
>[
'Runner'
],
logger
);
...
@@ -486,7 +487,8 @@ apply plugin: 'kotlin-android'
...
@@ -486,7 +487,8 @@ apply plugin: 'kotlin-android'
testWithMocks
(
'from build settings and plist, if default variable'
,
()
async
{
testWithMocks
(
'from build settings and plist, if default variable'
,
()
async
{
final
FlutterProject
project
=
await
someProject
();
final
FlutterProject
project
=
await
someProject
();
project
.
ios
.
xcodeProject
.
createSync
();
project
.
ios
.
xcodeProject
.
createSync
();
xcodeProjectInterpreter
.
buildSettings
=
<
String
,
String
>{
const
XcodeProjectBuildContext
buildContext
=
XcodeProjectBuildContext
(
scheme:
'Runner'
);
xcodeProjectInterpreter
.
buildSettingsByBuildContext
[
buildContext
]
=
<
String
,
String
>{
'PRODUCT_BUNDLE_IDENTIFIER'
:
'io.flutter.someProject'
,
'PRODUCT_BUNDLE_IDENTIFIER'
:
'io.flutter.someProject'
,
};
};
xcodeProjectInterpreter
.
xcodeProjectInfo
=
XcodeProjectInfo
(<
String
>[],
<
String
>[],
<
String
>[
'Runner'
],
logger
);
xcodeProjectInterpreter
.
xcodeProjectInfo
=
XcodeProjectInfo
(<
String
>[],
<
String
>[],
<
String
>[
'Runner'
],
logger
);
...
@@ -499,7 +501,8 @@ apply plugin: 'kotlin-android'
...
@@ -499,7 +501,8 @@ apply plugin: 'kotlin-android'
final
FlutterProject
project
=
await
someProject
();
final
FlutterProject
project
=
await
someProject
();
project
.
ios
.
xcodeProject
.
createSync
();
project
.
ios
.
xcodeProject
.
createSync
();
project
.
ios
.
defaultHostInfoPlist
.
createSync
(
recursive:
true
);
project
.
ios
.
defaultHostInfoPlist
.
createSync
(
recursive:
true
);
xcodeProjectInterpreter
.
buildSettings
=
<
String
,
String
>{
const
XcodeProjectBuildContext
buildContext
=
XcodeProjectBuildContext
(
scheme:
'Runner'
);
xcodeProjectInterpreter
.
buildSettingsByBuildContext
[
buildContext
]
=
<
String
,
String
>{
'PRODUCT_BUNDLE_IDENTIFIER'
:
'io.flutter.someProject'
,
'PRODUCT_BUNDLE_IDENTIFIER'
:
'io.flutter.someProject'
,
'SUFFIX'
:
'suffix'
,
'SUFFIX'
:
'suffix'
,
};
};
...
@@ -534,7 +537,8 @@ apply plugin: 'kotlin-android'
...
@@ -534,7 +537,8 @@ apply plugin: 'kotlin-android'
testWithMocks
(
'handles case insensitive flavor'
,
()
async
{
testWithMocks
(
'handles case insensitive flavor'
,
()
async
{
final
FlutterProject
project
=
await
someProject
();
final
FlutterProject
project
=
await
someProject
();
project
.
ios
.
xcodeProject
.
createSync
();
project
.
ios
.
xcodeProject
.
createSync
();
xcodeProjectInterpreter
.
buildSettings
=
<
String
,
String
>{
const
XcodeProjectBuildContext
buildContext
=
XcodeProjectBuildContext
(
scheme:
'Free'
);
xcodeProjectInterpreter
.
buildSettingsByBuildContext
[
buildContext
]
=
<
String
,
String
>{
'PRODUCT_BUNDLE_IDENTIFIER'
:
'io.flutter.someProject'
,
'PRODUCT_BUNDLE_IDENTIFIER'
:
'io.flutter.someProject'
,
};
};
xcodeProjectInterpreter
.
xcodeProjectInfo
=
XcodeProjectInfo
(<
String
>[],
<
String
>[],
<
String
>[
'Free'
],
logger
);
xcodeProjectInterpreter
.
xcodeProjectInfo
=
XcodeProjectInfo
(<
String
>[],
<
String
>[],
<
String
>[
'Free'
],
logger
);
...
@@ -603,7 +607,8 @@ apply plugin: 'kotlin-android'
...
@@ -603,7 +607,8 @@ apply plugin: 'kotlin-android'
testUsingContext
(
'app product name xcodebuild settings'
,
()
async
{
testUsingContext
(
'app product name xcodebuild settings'
,
()
async
{
final
FlutterProject
project
=
await
someProject
();
final
FlutterProject
project
=
await
someProject
();
project
.
ios
.
xcodeProject
.
createSync
();
project
.
ios
.
xcodeProject
.
createSync
();
mockXcodeProjectInterpreter
.
buildSettings
=
<
String
,
String
>{
const
XcodeProjectBuildContext
buildContext
=
XcodeProjectBuildContext
(
scheme:
'Runner'
);
mockXcodeProjectInterpreter
.
buildSettingsByBuildContext
[
buildContext
]
=
<
String
,
String
>{
'FULL_PRODUCT_NAME'
:
'My App.app'
,
'FULL_PRODUCT_NAME'
:
'My App.app'
,
};
};
mockXcodeProjectInterpreter
.
xcodeProjectInfo
=
XcodeProjectInfo
(<
String
>[],
<
String
>[],
<
String
>[
'Runner'
],
logger
);
mockXcodeProjectInterpreter
.
xcodeProjectInfo
=
XcodeProjectInfo
(<
String
>[],
<
String
>[],
<
String
>[
'Runner'
],
logger
);
...
@@ -705,7 +710,15 @@ apply plugin: 'kotlin-android'
...
@@ -705,7 +710,15 @@ apply plugin: 'kotlin-android'
testUsingContext
(
'cannot find bundle identifier'
,
()
async
{
testUsingContext
(
'cannot find bundle identifier'
,
()
async
{
final
FlutterProject
project
=
await
someProject
();
final
FlutterProject
project
=
await
someProject
();
expect
(
await
project
.
ios
.
containsWatchCompanion
(<
String
>[
'WatchTarget'
],
BuildInfo
.
debug
,
'123'
),
isFalse
);
expect
(
await
project
.
ios
.
containsWatchCompanion
(
targets:
<
String
>[
'WatchTarget'
],
schemes:
<
String
>[],
buildInfo:
BuildInfo
.
debug
,
deviceId:
'123'
,
),
isFalse
,
);
},
overrides:
<
Type
,
Generator
>{
},
overrides:
<
Type
,
Generator
>{
FileSystem:
()
=>
fs
,
FileSystem:
()
=>
fs
,
ProcessManager:
()
=>
FakeProcessManager
.
any
(),
ProcessManager:
()
=>
FakeProcessManager
.
any
(),
...
@@ -716,7 +729,8 @@ apply plugin: 'kotlin-android'
...
@@ -716,7 +729,8 @@ apply plugin: 'kotlin-android'
group
(
'with bundle identifier'
,
()
{
group
(
'with bundle identifier'
,
()
{
setUp
(()
{
setUp
(()
{
mockXcodeProjectInterpreter
.
buildSettings
=
<
String
,
String
>{
const
XcodeProjectBuildContext
buildContext
=
XcodeProjectBuildContext
(
scheme:
'Runner'
);
mockXcodeProjectInterpreter
.
buildSettingsByBuildContext
[
buildContext
]
=
<
String
,
String
>{
'PRODUCT_BUNDLE_IDENTIFIER'
:
'io.flutter.someProject'
,
'PRODUCT_BUNDLE_IDENTIFIER'
:
'io.flutter.someProject'
,
};
};
mockXcodeProjectInterpreter
.
xcodeProjectInfo
=
XcodeProjectInfo
(<
String
>[],
<
String
>[],
<
String
>[
'Runner'
],
logger
);
mockXcodeProjectInterpreter
.
xcodeProjectInfo
=
XcodeProjectInfo
(<
String
>[],
<
String
>[],
<
String
>[
'Runner'
],
logger
);
...
@@ -724,7 +738,15 @@ apply plugin: 'kotlin-android'
...
@@ -724,7 +738,15 @@ apply plugin: 'kotlin-android'
testUsingContext
(
'no Info.plist in target'
,
()
async
{
testUsingContext
(
'no Info.plist in target'
,
()
async
{
final
FlutterProject
project
=
await
someProject
();
final
FlutterProject
project
=
await
someProject
();
expect
(
await
project
.
ios
.
containsWatchCompanion
(<
String
>[
'WatchTarget'
],
BuildInfo
.
debug
,
'123'
),
isFalse
);
expect
(
await
project
.
ios
.
containsWatchCompanion
(
targets:
<
String
>[
'WatchTarget'
],
schemes:
<
String
>[],
buildInfo:
BuildInfo
.
debug
,
deviceId:
'123'
,
),
isFalse
,
);
},
overrides:
<
Type
,
Generator
>{
},
overrides:
<
Type
,
Generator
>{
FileSystem:
()
=>
fs
,
FileSystem:
()
=>
fs
,
ProcessManager:
()
=>
FakeProcessManager
.
any
(),
ProcessManager:
()
=>
FakeProcessManager
.
any
(),
...
@@ -737,7 +759,15 @@ apply plugin: 'kotlin-android'
...
@@ -737,7 +759,15 @@ apply plugin: 'kotlin-android'
final
FlutterProject
project
=
await
someProject
();
final
FlutterProject
project
=
await
someProject
();
project
.
ios
.
hostAppRoot
.
childDirectory
(
'WatchTarget'
).
childFile
(
'Info.plist'
).
createSync
(
recursive:
true
);
project
.
ios
.
hostAppRoot
.
childDirectory
(
'WatchTarget'
).
childFile
(
'Info.plist'
).
createSync
(
recursive:
true
);
expect
(
await
project
.
ios
.
containsWatchCompanion
(<
String
>[
'WatchTarget'
],
BuildInfo
.
debug
,
'123'
),
isFalse
);
expect
(
await
project
.
ios
.
containsWatchCompanion
(
targets:
<
String
>[
'WatchTarget'
],
schemes:
<
String
>[],
buildInfo:
BuildInfo
.
debug
,
deviceId:
'123'
,
),
isFalse
,
);
},
overrides:
<
Type
,
Generator
>{
},
overrides:
<
Type
,
Generator
>{
FileSystem:
()
=>
fs
,
FileSystem:
()
=>
fs
,
ProcessManager:
()
=>
FakeProcessManager
.
any
(),
ProcessManager:
()
=>
FakeProcessManager
.
any
(),
...
@@ -751,7 +781,15 @@ apply plugin: 'kotlin-android'
...
@@ -751,7 +781,15 @@ apply plugin: 'kotlin-android'
project
.
ios
.
hostAppRoot
.
childDirectory
(
'WatchTarget'
).
childFile
(
'Info.plist'
).
createSync
(
recursive:
true
);
project
.
ios
.
hostAppRoot
.
childDirectory
(
'WatchTarget'
).
childFile
(
'Info.plist'
).
createSync
(
recursive:
true
);
testPlistParser
.
setProperty
(
'WKCompanionAppBundleIdentifier'
,
'io.flutter.someOTHERproject'
);
testPlistParser
.
setProperty
(
'WKCompanionAppBundleIdentifier'
,
'io.flutter.someOTHERproject'
);
expect
(
await
project
.
ios
.
containsWatchCompanion
(<
String
>[
'WatchTarget'
],
BuildInfo
.
debug
,
'123'
),
isFalse
);
expect
(
await
project
.
ios
.
containsWatchCompanion
(
targets:
<
String
>[
'WatchTarget'
],
schemes:
<
String
>[],
buildInfo:
BuildInfo
.
debug
,
deviceId:
'123'
,
),
isFalse
,
);
},
overrides:
<
Type
,
Generator
>{
},
overrides:
<
Type
,
Generator
>{
FileSystem:
()
=>
fs
,
FileSystem:
()
=>
fs
,
ProcessManager:
()
=>
FakeProcessManager
.
any
(),
ProcessManager:
()
=>
FakeProcessManager
.
any
(),
...
@@ -760,13 +798,21 @@ apply plugin: 'kotlin-android'
...
@@ -760,13 +798,21 @@ apply plugin: 'kotlin-android'
FlutterProjectFactory:
()
=>
flutterProjectFactory
,
FlutterProjectFactory:
()
=>
flutterProjectFactory
,
});
});
testUsingContext
(
'has watch companion'
,
()
async
{
testUsingContext
(
'has watch companion
in plist
'
,
()
async
{
final
FlutterProject
project
=
await
someProject
();
final
FlutterProject
project
=
await
someProject
();
project
.
ios
.
xcodeProject
.
createSync
();
project
.
ios
.
xcodeProject
.
createSync
();
project
.
ios
.
hostAppRoot
.
childDirectory
(
'WatchTarget'
).
childFile
(
'Info.plist'
).
createSync
(
recursive:
true
);
project
.
ios
.
hostAppRoot
.
childDirectory
(
'WatchTarget'
).
childFile
(
'Info.plist'
).
createSync
(
recursive:
true
);
testPlistParser
.
setProperty
(
'WKCompanionAppBundleIdentifier'
,
'io.flutter.someProject'
);
testPlistParser
.
setProperty
(
'WKCompanionAppBundleIdentifier'
,
'io.flutter.someProject'
);
expect
(
await
project
.
ios
.
containsWatchCompanion
(<
String
>[
'WatchTarget'
],
BuildInfo
.
debug
,
'123'
),
isTrue
);
expect
(
await
project
.
ios
.
containsWatchCompanion
(
targets:
<
String
>[
'WatchTarget'
],
schemes:
<
String
>[],
buildInfo:
BuildInfo
.
debug
,
deviceId:
'123'
,
),
isTrue
,
);
},
overrides:
<
Type
,
Generator
>{
},
overrides:
<
Type
,
Generator
>{
FileSystem:
()
=>
fs
,
FileSystem:
()
=>
fs
,
ProcessManager:
()
=>
FakeProcessManager
.
any
(),
ProcessManager:
()
=>
FakeProcessManager
.
any
(),
...
@@ -775,16 +821,112 @@ apply plugin: 'kotlin-android'
...
@@ -775,16 +821,112 @@ apply plugin: 'kotlin-android'
FlutterProjectFactory:
()
=>
flutterProjectFactory
,
FlutterProjectFactory:
()
=>
flutterProjectFactory
,
});
});
testUsingContext
(
'has watch companion
with build settings
'
,
()
async
{
testUsingContext
(
'has watch companion
in plist with xcode variable
'
,
()
async
{
final
FlutterProject
project
=
await
someProject
();
final
FlutterProject
project
=
await
someProject
();
project
.
ios
.
xcodeProject
.
createSync
();
project
.
ios
.
xcodeProject
.
createSync
();
mockXcodeProjectInterpreter
.
buildSettings
=
<
String
,
String
>{
const
XcodeProjectBuildContext
buildContext
=
XcodeProjectBuildContext
(
scheme:
'Runner'
,
deviceId:
'123'
,
);
mockXcodeProjectInterpreter
.
buildSettingsByBuildContext
[
buildContext
]
=
<
String
,
String
>{
'PRODUCT_BUNDLE_IDENTIFIER'
:
'io.flutter.someProject'
,
'PRODUCT_BUNDLE_IDENTIFIER'
:
'io.flutter.someProject'
,
};
};
project
.
ios
.
hostAppRoot
.
childDirectory
(
'WatchTarget'
).
childFile
(
'Info.plist'
).
createSync
(
recursive:
true
);
project
.
ios
.
hostAppRoot
.
childDirectory
(
'WatchTarget'
).
childFile
(
'Info.plist'
).
createSync
(
recursive:
true
);
testPlistParser
.
setProperty
(
'WKCompanionAppBundleIdentifier'
,
r'$(PRODUCT_BUNDLE_IDENTIFIER)'
);
testPlistParser
.
setProperty
(
'WKCompanionAppBundleIdentifier'
,
r'$(PRODUCT_BUNDLE_IDENTIFIER)'
);
expect
(
await
project
.
ios
.
containsWatchCompanion
(<
String
>[
'WatchTarget'
],
BuildInfo
.
debug
,
'123'
),
isTrue
);
expect
(
await
project
.
ios
.
containsWatchCompanion
(
targets:
<
String
>[
'WatchTarget'
],
schemes:
<
String
>[],
buildInfo:
BuildInfo
.
debug
,
deviceId:
'123'
,
),
isTrue
,
);
},
overrides:
<
Type
,
Generator
>{
FileSystem:
()
=>
fs
,
ProcessManager:
()
=>
FakeProcessManager
.
any
(),
PlistParser:
()
=>
testPlistParser
,
XcodeProjectInterpreter:
()
=>
mockXcodeProjectInterpreter
,
FlutterProjectFactory:
()
=>
flutterProjectFactory
,
});
testUsingContext
(
'has watch companion in other scheme build settings'
,
()
async
{
final
FlutterProject
project
=
await
someProject
();
project
.
ios
.
xcodeProject
.
createSync
();
project
.
ios
.
xcodeProjectInfoFile
.
writeAsStringSync
(
'''
Build settings for action build and target "WatchTarget":
INFOPLIST_KEY_WKCompanionAppBundleIdentifier = io.flutter.someProject
'''
);
const
XcodeProjectBuildContext
buildContext
=
XcodeProjectBuildContext
(
scheme:
'Runner'
,
deviceId:
'123'
,
);
mockXcodeProjectInterpreter
.
buildSettingsByBuildContext
[
buildContext
]
=
<
String
,
String
>{
'PRODUCT_BUNDLE_IDENTIFIER'
:
'io.flutter.someProject'
,
};
const
XcodeProjectBuildContext
watchBuildContext
=
XcodeProjectBuildContext
(
scheme:
'WatchScheme'
,
deviceId:
'123'
,
isWatch:
true
,
);
mockXcodeProjectInterpreter
.
buildSettingsByBuildContext
[
watchBuildContext
]
=
<
String
,
String
>{
'INFOPLIST_KEY_WKCompanionAppBundleIdentifier'
:
'io.flutter.someProject'
,
};
expect
(
await
project
.
ios
.
containsWatchCompanion
(
targets:
<
String
>[
'Runner'
,
'WatchTarget'
],
schemes:
<
String
>[
'Runner'
,
'WatchScheme'
],
buildInfo:
BuildInfo
.
debug
,
deviceId:
'123'
,
),
isTrue
,
);
},
overrides:
<
Type
,
Generator
>{
FileSystem:
()
=>
fs
,
ProcessManager:
()
=>
FakeProcessManager
.
any
(),
PlistParser:
()
=>
testPlistParser
,
XcodeProjectInterpreter:
()
=>
mockXcodeProjectInterpreter
,
FlutterProjectFactory:
()
=>
flutterProjectFactory
,
});
testUsingContext
(
'has watch companion in other scheme build settings with xcode variable'
,
()
async
{
final
FlutterProject
project
=
await
someProject
();
project
.
ios
.
xcodeProject
.
createSync
();
project
.
ios
.
xcodeProjectInfoFile
.
writeAsStringSync
(
r''
'
Build settings for action build and target "WatchTarget":
INFOPLIST_KEY_WKCompanionAppBundleIdentifier =
$
(PRODUCT_BUNDLE_IDENTIFIER)
'''
);
const
XcodeProjectBuildContext
buildContext
=
XcodeProjectBuildContext
(
scheme:
'Runner'
,
deviceId:
'123'
);
mockXcodeProjectInterpreter
.
buildSettingsByBuildContext
[
buildContext
]
=
<
String
,
String
>{
'PRODUCT_BUNDLE_IDENTIFIER'
:
'io.flutter.someProject'
,
};
const
XcodeProjectBuildContext
watchBuildContext
=
XcodeProjectBuildContext
(
scheme:
'WatchScheme'
,
deviceId:
'123'
,
isWatch:
true
,
);
mockXcodeProjectInterpreter
.
buildSettingsByBuildContext
[
watchBuildContext
]
=
<
String
,
String
>{
'PRODUCT_BUNDLE_IDENTIFIER'
:
'io.flutter.someProject'
,
'INFOPLIST_KEY_WKCompanionAppBundleIdentifier'
:
r'$(PRODUCT_BUNDLE_IDENTIFIER)'
,
};
expect
(
await
project
.
ios
.
containsWatchCompanion
(
targets:
<
String
>[
'Runner'
,
'WatchTarget'
],
schemes:
<
String
>[
'Runner'
,
'WatchScheme'
],
buildInfo:
BuildInfo
.
debug
,
deviceId:
'123'
,
),
isTrue
,
);
},
overrides:
<
Type
,
Generator
>{
},
overrides:
<
Type
,
Generator
>{
FileSystem:
()
=>
fs
,
FileSystem:
()
=>
fs
,
ProcessManager:
()
=>
FakeProcessManager
.
any
(),
ProcessManager:
()
=>
FakeProcessManager
.
any
(),
...
@@ -1075,7 +1217,7 @@ File androidPluginRegistrant(Directory parent) {
...
@@ -1075,7 +1217,7 @@ File androidPluginRegistrant(Directory parent) {
}
}
class
FakeXcodeProjectInterpreter
extends
Fake
implements
XcodeProjectInterpreter
{
class
FakeXcodeProjectInterpreter
extends
Fake
implements
XcodeProjectInterpreter
{
Map
<
String
,
String
>
buildSettings
=
<
String
,
String
>{};
final
Map
<
XcodeProjectBuildContext
,
Map
<
String
,
String
>>
buildSettingsByBuildContext
=
<
XcodeProjectBuildContext
,
Map
<
String
,
String
>
>{};
late
XcodeProjectInfo
xcodeProjectInfo
;
late
XcodeProjectInfo
xcodeProjectInfo
;
@override
@override
...
@@ -1083,7 +1225,10 @@ class FakeXcodeProjectInterpreter extends Fake implements XcodeProjectInterprete
...
@@ -1083,7 +1225,10 @@ class FakeXcodeProjectInterpreter extends Fake implements XcodeProjectInterprete
XcodeProjectBuildContext
?
buildContext
,
XcodeProjectBuildContext
?
buildContext
,
Duration
timeout
=
const
Duration
(
minutes:
1
),
Duration
timeout
=
const
Duration
(
minutes:
1
),
})
async
{
})
async
{
return
buildSettings
;
if
(
buildSettingsByBuildContext
[
buildContext
]
==
null
)
{
return
<
String
,
String
>{};
}
return
buildSettingsByBuildContext
[
buildContext
]!;
}
}
@override
@override
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment