Printing in 4.2 SDK - would like to support 4.0 without app crashing - iphone

I'm trying to have printing in my application.
While this works, and I can indeed print from my application, I would like to be able to run my application on devices that aren't running iOS 4.2.
Even if I check the version before I run the code.
The method that prints the document has all of the classes that are being used to print.
Whenever I switch the simulator back to 4.1, I get a Symbol not found exception that displays the error:
dyld: Symbol not found: _OBJC_CLASS_$_UIMarkupTextPrintFormatter
Referenced from: /Users/Jack/Library/Application Support/iPhone Simulator/4.1/Applications/794534DB-DB53-42E7-A294-7E78FDD3899B/Documentation.app/Documentation
Expected in: /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator4.1.sdk/System/Library/Frameworks/UIKit.framework/UIKit
in /Users/Jack/Library/Application Support/iPhone Simulator/4.1/Applications/794534DB-DB53-42E7-A294-7E78FDD3899B/Documentation.app/Documentation
I don't want to discard the users who haven't upgraded to 4.2.
Any help appreciated.

Which compiler are you using? If you haven't, you should switch to LLVM GCC or LLVM to support automatic weak linking as described by Marco Arment in Supporting older versions of iOS while using new APIs.

Related

Swift Package Manager - How to `Always Embed Swift Standard Libraries`?

We have CLI tool written in Swift for common usage (Android and iOS developers) on macOS.
Android developers without Xcode installation get the following error:
dyld: Library not loaded: #rpath/libswiftCore.dylib
Referenced from: ~/git/myClITool/macosBin Reason: image not found
Abort trap: 6
We found that enabling Always Embed Swift Standard Libraries in Xcode would most likely help, but this CLI tool is exported with SPM, ignoring all Xcode settings.
How can I achieve this build behaviour using SPM only?
Found the following commandline argument: --static-swift-stdlib
Example usage:
swift build --static-swift-stdlib -c release
This would have produced the output we were looking for. Unfortunately since Swift 5, this argument no longer works for any platforms.
When used, SPM throws the following warning:
warning: Swift compiler no longer supports statically linking the
Swift libraries. They're included in the OS by default starting with
macOS Mojave 10.14.4 beta 3. For macOS Mojave 10.14.3 and earlier,
there's an optional Swift library package that can be downloaded from
"More Downloads" for Apple Developers at
https://developer.apple.com/download/more/
Related Swift bugticket: https://bugs.swift.org/browse/SR-648

update Xcode to 10.2.1 run project crash with problem dyld: Library not loaded: #rpath/libswiftCore.dylib

I have a project that was created with Xcode 10, Objective-C, and Swift 4.0 and now upgraded to Xcode 10.2.1.
Error reporting for each run.
I have set Always Embed Swift Standard Libraries to YES
Add #executable_path/Frameworks to "Runpath Search Paths"
These methods don't resolve the issue.
dyld: Library not loaded: #rpath/libswiftCore.dylib
Referenced from: /private/var/containers/Bundle/Application/48371FB5-6A90-4D14-9D65-C7AB5DCAC1A1/one mini.app/Frameworks/Framework152x.framework/Framework152x
Reason: image not found
Actually, the problem is the Framework152x.framework is developed in Swift with Xcode version below 10.2. If your project is built with Xcode 10 with Framework152x.framework means Framework152x.framework runtime is swift 4.2. But if you build your project in Xcode 10.2.1 this issue will occur. Because the XCode 10.2.1 has swift 5 Runtime but Framework152x.framework is expecting swift 4.2. You can resolve this problem only by using Framework152x.framework which needs to be built either in Xcode 10.2 or 10.2.1
I had the same or very similar issue with UI tests failing due to their deployment target being set to iOS 12 and the app under test being set to iOS 10. When I set them both to iOS 10 the UI tests would successfully launch (the app always launched fine). Not sure if that's the problem you're having as you've not mentioned UI tests but perhaps you neglected to mention that :)

Debug an obscure error on iPhone

My app crashes on versions 4.2 and 4.3 of iOS. The line of code that crashes is in a C++ library:
Ais8_001_22_Circle const *circle = dynamic_cast<Ais8_001_22_Circle const*>(*sa);
The console says:
dyld: lazy symbol binding failed: can't resolve symbol ___dynamic_cast MY_APP
because dependent dylib #2 could not be loaded
dyld: can't resolve symbol ___dynamic_cast in MY_APP
because dependent dylib #2 could not be loaded
It would probably help if I could figure out what "dylib #2" is.
It turns out I needed to include the lstdc++ linker flag under iOS 4.X
One possibility - Is the C++ library you are linking to a dynamic library (dylib)? If so, you'll need find a statically linked version for iOS as iOS does not allow dynamic libraries.

How to use Cocos 2D 1.1.0, When I run a sample Cocos2D Appication it gives error

How to use Cocos2D 1.1.0, When I am choose a template as Cocos2D Application and name it "NewCocos", When simply run this project without doing anything It gives me
124 errors
of same type = error: missing binary operator before token "("
this errors shows near "#if defined(__has_feature) && __has_feature(objc_arc)"
18 Warnings
of same type = warning: ignoring #pragma clang diagnostic
this warning shows near "#pragma clang diagnostic push" , "#pragma clang diagnostic pop" etc...
I am using XCode 3.2.4 and iOS / iPhone OS 4.1
In short statement gives (124 times) error of
error: missing binary operator before token "("
on the statement without quotes "#if defined(__has_feature) && __has_feature(objc_arc)"
This is working fine in Cocos v1.0.1 older version but not working on cocos v1.1.0
Cocos2D v1.1 requires to set the compiler to "Apple LLVM compiler" in Build Settings. Only Xcode 4.0 and newer are shipped with the Apple LLVM compiler. Furthermore, to enable ARC you must be using at least Xcode 4.2 with the "Apple LLVM compiler 3.0".
You should seriously consider upgrading. Xcode 3.2 is over 2 years old now (released: August 2009). As mentioned here, only apps built with the latest, or if not "too old" the second to latest iOS SDK version are going to be approved by Apple (at the time of this writing iOS 5.0 is the latest SDK but iOS 4.3 apps are also still accepted). Regardless of that, Xcode 4 makes it a lot easier to submit apps through its built-in Organizer.
this is XCode 3.2.4 problem Update Your X-Code Minimum X-Code 4.2.0

Symbol not found error after upgrading to iPhone SDK 4.0, running on 3.1.3

I just upgraded to iPhone SDK 4.0, and recompiled my static libraries and app, and when I run it on a device with iOS 3.1.3 (using deployment target 3.0), it says:
dyld: lazy symbol binding failed: Symbol not found: ___sync_fetch_and_add_4
Referenced from: /var/mobile/Applications/7CA42202-DA9D-4A10-918D-593362E18000/renderer.app/renderer
Expected in: /usr/lib/libSystem.B.dylib
dyld: Symbol not found: ___sync_fetch_and_add_4
Referenced from: /var/mobile/Applications/7CA42202-DA9D-4A10-918D-593362E18000/renderer.app/renderer
Expected in: /usr/lib/libSystem.B.dylib
I found this blog post, but it doesn't seem to give any advice other than
try to use gcc 4.0 instead of 4.2, and
it should have been fixed in the SDK 4.0.
It appears that the code he points to was fixed in SDK 4.0 (and his example of a minimal app that exhibits this behavior works fine for me), but I'm still getting this error.
It turns out that I had only compiled the app with deployment target of 3.0; once I also compiled the libraries with deployment target of 3.0, it worked correctly.