Closed cs2be closed 10 months ago
You want to put :coreDataModel
in the srcs
attribute instead, it doesn't produce a library it only generates source files
Thank you Keith, that worked and the core data swift files are now part of the project.
apple_core_data_model(
name = "coreDataModel",
srcs = ["//Resources:CoreDataModel.xcdatamodeld"]
)
swift_library(
name = "lib",
srcs = glob(["Sources/**/*.swift"]) + [":coreDataModel"],
data = ["//Resources:CoreDataModel.xcdatamodeld"]
)
ios_application(
name = "ChatGPTDemoApp",
bundle_id = "com.midoriapple.ChatGPTDemoApp",
families = [
"iphone",
"ipad",
],
infoplists = ["Info.plist"],
launch_storyboard = "//Resources:Launch.storyboard",
minimum_os_version = "15.0",
visibility = ["//visibility:public"],
deps = [":lib"],
)
However, it seems there were some compile problems for those generated core data swift classes, wonder if you've seen this issue before? Thanks for your help!
cs2be$ bazel build //:ChatGPTDemoApp
INFO: Analyzed target //:ChatGPTDemoApp (1 packages loaded, 15 targets configured).
ERROR: /Users/cs2be/programming/chatgpt_demo/ChatGPTDemoiOS/BUILD:24:14: Compiling Swift module //:lib failed: (Exit 1): worker failed: error executing SwiftCompile command (from target //:lib) bazel-out/darwin_arm64-opt-exec-ST-13d3ddad9198/bin/external/rules_swift~1.13.0/tools/worker/worker swiftc ... (remaining 1 argument skipped)
remark: Incremental compilation has been disabled: ChatThread+CoreDataClass.swift has no swiftDeps file
remark: Incremental compilation has been disabled: ChatThread+CoreDataClass.swift has no swiftDeps file
remark: Incremental compilation has been disabled: malformed dependencies file 'none?!'
remark: Incremental compilation has been disabled: ChatThread+CoreDataProperties.swift has no swiftDeps file
remark: Incremental compilation has been disabled: ChatThread+CoreDataProperties.swift has no swiftDeps file
remark: Incremental compilation has been disabled: malformed dependencies file 'none?!'
remark: Incremental compilation has been disabled: CoreDataModel+CoreDataModel.swift has no swiftDeps file
remark: Incremental compilation has been disabled: CoreDataModel+CoreDataModel.swift has no swiftDeps file
remark: Incremental compilation has been disabled: malformed dependencies file 'none?!'
swift_worker: Could not copy bazel-out/ios_sim_arm64-fastbuild-ios-sim_arm64-min15.0-applebin_ios-ST-52085178dc52/bin/_swift_incremental/lib_objs/coredatamodel.coreDataModel.coredata.sources.o to bazel-out/ios_sim_arm64-fastbuild-ios-sim_arm64-min15.0-applebin_ios-ST-52085178dc52/bin/lib_objs/coredatamodel.coreDataModel.coredata.sources.o (No such file or directory)
Target //:ChatGPTDemoApp failed to build
Use --verbose_failures to see the command lines of failed build steps.
INFO: Elapsed time: 1.061s, Critical Path: 0.94s
INFO: 2 processes: 2 internal.
ERROR: Build did NOT complete successfully
Interesting, I haven't seen this one, if you pass --swiftcopt=-wmo
does it fix it?
Unfortunately no :(. I'll dig into this a little further, thanks for helping
cs2be$ bazel build //:ChatGPTDemoApp --swiftcopt=-wmo --verbose_failures
INFO: Analyzed target //:ChatGPTDemoApp (0 packages loaded, 0 targets configured).
ERROR: /Users/cs2be/programming/chatgpt_demo/ChatGPTDemoiOS/BUILD:24:14: output 'lib_objs/coredatamodel.coreDataModel.coredata.sources.o' was not created
ERROR: /Users/cs2be/programming/chatgpt_demo/ChatGPTDemoiOS/BUILD:24:14: Compiling Swift module //:lib failed: not all outputs were created or valid
Target //:ChatGPTDemoApp failed to build
INFO: Elapsed time: 0.605s, Critical Path: 0.50s
INFO: 2 processes: 1 internal, 1 worker.
ERROR: Build did NOT complete successfully
it seems like this must be a bug in the rules, if you provide a repro case someone might be able to debug further
That would be awesome. Here's how to reproduce:
git clone git@github.com:cs2be/chatgpt_demo.git
cd chatgpt_demo/ChatGPTDemoiOS
bazel build //:ChatGPTDemoApp --verbose_failures --subcommands --verbose_explanations
This should produce the error, thanks again!
Thanks for the repro, that is very helpful! Turns out the problem is the same as this: https://github.com/bazelbuild/rules_swift/issues/969
A quick hack workaround is to pass --swiftcopt=-wmo --swiftcopt=-num-threads --swiftcopt=0
but this might have other downsides
Thanks Keith, I can confirm it works with those flags.
# Builds and runs on simulator
bazel run //:ChatGPTDemoApp --swiftcopt=-wmo --swiftcopt=-num-threads --swiftcopt=0
However strange thing is the xcode project still doesn't compile :(. Possibly I need to pass another set of flags to this build? Should I close this issue as a duplicate? Thanks!
bazel run //:xcodeproj --swiftcopt=-wmo --swiftcopt=-num-threads --swiftcopt=0
Yea I think you'd have to pipe those flags to rules_xcodeproj too, you probably should just add them to your .bazelrc
.
Hi @keith , I am facing the same issue when I use the latest version of rule_apple
and rule_swift
.
The workaround --swiftcopt=-wmo --swiftcopt=-num-threads --swiftcopt=0
doesn't work anymore.
I forked @cs2be 's repo and created a new branch new
to reproduce this issue.
Could you please help to take a look? Thanks
git@github.com:xuzhaocheng/chatgpt_demo.git
cd chatgpt_demo
git checkout new
cd ChatGPTDemoiOS
bazel build //:ChatGPTDemoApp --swiftcopt=-wmo --swiftcopt=-num-threads --swiftcopt=0
The latest rule versions where it worked was:
swift: 1.18.0 apple: 3.16.0
Do we have any plan to fix this issue on swift 2.x?
@xuzhaocheng maybe you could create a new issue since this one is closed
Hi, I'm trying to add core data build dependencies to my swift project, however I got an error when trying to run the build rule:
Running "bazel build //:lib", I get the following errors:
I suspect the build rule apple_core_data_model is missing SwiftInfo dictionary. The swift_library code that pulls SwiftInfo from deps is here.
I'm using these versions of rules_apple and rules_swift:
Thanks!