Load external libraries and SDK with appcelerator hyperloop - appcelerator

I'm working on a iOS and Android DVR app with remote controls.
I need to use a third-party library for network communication and video encoding, via hyperloop programming.
At the moment I tried importing the iOS version libraries.
The library consists of a static file libDVR_NET_SDK.a and a "include" folder with several .h header files inside.
I followed the official documentation by creating the references in the appc.js file:
appcelerator.com iOS Hyperloop Programming Guide
module.exports = {
hyperloop: {
ios: {
thirdparty: {
'libDVR_NET_SDK': {
source: 'platform/ios/SDK/include',
header: "platform/ios/SDK/include",
resource: 'platform/ios/SDK'
},
'MediaPlayerLib': {
source: 'platform/ios/MediaPlayerLib/include',
header: "platform/ios/MediaPlayerLib/include",
resource: 'platform/ios/MediaPlayerLib'
}
}
}
}
};
I can not understand how to call the external library from javascript code, at the moment I tried:
var libDVR_NET_SDK = require("libDVR_NET_SDK");
But the following error is generated:
Script Error Couldn't find module: /hyperloop/libdvr_net_sdk/libdvr_net_sdk for architecture: x86_64

Hyperloop docs says : This has been deprecated in Hyperloop 2.2.0 and will be removed in Hyperloop 3.0.0. Place it into your iOS platform directory instead and it will be automatically detected.
So, try putting your library in Project -> app -> platform -> ios folder & it will automatically detect it.
To use in js code, you can try to call it as mentioned in that library docs considering the names to be same as if you were calling them in native iOS.
I found similar to Android here : Hyperloop Android 3rd Party Example. It contains libraries in similar folder & you can check how it's used further in titanium app code.

Related

Swift Embedded Framework That Depends on Swift Package

My iOS app follows the "Photos Extension" template:
- A standalone, "container" app
- A Photo Editing extension, which is deployed by embedding it within the app above.
As suggested by Apple, code that is shared by both the app and the extension is gathered in a "core" cocoa framework that is embedded in the app, and to which both the app and the extension are linked.
So my Xcode project contains three targets:
The Framework target,
The Photo Editing Extension target, which links to the Framework but does not embed it, and
The App target, that embeds the Extension binary and the Framework binary, and links to both.
So far, so good.
Furthermore, the framework, the app, and the extension depend on two libraries MyLibraryA and MyLibraryB I have on Github (and in turn, MyLibraryA depends on MyLibraryB).
I originally set the dependency on MyLibraryA and MyLibraryB using Carthage, and everything was working fine.
Then, I decided to migrate my libraries A and B to Swift Packages.
I removed all Carthage-related settings in project and targets, framework search paths, etc. to make sure the Swift Package versions of my libraries are referenced and not the cached Carthage builds. I also deleted the Carthage directories (checkouts and build).
The Problem
When I build the shared/embedded Framework target, there are no issues.
But when I try to build either the App or App Extension targets, I get an error pointing to the shared frameworks Swift header (MyFramewor-Swift.h):
// ...
#import CoreGraphics;
#import CoreImage;
#import Foundation;
#import PhotosUI;
#import UIKit;
#import MyLibraryA; <-- Module 'MyLibraryA' Not Found
// ...
And the resulting:
Could not build Objective-C module 'MyFramework'
I know frameworks that are distributed as binaries cannot depend on Swift packages, but this embedded framework is compiled locally from source code and then embedded.
Perhaps there are some changes I can make to my setup on Xcode to get it to work?
I tried changing Enable Modules (C and Objective-C) to No in the Build Settings for the Framework target, to no avail.
You can currently set Install Objective-C Compatibility Header to No in Build Settings for modules that require a Swift Package dependency.
This's probably due to "Swift Packages" being "Swift", but still looks like a bug to me.

CommonJS require function not found running iOS Adhoc/Enterprise

