ios 如何将 iPhone 应用程序从 Xcode 部署到真正的 iPhone 设备?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/246422/
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
How can I deploy an iPhone application from Xcode to a real iPhone device?
提问by DFG
How can I deploy an iPhone application from Xcode to real iPhone device without having a US$99 Apple certificate?
如何在没有 99 美元 Apple 证书的情况下将 iPhone 应用程序从 Xcode 部署到真正的 iPhone 设备?
采纳答案by rpetrich
It sounds like the application isn't signed. Download ldid from Cydia and then use it like so: ldid -S /Applications/AccelerometerGraph.app/AccelerometerGraph
听起来应用程序没有签名。从 Cydia 下载 ldid 然后像这样使用它:ldid -S /Applications/AccelerometerGraph.app/AccelerometerGraph
Also be sure that the binary is marked as executable: chmod +x /Applications/AccelerometerGraph.app/AccelerometerGraph
还要确保二进制文件被标记为可执行文件: chmod +x /Applications/AccelerometerGraph.app/AccelerometerGraph
回答by cregox
I've used a mix of two howtos: Jason'sand alex's. With the second we have the advantage of being able to debug. I'll mostly just copy both below (and simplify alex's):
我混合使用了两种方法:Jason和alex 的. 使用第二个,我们具有能够调试的优势。我将主要复制下面的两个(并简化亚历克斯的):
Update Jan 2012:this still works on SDK 4.2.1 and iOS 5.0.1 - I've just tested it all on a new computer and device!
2012 年 1 月更新:这仍然适用于 SDK 4.2.1 和 iOS 5.0.1 - 我刚刚在一台新计算机和设备上测试了它!
1. Create Self-Signed Certificate
1. 创建自签名证书
Patch your iPhone SDK to allow the use of this certificate:
修补您的 iPhone SDK 以允许使用此证书:
Launch Keychain Access.app. With no items selected, from the Keychain menu select Certificate Assistant, then Create a Certificate.
- Name:iPhone Developer
- Certificate Type:Code Signing
- Let me override defaults:Yes
Click Continue
- Validity:3650 days
Click Continue
Blank outthe Emailaddress field.
Click Continue until complete.
You should see "This root certificate is not trusted". This is expected.
Set the iPhone SDK to allow the self-signed certificate to be used:
sudo /usr/bin/sed -i .bak 's/XCiPhoneOSCodeSignContext/XCCodeSignContext/' /Developer/Platforms/iPhoneOS.platform/Info.plist
If you have Xcode open, restart it for this change to take effect.
启动 Keychain Access.app。没有选择任何项目,从钥匙串菜单中选择证书助手,然后创建证书。
- 名称:iPhone 开发者
- 证书类型:代码签名
- 让我覆盖默认值:是
点击继续
- 有效期:3650天
点击继续
将电子邮件地址字段清空。
单击继续直到完成。
您应该看到“此根证书不受信任”。这是预期的。
设置 iPhone SDK 以允许使用自签名证书:
sudo /usr/bin/sed -i .bak 's/XCiPhoneOSCodeSignContext/XCCodeSignContext/' /Developer/Platforms/iPhoneOS.platform/Info.plist
如果您打开了 Xcode,请重新启动它以使此更改生效。
And if you're on iOS 5, that's it! Try it now! It may not allow debugging, but the app will be there!
如果您使用的是 iOS 5,就是这样!现在就试试!它可能不允许调试,但应用程序将在那里!
I was very surprised by this because, as you should know, I've got no idea on what all those hackings are all about! All I did was improving a little bit what I found elsewhere, as I pointed.
我对此感到非常惊讶,因为你应该知道,我不知道所有这些黑客攻击是关于什么的!正如我指出的那样,我所做的只是改进了我在其他地方发现的东西。
So yeah, the whole methoddoesn't work the same way anymore and I couldn't bother to find a new one... Except for this, which uses a tool called Theosbut I couldn't go through the whole process.
所以是的,整个方法不再以同样的方式工作,我无法费心寻找新的方法......除此之外,它使用了一个名为 Theos 的工具,但我无法完成整个过程。
Finally, if you need to uninstall itfor whatever reason, check the end of this post. In my case, I had to because I couldn't figure out why all of the blue this whole method stopped working, and I couldn't care anymore since we've already got the long waited license. (Freaking DUNS number takes so long...)
最后,如果您出于任何原因需要卸载它,请查看本文末尾。就我而言,我不得不这样做,因为我无法弄清楚为什么整个方法的所有蓝色都停止工作,而且我不再关心,因为我们已经获得了等待已久的许可证。(该死的 DUNS 号码需要这么长时间......)
.
.
.
.
.
.
.
.
.
.
2. Enable Xcode's to Build on Jailbroken Device
2. 启用 Xcode 在越狱设备上构建
On your jailbroken iPhone, install the app AppSyncby adding source ** http://repo.hackyouriphone.org**
Remove SDK requirements for code sign and entitlements (I'm loving sed!):
sudo /usr/bin/sed -i .bak '/_REQUIRED/N;s/YES/NO/' /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.0.sdk/SDKSettings.plist
Pay attentionto the
iPhoneOS5.0.sdk
part. If you're, for instance, using iOS 4.2 SDK, just replace it accordingly:sudo /usr/bin/sed -i .bak '/_REQUIRED/N;s/YES/NO/' /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.2.sdk/SDKSettings.plist
Conclude the requirement removal through patching Xcode. This means binary editing:
cd /Developer/Platforms/iPhoneOS.platform/Developer/Library/Xcode/Plug-ins/iPhoneOS\ Build\ System\ Support.xcplugin/Contents/MacOS/ dd if=iPhoneOS\ Build\ System\ Support of=working bs=500 count=255 printf "\xc3\x26\x00\x00" >> working /bin/mv -n iPhoneOS\ Build\ System\ Support iPhoneOS\ Build\ System\ Support.original /bin/mv working iPhoneOS\ Build\ System\ Support chmod a+x iPhoneOS\ Build\ System\ Support
If you have Xcode open, restart it for this change (and last one) to take effect.
Open "Project>Edit Project Settings"(from the menu). Click on the "Build"tab. Find "Code Signing Identity"and its child "Any iPhoneOS Device"in the list, and set both to the entry "Don't Code Sign":
After this feel free to undo step 3. At least in my case it went just fine.
Setting Xcode to code sign with our custom made self-signed certificate(the first how-to). This step can probably be skipped if you don't want to be able to debug:
mkdir /Developer/iphoneentitlements401 cd /Developer/iphoneentitlements401 curl -O http://www.alexwhittemore.com/iphone/gen_entitlements.txt mv gen_entitlements.txt gen_entitlements.py chmod 777 gen_entitlements.py
Plug your iPhone in and open Xcode. Open Window>Organizer. Select the device from the list on the left hand side, and click "Use for development." You'll be prompted for a provisioning website login, click cancel. It's there to make legitimate provisioning easier, but doesn't make illegitimate not-provisioning more difficult.
Now You have to do this last part for every new project you make. Go to the menu Project > New Build Phase > New Run Script Build Phase. In the window, copy/paste this:
export CODESIGN_ALLOCATE=/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/codesign_allocate if [ "${PLATFORM_NAME}" == "iphoneos" ]; then /Developer/iphoneentitlements401/gen_entitlements.py "my.company.${PROJECT_NAME}" "${BUILT_PRODUCTS_DIR}/${WRAPPER_NAME}/${PROJECT_NAME}.xcent"; codesign -f -s "iPhone Developer" --entitlements "${BUILT_PRODUCTS_DIR}/${WRAPPER_NAME}/${PROJECT_NAME}.xcent" "${BUILT_PRODUCTS_DIR}/${WRAPPER_NAME}/" fi
在越狱的 iPhone 上,通过添加源 ** http://repo.hackyouriphone.org** 来安装AppSync应用程序
删除代码签名和权利的 SDK 要求(我喜欢sed!):
sudo /usr/bin/sed -i .bak '/_REQUIRED/N;s/YES/NO/' /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.0.sdk/SDKSettings.plist
要注意的
iPhoneOS5.0.sdk
部分。例如,如果您使用的是 iOS 4.2 SDK,只需相应地替换它:sudo /usr/bin/sed -i .bak '/_REQUIRED/N;s/YES/NO/' /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.2.sdk/SDKSettings.plist
通过修补 Xcode 结束需求删除。这意味着二进制编辑:
cd /Developer/Platforms/iPhoneOS.platform/Developer/Library/Xcode/Plug-ins/iPhoneOS\ Build\ System\ Support.xcplugin/Contents/MacOS/ dd if=iPhoneOS\ Build\ System\ Support of=working bs=500 count=255 printf "\xc3\x26\x00\x00" >> working /bin/mv -n iPhoneOS\ Build\ System\ Support iPhoneOS\ Build\ System\ Support.original /bin/mv working iPhoneOS\ Build\ System\ Support chmod a+x iPhoneOS\ Build\ System\ Support
如果您打开了 Xcode,请重新启动它以使此更改(和最后一个)生效。
打开“项目>编辑项目设置”(从菜单)。单击“构建”选项卡。在列表中找到“Code Signing Identity”及其子“Any iPhoneOS Device”,并将两者都设置为“Don't Code Sign”条目:
在这之后可以随意撤消第 3 步。至少在我的情况下它进行得很好。
将 Xcode 设置为使用我们定制的自签名证书进行代码签名(第一个操作方法)。如果您不想调试,可以跳过此步骤:
mkdir /Developer/iphoneentitlements401 cd /Developer/iphoneentitlements401 curl -O http://www.alexwhittemore.com/iphone/gen_entitlements.txt mv gen_entitlements.txt gen_entitlements.py chmod 777 gen_entitlements.py
插入你的 iPhone 并打开 Xcode。打开窗口>组织者。从左侧列表中选择设备,然后单击“用于开发”。系统将提示您进行配置网站登录,单击取消。它的存在是为了使合法供应变得更容易,但不会使非法的不供应变得更加困难。
现在你必须为你制作的每个新项目做最后一部分。转到菜单 Project > New Build Phase > New Run Script Build Phase。在窗口中,复制/粘贴:
export CODESIGN_ALLOCATE=/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/codesign_allocate if [ "${PLATFORM_NAME}" == "iphoneos" ]; then /Developer/iphoneentitlements401/gen_entitlements.py "my.company.${PROJECT_NAME}" "${BUILT_PRODUCTS_DIR}/${WRAPPER_NAME}/${PROJECT_NAME}.xcent"; codesign -f -s "iPhone Developer" --entitlements "${BUILT_PRODUCTS_DIR}/${WRAPPER_NAME}/${PROJECT_NAME}.xcent" "${BUILT_PRODUCTS_DIR}/${WRAPPER_NAME}/" fi
.
.
.
.
.
.
.
.
Uninstalling
卸载
For the 1st part:
对于第一部分:
sudo mv -f /Developer/Platforms/iPhoneOS.platform/Info.plist.bak /Developer/Platforms/iPhoneOS.platform/Info.plist
For the 2nd part:
对于第二部分:
sudo mv -f /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.0.sdk/SDKSettings.plist.bak /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.0.sdk/SDKSettings.plist
sudo mv -f iPhoneOS\ Build\ System\ Support.original iPhoneOS\ Build\ System\ Support
in case you did do the step 3 instead of 2, simply modify it accordingly as well:
如果您确实执行了第 3 步而不是第 2 步,也只需对其进行相应修改:
sudo mv -f /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.2.sdk/SDKSettings.plist.bak /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.2.sdk/SDKSettings.plist
for the rest, is just reverting what you did on XCode and deleting /Developer/iphoneentitlements401/gen_entitlements.py
if you want:
其余的,只是恢复您在 XCode 上所做的操作,并/Developer/iphoneentitlements401/gen_entitlements.py
根据需要删除:
sudo rm -f /Developer/iphoneentitlements401/gen_entitlements.py
回答by Suragch
Free Provisioning after Xcode 7
Xcode 7 之后的免费配置
In order to test your app on a real device rather than pay the Apple Developer fee (or jailbreak your device), you can use the new free provisioning that Xcode 7 and iOS 9 supports.
为了在真实设备上测试您的应用程序而不是支付 Apple 开发人员费用(或越狱您的设备),您可以使用 Xcode 7 和 iOS 9 支持的新免费配置。
Here are the steps taken more or less from the documentation(which is pretty good, so give it a read):
以下是或多或少从文档中采取的步骤(非常好,所以请阅读):
1. Add your Apple ID in Xcode
1. 在 Xcode 中添加您的 Apple ID
Go to XCode > Preferences > Accounts tab > Add button (+) > Add Apple ID. See the docsfor more help.
转到 XCode > 首选项 > 帐户选项卡 > 添加按钮 (+) > 添加 Apple ID。请参阅文档以获取更多帮助。
2. Click the General tab in the Project Navigator
2. 单击 Project Navigator 中的 General 选项卡
3. Choose your Apple ID from the Team popup menu.
3. 从 Team 弹出菜单中选择您的 Apple ID。
4. Connect your device and choose it in the scheme menu.
4. 连接您的设备并在方案菜单中选择它。
5. Click the Fix Issues button
5. 单击修复问题按钮
If you get an error about the bundle name being invalid, change it to something unique.
如果您收到有关包名称无效的错误,请将其更改为唯一的名称。
6. Run your app
6. 运行你的应用
In Xcode, click the Build and run button.
在 Xcode 中,单击 Build and run 按钮。
7. Trust the app developer in the device settings
7. 在设备设置中信任应用开发者
After running your app, you will get a security error because the app you want to run is not from the App Store.
运行您的应用程序后,您将收到安全错误,因为您要运行的应用程序不是来自 App Store。
On your device, go to Settings > General > Profile > your-Apple-ID-name> Trust your-Apple-ID-name> Trust.
在您的设备上,前往“设置”>“通用”>“个人资料”>“您的 Apple-ID 名称”>“信任您的 Apple-ID 名称”>“信任”。
8. Run your app on your device again.
8. 再次在您的设备上运行您的应用程序。
That's it. You can now run your own (or any other apps that you have the source code for) without having to dish out the $99 dollars. Thank you, Apple, for finally allowing this.
就是这样。您现在可以运行自己的(或您拥有源代码的任何其他应用程序),而无需花费 99 美元。谢谢你,苹果,最终允许这样做。
回答by micmcg
You can't, not if you are talking about applications built with the official SDK and deploying straight from xcode.
如果您谈论的是使用官方 SDK 构建并直接从 xcode 部署的应用程序,则不能。
回答by Can Berk Güder
You'll have to jailbreak your device.
你必须越狱你的设备。
回答by Leo
There is a way to deploy iPhone apps without paying to apple You'll have to jailbreak your device and follow the instructions in http://www.alexwhittemore.com/?p=398
有一种无需向苹果付费即可部署 iPhone 应用程序的方法 您必须越狱您的设备并按照http://www.alexwhittemore.com/?p=398 中的说明进行操作
回答by Matthew Phillips
Nothing I've seen anywhere indicates you can ad-hoc deploy to a real iPhone without a (paid for) certificate.
我在任何地方都没有看到任何迹象表明您可以在没有(付费)证书的情况下临时部署到真正的 iPhone。
回答by Akshay
I was going through the Apple Developer last night and there in the Provisioning Certificate I found something like - "Signing Team Members". I think there is a way to add team members to the paid profile. You can just ask to the App Id Owner(paid one) to add you as a team member. I am not sure. Still searching on that.
昨晚我正在浏览 Apple Developer,在供应证书中我发现了类似“签署团队成员”的内容。我认为有一种方法可以将团队成员添加到付费配置文件中。您可以要求 App Id 所有者(已付费)将您添加为团队成员。我不确定。还在找那个。
回答by Akshay
No, its easy to do this. In Xcode, set the Active Configuration to Release. Change the device from Simulator to Device - whatever SDK. If you want to directly export to your iPhone, connect it to your computer. Press Build and Go. If your iPhone is not connected to your computer, a message will come up saying that your iPhone is not connected.
不,这很容易做到。在 Xcode 中,将 Active Configuration 设置为 Release。将设备从模拟器更改为设备 - 无论 SDK。如果您想直接导出到您的 iPhone,请将其连接到您的计算机。按 Build and Go。如果您的 iPhone 未连接到计算机,则会出现一条消息,说明您的 iPhone 未连接。
If this applies to you: (iPhone was not connected)
如果这适用于您:(iPhone 未连接)
Go to your projects folder and then to the build folder inside. Go to the Release-iphoneos folder and take the app inside, drag and drop on iTunes icon. When you sync your iTouch device, it will copy it to your device. It will also show up in iTunes as a application for the iPhone.
转到您的项目文件夹,然后转到里面的 build 文件夹。转到 Release-iphoneos 文件夹并将应用程序放入其中,拖放到 iTunes 图标上。当您同步 iTouch 设备时,它会将其复制到您的设备。它也将作为 iPhone 的应用程序出现在 iTunes 中。
Hope this helps!
希望这可以帮助!
P.S.: If it says something about a certificate not being valid, just click on the project in Xcode, the little project icon in the file stack to the left, and press Apple+I, or do Get Info from the menu bar. Click on Build at the top. Under Code Signing, change Code Signing Identity - Any iPhone OS Device to be Don't Sign.
PS:如果它说证书无效,只需单击Xcode中的项目,文件堆栈中左侧的小项目图标,然后按Apple + I,或从菜单栏中执行获取信息。单击顶部的构建。在代码签名下,将代码签名身份 - 任何 iPhone 操作系统设备更改为不签名。
回答by Magnatek
This really all depends on what version of Xcode you are using as different versions use different methods to deploy to your iPhone without a provisioning profile.
这实际上完全取决于您使用的 Xcode 版本,因为不同的版本使用不同的方法部署到您的 iPhone,而无需配置文件。
Xcode 3.2.1 is a good version and is easy to sort out, but we need to know what version you are using.
Xcode 3.2.1是一个很好的版本,很容易整理,但是我们需要知道你使用的是什么版本。