Commit graph

59 commits

Author SHA1 Message Date
Thomas Van Lenten
aefe47c6c4 [ObjC] Add a test for unknown runtime markers.
PiperOrigin-RevId: 740876067
2025-03-26 13:10:14 -07:00
Thomas Van Lenten
6b7233bd4e [ObjC] Add a new compile test for the new generated code format.
PiperOrigin-RevId: 740829890
2025-03-26 11:00:08 -07:00
Thomas Van Lenten
892ba26862 [ObjC] Add a new test for generated file support
This is the new current version, so capture a test that
ensure it works so this are already set up for the next time
the generate format has to evolve.

PiperOrigin-RevId: 729193386
2025-02-20 11:55:03 -08:00
Thomas Van Lenten
bf068d9e0e [ObjC] Make a test for the 30007 format
Pull in some 30007 generated sources to help ensure the format
doesn't break when moving to a new generated format.

PiperOrigin-RevId: 715082290
2025-01-13 13:17:28 -08:00
Thomas Van Lenten
cffa590260 [ObjC] Breaking Change: Remove support for older generated code.
Remove runtime methods that support the Objective-C gencode from before the 3.22.x release.

PiperOrigin-RevId: 684462445
2024-10-10 09:52:43 -07:00
Thomas Van Lenten
2b93422f7e [ObjC] Breaking Change: Remove GPBUnknownFieldSet.
GPBUnknownFieldSet and the related apis have been replaced by
GPBUnknownFields. The new api allows the Objective-C Protobuf
implementation to be fully conformant around requirements for
parsing/re-serialization of unknown fields.

PiperOrigin-RevId: 684140581
2024-10-09 16:14:56 -07:00
Thomas Van Lenten
6e5a867f3d [ObjC] Start of the internal api for GPBUnknownFields
Add in the support for pushing the data back onto a `GPBMessage`.

PiperOrigin-RevId: 649125923
2024-07-03 10:44:09 -07:00
Thomas Van Lenten
6750ed8cd8 [ObjC] Add Swift helpers for GPBUnknownFields/GPBUnknownField.
`GPBUnknownFields` additions:
- Provide `Optional` based apis for the `getFirst*` apis.
- Map the `NSFastEnumeration` over as a `Sequence` to support looping over the fields.

`GPBUnknownField` addition:
- Add an `enum` with associated values to provide a more type-safe way for inspection.

PiperOrigin-RevId: 649090744
2024-07-03 08:58:32 -07:00
Thomas Van Lenten
47f633eae6 [ObjC] Introduce the new GPBUnknownFields type.
`GPBUnknownFields` will be the eventually replacement for `GPBUnknownFieldSet`. This
introduces the type and the changes to `GPBUnknownField`.

The new api will preserve the wire ordering of unknown fields. This is now checked
in conformance tests.

While this adds the type changes and tests them, it does not yet wire the changes
in to the rest of the Runtime, so the conformance tests still done pass.
`GPBUnknownFieldSet` also hasn't been deprecated yet, that will come in later with
the wiring in to the runtime.

PiperOrigin-RevId: 648361455
2024-07-01 07:32:10 -07:00
Thomas Van Lenten
9f52d5e380 [ObjC] Fix issue using GPBBootstrap.h only.
GPB_ENUM_FWD_DECLARE needs `int32_t`, so add the import so GPBBootstrap.h
stands on its own without needing users to import something else.

Add another compile test file to ensure this doesn't break.

PiperOrigin-RevId: 610403337
2024-02-26 07:37:41 -08:00
Protobuf Team Bot
2fed1e3e83 [ObjC] Move the version check out into a sh_test.
Since the sources can't reference each other, this is what helps keep them in
sync. Move it out to be a stand alone test in bazel instead of having it wired
into the Xcode projects.

PiperOrigin-RevId: 508429454
2023-02-09 11:29:48 -08:00
Protobuf Team Bot
6566de53f6 [ObjC] Don't auto enable analysis during all builds.
This slows down the build and hasn't had an issue in a really long time. The
support is still there, so it can be manually run at any time from within Xcode.

PiperOrigin-RevId: 507810543
2023-02-07 09:55:08 -08:00
Protobuf Team Bot
d0c1a63347 [ObjC] Let Xcode 14 update the project settings
PiperOrigin-RevId: 488719873
2022-11-15 11:54:54 -08:00
Protobuf Team Bot
899c14a384 [ObjC] Avoid warning from Xcode 14.
Xcode 14 is warning:

