macos 如何将 .ipa 文件安装到我的 iPhone 模拟器

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/517463/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-21 06:02:08  来源:igfitidea点击:

How can I install a .ipa file to my iPhone simulator

iphonemacosios-simulator

提问by yinglcs

I have an iphone simulator running on my Mac.

我的 Mac 上运行着一个 iphone 模拟器。

I have a .ipa file, can you please tell me how can I install it on the simulator?

我有一个 .ipa 文件,你能告诉我如何在模拟器上安装它吗?

采纳答案by August

You can't. If it was downloaded via the iTunes store it was built for a different processor and won't work in the simulator.

你不能。如果它是通过 iTunes 商店下载的,则它是为不同的处理器构建的,在模拟器中将无法运行。

回答by Keeton Feavel

I found an .ipa file that I wanted using iTunes and copied it over to my desktop.

我找到了一个我想要使用 iTunes 的 .ipa 文件并将它复制到我的桌面上。

After that I changed the extension to .zipand extracted it.

之后,我将扩展名更改为.zip并提取了它。

Next I found the Payload folder and moved the application inside to my desktop.

接下来我找到了 Payload 文件夹并将里面的应用程序移到了我的桌面上。

Finally I moved that application to my iPhone simulators applications folder found at:

最后,我将该应用程序移至我的 iPhone 模拟器应用程序文件夹,该文件夹位于:

  • HD
  • > Applications
  • > Xcode.app (right click - Show Package Contents)
  • > Contents
  • > Developer
  • > Platforms
  • > iPhoneSimulator.platform
  • > SDKs
  • > iPhoneSimulator6.0.sdk
  • > Applications
  • 高清
  • > 应用
  • > Xcode.app(右键单击 - 显示包内容)
  • > 内容
  • > 开发商
  • > 平台
  • > iPhoneSimulator.platform
  • > SDK
  • > iPhoneSimulator6.0.sdk
  • > 应用

Hope this helps! (Note: Some apps crash more often than others.)

希望这可以帮助!(注意:某些应用程序比其他应用程序崩溃的频率更高。)

回答by sinh99

In Xcode 6+ and iOS8+ you can do the simple steps below

在 Xcode 6+ 和 iOS8+ 中,您可以执行以下简单步骤

  1. Paste .app file on desktop.
  2. Open terminal and paste the commands below:

    cd desktop

    xcrun simctl install booted xyz.app

  3. Open iPhone simulator and click on app and use
  1. 将 .app 文件粘贴到桌面上。
  2. 打开终端并粘贴以下命令:

    cd desktop

    xcrun simctl install booted xyz.app

  3. 打开iPhone模拟器并点击应用程序并使用

For versions below iOS 8, do the following simple steps.

对于 iOS 8 以下的版本,请执行以下简单步骤。

Note: You'll want to make sure that your app is built for all architectures, the Simulator is x386in the Build Settings and Build Active Architecture Onlyset to No.

注意:您需要确保您的应用程序是为所有架构构建的,模拟器x386位于构建设置中并Build Active Architecture Only设置为No.

  1. Path: Library->Application Support->iPhone Simulator->7.1 (or another version if you need it)->Applications
  2. Create a new folder with the name of the app
  3. Go inside the folder and place the .app file here.
  1. 路径:Library->Application Support->iPhone Simulator->7.1(或其他版本,如果需要)->Applications
  2. 使用应用程序名称创建一个新文件夹
  3. 进入文件夹并将 .app 文件放在此处。

回答by David Seek

For Xcode 9.4.1 and latest Simulators:

对于 Xcode 9.4.1 和最新的模拟器:

Hope my answer is getting seen down here as this took me a while to figure out but I just got it working.

希望我的答案能在这里看到,因为这花了我一段时间才弄明白,但我才刚刚开始工作。

First of all you need to build and run the App on your simulator. Then you open the Activity Monitor. Double click the name of your App to find its content.

