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.
Related
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)
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.
I'm trying to incorporate Parse into my iOS app. After adding all the Frameworks and building the app I get several error messages none being related to the code itself.
I read somewhere that you need to add the Facebook SDK to your project and I did that but it only took away 3 of the errors. Does anybody know the proper instructions on installing the Facebook SDK to your project? Perhaps I didn't add it correctly?
Thanks.
Are you using Swift?
I had the same problem and it was because the frameworks are in Obj-C.
If that's the case, you need to add a bridge header file - here's a quick overview of how to do so: http://blog.parse.com/announcements/building-apps-with-parse-and-swift/
Here's the content of my bridge header file:
#import <Parse/Parse.h>
#import <Bolts/Bolts.h>
#import <ParseUI/ParseUI.h>
#import <ParseFacebookUtilsV4/PFFacebookUtils.h>
#import <FBSDKCoreKit/FBSDKCoreKit.h>
This is my Podfile
platform :ios, 8.0
use_frameworks!
pod "ChartboostSDK"
pod "SVProgressHUD"
SVProgressHUD is being turning into a framework, but for some reason Chartboost is not.
That of course makes the import for Chartboost not working in my code.
The library ChartboostSDK is not supported for Swift directly using CocoaPods, you need to integrate it manually in the following way:
1.First, unzip the SDK package and drop the Chartboost Framework into your Xcode project. Be sure you've also linked these frameworks:
StoreKit
Foundation
CoreGraphics
UIKit
2.Then you need to add a Swift bridging header allows you to communicate with your old Objective-C classes from your Swift classes.You will need one if you plan to keep portions of your codebase in Objective-C. You can create it manually like in the following way:
Add a new file to Xcode (File > New > File), then select “Source” and click “Header File“.
Name your file “YourProjectName-Bridging-Header.h”.
Navigate to your project build settings and find the “Swift Compiler – Code Generation” section. You may find it faster to type in “Swift Compiler” into the search box to narrow down the results. Note: If you don’t have a “Swift Compiler – Code Generation” section, this means you probably don’t have any Swift classes added to your project yet. Add a Swift file, then try again.
Next to “Objective-C Bridging Header” you will need to add the name/path of your header file. If your file resides in your project’s root folder simply put the name of the header file there. Examples: “ProjectName/ProjectName-Bridging-Header.h” or simply “ProjectName-Bridging-Header.h”.
Open up your newly created bridging header and import your Objective-C classes using #import statements. Any class listed in this file will be able to be accessed from your swift classes.
You bridging header must be have inside the following lines:
#import <UIKit/UIKit.h>
#import <Chartboost/Chartboost.h>
#import <Chartboost/CBNewsfeed.h>
#import <CommonCrypto/CommonDigest.h>
#import <AdSupport/AdSupport.h>
You can read more about the next steps using Charboost in his iOS Integration help manual.
I hope this help you.
I've been looking all over the place but I can't find anything. Does anyone know how to create an Xcode 4 plugin?
As far as I know there is no official way to create Xcode 4 plugins (just like there wasn't one for v3.x).
Here is an openradar on Xcode's lack of plugin support:
Please support the ability for 3rd
parties to extend Xcode via a public
plugin API. Aperture, Visual Studio,
Eclipse, TextMate and other
applications benefit from this
ability. I would like to see more
advanced refactorings, code analysis
(think Resharper by Jetbrains) and
modeling.
Provide plugin API for Xcode 4 (rdar://8622025)
Please dupe this if you want plugins!
Edit: Just stumbled upon this:
Cédric Luthi:
"Xcode 4 does support user-defined
plugins, see CLITool-InfoPlist
for an example of a working Xcode 4
plugin. You just have to add
XC4Compatible (true) in the
Info.plist."
https://github.com/0xced/CLITool-InfoPlist
That being said these GitHub repos might be handy, too:
Xcode4 Plugin-API Documentation (link dead)
Xcode Plugin Template (link updated)
Further more mogenerator's Xmod plugin might be a good starting point.
(Wasn't Xcode-4 compatible yet, last time I checked, though)
Best way to learn is to look at github plugin code (see long list below):
Basically its a plugin bundle.
No main.m No MainMenu.xib
First class loaded by setting NSPrincipalClass in info.plist
in its init: you register for AppKit notifications
See the code samples
some check the mainBundle app id to make sure this is XCode
The XCode Editor window class is DVTSourceTextView
Its a subclass of DVTSourceTextView :NSTextView : NSText
so you can register to listen for its notifications for NSTextView or NSText
such as NSTextViewWillChangeNotifyingTextViewNotification
Because its not an official standard I noticed each sample loads in different ways.
XCODE PLUGIN SAMPLES
compiled by either searching github/web for
'DVTSourceTextView'
This is the Xcode Editor window class name
or
Info-list key
'XC4Compatible'
https://github.com/omz/ColorSense-for-Xcode
https://github.com/ciaran/xcode-bracket-matcher
- uses a ruby parser run as pipe!
https://github.com/joshaber/WTFXcode
https://github.com/0xced/NoLastUpgradeCheck
http://code.google.com/p/google-toolbox-for-mac/downloads/list
see GTMXcode4Plugin
https://github.com/DeepIT/XcodeColors
https://github.com/0xced/CLITool-InfoPlist
https://github.com/sap-production/xcode-ide-maven-integration
https://github.com/ciaran/xcode-bracket-matcher
TO GET TO THE NSTextView that is the console
https://github.com/sap-production/xcode-ide-maven-integration
- (NSTextView *)findConsoleAndActivate {
Class consoleTextViewClass = objc_getClass("IDEConsoleTextView");
NSTextView *console = (NSTextView *)[self findView:consoleTextViewClass inView:NSApplication.sharedApplication.mainWindow.contentView];
if (console) {
NSWindow *window = NSApplication.sharedApplication.keyWindow;
if ([window isKindOfClass:objc_getClass("IDEWorkspaceWindow")]) {
if ([window.windowController isKindOfClass:NSClassFromString(#"IDEWorkspaceWindowController")]) {
id editorArea = [window.windowController valueForKey:#"editorArea"];
[editorArea performSelector:#selector(activateConsole:) withObject:self];
}
}
}
return console;
}
Have a look at this new plugin: https://github.com/sap-production/xcode-ide-maven-integration. Maybe you can derive some concepts for your plugin.
Yesterday ColorSense for Xcode 4 was released on Github. Since the code is really compact spread over just 3 classes, I think you should take a look over there.
Xcode does not have a public plug-in API.
This was the case with earlier versions, and is the case with Xcode 4 as well.
No, Xcode doesn't support plugins, alternatively you may try AppCode, another IDE for iOS/MacOS, it does support plugins development.