I'm trying to access an iOS framework class from my NativeScript plugin.
Right now, this plugin only has a SampleClass with a test method that returns a number, but it will change soon. For now, what I'm trying to do is to call the class method from that native framework.
I have seen some examples where the plugin seed extends an iOS base class and creates everything there, but in this case, I want to use a .framework file.
I'm assuming this would be equivalent to use some .aar Android file. In that case, I've seen the call would be made with something like this
var c = java.lang.Class.forName("org.test.plugin.name.MyActivity");
So, I have copied the .framework file to platforms/ios, my question is about how to get this SampleClass method.
Also, I've seen some documentation that recommends the use of CocoaPods. I'm new to iOS development and still don't get this at all, but if my application won't use any native dependency, would this be necessary? Should I need another files? (got a default Info.plist and build.xcconfig)
Thank you for your answers.
Since you are using TypeScript, you have to either declare the classes like,
// iOS
declare var SampleClass;
// Android
declare var org;
then you may access all available packages / classes / methods directly.
// Android
const MyActivity = org.test.plugin.name.MyActivity;
// iOS
SampleClass.new()
If you like intellisense support for these libraries, then you may even generate declaration files for both iOS & Android libraries with the given steps in the docs.
Related
I would like to write something like import SignalProtocol at the top of one of my Swift files and then be able to call the C functions from libsignal-protocol-c.
libsignal-protocol-c's README says: "When integrating into actual applications, you should not need anything beyond CMake. Alternatively, you may integrate the code using a build system of your choice."
I think I'd like to use the Swift Package Manager to integrate libsignal-protocol-c into my Swift iOS app. Is there a way to automatically generate a manifest file, ie, Package.swift, and a module map, ie, a module.modulemap file, from libsignal-protocol-c's CMake files? Or if I need to create these files manually, what should they include? Otherwise, how would I do this with CMake?
How to import and use libsignal-protocol-c in an existing .xcodeProj? is a similar question but for Objective-C projects.
I'm not sure its an answer but I'm going to start using https://github.com/christophhagen/LibSignalProtocolSwift. Seems like a good start.
This seems like a basic request, but I can't find the answer to it anywhere. I want to wrap some existing iOS code that I wrote, in a Appcelerator module. That's it. Important points:
I am NOT wrapping a pre-existing 3rd party iOS SDK.
I wrote the iOS code being wrapped.
Code is verified as working within xcode.
There are no .a files. There are 2x .h files and 2x .m files though.
There are no UI elements in the iOS code as it is only designed to connect the native bluetooth hardware to the app.
I have created a generic appcelerator iOS module project, built it, and successfully called the generic ID function within my app.
I cannot figure out how to successfully edit the generic module so that it utilizes my code. Every attempt results in it refusing to compile, and it's maddening.
I do not have access to Hyperloop.
Once I can successfully build the wrapped module, I would call an initialization function which triggers a native bluetooth hardware search. Once connected, there are functions within the module to send commands to the hardware and receive data back. This is the official documentation I've followed so far:
http://docs.appcelerator.com/platform/latest/#!/guide/iOS_Module_Quick_Start
That helped me build the blank module, include it in the app, and ensure that it worked by calling the built in test property. From there it stops short of actually telling me what I need to know. These are the closest things I've found so far, while still not being what I need:
http://docs.appcelerator.com/platform/latest/#!/guide/iOS_Module_Project-section-43288810_iOSModuleProject-AddaThird-PartyFramework
appcelerator module for existing ios project sdk
Heck, I still don't even know if I can do this within studio or if I have to edit the generic module in Xcode. Help! :) Many thanks in advance.
so first of all, this is not best practice and will cause possible problems in the future when the SDK changes and your module still relies on outdated core API's.
Regarding your question, you could either create a new component that subclasses the existing class, e.g.
class TiMyModuleListViewProxy : TiUiListViewProxy {
}
and call it with
var myList = MyModule.createListView();
or you write a category to extend the existing API with your own logic, e.g.
#interface TiUIListViewProxy (MyListView)
- (void)setSomethingElse:(id)value;
#end
#implementation TiUIListViewProxy (MyListView)
- (void)setSomethingElse:(id)value
{
// Set the value of "somethingElse" now
}
#end
I would prefer the second option since it matches a better Objective-C code-style, but please still be aware of the possible core-changes that might effect your implementation in the feature. Thanks!
I have a app project using libgdx 1.2. I want to add Parse.com push notifications to its iOS and Android builds. No problems with the usual java interface that enables the core app to call into the native platform methods, but I have quite a few problems in understanding how to call Parse.com SDK methods from Java RoboVM code, e.g., assuming NativeMethods were my interface for native methods access, and IOSNatives my iOS RoboVM implementation:
public class IOSNatives implements NativeMethods
{
public void pushNotifications()
{
// how do I write the java code equivalent to this example?
// step 5 here: https://parse.com/tutorials/ios-push-notifications
}
}
I mean, step 5 here: and then I need some hints about steps 1-4 too...
I've already searched SO for similar questions, but the only one I could find is
Is there a way for push notifications in libGDX (Android and iOS projects)?
which doesn't really tell what I need.
In order to work with IOS sdk's written on Objective C, you must use bindings. Binding is wrapper which allows you to call objective C code from java. Fortunately you don't need to write your own binding fot parse, because here is existing one: RoboVM parse binding.
You can look at Sample.java for example of implementation.
You can get more info about bindings and how to add them to your project here
How does the minimal setup and usage of a custom iOS framework look like? I starting to look into this in order to share code with a Today Extension.
Here's what I did so far
Added a new Target choosing the Cocoa Touch Framework template and called it TesterKit
Inside the framework I created a new class TestClass.swift
Inside TestClass.swift I created a simple class method class fund tester() printing a string for testing
Looking at my app I can see that TesterKit has been added as Embedded Binaries and Linked Frameworks and Libraries, however it is red
In order to use this new Framework in the app, I added import TesterKit to the top of my AppDelegate
Then I tried to call the class method from the Framework using TestClass.tester(). But instead of showing the log message I get a …
"Use of unresolved identifier"
→ What am I doing wrong? Any wrong assumptions here?
Note: I already watched the WWDC sessions 416 "Building Modern Frameworks" and found the Framework Programmign Guide. If there are any example projects showing how to use such new custom iOS Frameworks, ideally using Swift + integrating this with Today Extensions, that might be helpful, too.
It seems like your import is not failing which means the framework is actually set up correctly...try making the function public.
public func tester() { print("tester()" }
I don't want to submit this app to AppStore. I've tried for many times but met so many problems :(
I use class-dump to get all the header files of UIKit.framework. In the UIApplication.h generated by class-dump, I saw the method I want to use----launchApplicationWithIdentifier.
Then I put UIApplication.h in my project and import it. Compile, I got a lot of "Redefinition of enumerator...." error because in the UIKit.framework I use previous, there's another UIApplication.h. But this file doesn't have the method launchApplicationWithIdentifier.
If I delete the previous UIKit.framework and import the folder generated by class-dump. Then it appears like a framework but if I unfold it, it's empty.
Then I want to make all generated header files a framework file ant replace the previous UIKit.framework. But I don't know how. As we can see, under the system framework directory, there's a file which has the same name as the framework and has a 'executed shell script' icon. How can I made this file?
I really got confused. Someone can give me a hand? Thank you.
Just specify the private methods in a category interface above the class implementation where you want to use it, like this:
#interface UIApplication (Private)
- (BOOL)launchApplicationWithIdentifier:(id)identifier suspended:(BOOL)suspended;
#end
Don't import the whole class-dump file and link with the original UIKit framework.
You must be very careful when using private API. These methods can change or be removed in future iOS versions!
Check if the method really exists with respondsToSelector: at runtime and be prepared for the case that it does not exist.
I used a secret MapKit feature in my own application and I knew that the private methods only exist in iOS 5. So my app still works in all iOS versions but this feature is only available in iOS 5 (Apple removed or changed it in iOS 6 beta 1).