Drag and Drop into a `UICollectionView` placeholder in iOS 11 Beta 4 - ios

The API for dragging and dropping into a UICollectionView changed in iOS 11 Beta 4. In beta 1-3, the code looked like:
let placeholderContext = coordinator.drop(
item.dragItem,
toPlaceholderInsertedAt: indexPath,
withReuseIdentifier: "reuseID",
cellUpdateHandler: { _ in }
)
In beta 4, the introduced UICollectionViewDropPlaceholder. My code is
let placeholder = UICollectionViewDropPlaceholder(
insertionIndexPath: indexPath,
reuseIdentifier: "reuseID"
)
let placeholderContext = coordinator.drop(item.dragItem, to: placeholder)
I am getting this compile error:
Undefined symbols for architecture arm64:
"_OBJC_CLASS_$_UICollectionViewDropPlaceholder", referenced from:
objc-class-ref in StickerLibraryViewController.o
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
note: symbol(s) not found for architecture arm64
error: linker command failed with exit code 1 (use -v to see invocation)
Other than not using a placeholder until beta 5, anyone have any ideas of how to get this working in beta 4?
Thanks!

Until this is fixed in Beta 5, I ended up solving this issue by dropping down into the Objective-C runtime.
In the Obj-C header…
NS_ASSUME_NONNULL_BEGIN
#interface RKNFactory : NSObject
- (UICollectionViewDropPlaceholder*)placeholderForIndexPath:(NSIndexPath*)indexPath resuseIdentifier:(NSString*)reuseIdentifier;
#end
NS_ASSUME_NONNULL_END
In the implementation…
#import ObjectiveC.runtime;
#implementation RKNFactory
- (UICollectionViewDropPlaceholder*)placeholderForIndexPath:(NSIndexPath*)indexPath resuseIdentifier:(NSString*)reuseIdentifier {
SEL initSelector = NSSelectorFromString(#"initWithInsertionIndexPath:reuseIdentifier:");
Class placeholderClass = NSClassFromString(#"UICollectionViewDropPlaceholder");
return [[placeholderClass alloc] performSelector:initSelector withObject:indexPath withObject:reuseIdentifier];
}
#end
And then from the Swift code…
return RKNFactory().placeholder(for: indexPath, resuseIdentifier: reuseIdentifier)

I had a similar problem with local authentication not compiling on on the simulator architecture when it was in beta.
Does it compile if you remove arm64 from valid architectures in build settings (or turn off “build all architectures”)?
If they compiled this symbol for simulator, but left it out for arm64, the only solution might be to prevent it from compiling on arm64 and test it only on the simulator for now.
You can also wrap the code temporarily in a “#if block” that prevents the compiler from looking at it when building arm64.
Finally, if you’re building for any versions of iOS under iOS 11, be sure to try turning those off for now, in case they forgot to mark API availability (which might have let the compiler provide a more helpful message).

Related

Linker Error while testing: Undefined symbols for architecture x86_64

I am working to support iOS 11 and XCode 9. When I try to execute the test suite, I receive a Linker Error:
Undefined symbols for architecture x86_64
"ConstantName", reference from: - [FileATest testMethod] in FileATest.o
In FileA.h
OBJC_EXTERN NSString *const ConstantName
In FileA.m
NSString *const ConstantName = #"ConstantValue"
In FileATest.m I use the constant and have the import
#import "FileA.h"
Using a static constant in the header file seems to work, but I read that it is not the proper way to declare a constant.
It was working fine with XCode 8 and previous versions, but for XCode 9 Beta 6 it doesn't. Has someone had this problem? How may I fix it?
I had the same issue when running unit tests and the solution for me was to go to the App Target > Build Settings > Dead Code Stripping and set it to NO.
Hope this helps.

Admob Conversion Tracking in Swift

I tried to set conversion tracking in my iOS game, but I didn't be able to do that. The tutorial can be found here: https://developers.google.com/app-conversion-tracking/ios/?hl=it#usage_and_disclosure
I integrate the GoogleConversionTrackingSDK to my project, load AdSupport framework and type -ObjC in Other linker flags.
I tried to convert this snippet from Obj-C:
[ACTConversionReporter reportWithConversionID:#"MY_ID" label:#"MY_LABEL" value:#"MY_VALUE" isRepeatable:NO];
to Swift:
ACTConversionReporter.reportWithConversionID("MY_ID", label: "MY_LABEL", value: "MY_VALUE", isRepeatable: false)
and I put that in didFinishLaunchingWithOptions method of AppDelegate.swift, but I get the error:
Use of unresolved identifier 'ACTConversionReporter'
If I type in Obj-C bridging header in Swift Compiler - Code Generation in Build Settings "ACTReporter.h" (without qm), I put the header file in the folder of my game or if I type the whole path of "ACTReporter.h" ending with its name, I fail the build and I get 2 errors:
Undefined symbols for architecture armv7:
"_OBJC_CLASS_$_ACTConversionReporter", referenced from:
type metadata accessor for __ObjC.ACTConversionReporter in AppDelegate.o
ld: symbol(s) not found for architecture armv7 clang: error: linker
command failed with exit code 1 (use -v to see invocation)
I don't know what to do. I hope there is someone who can fix this.
You need to add to your project "YourProjectName-Bridging-Header.h" file
Here you can see how to add the file
in Bridging Header file add #import "ACTReporter.h"
Then it will work for you!

UITest: Undefined symbols for architecture armv7

I'm trying to call a swift singleton from my UITest target. I'm importing the main module: #testable import Ary but when I try to build it says:
Undefined symbols for architecture armv7:
"Ary.DataModelLayerOperation.getter : Ary.DataModelLayer", referenced from:
AryUITests.AryUITests.setUp (AryUITests.AryUITests)() -> () in AryUITests.o
d: symbol(s) not found for architecture armv7
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Syntax highlighting works though (the singleton doesn't have access modifiers, so it's marked as internal which should be perfectly fine for access from the test target)...
The function I'm calling is [in an XCTestCase]:
override func setUp() {
super.setUp()
if !DataModelLayerOperation.isUserLoggedIn() {
//do something
}
}
I'm afraid what you want to achieve is not possible at the moment. I have encountered similar problem and asked my question here. I will soon accept the answer that says:
The UI tests are a separate module from the app, therefore not run
inside your app as a logic test would.
I'm hoping this will be improved in the next Xcode versions.

Linker error when implementing NSObject protocol while using enums?

Here is a distilled version of the code I am having trouble with in Swift:
enum E {
case C
}
class Test: NSObject {
var v: E = .C
}
When I attempt to build, I get the following error:
Undefined symbols for architecture x86_64:
"__TWvdvC8TestTest4Test1vOS_1E", referenced from:
__TFC8TestTest4Testm1vOS_1E in AppDelegate.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
To reproduce this, simply make a new Swift project and paste the above code right into "AppDelegate.swift". Alternatively, make a new file and stick it in there instead!
Am I missing something obvious or is this yet another Swift bug? I did try deleting all derived data and other forms of voodoo magic.
Thanks for the help!
It seems like the compiler removes the enum if there is only one case?
I can reproduce your issue, it disappears when I add a second case :
enum E {
case C,D
}
class Test: NSObject {
var v : E = .C
}
I noticed a couple things when trying this:
In the current non-beta version of Xcode, I see the error you're referring to (almost certainly a Swift bug). However, if I add an extra value to the enum (case C,D), it compiles just fine
I couldn't reproduce the crash in the latest Xcode beta (Version 6.3 (6D520o)), which leads me to believe that the bug has been fixed in Swift 1.2

Missing symbols from LayarSDK in the simulator

I'm including the Layar SDK framework into my app (version 8.0) and everything works fine on a device.
However, I can't run the app on a simulator anymore - I don't mind Layar not working (there's no camera after all!) but I do need it to compile for continual integration, automated tests etc (not to mention developing on the train top/from work!)
The linker gives me these errors :
ld: warning: ignoring file /Users/username/Documents/appname/libs/MPOAuth/libMPOAuthMobile.a, missing required architecture i386 in file /Users/username/Documents/appname/libs/MPOAuth/libMPOAuthMobile.a (2 slices)
ld: warning: ignoring file local/LayarSDK/LayarSDK.framework/LayarSDK, missing required architecture i386 in file local/LayarSDK/LayarSDK.framework/LayarSDK (2 slices)
Undefined symbols for architecture i386:
"_OBJC_CLASS_$_LayarSDK", referenced from:
objc-class-ref in MYAppDelegate.o
ld: symbol(s) not found for architecture i386
Checking, the LayarSDK doesn't contain i386, it only contains armv7 and armv7s.
My solution is pretty clumsy - if anyone has a better idea, please let me know!
I compile this file (LayarSimulatorStub.m) into my app :
#if TARGET_IPHONE_SIMULATOR
#import <Foundation/Foundation.h>
#interface LayarSDK : NSObject
#end
#implementation LayarSDK
+ (id)layarSDKWithConsumerKey:(id)a andConsumerSecret:(id)b andDelegate:(id)c { return nil; }
- (id)init { return nil; }
- (id)initWithConsumerKey:(id)a andConsumerSecret:(id)b andDelegate:(id)c { return nil; }
#end
#endif
Now, there is an i386 symbol LayarSDK. It just returns nil from all it's constructors. The app now compiles with Layar disabled.
The conditional compilation means that it's not present for the device architectures so there are no linker errors.

Resources