WatchKit and MagicalRecord - is that possible? - watchkit

I've got an iOS app with Core Data via MagicalRecord. Now I'd like to extend the app with a WatchKit Extension and therefore need access to MagicalRecord. Is this possible or do I have to switch over to "native" Core Data? It would be perfect if I could use Magical Record in the WatchKit extension, but I couldn't figure out how until now. I can't even include my cocoapods in the shared Cocoa Touch Framework... (use CocoaPods 0.36.0 in CocoaTouchFramework with Swift)

There shouldn't be any problems using MagicalRecord in your WatchKit Extension. You will need to do the following.
In your General Settings for your WatchKit Extension you will need to add libPods.a to your Linked Frameworks and Libraries.
You will need to have MagicalRecord used a database in the shared group folder and not its default app folder. To do that you will need to do this when you set up MagicalRecord
NSString* dbPath = [self sharedAppGroupDirectory];
dbPath = [dbPath stringByAppendingPathComponent:#"MyDatabaseName.sqlite"];
NSURL* dbURL = [NSURL fileURLWithPath:dbPath];
[MagicalRecord setupCoreDataStackWithAutoMigratingSqliteStoreNamed:(id)dbURL];
You can get the shared App Group Directory with this.
NSFileManager *fm = [NSFileManager defaultManager];
NSString *appGroupName = #"group.com.mygroup";
NSURL *groupContainerURL = [fm containerURLForSecurityApplicationGroupIdentifier:appGroupName];
NSString* path = [groupContainerURL filePathString];

Add one line in your Profile file
link_with 'yourApp', 'yourAppExtension'
Then run the command line on your Terminal
pod install

Related

Send data from Share Extension to Xamatin.Forms app

I work on Share Extension. And it only has a sample project (following link) and a general extension documentation.
Basic project:
Extension documentation:
When I click share with my app on iphone (for example on photos), I want to send this file to my app and upload it remote server. But I couldn't find anyway to send object from share extension. I looked up and probably I need to use "NSUserDefaults" and I tried to use it that:
I did necessary settings (creating group id, app id etc) on my apple developer account.
I did necessary settings on my project Entitlements.plist
I try to send on ShareViewController - DidSelectPost method in the my project's share extension as below:
var default = new NSUserDefaults ("group.com.myapp.AppName", NSUserDefaultsType.SuiteName);
default.SetString ("Test content", "TestKey");
default.Synchronize ();
4)I try to receive string data on my main project's AppDelegate as below:
var default = new NSUserDefaults ("group.com.myapp.AppName", NSUserDefaultsType.SuiteName);
var key = default.StringForKey ("TestKey");
string value = key;
But I couldn't do it. And I saw someone did this with OpenUrl function. I tried this and this didn't work.
I started mobile programming with Xamarin forms and I don't know enough native iOS programming (I only learn with Xamarin). I think share extension has insufficient documentation.

Access a Meteor App's unique .id

I'm writing a Meteor package that needs to know the id of the app that includes it -- the value that is saved in the .meteor/.id file relative to the project directory.
How can I access the id safely in development AND in production?
This is doable from server-side code using NPM. I just tested the following on my local project and it works:
// server-side code
// FYI, Npm.require works in packages only. Use meteorhacks:npm to use
// in non-package code. In meteor shell you can just use `require`.
var fs = Npm.require('fs');
var path = Npm.require('path');
var idPath = path.join(process.env.PWD, '.meteor/.id');
var fileContent = fs.readFileSync(idPath);
var fileContentLines = fileContent.toString().split('\n');
// this will contain the ID
var theId = fileContentLines[fileContentLines.length - 2];
Now, keep in mind that in production, you don't have the .meteor directory. After running a grep for the id in the build folder, it seems to me like that ID is not stored in any file within the build. Therefore, you will need to create a build plugin which makes sure to make it accessible somewhere during the build process. I may not have looked hard enough, so I would definitely take a look at the source for the build tool and see what it does with that ID during build.
In Meteor 1.2.1, (and 1.3) the appId is accessible via the __meteor_runtime_config__.appId variable on the client and server in development mode. This is undocumented so we don't know if it will be available in future versions.
The .appId property of __meteor_runtime_config__ is NOT available:
In production mode (when Meteor.isProduction)
In test mode (when Meteor.isTest)
In app test mode (when Meteor.isAppTest)
How about using Meteor Settings file http://docs.meteor.com/#/full/meteor_settings? It should be the right way to do that, Otherwise you will have to use Node.js to access the file directly

Unity ios build work with debug mode but crash with release mode (archive ipa)

