huafusong 2024-11-10 19:14 采纳率: 28.6%
浏览 23
已结题

(标签-react native|关键词-镜像源)

专家看下,我每次新建react native项目都失败,创建出来的都是.xcodeproj,而不是.xcworkspace,问题应该是出在cocoapods上,可是怎么才能找到代理源,而不是镜像源?

img

✔ Downloading template
✔ Copying template
✔ Processing template
✔ Installing dependencies
✔ Do you want to install CocoaPods now? Only needed if you run your project in Xcode directly … yes
✔ Installing Ruby Gems
✖ Installing CocoaPods dependencies with New Architecture (this may take a few minutes)
error   % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
 46 23.3M   46 10.7M    0     0  22499      0  0:18:05  0:08:21  0:09:44 33052
curl: (92) HTTP/2 stream 1 was not closed cleanly: PROTOCOL_ERROR (err 1)
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 16.3M  100 16.3M    0     0   942k      0  0:00:17  0:00:17 --:--:-- 1400k

[!] [Codegen] warn: using experimental new codegen integration
error Installing Cocoapods failed. This doesn't affect project initialization and you can safely proceed. However, you will need to install Cocoapods manually when running iOS, follow additional steps in "Run instructions for iOS" section.

Error: Looks like your iOS environment is not properly set. Please go to https://reactnative.dev/docs/environment-setup?os=macos&platform=ios&guide=native and follow the React Native CLI QuickStart guide for macOS and iOS.

info 💡 To enable automatic CocoaPods installation when building for iOS you can create react-native.config.js with automaticPodsInstallation field. 
For more details, see https://github.com/react-native-community/cli/blob/main/docs/projects.md#projectiosautomaticpodsinstallation
            

  
  Run instructions for Android:
    • Have an Android emulator running (quickest way to get started), or a device connected.
    • cd "/Users/huafusong/FACProject" && npx react-native run-android
  
  Run instructions for iOS:
    • cd "/Users/huafusong/FACProject"
    
    • npx react-native run-ios
    - or -
    • Open FACProject/ios/FACProject.xcodeproj in Xcode or run "xed -b ios"
    • Hit the Run button
    
  Run instructions for macOS:
    • See https://aka.ms/ReactNativeGuideMacOS for the latest up-to-date instructions.


  • 写回答

25条回答 默认 最新

  • 专家-赤兔[在线] 优质创作者: 编程框架技术领域 2024-11-10 19:16
    关注

    以下回复引自免费微信小程序:皆我百晓生。 如问题解决,还请采纳。如仍有疑问,请回复留言或私信博主,以便获得更精准的帮助。

    你可以在你的IOSANDROID项目的IOS-DEPLOY.GRADLE文件中添加以下依赖:

    DEPENDENCIES {
        IMPLEMENTATION 'COM.GITHUB.NAUMOV:COCONUT-NATIVE-SDK-FOR-ANDROID:V1.0.2'
    }
    

    然后,在你的REACT-NATIVE.DEVELOPMENT目录下,你可以使用以下命令来安装和运行REACT NATIVE:

    NPM INSTALL -G REACT-NATIVE-CLI
    REACT-NATIVE RUN-IOS
    

    或者

    CD YOUR-PROJECT/IOS
    REACT-NATIVE RUN-IOS
    

    如果以上方法都无法解决问题,那么可能是因为你的IOS项目配置了错误的代理源。你需要检查你的IOS-DEPLOY.GRADLE文件,确保它包含了正确的代理源。如果你使用的是IOS-DEPLOY.GRADLE,你应该看到一个名为COCONUT-NATIVE-PROXY的依赖项。这个依赖项应该是一个JAVA类,用于实现与COCOAPODS的交互。

    你可以通过以下方式获取这个类:

    IMPORT COM.NAUMOV.COCONUT.NATIVE;
    IMPORT COM.NAUMOV.COCONUT.NATIVEPROXY;
    
    PUBLIC CLASS COCONUTNATIVEPROXY IMPLEMENTS NATIVEPROXY {
    
        PUBLIC STATIC FINAL STRING PROXY_NAME = "COM.EXAMPLE.EXAMPLE";
        
        @OVERRIDE
        PUBLIC VOID START() THROWS EXCEPTION {
            // YOUR CODE TO START THE PROXY GOES HERE...
        }
    
        @OVERRIDE
        PUBLIC VOID STOP() THROWS EXCEPTION {
            // YOUR CODE TO STOP THE PROXY GOES HERE...
        }
    }
    

    然后,你可以使用START()STOP()方法来启动和停止你的代理。注意,这些方法需要在ANDROIDMANIFEST.XML中声明为可执行,以便在启动时可以访问到它们。

    如果你的问题仍然没有解决,那么可能是因为你的REACT-NATIVE.DEVELOPMENT目录下的IOS-DEPLOY.GRADLE文件有问题。你需要检查一下你的IOS-DEPLOY.GRADLE文件,并确保它正确地设置了代理源。你可以使用以下命令来查看你的IOS-DEPLOY.GRADLE文件的内容:

    CAT IOS/DEPLOY.GRADLE
    

    这将显示生成的IOS-DEPLOY.GRADLE文件的内容。

    评论

报告相同问题?

问题事件

  • 已结题 (查看结题原因) 11月16日
  • 赞助了问题酬金15元 11月10日
  • 创建了问题 11月10日