Cordova Plugin with third-party SDK - ios

I'm trying to figure out how to create a Cordova iOS plugin with the PressReader framework. I'm an iOS developer and have no experience with Cordova, this is why I hope to find some guidance here.
This is what i have done:
Created a plugin
Added the Objective-C classes to src/iOS
Added the PressReader_SDK.framework to src/iOS (is this the right place ?)
Edited the src/www/js file
Edited the plugin.xml with the following in the iOS platform:
<config-file target="config.xml" parent="/widget">
<feature name="Hello">
<param name="ios-package" value="HWPHello" />
</feature>
</config-file>
<resource-file src="src/ios/PressReader_SDK.framework"/>
<framework src="src/ios/PressReader_SDK.framework" custom="true" />
<framework src="Foundation.framework"/>
<framework src="UIKit.framework"/>
<header-file src="src/ios/HWPHello.h" target-dir="HelloPlugin"/>
<source-file src="src/ios/HWPHello.m" target-dir="HelloPlugin"/>
After this I've created a new Cordova app, added the plugin and then the iOS platform.
When opening the Xcode project from platforms/iOS I get the following Build error:
error: /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS10.1.sdk/System/Library/Frameworks/PressReader_SDK.framework: No such file or directory
Trying to run the app from terminal (cordova run ios --device) gives me the following error:
Error: Error code 65 for command: xcodebuild with args: -xcconfig,/Users/Andrei/desktop/hello/platforms/ios/cordova/build-debug.xcconfig,-workspace,Hello.xcworkspace,-scheme,Hello,-configuration,Debug,-destination,generic/platform=iOS,-archivePath,Hello.xcarchive,archive,CONFIGURATION_BUILD_DIR=/Users/Andrei/desktop/hello/platforms/ios/build/device,SHARED_PRECOMPS_DIR=/Users/Andrei/desktop/hello/platforms/ios/build/sharedpch
PS. the SDK does not seem to work on the simulator, and I need to test the app on a real device.

Related

Add AdSupport Framework to an Xcode project with CLI command or Ionic configuration

I am currently working on an ionic application whose targetted platform is ios. I use Firiebase Analytics plugin and this requires to add AdSupport Framework into Xcode build configuration.
I would like not to add this manually as it is documented because it breaks my continous delivery process. Is there a way to programitcally add a framework to the build with a CLI or ionic configuration ?
Try :
Open plugin.xml(in firebase analytics plugin folder) and below line under ios :
<platform name="ios">
<framework src="pointToYour/File.framework" embed="true" />
</platform>
According to the documentation(1)(2) It is not possible to specify that in a project config.xml. However you can specify which framework library you need for ios in Plugin.xml when you write a new plugin.
This is that framework property :
Identifies a framework (usually part of the OS/platform) on which the
plugin depends.
// In Plugin.xml
<framework src="libsqlite3.dylib" />
<framework src="social.framework" weak="true" />
<framework src="relative/path/to/my.framework" custom="true" />
<framework src="GoogleCloudMessaging" type="podspec" spec="~> 1.2.0" />
I found a plugin that allow that here and I forked it for my special needs.

Phonegap build fails with splash screen

