简体   繁体   English

如何使用iOS模拟器7 \\ XCode 5测试iOS 7之前的UI(不升级iOS 7的应用程序)

[英]How to use iOS Simulator 7 \ XCode 5 to test pre-iOS 7 UI (without upgrading the app for iOS 7)

Compiling my app on XCode 4.6.3 and running it on iOS 7 works great. 在XCode 4.6.3上编译我的应用程序并在iOS 7上运行它的效果很好。

Compiling my app on XCode 5 and running it on iOS 7 results a big UI mess I don't want to handle right now. 在XCode 5上编译我的应用程序并在iOS 7上运行它会导致我现在不想处理的大量UI问题。 (iOS 7 pickers, tabbars, tableviews etc') (iOS 7选择器,tabbars,tableviews等')

Goal: 目标:

I want to be able to use XCode 5 and test my app on the iOS 7 simulator but still use the iOS 6 and lower UI and feel. 我希望能够使用XCode 5并在iOS 7模拟器上测试我的应用程序,但仍然使用iOS 6和更低的UI和感觉。

Reason: 原因:

I don't want to redesign my app to iOS 7 but I do want to make sure it runs fine on iOS 7 using XCode 5 iOS 7 simulator. 我不想将我的应用程序重新设计到iOS 7,但我确实希望确保它在iOS 7上使用XCode 5 iOS 7模拟器正常运行。

Is there a quick toggle on XCode 5 to force everything to stay the same? 是否有一个快速切换XCode 5强制一切保持不变?

Is doing something like using iOS 6 Base SDK in XCode 5 acceptable or a bit too much hacky? 在XCode 5中使用iOS 6 Base SDK是否可以接受或者有点太多hacky?

Edit: 编辑:

Using iOS 6 SDK doesn't help. 使用iOS 6 SDK无济于事。 You'll still get the iOS 7 look on your app, just more buggy. 您仍然会在应用程序上看到iOS 7外观,只是更多的错误。

This is the scenario: 这是场景:

  • Your app works fine on iOS 6 and lower 您的应用在iOS 6及更低版本上运行良好
  • You want to test your app on iOS 7 您想在iOS 7上测试您的应用
  • If you have iOS 7 on your device you'll need XCode 5 in order to test it on it 如果您的设备上安装了iOS 7,则需要XCode 5才能对其进行测试
  • If you want to test it on the iOS 7 simulator you'll need to install XCode 5 for it 如果你想在iOS 7模拟器上测试它,你需要为它安装XCode 5
  • Compiling your working app on XCode 5 will break all hell loose and will force you to redesign your app at least for iOS 7 在XCode 5上编译你的工作应用程序将打破所有的地狱,并将迫使你至少为iOS 7重新设计你的应用程序
  • The solutions suggested here so far will help you to see how your app will look like on iOS 7 but will not keep your iOS 6 and lower look on iOS 7. 到目前为止建议的解决方案将帮助您了解您的应用在iOS 7上的外观,但不会在iOS 7上保持iOS 6及更低的外观。

Best solution I've found so far: 到目前为止我找到的最佳解决方案:

  1. Update your current XCode to XCode 5 将当前的XCode更新为XCode 5
  2. Download XCode 4.6.3 from here 这里下载XCode 4.6.3
  3. Install it in a different location and Change the name of the app to XCode4 in order to differentiate between the two. 将其安装在不同的位置,并将应用程序的名称更改为XCode4,以区分这两者。
  4. Find your XCode 5 app icon, right click it and select "Show Package Contents" 找到您的XCode 5应用程序图标,右键单击它并选择“显示包内容”
  5. Locate the folder MacOS and move the xcode file outside of its folder. 找到文件夹MacOS并将xcode文件移到其文件夹之外。 Those last two steps are to prevent you accidentally opening a project with XCode 5. An alternative is to change the default "Open With" app but for some reason that didn't work for me plus I wanted to be extra sure after I had one project opening with XCode 5 and the StoryBoard changed to be compatible to XCode 5 only. 最后两个步骤是为了防止你不小心用XCode 5打开一个项目。另一种方法是更改​​默认的“打开方式”应用程序但由于某些原因对我不起作用加上我想在我有一个之后更加确定使用XCode 5打开项目,并将StoryBoard更改为仅与XCode 5兼容。 * *
  6. Open XCode 4.6.3 and run your project. 打开XCode 4.6.3并运行您的项目。 In your simulator menu you should now See iOS 7. Even if in XCode top bar you'll see AppName->iPhone 6.1 Simulator , selecting iOS 7 on the simulator will run your app in iOS 7 and keep everything the same. 在您的模拟器菜单中,您现在应该看到iOS 7.即使在XCode顶部栏中您将看到AppName-> iPhone 6.1 Simulator ,在模拟器上选择iOS 7将在iOS 7中运行您的应用程序并保持一切相同。

After the above you'll have two versions of iOS simulator. 在上面你将有两个版本的iOS模拟器。 Version 6 and version 7 that contains iOS 7 Simulator. 包含iOS 7 Simulator的版本6和版本7。

Step 5: 第5步:

在此输入图像描述

COPY iPhoneSimulator6.1.sdk COPY iPhoneSimulator6.1.sdk

FROM

<YOUR XCode4 path>/Xcode4.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/

TO

/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/

and set your base target to iOS6.1 (It will be listed after copying/pasting from xcode4) and 并将您的基本目标设置为iOS6.1(它将在从xcode4复制/粘贴后列出)和

在此输入图像描述在此输入图像描述

You cannot do this on the iOS 7 Simulator. 你无法在iOS 7模拟器上执行此操作。 You can do it in the iOS 6 Simulator (running under Xcode 5) and on the device (running iOS 7 as long as you build with the iOS 6 SDK). 您可以在iOS 6 Simulator(在Xcode 5下运行)和设备上运行(只要您使用iOS 6 SDK构建,就可以运行iOS 7)。 But there is no iOS 6 compatibility mode in the iOS 7 Simulator. 但iOS 7模拟器中没有iOS 6兼容模式。

Note that iOS 6 compatibility mode is not a perfect replication of iOS 6. There are still various behavioral differences that you will likely have to test for and deal with. 请注意,iOS 6兼容模式并不是iOS 6的完美复制。您可能需要测试和处理各种行为差异。 But the basic UI components are what you expect. 但基本的UI组件是您所期望的。

EDIT - Note that it is not possible to force an app to use the iOS 6 interface on an iOS 7 device using Xcode 5 (unless you make custom graphics). 编辑 - 请注意, 无法强制应用程序在使用Xcode 5的iOS 7设备上使用iOS 6界面(除非您制作自定义图形)。 It is also not a good design approach . 也不是一个好的设计方法 Users on iOS 7 expect a certain UI style, that's why they updated; iOS 7上的用户期望具有某种UI风格,这就是他们更新的原因; so give it to them, don't force them back into an older interface. 所以给它们,不要强迫它们回到旧的界面。

If you really , really need the pre-iOS-7 interface, you can download a copy of Xcode 4 and build with that. 如果你真的需要预先的iOS-7接口,可以下载的Xcode 4的副本,并与建设。 However, starting February 1, 2014 Apple will stop accepting apps built with anything earlier than Xcode 5.0 (I think I saw something about that in the iOS 7 dev docs, but can't find the reference again). 但是,从2014年2月1日开始Apple将停止接受使用早于Xcode 5.0构建的应用程序(我想我在iOS 7开发文档中看到了一些相关内容,但无法再找到引用)。


Keeping the iOS 6 UI in your app, but building for iOS 7 is fairly straightforward. 在您的应用中保留iOS 6 UI,但为iOS 7构建相当简单。 Make sure that you've set your Deployment Target as iOS 6.1 or earlier. 确保将部署目标设置为iOS 6.1或更早版本。 Your Base SDK can still be set as iOS 7 though. 您的Base SDK仍然可以设置为iOS 7。 Now, just follow the instructions below for each of your interface files: 现在,只需按照以下说明为每个界面文件:

  1. Open your storyboard file or XIB file 打开故事板文件或XIB文件
  2. Open the Utilities Panel on the right side. 打开右侧的“实用工具”面板。
  3. Click on The File Inspector Tab. 单击“文件检查器”选项卡。 You should now see something like this: 你现在应该看到这样的事情:

    Xcode 5实用程序面板和文件检查器

  4. Next go to the Interface Build Document Section and change the Builds For setting to iOS 6.0 and Later or whatever version you need. 接下来转到Interface Build Document Section并将Builds For设置更改为iOS 6.0及更高版本或您需要的任何版本。

    Xcode 5实用程序面板界面构建文档部分

  5. Then change the View As setting to iOS 6.1 or earlier : 然后将“ View As设置更改为iOS 6.1或更早版本

    Xcode 5接口构建文档部分 - 作为设置查看

  6. Xcode will prompt you, just confirm that you want to convert to the older UI. Xcode会提示您,只需确认您要转换为旧的UI。

Make sure to run your project in the iOS 6 Simulator. 确保在iOS 6 Simulator中运行您的项目。 Otherwise, the iOS 7 Simulator will override it's own iOS 7 UI style. 否则,iOS 7 Simulator将覆盖它自己的iOS 7 UI样式。 To download the iOS 6 Simulator, go to the Xcode Menu Bar. 要下载iOS 6 Simulator,请转到Xcode菜单栏。 Select Xcode, Preferences. 选择Xcode,首选项。 Then click on the Downloads tab. 然后单击“下载”选项卡。 Finally, click on the Simulator(s) you need to download: 最后,单击您需要下载的模拟器:

在此输入图像描述

Then Run your app on the iOS 6 simulator: 然后在iOS 6模拟器上运行您的应用程序: 在此输入图像描述

Unfortunately, even disabling the iOS 7 UI in Xcode does not override it on the device / simulator. 不幸的是,即使在Xcode中禁用iOS 7 UI也不会在设备/模拟器上覆盖它。 Unless you design custom UI elements, there isn't a way to maintain your iOS 6 UI on iOS 7 . 除非您设计自定义UI元素,否则无法在iOS 7上维护iOS 6 UI But as I showed you, you can continue to edit it in iOS 6 and build for iOS 6 . 但正如我向您展示的那样, 您可以继续在iOS 6中编辑它并为iOS 6构建

Linking the 6.1 SDK into Xcode 5 as described in the other answers is one step. 如其他答案中所述,将6.1 SDK链接到X​​code 5是一步。 However this still doesn't solve the problem that running on iOS 7 new UI elements are taken, view controllers are made full-size etc. 但是,这仍然无法解决在iOS 7上运行新的UI元素,视图控制器是全尺寸等问题。

As described in this answer it is also required to switch the UI into legacy mode on iOS 7: 本回答所述,还需要在iOS 7上将UI切换为传统模式:

// put in main.m
[[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"UIUseLegacyUI"];
[[NSUserDefaults standardUserDefaults] synchronize];

Beware: This is an undocumented key and not recommended for App Store builds! 注意:这是一个未记录的密钥,不推荐用于App Store版本!

Also there are subtle differences to a version built using Xcode 4.6. 使用Xcode 4.6构建的版本也存在细微差别。 For instance, transparent navigation bars behave differently (causing the view to be full-size). 例如,透明导航栏的行为不同(导致视图为全尺寸)。

However, since Xcode 4.6.3 crashes on Mavericks (at least for me, see rdar://15318883 ), this is at least a solution to continue using Xcode 5 for debugging. 但是,由于Xcode 4.6.3在Mavericks上崩溃(至少对我而言,请参阅rdar:// 15318883 ),这至少是继续使用Xcode 5进行调试的解决方案。

Update: the crash of Xcode 4.6.3 on Mavericks only occurs when using LLDB. 更新: Xcode 4.6.3在Mavericks上的崩溃仅在使用LLDB时发生。 When switching back to GDB it works. 当切换回GDB时,它可以工作。

Contrary to my comments, I could actually follow the steps mentioned in the link . 与我的评论相反,我实际上可以按照链接中提到的步骤进行操作 What I tried was nothing sort of hacky: 我尝试的是什么都没有hacky:

  • Open XCode 4.6 app package (I have it still installed) 打开XCode 4.6应用程序包(我还安装了它)
  • Go to Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs folder. 转到Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs文件夹。
  • Copy iPhoneOS6.1.sdk folder. 复制iPhoneOS6.1.sdk文件夹。
  • Open XCode 5 app package. 打开XCode 5应用程序包。
  • Go to same Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs folder. 转到相同的Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs文件夹。
  • Paste. 糊。

I could then see iOS 6.1 as an option to base off my iOS project under Build Settings->Base SDKs . 然后,我可以看到iOS 6.1作为基于Build Settings->Base SDKs iOS项目的选项。

However, even after doing this when I ran the app under iOS 7 simulator, I could sense no visual difference - all was rendered in default iOS 7 style - borderless buttons and bars. 然而,即使在我在iOS 7模拟器下运行应用程序之后,我也能感觉到没有视觉差异 - 所有这些都是在默认的iOS 7风格中呈现 - 无边框按钮和条形图。

No change after resetting simulator. 重置模拟器后无变化。

No change after changing storyboard version too. 更改故事板版本后没有变化。

So this again seems to confirm my assertion that this isn't possible. 所以这似乎再次证实了我的断言,这是不可能的。

If anyone tried it, I want to know. 如果有人试过,我想知道。

I think that the only way to show iOS 6 controls on XCode 5 (and iOS7 Simulator) is to set the Base SDK of your Target to iOS 6.1(6.0). 我认为在XCode 5(和iOS7 Simulator)上显示iOS 6控件的唯一方法是将Target的Base SDK设置为iOS 6.1(6.0)。

You should copy the old sdk to XCode 5 like Nirav described and restart the XCode to make it visible under Base SDK selection. 你应该像Nirav描述的那样将旧的sdk复制到XCode 5并重新启动XCode以使其在Base SDK选择下可见。

My guess is that it didn't work for Nirav because he changed the settings of the project and in his case they have been dis-synchronized from settings of the target. 我的猜测是,它不适用于Nirav,因为他改变了项目的设置,在他的情况下,他们已经从目标的设置中解除了同步。 So make sure that Base SDK for your target is iOS 6.0. 因此,请确保您的目标的Base SDK是iOS 6.0。 Then it should work (at least it does for me). 然后它应该工作(至少它对我而言)。

This will give you a preview of how the app will look in iOS 6 using Xcode 5. 这将让您预览应用程序在iOS 6中使用Xcode 5的外观。

I saw this on a WWDC Video. 我在WWDC视频上看到了这个。

406 - taking control autolayout xcode 5 (about 32 mins in) 406 - 控制自动布局xcode 5(约32分钟)

Using, the preview function within the storyboard. 使用故事板中的预览功能。

在此输入图像描述

This will allow you to pick between how it will look on iOS 7 and iOS 6. 这将允许您在iOS 7和iOS 6之间进行选择。

在此输入图像描述

The video shows a cool (almost hidden) feature of xcode that allows you to see, both previews of iOS6 and iOS7 at the same time, splitting up Xcode into 3 separate views 视频显示了xcode的一个很酷(几乎隐藏)的功能,允许你同时看到iOS6和iOS7的预览,将Xcode分成3个独立的视图

我想补充一点,虽然您可能无法在模拟器中执行此操作,但您可以在具有iOS 7的实际设备上以兼容模式运行应用程序。

Wow, this is a real mess. 哇,这真是一团糟。 Thanks, Apple [*] 谢谢,Apple [*]

I got this (this: XCode 5 building iOS 6 apps) working for me, but I had several XIB's that were messed up, and it took a combination of several of the above steps to get it working. 我得到了这个(这个:XCode 5构建iOS 6应用程序)为我工作,但我有几个混乱的XIB,它采取了上述几个步骤的组合,以使其工作。

1) Setup XCode 5 with iOS 6 base sdk 1)使用iOS 6 base sdk设置XCode 5

@Sha has good steps for that: How to use iOS Simulator 7 \\ XCode 5 to test pre-iOS 7 UI (without upgrading the app for iOS 7) @Sha有很好的步骤: 如何使用iOS模拟器7 \\ XCode 5测试iOS 7以前的UI(不升级iOS 7的应用程序)

2) Go through each XIB and set it for XCode 4.6 mode 2)浏览每个XIB并将其设置为XCode 4.6模式

