I have an Ionic5 (cli 6.3.0)/Cordova 9.0.3 (cordova-lib#9.0.2) project that uses plugins.
I am attempting to create a custom plugin for a 3rd party framework.
I know the skeleton of the plugin is correct since I created it with Plugman and before adding the framework I could build/run and get feedback that "coolMethod" had been run from Objective-C file.
Even after adding the framework, I can get the plugin to install correctly with ionic cordova plugin add ./packages/cordova-plugin-my-custom-stuff
I can get Ionic/Cordova to build the iOS project successfully with ionic cordova build ios
But when I try to run the iOS emulator from either Ionic command line ionic cordova run ios or from auto-generated xCode project, I get
dyld: Library not loaded: #rpath/MyThirdPartySDK.framework/MyThirdPartySDK
Referenced from: /Users/myUser/Library/Developer/CoreSimulator/Devices/C9E28EFF-B017-4F5E-
BA89-5200AE5D64EA/data/Containers/Bundle/Application/775C8394-B014-4B01-89CA-
1D462FD54F4A/MyName Mobile-UAT.app/MyName Mobile-UAT
Reason: image not found
The structure of the project (condensed for clarity) is like so:
MyProject
-node_modules
-packages
-cordova-plugin-my-custom-stuff
-src
-ios
MyCustomStuff.m
-MyThirdPartySDK.framework
-Headers
MobileAPI.h
MyThirdPartySDK.h
-Modules
module.modulemap
MyThirdPartySDK
-www
cordova-plugin-my-custom-stuff.js
package.json
plugin.xml
The plugin.xml ios section looks like:
<platform name="ios">
<config-file parent="/*" target="config.xml">
<feature name="MyCustomStuff">
<param name="ios-package" value="MyCustomStuff"/>
</feature>
</config-file>
<source-file src="src/ios/MyCustomStuff.m"/>
<source-file src="src/ios/MyCustomStuffSDK.framework" framework="true"/>
<header-file src="src/ios/MyCustomStuffSDK.framework/Headers/MobileAPI.h" target-dir="MyCustomStuff" />
</platform>
I am looking for a solution that resides within the plugin.xml configuration or some other ionic /cordovaproject configuration. I would like to avoid editing the xCode project as this is all generated "automagically" by the ionic/cordova command line.
Finally figured it out.
<platform name="ios">
<config-file parent="/*" target="config.xml">
<feature name="MyCustomPlugin">
<param name="ios-package" value="MyCustomPlugin"/>
</feature>
</config-file>
<source-file src="src/ios/MyCustomPlugin.m"/>
<source-file src="src/ios/MyCustomPlugin.framework" target-dir="lib" framework="true" />
<framework src="src/ios/MyCustomPlugin.framework" embed="true" custom="true" />
<header-file src="src/ios/MyCustomPlugin.framework/Headers/MobileAPI.h" target-dir="MyCustomPlugin" />
</platform>
I am having trouble importing frameworks to my Cordova plugin. When I try to access them in my source files, it fails with 'undeclared' errors. My plugin folder structure is as follows:
plugin.xml
ios/ERS.swift
ios/ERS-Bridging-Header.h
ios/libs/AEXML.framework
ios/libs/KissXML.framework
ios/libs/SwiftyRSA.framework
ios/libs/XUCore.framework
ios/libs/XUEETCommunicator.swift
Content of bridging header is:
#ifndef ERS_Bridging_Header_h
#define ERS_Bridging_Header_h
#import <AEXML/AEXML.h>
#import <KissXML/KissXML.h>
#import <SwiftyRSA/SwiftyRSA.h>
#import <XUCore/XUCore.h>
#endif
And of my plugin.xml:
<platform name="ios">
<config-file parent="/*" target="config.xml">
<feature name="eet"><param name="ios-package" value="eet" />
</feature>
</config-file>
<source-file src="src/ios/ERS.swift" />
<source-file src="src/ios/ERS-Bridging-Header.h" />
<!-- Library for EET -->
<source-file src="src/ios/libs/XUCzechLocaleSpecificData.swift" />
<source-file src="src/ios/libs/XUEETCommunicator.swift" />
<framework src="src/ios/libs/AEXML.framework" custom="true" embed="true"/>
<framework src="src/ios/libs/KissXML.framework" custom="true" embed="true" />
<framework src="src/ios/libs/SwiftyRSA.framework" custom="true" embed="true" />
<framework src="src/ios/libs/XUCore.framework" custom="true" embed="true" />
</platform>
After this configuration, i am getting following error (along with others of the same type):
XUEETCommunicator.swift:99:18: error: use of unresolved identifier
'AEXMLOptions'
I am also using Cordova Swift Support plugin, but I still cant get it to work. Also tried this solution:
https://stackoverflow.com/a/36723619/7141625
But after that, the project file is corrupted and can not be parsed.
I am reviewing the code in XCode 9 and also trying to build it in Ionic3 project via
ionic cordova build ios
with the same result.
I'm new in developing with cordova and would like to add a custom written iOS plugin from file system. I use cordova version 4.3.0 with iOS version 3.8.0.
When trying to add the plugin with " $ cordova plugin add ../my_plugin_dir" I get the following error:
Error during processing of action! Attempting to revert...
Failed to install 'at.researchstudio.knowledgepulse.reminder':Error: Uh oh!
".../plugins/at.researchstudio.knowledgepulse.reminder/src/ios/Kpreminder.m" not found!
But the m-source file is in this folder!!! What am I doing wrong??
Plugin-Structure:
at.researchstudio.knowledgepulse.reminder/
plugin.xml
src/
ios/
Kpreminder.h
Kpreminder.m
www/
reminder.js
The plugin.xml looks like the following
<?xml version="1.0" encoding="UTF-8"?>
<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0"
id="at.researchstudio.knowledgepulse.reminder" version="0.0.1">
<name>Kpreminder</name>
<description>Reminder Functionalities for KP</description>
<keywords>KnowledgePulse reminder</keywords>
<js-module src="www/reminder.js" name="reminder">
<clobbers target="reminder" />
</js-module>
<platform name="ios">
<config-file target="config.xml" parent="/*">
<feature name="Kpreminder">
<param name="ios-package" value="Kpreminder"/>
</feature>
</config-file>
<header-file src="src/ios/Kpreminder.h" />
<source-file src="src/ios/Kpreminder.m" />
</platform>
</plugin>
I think you may put you plugin in 'plugins'folder,put into other folder
like $project_folder/myplugins/at.researchstudio.knowledgepulse.reminder
then install it
I´m getting this error in XCode:
2013-08-23 14:36:18.284 Tell The DJ[14955:c07] ERROR: Plugin 'Device' not found, or is not a CDVPlugin. Check your plugin mapping in config.xml.
2013-08-23 14:36:18.284 Tell The DJ[14955:c07] -[CDVCommandQueue executePending] [Line 116] FAILED pluginJSON = [
"Device1096677259",
"Device",
"getDeviceInfo",
[
]
]
2013-08-23 14:36:18.285 Tell The DJ[14955:c07] CDVPlugin class CDVConnection (pluginName: NetworkStatus) does not exist.
2013-08-23 14:36:18.285 Tell The DJ[14955:c07] ERROR: Plugin 'NetworkStatus' not found, or is not a CDVPlugin. Check your plugin mapping in config.xml.
2013-08-23 14:36:18.285 Tell The DJ[14955:c07] -[CDVCommandQueue executePending] [Line 116] FAILED pluginJSON = [
"NetworkStatus1096677260",
"NetworkStatus",
"getConnectionInfo",
[
]
]
I installed Phonegap 3.0 with the Command Line Interface and paste my www files into the project folders. The app works fine but when i come to native functions like device ID, camera, network connections it fails and gets me this error. But I think my config.xml is right?
<?xml version='1.0' encoding='utf-8'?>
<widget id="io.cordova.helloCordova" version="2.0.0" xmlns="http://www.w3.org/ns/widgets">
<name>Hello Cordova</name>
<description>
A sample Apache Cordova application that responds to the deviceready event.
</description>
<author email="dev#cordova.apache.org" href="http://cordova.io">
Apache Cordova Team
</author>
<content src="index.html" />
<feature name="LocalStorage">
<param name="ios-package" value="CDVLocalStorage" />
</feature>
<access origin="http://dev.tellthedj.de" />
<preference name="KeyboardDisplayRequiresUserAction" value="true" />
<preference name="SuppressesIncrementalRendering" value="false" />
<preference name="UIWebViewBounce" value="true" />
<preference name="TopActivityIndicator" value="gray" />
<preference name="EnableLocation" value="false" />
<preference name="EnableViewportScale" value="false" />
<preference name="AutoHideSplashScreen" value="true" />
<preference name="ShowSplashScreenSpinner" value="true" />
<preference name="MediaPlaybackRequiresUserAction" value="false" />
<preference name="AllowInlineMediaPlayback" value="false" />
<preference name="OpenAllWhitelistURLsInWebView" value="false" />
<preference name="BackupWebStorage" value="cloud" />
<preference name="orientation" value="portrait" />
<preference name="webviewbounce" value="false" />
<preference name="prerendered-icon" value="true" />
<preference name="phonegap-version" value="3.0.0" />
<preference name="fullscreen" value="false" />
<preference name="stay-in-webview" value="false" />
<preference name="android-minSdkVersion" value="7" />
<preference name="android-installLocation" value="internalOnly" />
<preference name="target-device" value="universal" />
<preference name="autohide-splashscreen" value="true" />
<preference name="load-url-timeout" value="60000" />
<preference name="show-splashscreen-spinner" value="true" />
<preference name="show-splash-screen-spinner" value="true" />
<preference name="allow-inline-media-playback" value="false" />
<preference name="launch-mode" value="standard" />
<feature name="Media">
<param name="ios-package" value="CDVSound" />
</feature>
<feature name="Camera">
<param name="ios-package" value="CDVCamera" />
</feature>
<feature name="Console">
<param name="ios-package" value="CDVLogger" />
</feature>
<feature name="Device">
<param name="ios-package" value="CDVDevice" />
</feature>
<feature name="Notification">
<param name="ios-package" value="CDVNotification" />
</feature>
<feature name="File">
<param name="ios-package" value="CDVFile" />
</feature>
<feature name="FileTransfer">
<param name="ios-package" value="CDVFileTransfer" />
</feature>
<feature name="Geolocation">
<param name="ios-package" value="CDVLocation" />
</feature>
<feature name="Capture">
<param name="ios-package" value="CDVCapture" />
</feature>
<feature name="NetworkStatus">
<param name="ios-package" value="CDVConnection" />
</feature>
<feature name="SplashScreen">
<param name="ios-package" value="CDVSplashScreen" />
</feature>
<plugins>
<plugin name="Device" value="CDVDevice" />
</plugins>
</widget>
I was using PhoneGap 3.0/3.1 and was removing the local build folder before rebuilding (since I had to copy icons and stuff in a secondary build script). This broke my plugins and produced this same error message.
In the end I found I had to remove ./plugins/ios.json when removing ./platforms/ios to make sure the plugins were rebuilt.
Deleting the platforms/ios folder is not a solution for me as all manual customizations to the xcode project will be lost.
But there is a simple way around:
In XCode, goto Build Phases -> open the Compiled Sources dropdown.
Click + and add the missing plugin .m file that should be in your
Plugins directory (but is missing from the compiled sources).
This solution came from another stack overflow answer, here: https://stackoverflow.com/a/21148428/80254
Another alternative:
In xcode make sure the source files of the plugin has the 'target membership' settings set: In File-Explorer go to Plugins > CDVDevice.m and check if there is a tick next to your app name at "target membership" on the right side of xcode window. This actually does the same as the other solution but is a bit more convenient.
From here: https://stackoverflow.com/a/20576744/80254
I encountered the same issue. I have followed the solution given by Jeffrey Van Alstine. This is my script for building and testing an iOS app developed using Phonegap 3.0/3.1.
#!/bin/bash
echo "Killing xcode..."
kill $(ps aux | grep 'Xcode' | awk '{print $2}')
rm -r platforms/ios
rm plugins/ios.json
phonegap build ios
open platforms/ios/*.xcodeproj
Save it as a bash file, for example, ios.sh into your working directory (directory that contains www folder) and run ./ios.sh
This seems to be a known issue for 3.* versions
https://issues.apache.org/jira/browse/CB-4971
you can solve this by upgrading Phonegap to release 3.4.
Try reinstalling the plugin:
phonegap local plugin add https://git-wip-us.apache.org/repos/asf/cordova-plugin-device.git
I use Cordova 3.7 and I solved the problem with Kobkrit Viriyayudhakorn 's solution, BUT of course you need to use
cordova build ios
instead of
phonegap build ios
i think you need to use the correct config.xml
for me, it is Xcode project target folder config.xml, and not platform www folder
I have found a solution that worked for me. I was using with the Compass plugin and after adding the plugin I have noticed that the config.xml (plugin docs) says it should have
<feature name="Compass">
<param name="ios-package" value="**CDVLocation**" />
</feature>
while the ios.json in plugin has added
"config.xml": {
"/*": {
"<feature name=\"Compass\"><param name=\"ios-package\" value=\"**CDVCompass**\" /></feature>": 1,
"<feature name=\"Device\"><param name=\"ios-package\" value=\"CDVDevice\" /></feature>": 1
}
One of then refers to CDVCompass while the other CDVLocation ... changing the xml to CDVCompass did the trick and now the app is working.
I am so tired of removing and re-adding platforms for plugin issues! It seems like it is still a problem even now (2014/10) where if you add plugins to an app after adding platforms the plugin sometime does not get propagated down to the corresponding platform folders/etc. Note this seems to mainly affect iOS - not Android.
I think my solution is just an updated method of doing same thing bjunix posted earlier - but in XCode 6 to fix this sort of thing without removing/re-adding my platform I:
Expand my App/Plugins folder in the left project navigator panel
Click on each plugin file in the list that is currently in red text (one at time)
Jump to the right side (Utilities) panel and click the folder icon in the Identity and Type section to re-link it to the actual file (see screenshot below).
After doing the above my project finally builds.
When this happens, it seems the xcode npm package responsible for making changes to the pbxproj file sometimes leaves references to plugin files that have been removed. I have not tracked down under what exact circumstances this occurs, but it appears to happen from frequent plugin remove/add operations (to update a plugin for example).
I suspect that when a plugin is removed and the xcode npm package fails at its job, it is only able to remove the plugin file references from the PBXBuildFile section but no other sections, leaving the pbxproj in a broken state.
When the xcode npm package attempts to add the plugin file references again, it first checks if the references are already in pbxproj. It looks in the PBXFileReference section, and since it finds references to the plugin in there, aborts further processing, getting us nowhere.
My solution, albeit a hack when it comes down to it, is to force the xcode npm package to check the PBXBuildFile section instead. That section will be missing the references and in turn the plugin will be re-installed correctly.
Change pbxFileReferenceSection to pbxBuildFileSection on this line: https://github.com/alunny/node-xcode/blob/master/lib/pbxProject.js#L620
Re-install your plugins, and you should be good to go.
I my case After install Paypal Plugin I am facing issue.
I resolved its by add "PayPalMobileCordovaPlugin.m" in the Compile Source.
So you just need to add .m file in Compile source add it works for me.
Check Screenshot.
Hope its work for you
This can also happen if you have a plugin that is referenced but not installed. If you have tried the above solutions and can't find the referenced plugin's .m file it might be that the plugin isn't really installed.
I would check your plugins directory to be sure that there are files in it. If not, reinstall the plugin. I ran into this when I had a typo in the git repo when restoring plugins from the config.xml.
I resolved this issue by changing the "plugin" entry to a "feature" entry in the config.xml. (using PhoneGap 3.1/iOS). This is what the fix looked like:
<feature name="DGGeofencing">
<param name="ios-package" value="DGGeofencing"/>
</feature>
I solved this issue with complete reinstall of Node.js and Phonegap through the CLI Tool
I am using PushPlugin https://github.com/phonegap-build/PushPlugin and Cordova 2.5 for an iOS applicaiton.
In my Plugins folder I have these files:
Appdelegate+notification.h
Appdelegate+notification.m
PushPlugin.h
PushPlugin.m
In config.xml I have included the plugin like this:
<plugin name="PushPlugin" value="PushPlugin" />
I have also PushNotification.js in my www folder and included that in index.html.
When I run the application and execute the line in my push.js file:
pushNotification.register(this.tokenHandler,this.errorHandler, {"badge":"true","sound":"true","alert":"true","ecb":app.onNotificationAPN"});
Then I get this error:
Error: Plugin 'PushPlugin' not found, or is not a CDVPlugin. Check your plugin mapping in config.xml
Is PushPlugin compatible with Cordova 2.5?
I had this same issue when trying to get the pushplugin to work. I got it working by putting this block of code inside the config.xml (not the one in the www folder, but the one in the project folder)
<!-- ios -->
<platform name="ios">
<config-file target="config.xml" parent="/*">
<feature name="PushPlugin">
<param name="ios-package" value="PushPlugin"/>
</feature>
</config-file>
<source-file src="src/ios/AppDelegate+notification.m" />
<source-file src="src/ios/PushPlugin.m" />
<header-file src="src/ios/AppDelegate+notification.h" />
<header-file src="src/ios/PushPlugin.h" />
</platform>
If you download the sample project from git, there's a file called plugin.xml that has a bunch of stuff that needs to be added to the xml (I think).
Hope that helps.