Uniapp runs on iOS real device or simulator

1. Run on a real machine (recommended)

  • Connect your phone to the computer and find : HBuilderXin the menu bar 运行:

    image.png

    After opening, both operating modes require certificates for cloud packaging installation. Please pay attention to the certificate details:

    image.png

    image.png

    Copy the above iPhone UDID. If it is not displayed UDID, you can see it through Dandelion , 爱思助手, and Xcodeso on.

    image.png

  • The copied device UDIDneeds to be added to the Apple Developer Center and Device Management . Note that the person logged in here is an Apple developer account. Otherwise, these configuration options will not be available. You can register as a developer on Baidu for money:

    image.png

    image.png

    Then there is the normal iOScertificate creation process, which needs to go through Bundle ID(例如:com.dzm.test):

    1. Create an identifier ( com.dzm.test).

    2. Add test equipment ( 刚才拷贝的 UDID). If it is a new device, you need to update or create profilesa configuration file to add the new device.

    3. Create a test certificate ( 发布就正式证书), download the certificate for later use, and the push certificate is also created here.

    4. Create profilesa file, check 测试证书and 测试设备, and then download this profilesconfiguration file for later use.

    image.png

    image.png

    5. uniappThe required p12certificate is the certificate created in the first 3step of creation .cer. .cerThe certificate only contains the public key. .p12The certificate may contain both the public key and the private key.

    .cerp12There are many ways to do this :

    方式一: Install macon the computer .cer, find the certificate in the keychain and export it, double-click to install the certificate into the keychain. If it shows that the certificate is not trusted, you can go to the Apple PKI website, download G3 或 G4the certificate and install it. If it still shows that it is not trusted, , you can delete the installed .cercertificate and reinstall it.

    image.png

    image.png

    Details: When exporting the keychain, you cannot select p12the certificate method to export because the entry method is incorrect:

    image.png

    image.png

    方式二.cer: You can convert to certificate format through the command line p12, download and install OpenSSL , and then use it to execute the command to convert:

    $ openssl pkcs12 -export -in certfile.cer -inkey privateKey.key -out certificate.p12
    

    Among them , represents the certificate file certfile.cerjust created and represents the private key file. is the certificate file to be generated. After executing the command, you will be prompted for a password to protect the certificate. Remember this password as you will need it to access and use the certificate in the future..cerprivateKey.keycertificate.p12P12P12P12

  • After you have all the certificates, open them HBuilderXand select here 方式一to conduct a real machine test:

    方式一: Through the run in the menu iOS App 基座, fill in the above certificate information, followed by the identifier, and the cloud package will be installed on the mobile phone.

    方式二: Customize the base through the release in the menu. The things you fill in are basically the same, there is no difference, and then you can iOS App 基座choose to automatically use the base when running.

    image.png

  • APPAfter the test is successfully installed on the phone, click to open and it will prompt that you need to be in 开发者模式before it can be used.

    image.png

    Find 设置 -》隐私与安全性 -》开发者模式 -》启用开发者模式and then restart the phone. After restarting, you will be prompted to enter a password to enable developer mode, and then you can open the installed one app.

    After the mobile phone is connected to the computer, you can always see the adjustment effect by modifying the code to support hot updates.

2. Run to the simulator

  • Download , Xcodeyou can download the latest version from the official website and other versions from the official website .App Store 下载

  • 方式一:Open Xcode, upper left corner Xcode -> Open Developer Tool -> Simulator, if you don’t have this option, follow 方式二the steps:

    image.png

    In the open simulator, you can switch to other models or versions at any time:

    image.png

  • 方式二:Open Xcodeand create a new empty project:

    image.png

    image.png

    image.png

    After entering the project, select the simulator you want to start, click Start, and then wait for the simulator to come out:

    image.png

    After the simulator comes out, you can stop the current project and close it, leaving the simulator window:

    image.png

  • After the simulator starts, you can open uniappthe project, turn on cpu x86support, and then run to iOS模拟器基座:

    image.png

    image.png

    image.png

Guess you like

Origin blog.csdn.net/zz00008888/article/details/135382915