搜尋

首頁  >  問答  >  主體

objective-c - Cordova插件开发时无法导入阿里百川的iOS SDK

最近在做阿里百川的Cordova插件,将其iOS SDK的.framework写入plugin.xml之后,在工程中添加插件报错如下:

Failed to install 'com.qiqujie.taobaoplugin':TypeError: Cannot read property 'nodeName' of null
    at Object.parse (/usr/local/lib/node_modules/cordova/node_modules/cordova-lib/node_modules/plist/lib/parse.js:45:26)
    at Object.module.exports.package_name (/usr/local/lib/node_modules/cordova/node_modules/cordova-lib/src/plugman/platforms/ios.js:143:22)
    at /usr/local/lib/node_modules/cordova/node_modules/cordova-lib/src/platforms/PlatformApiPoly.js:267:67
    at _fulfilled (/usr/local/lib/node_modules/cordova/node_modules/cordova-lib/node_modules/cordova-common/node_modules/q/q.js:834:54)
    at self.promiseDispatch.done (/usr/local/lib/node_modules/cordova/node_modules/cordova-lib/node_modules/cordova-common/node_modules/q/q.js:863:30)
    at Promise.promise.promiseDispatch (/usr/local/lib/node_modules/cordova/node_modules/cordova-lib/node_modules/cordova-common/node_modules/q/q.js:796:13)
    at /usr/local/lib/node_modules/cordova/node_modules/cordova-lib/node_modules/cordova-common/node_modules/q/q.js:857:14
    at runSingle (/usr/local/lib/node_modules/cordova/node_modules/cordova-lib/node_modules/cordova-common/node_modules/q/q.js:137:13)
    at flush (/usr/local/lib/node_modules/cordova/node_modules/cordova-lib/node_modules/cordova-common/node_modules/q/q.js:125:13)
    at doNTCallback0 (node.js:430:9)
Error: Cannot read property 'nodeName' of null

plugin.xml的iOS部分:

<platform name="ios">
    <config-file target="config.xml" parent="/*">
        <feature name="Wechat">
            <param name="ios-package" value="CDVWechat" />
            <param name="onload" value="true" />
        </feature>
    </config-file>

    <config-file target="*-Info.plist" parent="CFBundleURLTypes">
        <dict>
            <key>CFBundleURLName</key>
            <string>com.taobao.taesdk</string>
            <key>CFBundleURLSchemes</key>
            <array>
                <string>tbopen********</string>
            </array>
        </dict>
    </config-file>

    <!-- Plugin source code -->
    <header-file src="src/ios/CDVTaobao.h" />
    <source-file src="src/ios/CDVTaobao.m" />

    <!-- Baichuan frameworks -->
    <framework src="src/ios/libs/ALBBFullSecurityGuard.framework" custom="true" />
    <framework src="src/ios/libs/ALBBLoginSDK.framework" custom="true" />
    <framework src="src/ios/libs/ALBBRpcPlugin.framework" custom="true" />
    <framework src="src/ios/libs/ALBBTBOpenPlugin.framework" custom="true" />
    <framework src="src/ios/libs/ALBBTradeSDK.framework" custom="true" />
    <framework src="src/ios/libs/AlipaySDK.framework" custom="true" />
    <framework src="src/ios/libs/SecurityGuardSDK.framework" custom="true" />
    <framework src="src/ios/libs/TAESDK.framework" custom="true" />
    <framework src="src/ios/libs/TBAppLinkSDK.framework" custom="true" />
    <framework src="src/ios/libs/UTDID.framework" custom="true" />
    <framework src="src/ios/libs/UTMini.framework" custom="true" />

    <!-- Baichuan Resources -->
    <resource-file src="src/ios/libs/AlipaySDK.bundle" />
    <resource-file src="src/ios/libs/Tae.bundle" />
    <resource-file src="src/ios/libs/yw_1222.jpg" />

    <!-- Fundamental frameworks -->
    <framework src="libstdc++.6.0.9.dylib" />
    <framework src="libz.dylib" />
    <framework src="MobileCoreServices.framework" />
    <framework src="AssetsLibrary.framework" />
    <framework src="ImageIO.framework" />
    <framework src="CoreData.framework" />
    <framework src="CoreLocation.framework" />
    <framework src="Security.framework" />
    <framework src="SystemConfiguration.framework" />
    <framework src="CoreTelephony.framework" />
    <framework src="CFNetwork.framework" />
    <framework src="CoreGraphics.framework" />
    <framework src="UIKit.framework" />
    <framework src="Foundation.framework" />
</platform>

我尝试逐个framework文件添加时,只有部分framework文件会造成这个问题,例如ALBBLoginSDK.framework,而ALBBFullSecurityGuard.frameworkTAESDK.framework则不会
Google找到一个cordova的issue,说there was some corruption of the Info.plist which results in this crash,但是我用xcode可以顺利读出framework中的信息,有什么办法可以解决这个问题吗?先谢了:)

PHP中文网PHP中文网2773 天前726

全部回覆(3)我來回復

  • 天蓬老师

    天蓬老师2017-04-17 17:18:12

    樓主說的Cordova就是之前的PhoneGap吧?

    回覆
    0
  • PHP中文网

    PHP中文网2017-04-17 17:18:12

    似乎是ALBBLoginSDK.frameworkALBBTradeSDK.framework中同时含有Info.plist项目名-Info.plist,而且内容不一致,而其他framework文件中就只有Info.plist,把有问题的两个framework里的项目名-Info.plist刪除就可以成功導入,就喚起淘寶app這一功能來說暫時沒發現有什麼問題…

    回覆
    0
  • 怪我咯

    怪我咯2017-04-17 17:18:12

    嗯,以前寫一個蒲公英的cordvoa插件的時候也遇到過類似的,debug了半天發現是解析某個plist檔出錯了。結果發現蒲公英SDK裡面的info.plist是亂碼。 。 。導致解析失敗。
    估計是你那兩個framework的plist檔案內容有問題。

    回覆
    0
  • 取消回覆