首先,您需要在模拟器上构建并运行该应用程序。然后打开活动监视器。双击您的应用程序名称以查找其内容。

enter image description here

在此处输入图片说明

In the next screen open the Open Files and Portstab and find the line with MyAppName.app/MyAppName.

在下一个屏幕中,打开Open Files and Ports选项卡并找到 MyAppName.app/MyAppName 行。

enter image description here

在此处输入图片说明

Copy the link but make sure to stop at the MyAppName.app. Do not copy the path following it.

复制链接,但确保在 MyAppName.app 处停止。不要复制它后面的路径。

Control click onto the finder icon and select Go to folder.

控制单击查找器图标并选择Go to folder

enter image description here]

在此处输入图片说明]

Paste the path and click enter. You will see your MyAppName.app file. Copy it to the Desktop and zip it. Move it to your desired 2nd computer and unzip the file. Build a random project to have a simulator open.

粘贴路径并点击进入。您将看到 MyAppName.app 文件。将其复制到桌面并压缩。将其移动到您想要的第二台计算机并解压缩文件。构建一个随机项目以打开模拟器。

Lastly: Literally drag and drop the App from your Desktop into your Simulator. You will see the install and the App opens and does notcrash.

最后:将应用程序从桌面拖放到模拟器中。你会看到安装和应用程序打开,也不会崩溃。

enter image description here

在此处输入图片说明

回答by rjmunro

You cannot run an ipa file in the simulator because the ipa file is compiled for a phone's ARM architecture, not the simulator's x86 architecture.

您不能在模拟器中运行 ipa 文件,因为 ipa 文件是针对手机的 ARM 架构而不是模拟器的 x86 架构编译的。

However, you can extract an app installed in a local simulator, send it to someone else, and have them copy it to the simulator on their machine.

但是,您可以提取安装在本地模拟器中的应用程序,将其发送给其他人,然后让他们将其复制到他们机器上的模拟器中。

In terminal, type:

在终端中,输入:

