Skip to content

Commit

Permalink
Fix an issue where importing an Objective-C type called Optional caus…
Browse files Browse the repository at this point in the history
…es LLDB to sometimes not be able to distinguish between Swift.Optional and OptimizelySDKiOS.Optional. (#274)
  • Loading branch information
tprevost-phunware authored and thomaszurkan-optimizely committed Sep 25, 2018
1 parent f421f49 commit 428ad1d
Show file tree
Hide file tree
Showing 25 changed files with 64 additions and 64 deletions.
Expand Up @@ -57,16 +57,16 @@ DEPRECATED_ATTRIBUTE
* Protocol for defining optional properties in a JSON Model class. Use like below to define
* model properties that are not required to have values in the JSON input:
*
* @property (strong, nonatomic) NSString<Optional> *propertyName;
* @property (strong, nonatomic) NSString<OPTLYOptional> *propertyName;
*
*/
@protocol Optional
@protocol OPTLYOptional
@end

/**
* Make all objects compatible to avoid compiler warnings
*/
@interface NSObject (OPTLYJSONModelPropertyCompatibility) <Optional, Ignore>
@interface NSObject (OPTLYJSONModelPropertyCompatibility) <OPTLYOptional, Ignore>
@end

/////////////////////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -250,11 +250,11 @@ DEPRECATED_ATTRIBUTE
+ (OPTLYJSONKeyMapper *)keyMapper;

/**
* Indicates whether the property with the given name is Optional.
* To have a model with all of its properties being Optional just return YES.
* Indicates whether the property with the given name is OPTLYOptional.
* To have a model with all of its properties being OPTLYOptional just return YES.
* This method returns by default NO, since the default behaviour is to have all properties required.
* @param propertyName the name of the property
* @return a BOOL result indicating whether the property is optional
* @return a BOOL result indicating whether the property is OPTLYOptional
*/
+ (BOOL)propertyIsOptional:(NSString *)propertyName;

Expand Down
Expand Up @@ -607,7 +607,7 @@ -(void)__inspectProperties

[scanner scanUpToString:@">" intoString: &protocolName];

if ([protocolName isEqualToString:@"Optional"]) {
if ([protocolName isEqualToString:@"OPTLYOptional"]) {
p.isOptional = YES;
} else if([protocolName isEqualToString:@"Index"]) {
#pragma GCC diagnostic push
Expand Down
4 changes: 2 additions & 2 deletions OptimizelySDKCore/OPTLYJSONModel/README.md
Expand Up @@ -211,9 +211,9 @@ for OPTLYJSONModel to work, the protocol must be in place.
```objc
@interface ProductModel : OPTLYJSONModel
@property (nonatomic) NSInteger id;
@property (nonatomic) NSString <Optional> *name;
@property (nonatomic) NSString <OPTLYOptional> *name;
@property (nonatomic) float price;
@property (nonatomic) NSNumber <Optional> *uuid;
@property (nonatomic) NSNumber <OPTLYOptional> *uuid;
@end
```

Expand Down
4 changes: 2 additions & 2 deletions OptimizelySDKCore/OPTLYJSONModelTests/KeyMappingTests.m
Expand Up @@ -39,9 +39,9 @@
@interface TestModel: OPTLYJSONModel

@property (strong, nonatomic) NSString* text1;
@property (strong, nonatomic) NSString<Optional>* text2;
@property (strong, nonatomic) NSString<OPTLYOptional>* text2;

@property (strong, nonatomic) NSString<Optional>* text3;
@property (strong, nonatomic) NSString<OPTLYOptional>* text3;

@end

Expand Down
Expand Up @@ -32,7 +32,7 @@
@property (assign, nonatomic) int watchers;
@property (strong, nonatomic) NSString* owner;
@property (assign, nonatomic) int forks;
@property (strong, nonatomic) NSString<Optional>* language;
@property (strong, nonatomic) NSString<OPTLYOptional>* language;
@property (assign, nonatomic) BOOL fork;
@property (assign, nonatomic) double size;
@property (assign, nonatomic) int followers;
Expand Down
Expand Up @@ -27,7 +27,7 @@
@interface GitHubKeyMapRepoModel : OPTLYJSONModel

@property (strong, nonatomic) NSString* __description;
@property (strong, nonatomic) NSString<Optional>* language;
@property (strong, nonatomic) NSString<OPTLYOptional>* language;

#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
Expand Down
Expand Up @@ -31,7 +31,7 @@
@property (assign, nonatomic) int watchers;
@property (strong, nonatomic) NSString* owner;
@property (assign, nonatomic) int forks;
@property (strong, nonatomic) NSString<Optional>* language;
@property (strong, nonatomic) NSString<OPTLYOptional>* language;
@property (assign, nonatomic) BOOL fork;
@property (assign, nonatomic) double size;
@property (assign, nonatomic) int followers;
Expand Down
Expand Up @@ -30,6 +30,6 @@
@property (strong, nonatomic) NSDate* createdAt;
@property (assign, nonatomic) int aVeryLongPropertyName;
@property (strong, nonatomic) NSString* itemObject145;
@property (strong, nonatomic) NSString<Optional>* itemObject176Details;
@property (strong, nonatomic) NSString<OPTLYOptional>* itemObject176Details;

@end
Expand Up @@ -30,6 +30,6 @@

@property (strong, nonatomic) NSNumber* idImage;
@property (strong, nonatomic) NSString* name;
@property (strong, nonatomic) CopyrightModel<Optional>* copyright;
@property (strong, nonatomic) CopyrightModel<OPTLYOptional>* copyright;

@end
Expand Up @@ -34,6 +34,6 @@
@property (strong, nonatomic) NSMutableArray* dynamicList;
@property (strong, nonatomic) NSDictionary* dictionary;
@property (strong, nonatomic) NSMutableDictionary* dynamicDictionary;
@property (strong, nonatomic) NSString<Optional>* notAvailable;
@property (strong, nonatomic) NSString<OPTLYOptional>* notAvailable;

@end
Expand Up @@ -28,7 +28,7 @@
@interface OptionalPropModel : OPTLYJSONModel

@property (assign, nonatomic) int fillerNumber;
@property (strong, nonatomic) NSString<Optional>* notRequredProperty;
@property (strong, nonatomic) NSString<OPTLYOptional>* notRequredProperty;
@property (strong, nonatomic) NSString<Ignore>* ignoredProperty;
@property (assign, nonatomic) CGPoint notRequiredPoint;

Expand Down
Expand Up @@ -31,6 +31,6 @@
@property (strong, nonatomic) NSString<Index>* id;
#pragma GCC diagnostic pop

@property (strong, nonatomic) NSString<Optional>* name;
@property (strong, nonatomic) NSString<OPTLYOptional>* name;

@end
4 changes: 2 additions & 2 deletions OptimizelySDKCore/OPTLYJSONModelTests/NullTests.m
Expand Up @@ -26,15 +26,15 @@
@import OptimizelySDKCore;

@interface NullModelA : OPTLYJSONModel
@property (nonatomic) NSString <Optional> *optional;
@property (nonatomic) NSString <OPTLYOptional> *optional;
@property (nonatomic) NSString *required;
@end

@implementation NullModelA
@end

@interface NullModelB : OPTLYJSONModel
@property (nonatomic) NSString <Optional> *prop;
@property (nonatomic) NSString <OPTLYOptional> *prop;
@end

@implementation NullModelB
Expand Down
18 changes: 9 additions & 9 deletions OptimizelySDKCore/OptimizelySDKCore/OPTLYDecisionEventTicket.h
Expand Up @@ -30,33 +30,33 @@
//The time the decision was made.
@property (nonatomic, assign) long long timestamp;
// Revision of client DATA, corresponding to a stored snapshot
@property (nonatomic, strong, nullable) NSString<Optional> *revision;
@property (nonatomic, strong, nullable) NSString<OPTLYOptional> *revision;
// Unique ID shared by all events in the current activation cycle
@property (nonatomic, strong, nullable) NSString<Optional> *activationId;
@property (nonatomic, strong, nullable) NSString<OPTLYOptional> *activationId;
// GUID ID uniquely identifying the decision event triggering
@property (nonatomic, strong, nullable) NSString<Optional> *decisionId;
@property (nonatomic, strong, nullable) NSString<OPTLYOptional> *decisionId;
// GUID ID uniquely identifying the user’s current session
@property (nonatomic, strong, nullable) NSString<Optional> *sessionId;
@property (nonatomic, strong, nullable) NSString<OPTLYOptional> *sessionId;
// Project ID of the decision.
@property (nonatomic, strong, nonnull) NSString *projectId;
// Account ID of the decision.
@property (nonatomic, strong, nonnull) NSString *accountId;
// The type of client engine sending this event: ‘ios’, ‘android’, ‘js’.
@property (nonatomic, strong, nullable) NSString<Optional> *clientEngine;
@property (nonatomic, strong, nullable) NSString<OPTLYOptional> *clientEngine;
// The version of the client engine sending this event.
@property (nonatomic, strong, nullable) NSString<Optional> *clientVersion;
@property (nonatomic, strong, nullable) NSString<OPTLYOptional> *clientVersion;
// Event information taken from the http header instead of the payload
@property (nonatomic, strong, nullable) OPTLYEventHeader<Optional> *header;
@property (nonatomic, strong, nullable) OPTLYEventHeader<OPTLYOptional> *header;
// The layer affected by this decision
@property (nonatomic, strong, nonnull) NSString *layerId;
// Visitor-specific input to Client Decision Engine
@property (nonatomic, strong, nullable) NSArray<OPTLYEventDecisionTicket, Optional> *decisionTicket;
@property (nonatomic, strong, nullable) NSArray<OPTLYEventDecisionTicket, OPTLYOptional> *decisionTicket;
// Output of the Client Decision Engine
@property (nonatomic, strong, nonnull) OPTLYEventDecision *decision;
// The ID of the user
@property (nonatomic, strong, nonnull) NSString *visitorId;
// The unique user ID of the user (if available)
@property (nonatomic, strong, nullable) NSString<Optional> *visitorUUID;
@property (nonatomic, strong, nullable) NSString<OPTLYOptional> *visitorUUID;
// Features attached to the user
@property (nonatomic, strong, nonnull) NSArray<OPTLYEventFeature> *userFeatures;
// If true, then the experience in this decision was held back at the global level
Expand Down
4 changes: 2 additions & 2 deletions OptimizelySDKCore/OptimizelySDKCore/OPTLYEventAudience.h
Expand Up @@ -29,8 +29,8 @@
@interface OPTLYEventAudience : OPTLYJSONModel

// The ID of the audience
@property (nonatomic, strong, nullable) NSString<Optional> *audienceId;
@property (nonatomic, strong, nullable) NSString<OPTLYOptional> *audienceId;
// The audience’s name
@property (nonatomic, strong, nullable) NSString<Optional> *name;
@property (nonatomic, strong, nullable) NSString<OPTLYOptional> *name;

@end
4 changes: 2 additions & 2 deletions OptimizelySDKCore/OptimizelySDKCore/OPTLYEventDecision.h
Expand Up @@ -29,9 +29,9 @@
@interface OPTLYEventDecision : OPTLYJSONModel

// ID of chosen experiment, null if visitor is not targeted for any experiments
@property (nonatomic, strong, nullable) NSString<Optional> *experimentId;
@property (nonatomic, strong, nullable) NSString<OPTLYOptional> *experimentId;
// ID of chosen variation, null if if visitor is not targeted for any experiments
@property (nonatomic, strong, nullable) NSString<Optional> *variationId;
@property (nonatomic, strong, nullable) NSString<OPTLYOptional> *variationId;
// If true, the chosen experience was held back at the layer level
// TODO - Remove later when this ticket is completed: https://optimizely.atlassian.net/browse/NB-1493
@property (nonatomic, assign) BOOL isLayerHoldback;
Expand Down
Expand Up @@ -31,8 +31,8 @@
@interface OPTLYEventDecisionTicket : OPTLYJSONModel

// The audiences bucketed at decision time
@property (nonatomic, strong, nullable) NSArray<OPTLYEventAudience, Optional> *audiences;
@property (nonatomic, strong, nullable) NSArray<OPTLYEventAudience, OPTLYOptional> *audiences;
// Id (UUID or visitorId) used for bucketing
@property (nonatomic, strong, nullable) NSString<Optional> *bucketingId;
@property (nonatomic, strong, nullable) NSString<OPTLYOptional> *bucketingId;

@end
6 changes: 3 additions & 3 deletions OptimizelySDKCore/OptimizelySDKCore/OPTLYEventFeature.h
Expand Up @@ -33,11 +33,11 @@ NS_ASSUME_NONNULL_END
@interface OPTLYEventFeature : OPTLYJSONModel

// The ID of feature for non-custom features. Should be the GAE ID if it exists.
@property (nonatomic, strong, nullable) NSString<Optional> *featureId;
@property (nonatomic, strong, nullable) NSString<OPTLYOptional> *featureId;
// The name of the feature, which along with type uniquely identify the feature.
@property (nonatomic, strong, nullable) NSString<Optional> *name;
@property (nonatomic, strong, nullable) NSString<OPTLYOptional> *name;
// The type the feature, which along with name uniquely identifies the feature.
@property (nonatomic, strong, nullable) NSString<Optional> *type;
@property (nonatomic, strong, nullable) NSString<OPTLYOptional> *type;
// The value of the feature (supports: string, long, int, double, float, boolean)
@property (nonatomic, strong, nonnull) id value;
// If true, this feature will be indexed in the counting service. Otherwise it will just be logged
Expand Down
4 changes: 2 additions & 2 deletions OptimizelySDKCore/OptimizelySDKCore/OPTLYEventHeader.h
Expand Up @@ -31,8 +31,8 @@
// The IP address of the client
@property (nonatomic, strong, nonnull) NSString *clientIp;
// The user agent of the client. Null on mobile.
@property (nonatomic, strong, nullable) NSString<Optional> *userAgent;
@property (nonatomic, strong, nullable) NSString<OPTLYOptional> *userAgent;
// The referrer of the client. Null on mobile.
@property (nonatomic, strong, nullable) NSString<Optional> *referer;
@property (nonatomic, strong, nullable) NSString<OPTLYOptional> *referer;

@end
20 changes: 10 additions & 10 deletions OptimizelySDKCore/OptimizelySDKCore/OPTLYEventLayerState.h
Expand Up @@ -33,27 +33,27 @@
// The id of the layer state
@property (nonatomic, strong, nonnull) NSString *layerId;
// Visitor-specific input to Client Decision Engine
@property (nonatomic, strong, nullable) OPTLYEventDecisionTicket<Optional> *decisionTicket;
@property (nonatomic, strong, nullable) OPTLYEventDecisionTicket<OPTLYOptional> *decisionTicket;
// Output of the Client Decision Engine
@property (nonatomic, strong, nullable) OPTLYEventDecision<Optional> *decision;
@property (nonatomic, strong, nullable) OPTLYEventDecision<OPTLYOptional> *decision;
// The activationId when the decision was made
@property (nonatomic, strong, nullable) NSString<Optional> *decisionActivationId;
@property (nonatomic, strong, nullable) NSString<OPTLYOptional> *decisionActivationId;
// The sessionId when the decision was made
@property (nonatomic, strong, nullable) NSString<Optional> *decisionSessionId;
@property (nonatomic, strong, nullable) NSString<OPTLYOptional> *decisionSessionId;
// The timestamp when the decision was made
@property (nonatomic, strong, nullable) NSNumber<Optional> *decisionTimestamp;
@property (nonatomic, strong, nullable) NSNumber<OPTLYOptional> *decisionTimestamp;
// The generated UID for the DecisionEventTicketAvro logged when this decision was made.
@property (nonatomic, strong, nullable) NSString<Optional> *decisionEventId;
@property (nonatomic, strong, nullable) NSString<OPTLYOptional> *decisionEventId;
// Indicates whether any actions for this layer have trigged
@property (nonatomic, assign) BOOL actionTriggered;
// The activation ID when the action was last triggered
@property (nonatomic, strong, nullable) NSString<Optional> *actionActivationId;
@property (nonatomic, strong, nullable) NSString<OPTLYOptional> *actionActivationId;
// The session Id when the action was last triggered
@property (nonatomic, strong, nullable) NSString<Optional> *actionSessionId;
@property (nonatomic, strong, nullable) NSString<OPTLYOptional> *actionSessionId;
// The timestamp when the action was last triggered
@property (nonatomic, strong, nullable) NSNumber<Optional> *actionTimestamp;
@property (nonatomic, strong, nullable) NSNumber<OPTLYOptional> *actionTimestamp;
// The DATA revision of the layer definition in use when this layer was processed
@property (nonatomic, strong, nullable) NSString<Optional> *revision;
@property (nonatomic, strong, nullable) NSString<OPTLYOptional> *revision;


@end
4 changes: 2 additions & 2 deletions OptimizelySDKCore/OptimizelySDKCore/OPTLYEventRelatedEvent.h
Expand Up @@ -29,8 +29,8 @@
@interface OPTLYEventRelatedEvent : OPTLYJSONModel

// The id of the related event
@property (nonatomic, strong, nullable) NSString<Optional> *eventId;
@property (nonatomic, strong, nullable) NSString<OPTLYOptional> *eventId;
// The type of the relationship to this event
@property (nonatomic, strong, nullable) NSString<Optional> *relationship;
@property (nonatomic, strong, nullable) NSString<OPTLYOptional> *relationship;

@end
6 changes: 3 additions & 3 deletions OptimizelySDKCore/OptimizelySDKCore/OPTLYEventView.h
Expand Up @@ -31,10 +31,10 @@
@interface OPTLYEventView : OPTLYJSONModel

// The ID of the view containing this impression.
@property (nonatomic, strong, nullable) NSString<Optional> *viewId;
@property (nonatomic, strong, nullable) NSString<OPTLYOptional> *viewId;
// The timestamp when the containing view was activated.
@property (nonatomic, strong, nullable) NSNumber<Optional> *activatedTimestamp;
@property (nonatomic, strong, nullable) NSNumber<OPTLYOptional> *activatedTimestamp;
// Features attached to the view.
@property (nonatomic, strong, nullable) NSArray<OPTLYEventFeature, Optional> *viewFeatures;
@property (nonatomic, strong, nullable) NSArray<OPTLYEventFeature, OPTLYOptional> *viewFeatures;

@end
2 changes: 1 addition & 1 deletion OptimizelySDKCore/OptimizelySDKCore/OPTLYFeatureFlag.h
Expand Up @@ -39,7 +39,7 @@
/// an NSArray of the feature variables that are part of this feature
@property (nonatomic, strong, nonnull) NSArray<OPTLYFeatureVariable> *variables;
/// an NSString to hold the group Id the feature belongs to.
@property (nonatomic, strong, nullable) NSString<Optional> *groupId;
@property (nonatomic, strong, nullable) NSString<OPTLYOptional> *groupId;

/**
* Determines whether all the experiments in the feature flag belongs to the same mutex group
Expand Down
10 changes: 5 additions & 5 deletions OptimizelySDKCore/OptimizelySDKCore/OPTLYProjectConfig.h
Expand Up @@ -45,9 +45,9 @@ NS_ASSUME_NONNULL_END
/// Datafile Revision number
@property (nonatomic, strong, nonnull) NSString *revision;
/// Flag for IP anonymization
@property (nonatomic, strong, nonnull) NSNumber<Optional> *anonymizeIP;
@property (nonatomic, strong, nonnull) NSNumber<OPTLYOptional> *anonymizeIP;
/// Flag for Bot Filtering
@property (nonatomic, strong, nonnull) NSNumber<Optional> *botFiltering;
@property (nonatomic, strong, nonnull) NSNumber<OPTLYOptional> *botFiltering;
/// List of Optimizely Experiment objects
@property (nonatomic, strong, nonnull) NSArray<OPTLYExperiment> *experiments;
/// List of Optimizely Event Type objects
Expand All @@ -59,7 +59,7 @@ NS_ASSUME_NONNULL_END
/// List of group objects
@property (nonatomic, strong, nonnull) NSArray<OPTLYGroup> *groups;
/// List of live variable objects (DEPRECATED)
@property (nonatomic, strong, nonnull) NSArray<OPTLYVariable, Optional> *variables;
@property (nonatomic, strong, nonnull) NSArray<OPTLYVariable, OPTLYOptional> *variables;

/// a comprehensive list of experiments that includes experiments being whitelisted (in Groups)
@property (nonatomic, strong, nullable) NSArray<OPTLYExperiment, Ignore> *allExperiments;
Expand All @@ -72,9 +72,9 @@ NS_ASSUME_NONNULL_END
/// Returns the client version number
@property (nonatomic, strong, readonly, nonnull) NSString<Ignore> *clientVersion;
/// List of Optimizely Feature Flags objects
@property (nonatomic, strong, nonnull) NSArray<OPTLYFeatureFlag, Optional> *featureFlags;
@property (nonatomic, strong, nonnull) NSArray<OPTLYFeatureFlag, OPTLYOptional> *featureFlags;
/// List of Optimizely Rollouts objects
@property (nonatomic, strong, nonnull) NSArray<OPTLYRollout, Optional> *rollouts;
@property (nonatomic, strong, nonnull) NSArray<OPTLYRollout, OPTLYOptional> *rollouts;

/**
* Initialize the Project Config from a builder block.
Expand Down
4 changes: 2 additions & 2 deletions OptimizelySDKCore/OptimizelySDKCore/OPTLYVariation.h
Expand Up @@ -37,14 +37,14 @@
/// The variation's Key.
@property (nonatomic, strong, nonnull) NSString *variationKey;
/// The array containing the variables usage instances that are part of this variation.
@property (nonatomic, strong, nullable) NSArray<OPTLYVariableUsage, Optional> *variableUsageInstances;
@property (nonatomic, strong, nullable) NSArray<OPTLYVariableUsage, OPTLYOptional> *variableUsageInstances;
/// Flag for Feature Toggle Ability
@property (nonatomic, assign) BOOL featureEnabled;

/// Gets the variable usage instance for a given variable id
- (nullable OPTLYVariableUsage *)getVariableUsageForVariableId:(nullable NSString *)variableId;

/// The array containing the variation's live variable information -- variable ID and variable value. (DEPRECATED)
@property (nonatomic, strong, nullable) NSArray<OPTLYVariationVariable, Optional> *variables;
@property (nonatomic, strong, nullable) NSArray<OPTLYVariationVariable, OPTLYOptional> *variables;

@end

0 comments on commit 428ad1d

Please sign in to comment.