mirror of
https://github.com/zhigang1992/RubyMotion.git
synced 2026-05-18 03:53:50 +08:00
[REPL/OSX] Make it work when codesigned and sandboxed.
Fixes http://hipbyte.myjetbrains.com/youtrack/issue/RM-410
This commit is contained in:
2
NEWS
2
NEWS
@@ -3,6 +3,8 @@
|
||||
* Fixed a bug with the `activate' CLI command. Thanks to Joffrey Jaffeux for
|
||||
the patch.
|
||||
* Added a feature to support Subscripting (Objective-C Literals).
|
||||
* Made the REPL for a OS X application work in development mode when it is
|
||||
sandboxed.
|
||||
|
||||
= RubyMotion 2.22 =
|
||||
|
||||
|
||||
24
bin/sim.m
24
bin/sim.m
@@ -1334,16 +1334,20 @@ main(int argc, char **argv)
|
||||
environment] mutableCopy];
|
||||
if (debug_mode != DEBUG_NOTHING) {
|
||||
// Prepare repl socket path.
|
||||
NSString *tmpdir = NSTemporaryDirectory();
|
||||
assert(tmpdir != nil);
|
||||
char path[PATH_MAX];
|
||||
snprintf(path, sizeof path, "%s/rubymotion-repl-XXXXXX",
|
||||
[tmpdir fileSystemRepresentation]);
|
||||
assert(mktemp(path) != NULL);
|
||||
replSocketPath = [[[NSFileManager defaultManager]
|
||||
stringWithFileSystemRepresentation:path length:strlen(path)]
|
||||
retain];
|
||||
[appEnvironment setObject:replSocketPath forKey:@"REPL_SOCKET_PATH"];
|
||||
replSocketPath = [appEnvironment[@"REPL_SOCKET_PATH"] retain];
|
||||
if (replSocketPath == nil) {
|
||||
NSString *tmpdir = NSTemporaryDirectory();
|
||||
assert(tmpdir != nil);
|
||||
char path[PATH_MAX];
|
||||
snprintf(path, sizeof path, "%s/rubymotion-repl-XXXXXX",
|
||||
[tmpdir fileSystemRepresentation]);
|
||||
assert(mktemp(path) != NULL);
|
||||
replSocketPath = [[[NSFileManager defaultManager]
|
||||
stringWithFileSystemRepresentation:path length:strlen(path)]
|
||||
retain];
|
||||
[appEnvironment setObject:replSocketPath
|
||||
forKey:@"REPL_SOCKET_PATH"];
|
||||
}
|
||||
|
||||
// Make sure the unix socket path does not exist.
|
||||
[[NSFileManager defaultManager] removeItemAtPath:replSocketPath
|
||||
|
||||
@@ -58,7 +58,10 @@ task :run do
|
||||
end
|
||||
exec = App.config.app_bundle_executable('MacOSX')
|
||||
env = ''
|
||||
env << 'SIM_SPEC_MODE=1' if App.config.spec_mode
|
||||
env << 'SIM_SPEC_MODE=1 ' if App.config.spec_mode
|
||||
if App.config.needs_repl_sandbox_entitlements?
|
||||
env << "REPL_SOCKET_PATH='#{App.config.app_sandbox_repl_socket_path}' "
|
||||
end
|
||||
sim = File.join(App.config.bindir, 'osx/sim')
|
||||
debug = (ENV['debug'] ? 1 : (App.config.spec_mode ? '0' : '2'))
|
||||
target = App.config.sdk_version
|
||||
|
||||
@@ -100,8 +100,16 @@ module Motion; module Project;
|
||||
super('Mac')
|
||||
end
|
||||
|
||||
def needs_repl_sandbox_entitlements?
|
||||
development? && codesign_for_development && entitlements['com.apple.security.app-sandbox']
|
||||
end
|
||||
|
||||
def entitlements_data
|
||||
dict = entitlements
|
||||
dict = entitlements.dup
|
||||
if needs_repl_sandbox_entitlements?
|
||||
files = (dict['com.apple.security.temporary-exception.files.absolute-path.read-only'] ||= [])
|
||||
files << datadir('librubymotion-repl.dylib')
|
||||
end
|
||||
Motion::PropertyList.to_s(dict)
|
||||
end
|
||||
|
||||
@@ -135,6 +143,10 @@ module Motion; module Project;
|
||||
File.join(app_bundle(platform), 'Resources')
|
||||
end
|
||||
|
||||
def app_sandbox_repl_socket_path
|
||||
File.expand_path(File.join('~/Library/Containers', identifier, "Data/rubymotion-repl-#{Time.now.to_i}"))
|
||||
end
|
||||
|
||||
def info_plist_data(platform)
|
||||
Motion::PropertyList.to_s({
|
||||
'NSHumanReadableCopyright' => copyright,
|
||||
|
||||
Reference in New Issue
Block a user