```
warning: Run script build phase 'Script: Check Runtime Stamps' will be run during every build because it does not specify any outputs. To address this warning, either add output dependencies to the script phase, or configure it to run in every build by unchecking "Based on dependency analysis" in the script phase. (in target 'UnitTests' from project 'ProtocolBuffers_OSX')
```

This setting avoids that warning.

PiperOrigin-RevId: 488703116
2022-11-15 10:53:17 -08:00
Thomas Van Lenten
a6f9ec815e [ObjC] Raise the min OS versions (and required Xcode)
Xcode min: 13.3.1
iOS min: 10.0
macOS min: 10.12
tvOS min: 12.0
watchOS min: 6.0

Apple's AppStore requirements now require Xcode 13:
  https://developer.apple.com/news/?id=2t1chhp3

Update to the minOS version and Xcode version that also matches what Firebase
as done as that seems like a common set for most Apple platforms
(https://firebase.google.com/docs/ios/setup).
2022-09-26 11:50:22 -04:00
Thomas Van Lenten
5a823ffd16 [ObjC] Fix the name of the test file. 2022-09-01 17:13:01 -04:00
Thomas Van Lenten
5cf61b7e47 [ObjC] Test file cleanups
- Remove some types not needed.
- Remove some files not needed.
- Move some tests files into different prefixes to logically segment things.
- Add objc_class_prefix to the files.
- Use an expected prefix file during generation to exercise that code and
  validate things.
- Require prefixes for the test file.
2022-08-30 10:46:17 -04:00
Thomas Van Lenten
3e0d399c3e [ObjC] Give the ObjC tests copies of all their protos.
This isolates them from changes to the C++ tests by making things self contains.
2022-08-23 15:43:18 -04:00
Thomas Van Lenten
43b8721457 [ObjC] Remove the need for descriptor.proto in tests.
Add a test message to one of the objc test proto files for the one case that was
using what was in descriptor.proto.
2022-08-23 12:59:16 -04:00
Thomas Van Lenten
d979267a7f Remove some test files not used. 2022-08-23 12:59:16 -04:00
Thomas Van Lenten
4b3da9f618 Revert "Add option for eliding property metadata from messages"
This reverts commit ca3674b7d5.

While there are savings, it ends up being to easy/common to run into issues with
AppStore validation since the selector usage now appears to be a possible match
for private apis vs. for selectors/properties in the generated code.
2021-07-12 09:47:16 -04:00
Dave MacLachlan
ca3674b7d5 Add option for eliding property metadata from messages
Adds an option to protoc `--objc_opt=elide_message_metadata` to remove all the property
metadata from message classes. This significantly reduces the codegen size of the clases.
The downside is that iterating through properties using objective c runtime calls will no
longer function. This is mitigated by the fact that most (all?) of the information that
folks are interested in can be extracted via the message descriptor.

We do this by defining our own classes using the `GPB_MESSAGE_SUBCLASS_IMPL` macro.
2021-06-23 14:23:23 -04:00
Twig
c7d2a97879
Sets SKIP_INSTALL to YES for the ProtocolBuffers target (#8560) 2021-05-14 12:17:42 -04:00
Thomas Van Lenten
a645d7176b Update the iOS project for Xcode 12.
- Move the min up to iOS 9.  Things should still work with 8, just can't have
  the project set to that and be able to run the tests, so moving it up to
  support running the tests.
- Remove the bitcode setting from the unittest bundle, was causing an error
  with Xcode 12.
2020-10-21 15:42:09 -04:00
Thomas Van Lenten
56c48ae592 Revisit how the WKTs are bundled with ObjC.
There are have been a few issues around people using case sensitive file systems
what Xcode/clang does when looking at the paths. In attempts to solve one set of
warnings, new warnings/errors happened in different setup. So, to hopefully put
these problem away for got, move the WKTs to be at the same level as the other
headers.

- Revert "Override CocoaPods module to lowercase (#6464)"
  This reverts commit 479ba8226b.
- Move WKTs to the objectivec directory and make the old headers shim back to
  the new locations.
- Update objectivec/generate_well_known_types.sh to check them one at a time
  and to deal with the new locations for them.

Fixes #6803
2020-02-10 12:20:05 -05:00
Dave MacLachlan
74956e1c15 Use references to Objective C classes instead of looking classes up by name.
This should reduce binary size slightly, small performance improvement, and improve linkage by forcing references to all used classes.

Note that this maintains backwards compatibility for sources generated by older protoc for the time being. If you want the benefits
you will need to recompile your protos with the newer protoc.
2020-01-15 15:01:53 -05:00
Thomas Van Lenten
f56adaeb57 Remove stale target reference. 2019-01-08 08:22:12 -05:00
Dave MacLachlan
ef3a725002 Make sure Objective C Proto compiler doesn't "duplicate" prefixes unnecessarily.
In some cases proto files that want/need to use the objc_class_prefix option have
types that already have the prefix on a subset of their names. In this case we don't
want to duplicate the prefix.

Added tests for this (and prefixes in general).
2018-11-27 08:06:36 -05:00
Thomas Van Lenten
92a879b2eb Add a unittest for ObjC TextFormat extension support. 2018-11-14 17:06:51 -05:00
Thomas Van Lenten
c0bc265b67 Fix up the Xcode project.
The builds were failing under Xcode 10 because of the new build system.
Even when reverted to the old build system, the build was failing
on the analyzer and swift bridging header, so it seems the general
logic for searching for things was changed in a way the setting does
not always cover.

- Disable HeaderMaps.
- Set user header search paths instead of system search paths.
- Turn off always search user paths (now recommended).

Tested in Xcode 10.1 and 9.4.1; both are able to build/pass with this.
2018-11-14 12:32:02 -05:00
Thomas Van Lenten
eecccdc802 Let the 9.4 migrator migrate the Swift source.
No changes were needed, but since the Xcode projects pick up the updated
setting, the tests require a newer Xcode that supports Swift 4.

This is being done because Xcode 10 starting warning about Swift 3 support
going away in the future, so we might as well do the updates since most
folks shouldn't be on those really old Xcode versions any more.
2018-11-02 13:28:33 -04:00
Thomas Van Lenten
97d03abb85 Turn off ALWAYS_SEARCH_USER_PATHS.
Causes a warning in newer Xcodes.
2018-10-02 13:45:18 -04:00
Thomas Van Lenten
b59da6d099 Remove the iOS Test App.
The tests can run as what Apple calls a Logic Test (under xctest), which means
it doesn't have to load an full UI App under the simulator, which speeds things
up a fair amount.
2018-04-20 17:26:38 -04:00
Sergio Campama
ce24b8a224 Update Xcode settings 2018-04-06 10:37:14 -04:00
Thomas Van Lenten
e998b8ff66 Add compile test sources for to test include order.
To ensure all headers aren't dependent on other things being imported
before/after them, make a source that just imports each header and add
it to the unittesting target, that way we ensure it can be included on
its own with ordering issues.

Also do this testing with a few generated headers that aren't part of
the library to help ensure the different generated imports needed are
complete.
2018-04-02 09:54:29 -04:00
dmaclach
8537f1e6d5 Fix up warnings from Xcode 9.1 (#3887)
Fix up warnings from Xcode 9.1
2017-11-16 08:24:17 -05:00
Thomas Van Lenten
9477123538 Let Xcode 9 update project/scheme settings. 2017-10-03 09:56:02 -04:00
Thomas Van Lenten
49e4ba6098 Fix ExtensionRegistry copying and add tests.
- Fix up -copyWithZone: to not leave the two registries sharing
  some of the storage by using -addExtensions:.
- Improve -addExtensions: to clone the sub dict when there is
  nothing to merge into.
- A ExtensionRegistry unittests.
- Update project schemes to not have extra things in perf scheme.
2017-05-17 14:51:02 -04:00
Thomas Van Lenten
988ffe0a78 Minor fix for autocreated object repeated fields and maps.
- If setting/clearing a repeated field/map that was objects, check the class
  before checking the autocreator.
- Just to be paranoid, don’t mutate within copy/mutableCopy for the autocreated
  classes to ensure there is less chance of issues if someone does something
  really crazy threading wise.
- Some more tests for the internal AutocreatedArray/AutocreatedDictionary
  classes to ensure things are working as expected.
- Add Xcode 8.2 to the full_mac_build.sh supported list.
2017-01-05 09:15:40 -05:00
Thomas Van Lenten
297449aaf4 Update the ObjC projects for Xcode 8
- Let Xcode 8 update settings on the projects/schemes.
- Migrate Swift tests to Swift 3 syntax.
- Update the build/test script:
  - Require Xcode 8 (because of the Swift 3 requirement for tests)
  - Update the devices to what Xcode 8 has (8.x simulator seem to fail even
    though they can be downloaded in Xcode 8)
- Update the travis images to ones with Xcode 8.
2016-10-03 13:24:24 -04:00
Sergio Campamá
14e74f6a21 Support the -Wassign-enum compiler flag. (#2085)
Support the -Wassign-enum compiler flag.
2016-09-08 15:15:12 -04:00
Thomas Van Lenten
13a41246dd Make Root's +extensionRegistry generation smarter.
At generation time, walk the file's dependencies to see what really contains
extensions so we can generate more minimal code that only links together the
roots that provided extensions. Gets a bunch of otherwise noop code out of
the call flow when the roots are +initialized.
2016-09-01 18:08:59 -04:00
Thomas Van Lenten
8c23655519 Drop the performace baselines.
We weren't really using them, and the nested path causes checkout problems
on windows.
2016-07-08 12:21:53 -04:00
Thomas Van Lenten
be0d7f6664 Don't #import the .m files.
As bazel folks are looking at getting auto generation of module maps going and
the importing of sources files causes issues there.  We were only do it to
hack around some of the apple linker behaviors around objc classes and
categories, but even that isn't complete and CocoaPods was already doing -ObjC,
and developers not using pods could have still needed it to ensure everything
was linked anyways; so drop the hack of importing sources.
2016-07-07 08:45:18 -04:00
Thomas Van Lenten
6cfc19edde Xcode project cleanup/setup.
- Correct some cases sources were compiled into the static lib and the tests.
- Enable Xcodes code coverage support on the unittests.  We aren't complete on
  coverage, but having the data always there should make it easier to chip away
  at this going forward.
- Drop method in tests that isn't used, wire up a validator in another test.
2016-06-29 09:53:46 -04:00
Thomas Van Lenten
38b9e74691 Add -Woverriding-method-mismatch.
Fixes up the code to avoid some issues with isEqual: methods.

Opened https://github.com/google/protobuf/issues/1616 to track the KVC
collision.
2016-05-27 12:52:35 -04:00
Thomas Van Lenten
c8a440dfb6 Add more warnings to for the ObjC runtime build
Working on https://github.com/google/protobuf/issues/1599, specifically:
- Turn on more warnings that the Xcode UI calls out with individual controls.
- Manually add:
  -Wundef
  -Wswitch-enum
- Manually add and then diable in the unittests because of XCTest's headers:
  -Wreserved-id-macro
  -Wdocumentation-unknown-command
- Manually add -Wdirect-ivar-access, but disable it for the unittests and in
  the library code (via #pragmas to suppress it). This is done so proto users
  can enable the warning.
2016-05-25 16:42:31 -04:00
Thomas Van Lenten
79a23c435c Shrink ObjC overhead (generated size and some runtime sizes)
NOTE: This is a binary breaking change as structure sizes have changed size
and/or order.

- Drop capturing field options, no other options were captured and other mobile
  targeted languages don't try to capture this sort information (saved 8
  bytes for every field defined (in static data and again in field descriptor
  instance size data).
- No longer generate/compile in the messages/enums in descriptor.proto. If
  developers need it, they should generate it and compile it in. Reduced the
  overhead of the core library.
- Compute the number of has_bits actually needs to avoid over reserving.
- Let the boolean single fields store via a has_bit to avoid storage, makes
  the common cases of the instance size smaller.
- Reorder some flags and down size the enums to contain the bits needed.
- Reorder the items in the structures to manually ensure they are are packed
  better (especially when generating 64bit code - 8 bytes for every field,
  16 bytes for every extension, instance sizes 8 bytes also).
- Split off the structure initialization so when the default is zero, the
  generated static storage doesn't need to reserve the space. This is batched
  at the message level, so all the fields for the message have to have zero
  defaults to get the saves. By definition all proto3 syntax  files fall into
  this case but it also saves space for the proto2 that use the standard
  defaults. (saves 8 bytes of static data for every field that had a zero
  default)
- Don't track the enums defined by a message. Nothing in the runtime needs it
  and it was just generation and runtime overhead. (saves 8 bytes per enum)
- Ensure EnumDescriptors are started up threadsafe in all cases.
- Split some of the Descriptor initialization into multiple methods so the
  generated code isn't padded with lots of zero/nil args.
- Change how oneof info is feed to the runtime enabling us to generate less
  static data (8 bytes saved per oneof for 64bit).
- Change how enum value informat is capture to pack the data and only decode
  it if it ends up being needed. Avoids padding issues causing bloat of 64bit,
  and removes the needs for extra pointers in addition to the data (just the
  data and one pointer now).
2016-03-17 10:04:21 -04:00
Thomas Van Lenten
36650a07cf HeaderDoc support in the library and generated sources
- Convert most of the core library headers over to HeaderDoc format.
- Switch the generated comments over to HeaderDoc.
- Create GPBCodedOutputStream_PackagePrivate and move some things into there
  that should be more internal.
2016-03-07 12:07:03 -05:00
Thomas Van Lenten
0e42ed30cb Remove the stale reference to test no longer around, and keep the performance test limited to just performance tests. 2016-01-07 10:31:33 -05:00