how to add a ready-to-use project to Three20UI - three20

I have a ready-to-use project ( microblog ),I want to add the microblog project to my other project which has Three20 integrated in. From the - (void)clickActionItem {}; function of the three20UI, to call the microblog project.
And now, I can call the microblog project from my other project, but can't call it from my other project's three20UI.
For those codes: self.window.rootViewController = self.sinaWeiBoSDKDemoViewController;
[self.window makeKeyAndVisible];
I get errors: "request for member 'window' in something not a structure or union"
Would you please tell me how to do it?
thanks!

Related

How to add trivial OpenGL functionality to Xamarin forms app

Can anyone please help with the following?
I have a trivial Xamarin forms app working and I want to add an OpenTK view.
The following works fine:
In my MainPage.xaml.cs I have the following event handler for a button which spawns an empty OpenTK view on each click:
private void OnXAMLButtonClicked(object sender, EventArgs e)
{
var view = new OpenGLView { HasRenderLoop = true };
view.HeightRequest = 300;
view.WidthRequest = 300;
view.OnDisplay = r =>
{
//GL.ClearColor(red, green, blue, 1.0f);
};
m_SL.Children.Add(view);
}
(where m_SL is the name of my StackLayout).
I get a new black window on each click. Great.
Now, see that commented-out line, that's because the value GL is undefined.
This code is from the simple example here:
https://learn.microsoft.com/en-us/dotnet/api/xamarin.forms.openglview?view=xamarin-forms
I see at the top of that example there is the following:
using OpenTK.Graphics.ES30;
But I cannot include this, OpenTK is not recognized as a namespace. I expected to have to add it as a reference, but how?
I can add a reference to it in my .Android project so that I can add the above using statement in my MainActivity.cs page but that is not where it belongs (although I see that I then have GL defined, so this proves that I need to add these using statements to my MainPage.xaml.cs in order to get GL defined), but like I say, how do I add the reference to OpenTK for the project that contains MainPage.xaml.cs.
Thanks for any help,
Mitch.
----- EDIT -----
Thanks to the poster for helping me so far, the new problem is a reference to System.Private.Core that cannot be resolved. Here's the my full workflow for creating this error:
1: Create a new project.
This gives me the three projects:
2: Change to .NET standard 2.1 in the OGLMobile project:
The .Android and .iOS projects don't have a .NET choice option.
3: Add reference to OpenTK to OGLMobile project:
4: OGLMobile project builds fine but .Android project gives:
If I remove reference to OpenTK everything builds again. Makes no difference if I add OpenTK Nuget package to .Android project, I still get the same error.
So close,
thanks for any advice.
You need to install Nuget Package OpenTK.Graphics, then can use that.
Now can refer it:
Note: 4.0.1 of OpenTK.Graphics need .NET Standard 2.1.

NativeScript: use custom objective-c imported class into Xcode project in NativeScript

basically I have some Objective-c class already existing and I want to use them in my NativeScript projet. Currently I have added those files to the Xcode project target and I want to be able to call my objective-c code from nativeScript js. I've read the doc but I don't understand it. It seems so complicated. basically currently all I want to do is be able to present my custom view controller by calling probably something along
const vc = MyCustomViewController.alloc.initWithNibName("xib file")
page.frame.ios.controller.present(vc,true, nil)
Am I obligated to create a plugin for that? Am I obligated to use my objective-c class to build a framework in Xcode and then import the framework?
So I found out.
Actually what you need to do is first to compile your native iOS code into a framework. As per the documentation all your classes must inherit NSObject and all your function must be marked with #objc to be exposed to the objective-c Nativescript side if you write in swift. You will notice as well that in a framework your bundle is not the main bundle. In this example you can see how you can retrieve the bundle from the framework and load a xib from it.
Then you need to add your framework file to a Nativescript plugin. For that, you want to add the framework to the plugin's iOS folder yourPlugin/platform/iOS/yourFramework.framework.
then, you need to add your plugin to your app. You can add your local plugin by using the next command line. Notice the path end with the /src folder.
tns plugin add /path/to/yourplugin/src
Now, you can then call your native functions and classes without even importing them. Of course this works only on iOS. If you run your app on android, calling those methods will crash.
To show this viewController on your Nativescript side you will need to call the following code. By the way You can find documentation elsewhere to get a reference to the current page or frame object.
const controller = page.frame.ios.controller
const vc = IOMediaViewController.create()
vc.modalPresentationStyle = UIModalPresentationFullScreen
controller.presentViewControllerAnimatedCompletion(vc,true,null)

Next step to Make Binding for embedded framework for Xamarin.iOS?

I'm trying to use Native iOS framework from BLE chip bender(nordic) on Xamarin iOS.
this framework (iOS Native - swift) : https://github.com/NordicSemiconductor/IOS-DFU-Library/tree/master/documentation
I made a fat framework with those iOS library. And I looked this doc.
https://developer.xamarin.com/guides/ios/advanced_topics/embedded_frameworks/
I imported it as Native framework on Xamarin.iOS project. And I want to use it.
Below code is from that I used when i'm making iOS native app. I will have to use it on Xamarin.
(part of my app's code(objc base) - using that library )
DFUServiceInitiator *initiator = [[DFUServiceInitiator alloc] initWithCentralManager: [DeviceManager getInstance].central target:[DeviceManager getInstance].connectedPeripheral];
[initiator withFirmwareFile:nil];
initiator.forceDfu = [[[NSUserDefaults standardUserDefaults] valueForKey:#"dfu_force_dfu"] boolValue];
initiator.packetReceiptNotificationParameter = [[[NSUserDefaults standardUserDefaults] valueForKey:#"dfu_number_of_packets"] intValue];
initiator.logger = self;
initiator.delegate = self;
initiator.progressDelegate = self;
// initiator.peripheralSelector = ... // the default selector is used
DFUServiceController *controller = [initiator start];
So in Xamarin.iOS project.
I will use framework that I just imported. And I tried declaring 'DFUServiceInitiator' class. But nothing works but gives 'could not be found' error. Maybe there is many things left I have to do. Yes, this can't be that easy.
Next step is 'binding(wrapping) framework to c#'? Could you guide little bit please?
Is this document I should look next?
https://developer.xamarin.com/guides/ios/advanced_topics/native_interop/
or this?
https://developer.xamarin.com/guides/ios/advanced_topics/binding_objective-c/walkthrough/
Thanks.
You can not simply include a Objective-C or Swift library in you Xamarin project and use it by copying Objective-C or Swif code. You need to create a binding project to create wrapping-classes to get a .NET-api. And that is where Xamarin binding projects come into play.
So you should go with https://developer.xamarin.com/guides/ios/advanced_topics/binding_objective-c/walkthrough/ and learn about how to build bindings for native libraries. Depending on the library it isn't that hard.

NSBundle from my library is nil

I created my own iOS library with core data inside,
as suggested here.
I added library to my project and build is success, but when I am trying to load the database:
bundleWithIdentifier method for my bundle returns nil.
NSBundle * testBundle = [NSBundle bundleWithIdentifier:#"result.BIModel"];
// testBundle = nil;
My library's bundle identifier is set(see image below), I added the framework to "Link Binary With Libraries" and "Embed Frameworks".
What am I missing ?
EDIT :
I notice that when framework is created one file is missing.
I build test framework (that works and bundleWithIdentifier return bundle) and get (see last file),
but when I build my framework i get
. See that last file is missing.

How to add Social Framework in Xcode project?

Just starting to learn Xcode and for this lesson I'm supposed to add the Social Framework in Xcode as to add Twitter composer features.
So I'm following the steps in the book:
I select my project and my target and go to Build Phrases.
I open Link Binary with Libraries and click the + sign
I look for Social Frameworks and click on Add
I now can see Social Frameworks beneath my project
Then I'm supposed to go to my .m file and add this code:
Code:
SLComposeViewController *composer = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeTwitter];
[composer setInitialText:self.tweetTextView.text];
[self presentViewController:composer animated:YES completion:nil];
It then shows 3 error signs saying : 'Use of undeclared Identifier: SLComposeViewController'. And the project won't build.
Have I done something wrong?
You simply need to add:
#import <Social/Social.h>
to the top of your .m file where you're using Social framework API's.
I also did a chat.stackoverflow.com presentation on the Social framework and that transcript is here, and a sample project can be found on github.

Resources