@RazorSharps post has good steps: How to use iOS Simulator 7 \\ XCode 5 to test pre-iOS 7 UI (without upgrading the app for iOS 7) @RazorSharps帖子有很好的步骤: 如何使用iOS模拟器7 \\ XCode 5测试iOS 7之前的UI(不升级iOS 7的应用程序)

I'm not sure this was 100% required, but I did it and it works. 我不确定这是100%要求,但我做了它并且它有效。 (Perhaps I'll go back later and try without this, when I'm not still fuming). (也许我会稍后回去尝试没有这个,当我还没有发情时)。

3) Find any Navigation Controllers in XIB (or code) that may be set to Translucent, set them to Opaque 3)在XIB(或代码)中找到可能设置为半透明的任何导航控制器,将它们设置为不透明

This was the trick for me. 这对我来说很有把戏。 I had a root XIB that defined the Navigation Bar as Black Translucent, but all the XIB's that loaded overrode with their own appearance. 我有一个根XIB,它将导航栏定义为黑色半透明,但所有加载的XIB都有自己的外观。
In 'real iOS 6' the controllers setting would override this (that is, the navbar would appear as opaque), but in iOS 6 Compatibility Mode on iOS 7 it wouldn't (that is, it would have an iOS 6 appearance, but be transparent, and mess up view layout). 在“真正的iOS 6”中,控制器设置将覆盖此设置(即,导航栏显示为不透明),但在iOS 7上的iOS 6兼容模式中它不会(也就是说,它会有iOS 6外观,但是透明,搞乱视图布局)。

    • @appledevtools: We appreciate your hard work, this is tough to get right. @appledevtools:我们感谢您的辛勤工作,这很难做到。 But here's a suggestion: When upgrading an existing project to XCode 5, IB xib's should be left in XCode 4.6 mode. 但是这里有一个建议:当将现有项目升级到XCode 5时,IB xib应保留在XCode 4.6模式下。 Let the Editor > Validate Settings code offer to upgrade the settings, with a reasonable warning of the implications. 让编辑器>验证设置代码提供升级设置,并对其含义进行合理警告。 Don't do this automatically & silently :-) Also, please find & fix why the navbar style changed in iOS 6 compatibility mode. 不要自动且无声地执行此操作 :-)另外,请查找并修复iOS 6兼容模式下导航栏样式更改的原因。

