lib/run_loop/app.rb in run_loop-2.7.1 vs lib/run_loop/app.rb in run_loop-3.0.0
- old
+ new
@@ -14,11 +14,25 @@
# @return [RunLoop::App] A instance of App with a path.
def initialize(app_bundle_path)
@path = File.expand_path(app_bundle_path)
if !App.valid?(app_bundle_path)
- raise ArgumentError,
+ if App.cached_app_on_simulator?(app_bundle_path)
+ raise RuntimeError, %Q{
+App is "cached" on the simulator.
+
+#{app_bundle_path}
+
+This can happen if there was an incomplete install or uninstall.
+
+Try manually deleting the application data container and relaunching the simulator.
+
+$ rm -r #{File.dirname(app_bundle_path)}
+$ run-loop simctl manage-processes
+}
+ else
+ raise ArgumentError,
%Q{App does not exist at path or is not an app bundle.
#{app_bundle_path}
Bundle must:
@@ -26,10 +40,11 @@
1. be a directory that exists,
2. have a .app extension,
3. contain an Info.plist,
4. and the app binary (CFBundleExecutable) must exist
}
+ end
end
end
# @!visibility private
def to_s
@@ -69,10 +84,23 @@
return false if !self.info_plist_exist?(app_bundle_path)
return false if !self.executable_file_exist?(app_bundle_path)
true
end
+ # @!visibility private
+ #
+ # Starting in Xcode 10 betas, this can happen if there was an incomplete
+ # install or uninstall.
+ def self.cached_app_on_simulator?(app_bundle_path)
+ return false if Dir[File.join(app_bundle_path, "**/*")].length != 2
+ return false if !app_bundle_path[RunLoop::Regex::CORE_SIMULATOR_UDID_REGEX]
+ [File.join(app_bundle_path, "Info.plist"),
+ File.join(app_bundle_path, "Icon.png")].all? do |file|
+ File.exist?(file)
+ end
+ end
+
# Returns the Info.plist path.
# @raise [RuntimeError] If there is no Info.plist.
def info_plist_path
@info_plist_path ||= File.join(path, 'Info.plist')
end
@@ -124,9 +152,17 @@
executables.each do |executable|
version = strings(executable).server_version
break if version
end
version
+ end
+
+ # @!visibility private
+ # Return the fingerprint of the linked server
+ def calabash_server_id
+ name = plist_buddy.plist_read("CFBundleExecutable", info_plist_path)
+ app_executable = File.join(self.path, name)
+ strings(app_executable).server_id
end
# @!visibility private
def codesign_info
RunLoop::Codesign.info(path)