Cordova:在iOS平台上构建Ionic1应用程序时出错

时间:2018-01-05 14:40:45

标签: cordova ionic-framework

我试图在iOS中模拟Ionic1应用,但构建命令给了我错误,我不知道如何解决它。我该怎么办?

$ ionic info

cli packages: (/usr/local/lib/node_modules)

    @ionic/cli-utils  : 1.19.0
    ionic (Ionic CLI) : 3.19.0

global packages:

    cordova (Cordova CLI) : 8.0.0 
    Gulp CLI              : CLI version 3.9.1 Local version 3.9.1

local packages:

    Cordova Platforms : ios 4.5.4
    Ionic Framework   : ionic1 1.3.4

System:

    ios-deploy : 1.9.2 
    ios-sim    : 6.1.2 
    Node       : v8.1.2
    npm        : 5.6.0 
    OS         : OS X Yosemite
    Xcode      : Xcode 7.1 Build version 7B91b 

Environment Variables:

    ANDROID_HOME : not set

Misc:

    backend : legacy

$ cordova插件列表

cordova-plugin-device 1.1.4 "Device"
cordova-plugin-ionic-webview 1.1.16 "cordova-plugin-ionic-webview"
cordova-plugin-splashscreen 4.0.3 "Splashscreen"
cordova-plugin-whitelist 1.3.1 "Whitelist"
ionic-plugin-keyboard 2.2.1 "Keyboard"

我试过了:

$ sudo npm install -g ios-sim
$ ionic cordova platform add ios
$ ionic cordova build ios

并收到以下错误消息:

错误

** BUILD FAILED **


The following build commands failed:
    CompileC /Users/otero/Library/Developer/Xcode/DerivedData/conFusion-fibudfuhdifeioamjwrjiuwgycdy/Build/Intermediates/conFusion.build/Debug-iphonesimulator/conFusion.build/Objects-normal/x86_64/GCDWebServerDataRequest.o conFusion/Plugins/cordova-plugin-ionic-webview/GCDWebServerDataRequest.m normal x86_64 objective-c com.apple.compilers.llvm.clang.1_0.compiler
(1 failure)
(node:547) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): Error code 65 for command: xcodebuild with args: -xcconfig,/Users/otero/Google Drive/coursera/full stack web development/course 4/ionic/conFusion/platforms/ios/cordova/build-debug.xcconfig,-workspace,conFusion.xcworkspace,-scheme,conFusion,-configuration,Debug,-sdk,iphonesimulator,-destination,platform=iOS Simulator,name=iPhone 6s Plus,build,CONFIGURATION_BUILD_DIR=/Users/otero/Google Drive/coursera/full stack web development/course 4/ionic/conFusion/platforms/ios/build/emulator,SHARED_PRECOMPS_DIR=/Users/otero/Google Drive/coursera/full stack web development/course 4/ionic/conFusion/platforms/ios/build/sharedpch
(node:547) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

1 个答案:

答案 0 :(得分:0)

此处发布的解决方案对我有用: https://github.com/ionic-team/cordova-plugin-ionic-webview/issues/42

查看错误日志,我发现错误是:

ionic/conFusion/platforms/ios/conFusion/Plugins/cordova-plugin-ionic-webview/GCDWebServerDataRequest.m:59:10: error: no visible @interface for 'NSData' declares the selector 'appendData:'
  [_data appendData:data];

然后我只需找到相应的.h文件并编辑一行:

//from this: @property(nonatomic, readonly) NSData* data;
@property(nonatomic, readonly) NSMutableData* data; //to this

然后再次运行$ ionic cordova build ios。它起作用了。

来自帖子的作者:

  

我做了一些研究并对底层进行了一些小调整   图书馆并修复了这个问题。但我不知道是否必然   正确。 .h文件中的公共接口与私有接口不匹配   .m文件中的接口。有一个名为"数据的@property"那是   .h文件中的NSData类型和.m中的NSMutableData类型   文件。当我在.h文件中将数据@property更改为NSMutable时,   离子构建命令再次起作用。

     

我已经涉足了目标-C但从未完全理解过   用于声明事物的@interface,@ property和syntize语法。一世   不知道.h和.m是否需要匹配。我做了这个改变是因为   我注意到NSData对象没有appendData:方法   但NSMutableData呢。你可以尝试自己,看看是否这样   的工作原理。