繁体   English   中英

iOS Ionic构建失败

[英]iOS Ionic build failed

我尝试在IOS上使用Ionic来构建我的应用程序,但是当我尝试Ionic来构建iOS时出现错误。 这是错误代码

建立失败

以下构建命令失败:

CompileC 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,-配置,调试,-sdk,iphonesimulator,构建,VALID_ARCHS = i386,CONFIGURATION_BUILD_DIR = / Users / lorenzo / Desktop / varfinz5 / platforms / ios / build / emulator,SHARED_PRECOMPS_DIRz = / Users / lorenzo / Desktop / varfinz ios /构建/ sharedpch

这是带有错误的代码部分。 错误出现在第三行,代码段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;
}

您可以通过两种方式解决此问题:

1-用[super initWithWebView:theWebView] [super init]替换[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平台,您就完成了。

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

cordova platform remove ios
ionic serve
cordova platform add ios

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM