【问题标题】:iOS Ionic build failediOS Ionic 构建失败
【发布时间】:2016-10-03 11:47:12
【问题描述】:

我尝试在 ionic 中将我的应用程序构建到 IOS,但是当我尝试使用 ionic 构建 iOS 时出现错误。这是错误代码

构建失败

以下构建命令失败:

编译C build/varfinz.build/Debug-iphonesimulator/varfinz.build/Objects-normal/i386/CDVFile.o varfinz/Plugins/org.apache.cordova.file/CDVFile.m 正常 i386 Objective-c com.apple.compilers.llvm.clang.1_0.compiler (1 失败)

错误:命令的错误代码 65:带有 args 的 xcodebuild: -xcconfig,/Users/lorenzo/Desktop/varfinz5/platforms/ios/cordova/build-debug.xcconfig,-project,varfinz.xcodeproj,ARCHS=i386,-target,varfinz,-configuration,Debug,-sdk,iphonesimulator, build,VALID_ARCHS=i386,CONFIGURATION_BUILD_DIR=/Users/lorenzo/Desktop/varfinz5/platforms/ios/build/emulator,SHARED_PRECOMPS_DIR=/Users/lorenzo/Desktop/varfinz5/platforms/ios/build/sharedpch

这是有错误的代码部分。错误在第 3 行,带有 sn-p self = (CDVFile*)[super initWithWebView:theWebView]; Xcode 说如下:“CDVPlugin 没有可见的@interface 声明选择器 initWithWebView

- (id)initWithWebView:(UIWebView*)theWebView
{
    self = (CDVFile*)[super initWithWebView:theWebView];
    if (self) {
        filePlugin = self;
        [NSURLProtocol registerClass:[CDVFilesystemURLProtocol class]];

        fileSystems_ = [[NSMutableArray alloc] initWithCapacity:3];

        // Get the Library directory path
        NSArray* paths = NSSearchPathForDirectoriesInDomains(NSLibraryDirectory, NSUserDomainMask, YES);
        self.appLibraryPath = [[paths objectAtIndex:0] stringByAppendingPathComponent:@"files"];

        // Get the Temporary directory path
        self.appTempPath = [NSTemporaryDirectory()stringByStandardizingPath];   // remove trailing slash from NSTemporaryDirectory()

        // Get the Documents directory path
        paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
        self.rootDocsPath = [paths objectAtIndex:0];
        self.appDocsPath = [self.rootDocsPath stringByAppendingPathComponent:@"files"];

    }

    return self;
}

【问题讨论】:

  • 你能提供一些代码吗?尝试在代码中添加一些断点并调试以查看它在哪里中断
  • 嗨,是的,我编辑了上面的帖子
  • @Lorenzo 你在使用钥匙串还是 Facebook 插件?
  • 嗨甘地,是的钥匙链

标签: ios cordova ionic-framework


【解决方案1】:

你可以通过两种方式解决这个问题:

1- 将[super initWithWebView:theWebView] 替换为[super init]。

2-给CDVFile添加一个编译器标志来禁用ARC,编译器标志是-fno-objc-arc

从我的角度来看,我推荐第二种解决方案,因为它不会影响代码。

如果您正在寻找分步解决方案,请在 Xcode 中执行以下操作。

  1. 选择您的主要项目。
  2. 选择您的目标
  3. 进入构建阶段
  4. 展开已编译的资源点击
  5. 选择“CDVFile.m”
  6. 在“CDVFile.m”的右侧,可以添加以下编译器标志

    -fno-objc-arc

现在,如果您想详细了解问题:

CDVFile 是在非 ARC 环境下构建的,他控制着他的内存消耗。 但是 Xcode 不允许这样做,因为它使用 ARC 来控制整个应用程序的内存消耗。 所以这个冲突的解决方案是修改 CDVFile 代码以使用 ARC,或者只是通过添加编译器标志告诉 Xcode 你负责这个类的内存管理。

更新 注意:每次添加平台时都应完成上述两种解决方案。

要永久解决问题,请执行以下操作:

  1. 转到插件文件夹
  2. 查找导致问题的插件(在本例中为:cordova-plugin-file)
  3. 打开 plugin.xml 文件
  4. 定位<platform name="ios">
  5. 找到以下标签:<source-file src="src/ios/CDVFile.m"/> 并将其替换为:<source-file src="src/ios/CDVFile.m" compiler-flags="-fno-objc-arc"/>
  6. 移除并添加 ios 平台,您就完成了。

【讨论】:

    【解决方案2】:

    我间歇性地遇到这个问题。虽然我无法说出问题的根本原因,但以下内容对我有用 - 来自 CLI:

    cordova platform remove ios
    ionic serve
    cordova platform add ios
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-06-07
      • 2019-05-27
      • 2019-07-28
      • 1970-01-01
      • 1970-01-01
      • 2019-06-19
      • 1970-01-01
      • 2016-11-05
      相关资源
      最近更新 更多