Troubleshoot Your Objective-C JMS Client
This topic contains descriptions of common errors that might occur when using the Objective-C client library and provides steps on how to prevent these errors.
Before You Begin
This procedure is part of Checklist: Build Objective-C (iOS) JMS Clients Using Kaazing Gateway, that includes the following steps:
- Use the Objective-C JMS Client API
- Secure Your Objective-C Client
- Troubleshoot Your Objective-C JMS Client
- Display Logs for the Objective-C JMS Client
Note: Learn about supported browsers, operating systems, and platform versions in the Release Notes.
What Problem Are You Having?
- Lexical or Preprocessor Issue: KMStompJMS not found
- Apple Mach-O Linker (Id) Error
- Error: Selector Not Recognized or NSInvalidArgumentException
- Expected Messages Are Not Being Received for a Queue or Durable Subscriber
Cause: This error occurs because Xcode cannot locate the KMStompJMS.framework file that is referenced by a header file. If Xcode cannot locate the KGWebSocket.framework file, the following error is reported:
Lexical or Preprocessor Issue: KGWebSocket not found
Solution: To resolve this error, correct the Framework Search Paths setting to include both the KMStompJMS.framework and KGWebSocket.framework files by performing the following steps:
- Navigate to the location of your downloaded Objective-C (iOS) SDK.
- In the
libfolder, double-click the KMStompJMS.dmg and KGWebSocket.dmg images to mount them.
- Drag the KGWebSocket.framework file from the mounted volume into the Frameworks folder in the Xcode project navigator.
In the Choose options for adding these files dialog that appears, enable the Copy items into destination group’s folder checkbox, select your project in Add to targets, and click Finish.
- Repeat steps 3 and 4 for the KMStompJMS.framework.
Xcode adds the frameworks to the project navigator, updates the Framework Search Paths setting in Build Settings with the path to the frameworks, and updates the Link Binary With Libraries settings in Build Phases automatically.
Note: You can also choose to add the KGWebSocket.framework and KMStompJMS.framework files into your local /Library/Frameworks/ folder or a network share before adding them to your project. This is a common practice for managing frameworks.
Cause: This error will refer to "undefined symbols" beginning with _CFHTTP, for example _CFHTTPMessageAddAuthentication. The error occurs because the Xcode project is missing the CFNetwork.framework file. Clients built using the Kaazing Gateway Objective-C library also require the CFNetwork.framework.
Solution: To resolve this error, add CFNetwork.framework by performing the following steps:
- Click Build Phases at the top of the project editor.
- Open the Link Binary With Libraries section.
- Click the Add (+) button to add a library or framework.
Enter CFNetwork.framework in the search field. CFNetwork.framework is displayed automatically.
If you do not see CFNetwork.framework, then you might not have iOS SDK 5.1 or later installed. You can install the SDK as part of the Xcode bundle.
- Select CFNetwork.framework and click Add. CFNetwork.framework is added to the Xcode project and appears in the Xcode project navigator. You can drag CFNetwork.framework into the Frameworks folder.
Cause: These errors occur because the Xcode project is linking against an Objective-C static library that contains categories and the -ObjC value for the Other Linker Flags build setting is not configured. Basically, the error occurs when a library extends one of the built-in classes using a category. An example of the Selector Not Recognized error:
[__NSCFConstantString indexOf:]: unrecognized selector sent to instance 0x...
Objective-C does not define linker symbols for each function (or method, in Objective-C). Linker symbols are only generated for each class. If you extend a pre-existing class with categories, the linker does not know to associate the object code of the core class implementation and the category implementation. This prevents objects created in the resulting application from responding to a selector that is defined in the category. The -ObjC flag causes the linker to load every object file in the library that defines an Objective-C class or category.
For more information, see Building Objective-C static libraries with categories.
Solution: To resolve this error, add the -ObjC value for the Other Linker Flags build setting by performing the following steps:
- In the project navigator, select the target to which you want to add a library or framework.
- Click the Build Settings tab and scroll down to the Linking section.
- In Other Linker Flags, add the value -ObjC.
Cause: If expected messages are not being received for a queue or durable subscriber, then it could be because the application has received messages without acknowledging them. The Gateway will send a maximum of maximum.pending.acknowledgments messages until the client acknowledges. The maximum.pending.acknowledgments property is set to 1 for JMS providers that do not support individual message acknowledgement.
Solution: If you are using a JMS provider other than Apache ActiveMQ or TIBCO Enterprise Message Service (TIBCO EMS), you must ensure your client applications acknowledge each message received from a queue or durable subscriber.