open ~/Library/Application\ Support/iPhone\ Simulator/*/Applications

This will open all the applications folders of all the simulators you have installed. Each of the applications will be in a folder with a random hexadecimal name. You can work out which is your application by looking inside each of them. Once you have found out which one you want, right click it and choose "Compress ..." and it will make a zip file that you can easily copy to another computer and unzip to a similar location.

这将打开您已安装的所有模拟器的所有应用程序文件夹。每个应用程序都将位于一个具有随机十六进制名称的文件夹中。您可以通过查看每个应用程序的内部来确定哪个是您的应用程序。一旦你找到你想要的,右键单击它并选择“压缩...”,它会生成一个 zip 文件,你可以轻松地将其复制到另一台计算机并解压缩到类似的位置。

回答by Kampai

UPDATE: For Xcode 8.0+ you need to follow below Steps:

更新:对于 Xcode 8.0+,您需要遵循以下步骤:

  1. Download application from iTunes
  2. Select downloaded app, right click show in finder
  3. Copy .ipafile to Desktop, rename it to .zipfile
  4. Extract that .zipfile and you will get directory with application name
  5. Check that directory you will find appfile in Payloadfolder, copy this appfile

  6. Go to ~/Library/Developer/CoreSimulator/Devices

  1. 从 iTunes 下载应用程序
  2. 选择下载的应用程序,右键单击在finder中显示
  3. .ipa文件复制到桌面,将其重命名为.zip文件
  4. 提取该.zip文件,您将获得带有应用程序名称的目录
  5. 检查您将appPayload文件夹中找到文件的目录,复制此app文件

  6. ~/Library/Developer/CoreSimulator/Devices

FYI: Libraryfolder is hidden by default in mac, you can see hidden file using below command.

仅供参考:Library文件夹在 mac 中默认是隐藏的,您可以使用以下命令查看隐藏文件。

defaults write com.apple.finder AppleShowAllFiles YES;
killall Finder /System/Library/CoreServices/Finder.app

Now here you'll see many directories with long hexadecimal names, these all are simulators.

现在在这里你会看到许多具有长十六进制名称的目录,这些都是模拟器。

To find your desired simulator, sort these directories using "Arranged By > Date Modified".

要找到所需的模拟器,请使用“排列方式 > 修改日期”对这些目录进行排序。

Select that simulator file and go to below location.

选择该模拟器文件并转到以下位置。

  1. <HEXADECIMAL-SIMULATOR-STRING>/data/Containers/Bundle/Application/
  2. Create new folder name with <download-app-name>and paste appfile in that folder
  3. Open Terminaland run below command to install this application

    xcrun simctl install booted <APP_FILE_PATH>
    
  1. <HEXADECIMAL-SIMULATOR-STRING>/data/Containers/Bundle/Application/
  2. 使用该文件夹创建新文件夹名称<download-app-name>并将app文件粘贴到该文件夹​​中
  3. 打开终端并运行以下命令来安装此应用程序

    xcrun simctl install booted <APP_FILE_PATH>
    

Example <APP_FILE_PATH>will be looks like below:

示例<APP_FILE_PATH>如下所示:

~/Library/Developer/CoreSimulator/Devices/<HEXADECIMAL-SIMULATOR-STRING>/data/Containers/Bundle/Application/<APP_NAME>

回答by russbishop

First of all, IPAs usually only have ARM slices because the App Store does not currently accept Simulator slices in uploads.

首先,IPA 通常只有 ARM 切片,因为 App Store 目前不接受上传模拟器切片。

Secondly, as of Xcode 8.3 you can drag & drop a .appbundle into the Simulator window and it will be installed. You can find the app in your build products directory ~/Library/Developer/Xcode/DerivedData/projectname-xyzzyabcdefg/Build/Products/Debug-iphonesimulatorif you want to save it or distribute it to other people.

其次,从 Xcode 8.3 开始,您可以将一个.app包拖放到 Simulator 窗口中,然后它就会被安装。~/Library/Developer/Xcode/DerivedData/projectname-xyzzyabcdefg/Build/Products/Debug-iphonesimulator如果您想保存或分发给其他人,您可以在构建产品目录中找到该应用程序。

To install from the command line use xcrun simctl install <device> <path>.

要从命令行安装,请使用xcrun simctl install <device> <path>.

devicecan be the device UUID, its name, or bootedwhich means the currently booted device.

device可以是设备 UUID、其名称或booted表示当前启动的设备。

回答by humblePilgrim

You can run the application file of project in simulator - not .ipa file.

您可以在模拟器中运行项目的应用程序文件 - 而不是 .ipa 文件。

You can get it from:

你可以从:

Libraries-->Applicationsupport-->iphone simulator-->4.3(its ur simulator version)-->applications-->then u can see many files like 0CD04F....find out your application file through open it.

Libraries-->Applicationsupport-->iphone simulator-->4.3(its ur simulator version)-->applications-->然后你可以看到很多文件,比如0CD04F....通过打开它找出你的应用程序文件。

You can copy the file to your system(which system simulator u need run ) location Libraries-->Applicationsupport-->iphone simulator-->4.3(its your simulator version)-->applications-->

您可以将文件复制到您的系统(您需要运行哪个系统模拟器)位置 Libraries-->Applicationsupport-->iphone simulator-->4.3(its your simulator version)-->applications-->

Then open the simulator 4.3 (its your simulator version where you pasted). You can see the application installed there.

然后打开模拟器 4.3(它是您粘贴的模拟器版本)。您可以在那里看到安装的应用程序。



Getting from other people:

从其他人那里获取:

Please tell them to find out Libraries-->Applicationsupport-->iphone simulator-->4.3(its ur simulator version)-->applications-->then you can see many files like 0CD04F....from their system and receive that file from them.

请告诉他们找出Libraries-->Applicationsupport-->iphone simulator-->4.3(its ur simulator version)-->applications-->然后您可以0CD04F....从他们的系统中看到许多文件并从他们那里接收该文件。

After they have got the file, please copy and paste the file in to your system `Libraries-->Applicationsupport-->iphone simulator-->4.3(its your simulator version)-->applications-->(paste the file here).

在他们得到文件后,请将文件复制并粘贴到您的系统中`Libraries-->Applicationsupport-->iphone模拟器-->4.3(您的模拟器版本)-->应用程序-->(将文件粘贴到这里)。

Then you can see the app is installed in your system simulator and you can run it after clicking the file.

然后您可以看到该应用程序已安装在您的系统模拟器中,您可以在单击该文件后运行它。

回答by Satheesh Guduri

Copy From Here:
- Run the application in the Xcode. - Select Finder go to Go and click on select Library Library/Application Support/iPhone Simulator/7.0.3-64/Applications - Select 32 bit folder Copy your application.

从这里复制:
- 在 Xcode 中运行应用程序。- 选择 Finder 转到 Go 并单击选择 Library Library/Application Support/iPhone Simulator/7.0.3-64/Applications - 选择 32 位文件夹复制您的应用程序。

Paste To Here:
- /Applications/Xcode-Beta.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhone Simulator. SDK/Applications
- Paste here and run the simulator.

粘贴到此处:
- /Applications/Xcode-Beta.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhone Simulator。SDK/应用程序
- 粘贴在这里并运行模拟器。

回答by rfrittelli

With Xcode 6:

使用 Xcode 6:

It's very possible to build and install on a simulator.

在模拟器上构建和安装是非常可能的。

I did it by copying the debug build configuration (I called it SimRelease for my example below) in the project settings. I changed the architectures to i386 and x86_64 (not sure how necessary this was), but key difference to change between the copied build configuration is build for active architecture set to NO. After that a couple simple command line tools will do the rest!

我通过在项目设置中复制调试构建配置(我在下面的示例中将其称为 SimRelease)来做到这一点。我将架构更改为 i386 和 x86_64(不确定这有多大必要),但在复制的构建配置之间更改的主要区别是将活动架构的构建设置为 NO。之后,几个简单的命令行工具将完成剩下的工作!

xcodebuild -scheme YOUR_SCHEME -configuration SimRelease -sdk iphonesimulator8.1

Depending on where you have your DerivedData set you need to go find the outputted .app folder. Once you've found it you can simply install it on any simulator device. To find the device UUID's open Xcode and go to Window->Devices you'll see the list of the device instances and you can grab the UUID's. For a trivial script you could grab all of them from: ~/Library/Developer/CoreSimulator/Devices/ and install on every device.

根据您设置 DerivedData 的位置,您需要找到输出的 .app 文件夹。找到它后,您可以简单地将其安装在任何模拟器设备上。要找到设备 UUID 的打开 Xcode 并转到 Window->Devices,您将看到设备实例列表,您可以获取 UUID。对于一个简单的脚本,您可以从以下位置获取所有脚本:~/Library/Developer/CoreSimulator/Devices/ 并安装在每个设备上。

From there the simple command to install on a device is:

从那里安装在设备上的简单命令是:

xcrun simctl install DEVICE_ID APP_FOLDER_LOCATION

xcrun simctl 安装 DEVICE_ID APP_FOLDER_LOCATION

Here's a simple shell script to take the app and install it on every device:

这是一个简单的 shell 脚本,用于获取应用程序并将其安装在每台设备上:

app_dir=
current_dir=$(pwd)
cd ~/Library/Developer/CoreSimulator/Devices/
devices=$(ls -d */)
cd "$current_dir"
for device in $devices
do
    device_id=${device%/}
    xcrun simctl install "$device_id" "$app_dir"
done

Hope this helps! Took me a while to figure out the best way to do it.

希望这可以帮助!我花了一段时间才找到最好的方法。