I'm trying to use sqlite with sqlcipher for unity ios game.
I get an sqlite unity example https://github.com/takezoux2/unity-orm
I added a method for unity to call function set key:
[DllImport("__Internal", EntryPoint = "sqlite3_key")]
private static extern int sqlite3_key(IntPtr stmHandle, string key, int len);
I compiled sqlcipher to static library (libsqlcipher.a). Add it to Assets/Plugins/iOS with header sqlite3.h, sqlite3ext.h
In Unity editor, it works without encryption. It's ok. I just want encryption work on ios devices.
I keep moving on export Xcode project, config OPENSSL_SRC in Source trees, add C flag -DSQLITE_HAS_CODEC, add search header "sqlcipher", add Security framework then run on device.
It works! There is no issue. I get the database encrypted in Document folder (i tested it with hexdump -C, SQLiteManager)
The problem only occurred after I archive the app to ipa file (using enterprise provisioning profile). I Use iFunbox to install app to device. The app crash immediately on launch.
This is what i get from crash log:
Exception Type: EXC_BAD_ACCESS (SIGABRT)
Exception Subtype: KERN_INVALID_ADDRESS at 0x00000000
I try to replace sqlite3_key with PRAGMA key='123456';
No more crash, everything works but the output database is not encrypted.
I don't know what different between Archive and Build mode. My example works if i build directly to device (with both sqlite3_key and PRAGMA key='123456';), but archive mode does not.
I also try to import sqlcipher xcode project to unity xcode project (remove libsqlcipher.a from Plugins/iOS), set all architectures to armv7 (also try with/without -mno-thumb), add C flag -DSQLITE_HAS_CODEC, add search header "sqlcipher", add Security framework then run directly on device. It work!!!
Then i try to archive app, install app with iFunbox. Again, i get crash on launch.
I'm not sure if i'm setting something wrong with my project (https://github.com/tamhv/unity-orm-with-encrypt). Please someone take a look on this and give me advice. Thank you so much!
I can't tell you why you are crashing, but you can switch your app to Release mode and then debug it to find out.
In XCode, On the top toolbar next to the play/stop button press on the Project name to bring up the context menu and select Edit Schema.
Under Run/Debug change the Build configuration to Release.
Now run the app from XCode and hopefully you'll see the same crash but have a stack trace.

AIR 2.0 NativeProcess is not supported problem

I have built a application that use a nativeProcess to open exe.
The application into Flex Builder 3 run whitout errors.
Then the problem come when I export the aplicaction AIR in .air and install the applicaction in the developer pc or other pc.
When I push the button to open the .exe, appear the message "Native Process is not supported".
The code in the main.mxml that I use:
if (NativeProcess.isSupported)
{
var file:File = new File("app:/config/AbrirAplicacion.exe");
var nativeProcessStartupInfo:NativeProcessStartupInfo = new NativeProcessStartupInfo();
nativeProcessStartupInfo.executable = file;
process = new NativeProcess();
process.start(nativeProcessStartupInfo);
process.standardInput.writeUTFBytes(textReceived.text+"\n");
process.addEventListener(ProgressEvent.STANDARD_OUTPUT_DATA, onOutputData);
process.addEventListener(ProgressEvent.STANDARD_INPUT_PROGRESS, inputProgressListener);
}
else
{
textReceived.text = "NativeProcess not supported.";
}
Any ideas of what I'm doing wrong?
NativeProcess is only available when applications are compiled to native binaries, not .air installers.
You have to set the supportedProfiles-tag to 'extendedDesktop' in order to work with Native Process.
Put / uncomment this line below in your app.xml:
<supportedProfiles>extendedDesktop</supportedProfiles>
NativeProcess can be compiled with Air2 it's just very tricky. The problem is that you have to COMPLETLEY overlay your Flex SDK and the new Air2. Surprisingly, according to this link, you cannot do it through the finder and should do it through the terminal. In Mac:
Download the SDK from Air SDK and put it in folder 1.
Make a copy of your flex SDK and put it on folder 2 (in the flex Builder sdks folder)
Write ditto -V folder1 folder2 in the terminal to overlay them.
Now go to your project's preferences and select the folder2 as sdk (now it's overlay with folder1).
Also, you will probably need to change the description to:
http://ns.adobe.com/air/application/2.0
There is very good description on Installing the Adobe AIR 2 SDK in Eclipse (check part 3).
Hope that helps.
Solved by
Export with native signed not AIR sign

Open local file with AIR / Flex

I have written an AIR Application that downloads videos and documents from a server. The videos play inside of the application, but I would like the user to be able to open the documents in their native applications.
I am looking for a way to prompt the user to Open / Save As on a local file stored in the Application Storage Directory. I have tried using the FileReference + URLRequest classes but this throws an exception that it needs a remote url.
My last resort is just copying the file to their desktop : \
You can use the new openWithDefaultApplication(); function that's available on the File class (I believe it's only available in AIR 2)
eg:
var file:File = File.desktopDirectory.resolvePath(fileLocation);
file.openWithDefaultApplication();
Only way I could figure out how to do it without just moving the file and telling the user was to pass it off to the browser.
navigateToURL(new URLRequest(File.applicationStorageDirectory.nativePath + "/courses/" + fileName));
This is the first release of the FluorineFx Aperture framework.
The framework provides native OS integration (Windows only) support for AIR desktop applications.
The framework extends Adobe AIR applications in a non-intrusive way: simply redistribute the provided libraries with your AIR application, at runtime the framework will automatically hook into your application.
Features
Launch native applications and documents with the provided apsystem library
Take screenshots of the whole screen with the provided apimaging library
Access Outlook contacts from an Air application with the provided apoutlook library
http://aperture.fluorinefx.com/
Currently adobe is not supporting opening files in there default applications. Passing it off to the browser seems to be the only way to make it work.
You could however use a FileStream and write a small html file with some javascript that sets the location of an iframe to the file, then after 100ms or so calls window.close(). Then open that file in the browser.
For me it's:
var request:URLRequest = new URLRequest();
request.url = file.url;
navigateToURL(request, "_blank");
The navigateToURL(file.nativePath) didn't work since the path, "/users/mydirectory/..." was outside the application sandbox. AIR only allows some protocols to be opened with navigateToURL().

Resources