老项目模拟器运行提示Executable Path is a Directory

Executable Path is a Directory

/Users/flymac/Library/Developer/Xcode/DerivedData/project-fidnwpgktjppikakteauackxjniw/Build/Products/Debug-iphonesimulator/project.app is not a valid path to an executable file.

原因:

Xcode12淘汰了VALID_ARCHS,但是有些集成进来的第三方库还是有这个key,Xcode12模拟器已经用arm架构来编译项目,而link链接的还是x86架构

解决方法:

到Build Settings 中找到VALID_ARCHS,添加x86_64

这个问题解决后,可能还会出现第三方库未找到框架x86_64的问题

not found for architecture x86_64

复制代码
Undefined symbols for architecture x86_64:
  "_OBJC_CLASS_$_AFHTTPSessionManager", referenced from:
       in ANHttpTool.o
  "_OBJC_CLASS_$_AFNetworkReachabilityManager", referenced from:
       in ANHttpTool.o
  "_OBJC_CLASS_$_AFSecurityPolicy", referenced from:
       in ANHttpTool.o
  "_OBJC_CLASS_$_DWKWebView", referenced from:
       in YJPracticeWebViewController.o
  "_OBJC_CLASS_$_IQKeyboardManager", referenced from:
       in AppDelegate.o
  "_OBJC_CLASS_$_MJRefreshAutoNormalFooter", referenced from:
       in YJCommentsListController.o
  "_OBJC_CLASS_$_MJRefreshNormalHeader", referenced from:
       in YJCommentsListController.o
  "_OBJC_CLASS_$_RACCommand", referenced from:
       in YJCommentViewModel.o
  "_OBJC_CLASS_$_RACSignal", referenced from:
       in YJCommentViewModel.o
  "_OBJC_CLASS_$_SDImageCache", referenced from:
       in ANCacheManager.o
  "_OBJC_CLASS_$_SDWebImageDownloader", referenced from:
       in YJCommentViewController.o
  "_OBJC_CLASS_$_SVProgressHUD", referenced from:
       in NetWorkTools.o
  "_OBJC_CLASS_$_TKAlertCenter", referenced from:
       in UIView+ANHUD.o
  "_YYScreenSize", referenced from:
      -[YJWKWebViewController webView] in YJWKWebViewController.o
      -[YJWKWebViewController webView] in YJWKWebViewController.o
      ___54-[YJPracticeDetailController setDataWithIndex:isLast:]_block_invoke_2 in YJPracticeDetailController.o
      -[YJPracticeDetailController scrollView] in YJPracticeDetailController.o
      -[YJPracticeDetailController becomeVipView] in YJPracticeDetailController.o
      -[YJSingCourseListController setUpView] in YJSingCourseListController.o
      -[YJPracticeWebViewController webView] in YJPracticeWebViewController.o
      -[YJPracticeWebViewController webView] in YJPracticeWebViewController.o
      ...
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

解决方法:

在Podfie中添加以下代码

复制代码
post_install do |installer|
  installer.generated_projects.each do |project|
    project.targets.each do |target|
      target.build_configurations.each do |config|
            config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '12.0'
            config.build_settings["EXCLUDED_ARCHS[sdk=iphonesimulator*]"] = "arm64"
       end
    end
  end
end