Xcode中的多个目标:“无法启动模拟应用程序:未知错误。” [英] Multiple Targets in Xcode: "Failed to launch simulated application: Unknown error."

查看:115
本文介绍了Xcode中的多个目标:“无法启动模拟应用程序:未知错误。”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在Xcode中构建多个目标,以简化创建应用程序的精简版和专业版的过程。从理论上讲,这很好,我可以将定义传递给 GCC_PREPROCESSOR_DEFINITIONS ,以便在我的代码中使用。但是,由于尝试在模拟器中启动第二个目标时出错,我实际上遇到了问题:无法启动模拟应用程序:未知错误。

I'm trying to build for multiple targets in Xcode, to simplify the process of creating a "lite" and "pro" version of my application. In theory, this is great and I can pass defines to GCC_PREPROCESSOR_DEFINITIONS for use in my code. However, I'm having problems actually getting it to work due to an error trying to launch the second target in the simulator: Failed to launch simulated application: Unknown error.

以下是我用来创建额外目标的简单流程:

Here is the simple process I'm using to create the additional target:


  1. 将#ifdef MYAPP_PRO添加到源文件以根据应用程序的pro / lite版本修改行为(并验证应用程序是否按预期工作)

  2. 选择项目>> New Target ... 从菜单中选择Cocoa Touch Application(名为MyAppPro)

  3. 编辑新的目标设置;添加 GCC_PREPROCESSOR_DEFINITIONS 用户定义设置并将值设置为MYAPP_PRO(无引号)

  4. 将活动目标设置为 MyAppPro;构建并运行。

  5. 无法启动模拟应用程序:未知错误。

  6. 将所有设置从Info.plist复制到MyAppPro-Info.plist再试一次

  7. 失败了unch模拟应用程序:未知错误。

  1. Add #ifdef MYAPP_PRO to source files to modify behavior based on pro/lite version of app (and verify application is working as expected)
  2. Select Project > New Target... from menu, and pick "Cocoa Touch Application" (named MyAppPro")
  3. Edit new target settings; add GCC_PREPROCESSOR_DEFINITIONS user-defined setting and set the value to "MYAPP_PRO" (no quotes)
  4. Set active target to "MyAppPro"; build and run.
  5. Failed to launch simulated application: Unknown error.
  6. Copy all settings from Info.plist to MyAppPro-Info.plist and try again
  7. Failed to launch simulated application: Unknown error.

构建完成正常,但我无法运行在模拟器中。

The build completes just fine, but I'm unable to run in simulator.

编辑.xcodeproj目录中的project.pbxproj,我注意到两个目标定义的构建设置之间存在一些关键差异。我尝试手动编辑文件,但一定做错了,因为我之后无法在Xcode中加载它。

Editing the project.pbxproj in the .xcodeproj directory, I notice there are some key differences between the two target definitions' build settings. I tried manually editing the file but must have done something wrong because I couldn't get it to load in Xcode afterwards.

原始目标的Debug构建设置:

Original target's "Debug" build settings:

        buildSettings = {
            ALWAYS_SEARCH_USER_PATHS = YES;
            ARCHS = "$(ARCHS_STANDARD_32_BIT)";
            "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
            GCC_C_LANGUAGE_STANDARD = c99;
            GCC_WARN_ABOUT_RETURN_TYPE = YES;
            GCC_WARN_UNUSED_VARIABLE = YES;
            ONLY_ACTIVE_ARCH = YES;
            PREBINDING = NO;
            SDKROOT = iphoneos2.2.1;
        };

新的MyAppPro目标的调试构建设置:

Thew new MyAppPro target's "Debug" build settings:

        buildSettings = {
            ALWAYS_SEARCH_USER_PATHS = NO;
            CODE_SIGN_IDENTITY = "iPhone Developer";
            COPY_PHASE_STRIP = NO;
            GCC_DYNAMIC_NO_PIC = NO;
            GCC_OPTIMIZATION_LEVEL = 0;
            GCC_PRECOMPILE_PREFIX_HEADER = YES;
            GCC_PREFIX_HEADER = "$(SYSTEM_LIBRARY_DIR)/Frameworks/UIKit.framework/Headers/UIKit.h";
            INFOPLIST_FILE = "MyAppPro-Info.plist";
            INSTALL_PATH = "$(HOME)/Applications";
            OTHER_LDFLAGS = (
                "-framework",
                Foundation,
                "-framework",
                UIKit,
            );
            PREBINDING = NO;
            PRODUCT_NAME = MyAppPro;
            SDKROOT = iphoneos2.2.1;
        };


推荐答案

你没有说你是否真的添加过来源文件到目标。新目标(与新项目不同)没有源文件模板;你必须自己添加它们。所以模拟器可能会告诉你你已经成功建造,但没有什么可以运行的。

You didn't say whether you actually ever added source files to the target. A new target (unlike a new project) has no source file templates; you have to add them yourself. So the Simulator might be telling you "you built successfully, but there's nothing to run."

这篇关于Xcode中的多个目标:“无法启动模拟应用程序:未知错误。”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