-
-
Notifications
You must be signed in to change notification settings - Fork 6.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Issue #1571 - Improved objc Compatibility #1599
Conversation
Improved Objective C compatibility when using **objcCompatible** - Use **class** instead of **struct** - Add **@objc** and **NSObject** for classes in API and model classes
Thanks for the PR but your commit (as shown in the Commits tab) is not linked to your Github account, which means this PR won't count as your contribution in https://github.com/OpenAPITools/openapi-generator/graphs/contributors. Let me know if you need help fixing it. |
That is fine for me. However if you need me to fix it I will look into it. |
- Models: Expose non-optional variables to @objc. Otherwise e.g. Int64 is not visible in objc - Models: Try avoiding generated code that has boolVariable.map ({ return NSNumber(value: $0) }) as map does not exist for Bool in Swift (see Issue OpenAPITools#1456) - API: Avoid Void? arguments with @objc, as they are not available in objc
{{^returnType}} | ||
{{^returnType}}{{#objcCompatible}} | ||
completion(error) | ||
{{/objcCompatible}}{{^objcCompatible}} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Sal0g you may want to use the following instead to avoid trailing/leading spaces or empty lines:
{{^returnType}}
{{#objcCompatible}}
completion(error)
{{/objcCompatible}}
{{^objcCompatible}}
...
{{/objcCompatible}}
{{/returnType}}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, thanks! Considered this in latest commit.
Cosmetic changes to avoid trailing/leading spaces or empty lines.
I have updated the branch and added include part fixes to #1456 as they are connected. As far as I understand, I do not need create a new PR? |
@Sal0g Thanks for your PR! Are you still interested in merging this PR? The objc interoperability is currently broken, and your PR improves it. I have tested it and the generated code is better for objc interoperability, but the build on the sample project for objc interoperability fails with the changes. The two issues I found are related to methods marked with the @objc annotation that have parameters that are not eligible in objc like Int?, and models that contains properties with the same issue described before. To see the issue can you please merge master into your branch and run the following command on the terminal from the root directory of openapi-generator?
This command will build openapi-generator with your changes, generate the objc interoperability project sample and build it. |
Hi! Yes I definitiv want to merge this PR and I will do this in the following days as I am currently busy. |
When you have time 🙂 You may want to make this changes in the new Swift5 generator that just got merged. #4086 By the way, I look a into the objc compatibility problem and made some progress, but it's not yet there, so if this can somehow help you to finish this, here is the things I tried. https://github.com/4brunu/openapi-generator/tree/feature/swift5-objc-compatible |
Since #5410 was merged, I think this PR can now be closed. #5410 doesn't fix everything related to objc compatibility, but it makes some progress. The remaining issues are the variables that are:
|
Agreed with closing this for the time being. If anyone wants to reopen, please reply to let us know. |
PR checklist
./bin/
to update Petstore sample so that CIs can verify the change. (For instance, only need to run./bin/{LANG}-petstore.sh
and./bin/security/{LANG}-petstore.sh
if updating the {LANG} (e.g. php, ruby, python, etc) code generator or {LANG} client's mustache templates). Windows batch files can be found in.\bin\windows\
.master
,3.4.x
,4.0.x
. Default:master
.@jgavris (2017/07) @ehyche (2017/08) @Edubits (2017/09) @jaz-ah (2017/09) @d-date (2018/03)
Description of the PR
PR to improve the Objc compatibility, see Issue #1571