Good news is that we can set the base sdk to iOS 6.1 with XCode 5 now(in my case, it's Version 5.0.1 (5A2053)), and test & debug our pre-iOS7 designed app on iOS 7 simulator now. 好消息是我们现在可以使用XCode 5将基本sdk设置为iOS 6.1(在我的例子中,它是版本5.0.1(5A2053)),并且现在在iOS 7模拟器上测试和调试我们的iOS7之前设计的应用程序。

For those who don't know how to set base sdk to iOS 6.1 for XCode, this link might be a guide. 对于那些不知道如何将基本sdk设置为iOS 6.1 for XCode的人, 此链接可能是一个指南。

Everything seems to work fine, the same pre-iOS7 design look & feel, except some os provided controls like ActionSheet look & behavior in the iOS 7 way. 一切似乎工作正常,iOS7之前的设计外观和感觉,除了一些操作系统提供像iOS 7方式的ActionSheet外观和行为控件。

BTW, I've upgrade my mac os to maverick yesterday, not sure whether this is an affect factor. 顺便说一句,我昨天将我的mac os升级为特立独行,不确定这是否是影响因素。

This worked for me but the explanation here needs cleaning up and detailing. 这对我有用 ,但这里的解释需要清理和细节。 If still desired, let me know and I will go into more detail. 如果仍然需要,请告诉我,我会详细介绍。

It follows on from this answer 它从这个答案开始

  • In addition to copying the iPhoneOS6.1.sdk folder, you also need to download the iOS 6.1 simulator (the proper way or copy it from an older installation of Xcode) 除了复制iPhoneOS6.1.sdk文件夹外,还需要下载iOS 6.1模拟器(正确的方法或从较旧的Xcode安装中复制)
  • Then, make a duplicate of the iOS 7 simulator and replace it's plist with the 6.1 simulator's plist 然后,复制iOS 7模拟器并用6.1模拟器的plist替换它的plist
  • Restart Xcode 重启Xcode
  • You will then see two iOS 7 simulator options for each device option. 然后,您将看到每个设备选项的两个iOS 7模拟器选项。 One will be the normal iOS 7 simulator. 一个将是正常的iOS 7模拟器。 The other will run your 6.1 SDK builds on the 7 simulator 另一个将在7模拟器上运行6.1 SDK构建
  • WARNING You may not be able to remove the dummy simulator from Xcode's drop-down list afterwards (I haven't tried. It stuck around after I removed the dummy simulator folder) 警告之后您可能无法从Xcode的下拉列表中删除虚拟模拟器(我还没有尝试过。在我删除了虚拟模拟器文件夹后它停留了)

Set deployment target to iOS 7.0 from deployment info. 从部署信息将部署目标设置为iOS 7.0。 For that tap on project name and on first screen you will see deployment info... Change deployment target to 7.0. 对于项目名称的点击,在第一个屏幕上,您将看到部署信息...将部署目标更改为7.0。 After that quit simulator, build and run app again. 在退出模拟器之后,再次构建并运行应用程序。

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

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