I have an Appcelerator Alloy 6.3.0 iOS app that runs fine on device when running in development.
I packaged the app using my enterprise certificate then build my .ipa and install (and trust) the app on the device.
The app runs fine but then throws an error when attempting to use the commonJS library (pure JS).
try{
var netUtil = require('API');
netUtil.getList($.labelModel.text, myCallBackFunction);
catch(e){
alert('Error: ' + e);
}
The error shown is...
TypeError: undefined is not a function (evaluating 'a.getList(k.label-Model.text,g)' )
The exact same code runs fine on device without changes when running dev certificate with/without liveview.
What may be causing CommonJS require function not found only when running iOS .ipa Adhoc/Enterprise ?
I believe that API name is reserved in Apple's internal apis or could be used by Titanium itself. So you should rename your API.js file to something non-generic like custom_api.js or my_api.js & then try again.
I have had this issue once when I named some lib file to animation.js or something like this (not remember exactly) & figured out that it's always better & safer to use underscore formatting while naming lib files or other js files because internal apis mostly don't use underscore name formatting.

Xcode 7 - SystemConfiguration/SystemConfiguration.h file not found [duplicate]

I've been trying to modify my project to support WatchOS2 architecture.
Currently I have a networking framework that is based on AFNetworking. I've been using it with my watch app so far.
Now I'm trying to build the framework for watchos/watchsimulator platforms.
What I'm getting is
'SystemConfiguration/SystemConfiguration.h' file not found
error for some AFNetworking classes.
I know that system configuration is not one of the available system frameworks for watchOS2. And for networking apple says:
Networking
Support for network-based operations includes the following technologies:
WatchKit extensions can access the network directly using an NSURLSession object. WatchKit extensions have full access to the NSURLSession capabilities, including the ability to download files in the background. For information on how to use this class, see URL Loading System Programming Guide.
The Watch Connectivity framework supports bidirectional communication between your Watch app and iOS app. Use this framework to coordinate activities between the two apps. For more information, see Communicating with Your Companion iOS App.
I want to support both iOS and watchos for my networking sdk.
Is there a way to make this project built for watchOS platform?
Or is that mean I am only allowed to use NSURLConnection inside my watch app?
According to the AFNetworking documentation:
URL Loading The most commonly used classes in the URL loading system
allow your app to retrieve the content of a URL from the source. You
can retrieve that content in many ways, depending on your app’s
requirements. The API you choose depends on the version of OS X or iOS
your app targets and whether you wish to obtain the data as a file or
an in-memory block of data:
In iOS 7 and later or OS X v10.9 and later, NSURLSession is the preferred API for new code that performs URL requests.
If you take a look at the diagrams on that page, it indicates that AFNetworking actually uses NSURLSession in some cases. However, since the SystemConfiguration framework is not available in watchkit, you would need to remove that dependency in order to include AFNetworking in both your iOS and watchkit apps.
I'm not sure what AFNetworking uses this framework for (it is probably very important!), but if there are certain files that wouldn't need these settings in the watch app you could modify the AFNetworking source code to not include those items on the watch app:
#if os(iOS)
// Include SystemConfiguration framework
#elseif os(watchOS)
// Exclude SystemConfiguration framework
#endif
Here is a recent commit on github for AFNetworking to support watchOS.
https://github.com/AFNetworking/AFNetworking/commit/d184833fa015a783742b573cf48a3080b863a900
Looking at the changelog..
https://cocoapods.org/pods/AFNetworking#changelog
Version 2.6.0 supports watchOS...
This release now supports watchOS 2.0, which relys on target
conditionals that are only present in Xcode 7 and iOS 9/watchOS 2.0/OS
X 10.10. If you install the library using CocoaPods, AFNetworking will
define these target conditionals for on older platforms, allowing your
code to complile. If you do not use Cocoapods, you will need to add
the following code your to PCH file.

Linking libz.dylib and libsqlite3.dylib in Xamarin iOS Project

I created a Xamarin iOS binding project that requires the following frameworks:
SystemConfiguration.framework
CoreTelephony.framework
libz.dylib
libsqlite3.dylib
I added the following line in my iOS binding project to the linkwith.cs file:
Frameworks = "SystemConfiguration CoreTelephony"
This seems to work correctly and tells that project to include these frameworks when binding. From what I have read, it sounds like the remaining 2 libraries need to be added as linker flags in the project referring to the DLL generated from my iOS binding project. So I created a test app, imported the DLL, and now need to add the linker flags but my project cannot find the right libraries.
My linker flags in Xamarin Studio are as follows:
-gcc_flags "-lz -lsqlite3.0"
When I build my Xamarin test app I get a few errors regarding the frameworks that cannot be found. Are there additional flags that need to be linked or do I need to do some additional configuration in my iOS binding project?
I found a great resource: http://ipixels.net/blog/specify-extra-gcc-flags-for-native-library-binding-in-xamarin-ios/
I needed to add LinkerFlags = "-lz -lsqlite3.0" to my .linkwith.cs file. I then rebuilt the library to generate a new DLL and added this to my test app. The test app builds correctly then.
If you are creating your bindings for a cocoapod using sharpie:
sharpie pod init ios nameOfCocoaPod
sharpie pod bind
you get a nameOfCocoaPod.framework file and .cs-binding files.
The nameOfCocoaPod.framework file should be added to your binding project under Native References. To change e.g. Frameworks or LinkerFlags, right-click and open properties.

Building a universal app for iOS 3.1, iOS 3.2 using iOS SDK 4.2

I have a universal app which was originally built for iOS4.2. Since this project does not use many 4.0+ specific APIs, I would like to build this app with deployment target set to 3.1.
It gets built with no problems.
But when I install and start the app on the iPhone 3.1.3 simulator, I get the following dyld error:
Dyld Error Message:
Symbol not found: _OBJC_CLASS_$_UIActionSheet
iPad specific part of my code is already employs checks to make sure that it doesn't reference any unavailable symbols using:
Class cls = NSClassFromString(#"UIPopoverController");
if (cls != nil) {
_popOverController = [[cls alloc] initWithContentViewController:_settingsController];
}
Any ideas?

Resources