I'm attempting to use the new phonegap build with CLI 7.0.1
The build fails with this error:
The following build commands failed:
CompileAssetCatalog /Library/Developer/Xcode/DerivedData/Our_HNZC_Learning_space-ddfmniquktwfmabpvilymbvzreak/Build/Intermediates/ArchiveIntermediates/Our\ HNZC\ Learning\ space/InstallationBuildProductsLocation/Applications/Our\ HNZC\ Learning\ space.app Our\ HNZC\ Learning\ space/Images.xcassets
(1 failure)
Error code 65 for command: xcodebuild with args: -xcconfig,/private/project/cordova/build-release.xcconfig,-workspace,Our HNZC Learning space.xcworkspace,-scheme,Our HNZC Learning space,-configuration,Release,-destination,generic/platform=iOS,-archivePath,Our HNZC Learning space.xcarchive,archive,CONFIGURATION_BUILD_DIR=/private/project/build/device,SHARED_PRECOMPS_DIR=/private/project/build/sharedpch
I've added these to config.png
<icon src="res/icon.png" />
<splash src="res/splash.png" />
And I've added this plugin
<plugin name="cordova-plugin-splashscreen" />
And the files are in the right place.
Splash works fine, Icon is causing the error
Not sure what the exact problem is based upon the info you provided.
A starting point would be to remove the splashscreen plugin and re-add it:
cordova plugin remove cordova-plugin-splashscreen
cordova plugin add cordova-plugin-splashscreen
cordova prepare
I would suggest using an Icon and Splashscreen generator such as this one: http://phonegap.appiq.software/
It does all of the hard work for you and gives you the exact code for your config.xml
I hope this is helpful.

error : package com.google.android.gms.auth does not exist in ant release in cordova app

I installed cordova-plugin-googleplus plugin to login using google. After installing I run "cordova build andriod" in CLI, it was successful and apk file works fine for google login. Then for releasing the app I run "ant release" in platforms/android folder in CLI, then build failed with errors like " package com.google.android.gms.auth does not exist import com.google.android.gms.auth". Please give me the solution for this.
Thanks in advance.
https://github.com/EddyVerbruggen/cordova-plugin-googleplus/issues/252
Replace
<framework src="com.google.android.gms:play-services-plus:+" />
<framework src="com.google.android.gms:play-services-identity:+" />
with
<framework src="com.google.android.gms:play-services-plus:9.0.2" />
<framework src="com.google.android.gms:play-services-identity:9.0.2" />
in both plugin.xml as well as platforms/android/project.properties. In my case if I replace only plugin.xml then build.gradle was getting overridden with project.properties content and + version was being used instead of specific version

Accessing iOS native code with PhoneGap, build issue

I've wrote a very simple plugin and added it to my config.xml:
<feature name="FileWriter">
<param name="ios-package" value="FileWriter" />
</feature>
after executing "Cordova prepare" it does not copy it to the staging/config.xml, and thus when I run the app I get an error:
2014-11-18 14:12:58.929 iOS Test[1280:723270] -[CDVCommandQueue executePending] [Line 158] FAILED pluginJSON = [
"FileWriter1220649673",
"FileWriter",
"cordovaGetFileContents",
[
]
]
If I manually add the feature to the config.xml found in the platform folder it works fine.
Basically there seems to be some sort of step missing in the "cordova prepare" step which is not copying this feature. All of the other elements in the base config.xml are copied properly to the platform specific one.
I've based the code off of the tutorial here
Follow the oficial tutorial instead
http://docs.phonegap.com/en/3.5.0/guide_hybrid_plugins_index.md.html#Plugin%20Development%20Guide
The one you linked is missing the part of the plugin.xml, that's the file read on cordova prepare to copy the necessary files to the iOS project.

PushPlugin not found for iOS PhoneGap

I just installed PhoneGap 3.5 and the PushPlugin using the PhoneGap CLI. I created a project using the PhoneGap CLI. In the receivedEvent method of index.js, I added these lines:
var pushNotification = window.plugins.pushNotification;
pushNotification.register(myTokenMethod, onError, {"badge": "true", "sound": "true", "alert":"true", "ecb": "mycallback"}
this leads to the error in xCode of:
CDVPlugin class PushPlugin (pluginName: PushPlugin) does not exist
ERROR: Plugin 'PushPlugin' not found or is not a CDVPlugin. Check your plugin mapping in config.xml
And although the instructions do not indicate I need to for automatic installation of the plugin, I went ahead and added
<feature name="PushPlugin">
<param name="ios-package" value="PushPlugin" />
</feature>
to my config.xml and receive the same error. The plugin version is 2.4, I am using an iPhone 6 as a test device and xCode 6.
Any ideas where to look?
Make sure your PushPlugin.m inside Build Phases > Compile Sources

Resources